var global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};

// based off https://github.com/defunctzombie/node-process/blob/master/browser.js

function defaultSetTimout() {
  throw new Error('setTimeout has not been defined');
}

function defaultClearTimeout() {
  throw new Error('clearTimeout has not been defined');
}

var cachedSetTimeout = defaultSetTimout;
var cachedClearTimeout = defaultClearTimeout;

if (typeof global$1.setTimeout === 'function') {
  cachedSetTimeout = setTimeout;
}

if (typeof global$1.clearTimeout === 'function') {
  cachedClearTimeout = clearTimeout;
}

function runTimeout(fun) {
  if (cachedSetTimeout === setTimeout) {
    //normal enviroments in sane situations
    return setTimeout(fun, 0);
  } // if setTimeout wasn't available but was latter defined


  if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
    cachedSetTimeout = setTimeout;
    return setTimeout(fun, 0);
  }

  try {
    // when when somebody has screwed with setTimeout but no I.E. maddness
    return cachedSetTimeout(fun, 0);
  } catch (e) {
    try {
      // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
      return cachedSetTimeout.call(null, fun, 0);
    } catch (e) {
      // 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
      return cachedSetTimeout.call(this, fun, 0);
    }
  }
}

function runClearTimeout(marker) {
  if (cachedClearTimeout === clearTimeout) {
    //normal enviroments in sane situations
    return clearTimeout(marker);
  } // if clearTimeout wasn't available but was latter defined


  if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
    cachedClearTimeout = clearTimeout;
    return clearTimeout(marker);
  }

  try {
    // when when somebody has screwed with setTimeout but no I.E. maddness
    return cachedClearTimeout(marker);
  } catch (e) {
    try {
      // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally
      return cachedClearTimeout.call(null, marker);
    } catch (e) {
      // 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.
      // Some versions of I.E. have different rules for clearTimeout vs setTimeout
      return cachedClearTimeout.call(this, marker);
    }
  }
}

var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;

function cleanUpNextTick() {
  if (!draining || !currentQueue) {
    return;
  }

  draining = false;

  if (currentQueue.length) {
    queue = currentQueue.concat(queue);
  } else {
    queueIndex = -1;
  }

  if (queue.length) {
    drainQueue();
  }
}

function drainQueue() {
  if (draining) {
    return;
  }

  var timeout = runTimeout(cleanUpNextTick);
  draining = true;
  var len = queue.length;

  while (len) {
    currentQueue = queue;
    queue = [];

    while (++queueIndex < len) {
      if (currentQueue) {
        currentQueue[queueIndex].run();
      }
    }

    queueIndex = -1;
    len = queue.length;
  }

  currentQueue = null;
  draining = false;
  runClearTimeout(timeout);
}

function nextTick(fun) {
  var args = new Array(arguments.length - 1);

  if (arguments.length > 1) {
    for (var i = 1; i < arguments.length; i++) {
      args[i - 1] = arguments[i];
    }
  }

  queue.push(new Item(fun, args));

  if (queue.length === 1 && !draining) {
    runTimeout(drainQueue);
  }
} // v8 likes predictible objects

function Item(fun, array) {
  this.fun = fun;
  this.array = array;
}

Item.prototype.run = function () {
  this.fun.apply(null, this.array);
};

var title = 'browser';
var platform = 'browser';
var browser$1 = true;
var env = {};
var argv = [];
var version = ''; // empty string to avoid regexp issues

var versions = {};
var release = {};
var config = {};

function noop() {}

var on = noop;
var addListener = noop;
var once = noop;
var off = noop;
var removeListener = noop;
var removeAllListeners = noop;
var emit = noop;
function binding(name) {
  throw new Error('process.binding is not supported');
}
function cwd() {
  return '/';
}
function chdir(dir) {
  throw new Error('process.chdir is not supported');
}
function umask() {
  return 0;
} // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js

var performance$1 = global$1.performance || {};

var performanceNow = performance$1.now || performance$1.mozNow || performance$1.msNow || performance$1.oNow || performance$1.webkitNow || function () {
  return new Date().getTime();
}; // generate timestamp or delta
// see http://nodejs.org/api/process.html#process_process_hrtime


function hrtime(previousTimestamp) {
  var clocktime = performanceNow.call(performance$1) * 1e-3;
  var seconds = Math.floor(clocktime);
  var nanoseconds = Math.floor(clocktime % 1 * 1e9);

  if (previousTimestamp) {
    seconds = seconds - previousTimestamp[0];
    nanoseconds = nanoseconds - previousTimestamp[1];

    if (nanoseconds < 0) {
      seconds--;
      nanoseconds += 1e9;
    }
  }

  return [seconds, nanoseconds];
}
var startTime = new Date();
function uptime() {
  var currentTime = new Date();
  var dif = currentTime - startTime;
  return dif / 1000;
}
var process = {
  nextTick: nextTick,
  title: title,
  browser: browser$1,
  env: env,
  argv: argv,
  version: version,
  versions: versions,
  on: on,
  addListener: addListener,
  once: once,
  off: off,
  removeListener: removeListener,
  removeAllListeners: removeAllListeners,
  emit: emit,
  binding: binding,
  cwd: cwd,
  chdir: chdir,
  umask: umask,
  hrtime: hrtime,
  platform: platform,
  release: release,
  config: config,
  uptime: uptime
};

function createCommonjsModule(fn, basedir, module) {
	return module = {
		path: basedir,
		exports: {},
		require: function (path, base) {
			return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
		}
	}, fn(module, module.exports), module.exports;
}

function commonjsRequire () {
	throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
}

function _typeof$1(obj) {
  "@babel/helpers - typeof";

  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
    _typeof$1 = function (obj) {
      return typeof obj;
    };
  } else {
    _typeof$1 = function (obj) {
      return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
    };
  }

  return _typeof$1(obj);
}

function 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);
  }
}

function _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);
    });
  };
}

function _classCallCheck(instance, Constructor) {
  if (!(instance instanceof Constructor)) {
    throw new TypeError("Cannot call a class as a function");
  }
}

function _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);
  }
}

function _createClass(Constructor, protoProps, staticProps) {
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  if (staticProps) _defineProperties(Constructor, staticProps);
  return Constructor;
}

function _defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }

  return obj;
}

function _inherits(subClass, superClass) {
  if (typeof superClass !== "function" && superClass !== null) {
    throw new TypeError("Super expression must either be null or a function");
  }

  subClass.prototype = Object.create(superClass && superClass.prototype, {
    constructor: {
      value: subClass,
      writable: true,
      configurable: true
    }
  });
  if (superClass) _setPrototypeOf(subClass, superClass);
}

function _getPrototypeOf(o) {
  _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
    return o.__proto__ || Object.getPrototypeOf(o);
  };
  return _getPrototypeOf(o);
}

function _setPrototypeOf(o, p) {
  _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
    o.__proto__ = p;
    return o;
  };

  return _setPrototypeOf(o, p);
}

function _isNativeReflectConstruct() {
  if (typeof Reflect === "undefined" || !Reflect.construct) return false;
  if (Reflect.construct.sham) return false;
  if (typeof Proxy === "function") return true;

  try {
    Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
    return true;
  } catch (e) {
    return false;
  }
}

function _construct(Parent, args, Class) {
  if (_isNativeReflectConstruct()) {
    _construct = Reflect.construct;
  } else {
    _construct = function _construct(Parent, args, Class) {
      var a = [null];
      a.push.apply(a, args);
      var Constructor = Function.bind.apply(Parent, a);
      var instance = new Constructor();
      if (Class) _setPrototypeOf(instance, Class.prototype);
      return instance;
    };
  }

  return _construct.apply(null, arguments);
}

function _assertThisInitialized(self) {
  if (self === void 0) {
    throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  }

  return self;
}

function _possibleConstructorReturn(self, call) {
  if (call && (typeof call === "object" || typeof call === "function")) {
    return call;
  }

  return _assertThisInitialized(self);
}

function _createSuper(Derived) {
  var hasNativeReflectConstruct = _isNativeReflectConstruct();

  return function _createSuperInternal() {
    var Super = _getPrototypeOf(Derived),
        result;

    if (hasNativeReflectConstruct) {
      var NewTarget = _getPrototypeOf(this).constructor;

      result = Reflect.construct(Super, arguments, NewTarget);
    } else {
      result = Super.apply(this, arguments);
    }

    return _possibleConstructorReturn(this, result);
  };
}

function _superPropBase(object, property) {
  while (!Object.prototype.hasOwnProperty.call(object, property)) {
    object = _getPrototypeOf(object);
    if (object === null) break;
  }

  return object;
}

function _get(target, property, receiver) {
  if (typeof Reflect !== "undefined" && Reflect.get) {
    _get = Reflect.get;
  } else {
    _get = function _get(target, property, receiver) {
      var base = _superPropBase(target, property);

      if (!base) return;
      var desc = Object.getOwnPropertyDescriptor(base, property);

      if (desc.get) {
        return desc.get.call(receiver);
      }

      return desc.value;
    };
  }

  return _get(target, property, receiver || target);
}

function _slicedToArray(arr, i) {
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}

function _toArray(arr) {
  return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
}

function _toConsumableArray(arr) {
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}

function _arrayWithoutHoles(arr) {
  if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}

function _arrayWithHoles(arr) {
  if (Array.isArray(arr)) return arr;
}

function _iterableToArray(iter) {
  if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
}

function _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;
}

function _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(o);
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}

function _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;
}

function _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.");
}

function _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.");
}

function _createForOfIteratorHelper(o, allowArrayLike) {
  var it;

  if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
    if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
      if (it) o = it;
      var i = 0;

      var F = function () {};

      return {
        s: F,
        n: function () {
          if (i >= o.length) return {
            done: true
          };
          return {
            done: false,
            value: o[i++]
          };
        },
        e: function (e) {
          throw e;
        },
        f: F
      };
    }

    throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  }

  var normalCompletion = true,
      didErr = false,
      err;
  return {
    s: function () {
      it = o[Symbol.iterator]();
    },
    n: function () {
      var step = it.next();
      normalCompletion = step.done;
      return step;
    },
    e: function (e) {
      didErr = true;
      err = e;
    },
    f: function () {
      try {
        if (!normalCompletion && it.return != null) it.return();
      } finally {
        if (didErr) throw err;
      }
    }
  };
}

/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/* eslint-disable no-unused-vars */

var getOwnPropertySymbols = Object.getOwnPropertySymbols;
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;

function toObject(val) {
  if (val === null || val === undefined) {
    throw new TypeError('Object.assign cannot be called with null or undefined');
  }

  return Object(val);
}

function shouldUseNative() {
  try {
    if (!Object.assign) {
      return false;
    } // Detect buggy property enumeration order in older V8 versions.
    // https://bugs.chromium.org/p/v8/issues/detail?id=4118


    var test1 = new String('abc'); // eslint-disable-line no-new-wrappers

    test1[5] = 'de';

    if (Object.getOwnPropertyNames(test1)[0] === '5') {
      return false;
    } // https://bugs.chromium.org/p/v8/issues/detail?id=3056


    var test2 = {};

    for (var i = 0; i < 10; i++) {
      test2['_' + String.fromCharCode(i)] = i;
    }

    var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
      return test2[n];
    });

    if (order2.join('') !== '0123456789') {
      return false;
    } // https://bugs.chromium.org/p/v8/issues/detail?id=3056


    var test3 = {};
    'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
      test3[letter] = letter;
    });

    if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') {
      return false;
    }

    return true;
  } catch (err) {
    // We don't expect any of the above to throw, but better to be safe.
    return false;
  }
}

var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
  var from;
  var to = toObject(target);
  var symbols;

  for (var s = 1; s < arguments.length; s++) {
    from = Object(arguments[s]);

    for (var key in from) {
      if (hasOwnProperty.call(from, key)) {
        to[key] = from[key];
      }
    }

    if (getOwnPropertySymbols) {
      symbols = getOwnPropertySymbols(from);

      for (var i = 0; i < symbols.length; i++) {
        if (propIsEnumerable.call(from, symbols[i])) {
          to[symbols[i]] = from[symbols[i]];
        }
      }
    }
  }

  return to;
};

function C(a) {
  for (var b = "https://reactjs.org/docs/error-decoder.html?invariant=" + a, c = 1; c < arguments.length; c++) {
    b += "&args[]=" + encodeURIComponent(arguments[c]);
  }

  return "Minified React error #" + a + "; visit " + b + " for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";
}

var D = {
  isMounted: function isMounted() {
    return !1;
  },
  enqueueForceUpdate: function enqueueForceUpdate() {},
  enqueueReplaceState: function enqueueReplaceState() {},
  enqueueSetState: function enqueueSetState() {}
},
    E = {};

function F(a, b, c) {
  this.props = a;
  this.context = b;
  this.refs = E;
  this.updater = c || D;
}

F.prototype.isReactComponent = {};

F.prototype.setState = function (a, b) {
  if ("object" !== _typeof$1(a) && "function" !== typeof a && null != a) throw Error(C(85));
  this.updater.enqueueSetState(this, a, b, "setState");
};

F.prototype.forceUpdate = function (a) {
  this.updater.enqueueForceUpdate(this, a, "forceUpdate");
};

function G() {}

G.prototype = F.prototype;

function H(a, b, c) {
  this.props = a;
  this.context = b;
  this.refs = E;
  this.updater = c || D;
}

var I = H.prototype = new G();
I.constructor = H;
objectAssign(I, F.prototype);
I.isPureReactComponent = !0;

/**
 * Copyright (c) 2013-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;

var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);

var printWarning$1 = function printWarning() {};

{
  var ReactPropTypesSecret = ReactPropTypesSecret_1;
  var loggedTypeFailures = {};
  var has = has$1;

  printWarning$1 = function printWarning(text) {
    var message = 'Warning: ' + text;

    if (typeof console !== 'undefined') {
      console.error(message);
    }

    try {
      // --- Welcome to debugging React ---
      // This error was thrown as a convenience so that you can use this stack
      // to find the callsite that caused this warning to fire.
      throw new Error(message);
    } catch (x) {
      /**/
    }
  };
}
/**
 * Assert that the values match with the type specs.
 * Error messages are memorized and will only be shown once.
 *
 * @param {object} typeSpecs Map of name to a ReactPropType
 * @param {object} values Runtime values that need to be type-checked
 * @param {string} location e.g. "prop", "context", "child context"
 * @param {string} componentName Name of the component for error messages.
 * @param {?Function} getStack Returns the component stack.
 * @private
 */


function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  {
    for (var typeSpecName in typeSpecs) {
      if (has(typeSpecs, typeSpecName)) {
        var error; // Prop type validation may throw. In case they do, we don't want to
        // fail the render phase where it didn't fail before. So we log it.
        // After these have been cleaned up, we'll let them throw.

        try {
          // This is intentionally an invariant that gets caught. It's the same
          // behavior as without this statement except with a better message.
          if (typeof typeSpecs[typeSpecName] !== 'function') {
            var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + _typeof$1(typeSpecs[typeSpecName]) + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
            err.name = 'Invariant Violation';
            throw err;
          }

          error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
        } catch (ex) {
          error = ex;
        }

        if (error && !(error instanceof Error)) {
          printWarning$1((componentName || 'React class') + ': type specification of ' + location + ' `' + typeSpecName + '` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a ' + _typeof$1(error) + '. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).');
        }

        if (error instanceof Error && !(error.message in loggedTypeFailures)) {
          // Only monitor this failure once because there tends to be a lot of the
          // same error.
          loggedTypeFailures[error.message] = true;
          var stack = getStack ? getStack() : '';
          printWarning$1('Failed ' + location + ' type: ' + error.message + (stack != null ? stack : ''));
        }
      }
    }
  }
}
/**
 * Resets warning cache when testing.
 *
 * @private
 */


checkPropTypes.resetWarningCache = function () {
  {
    loggedTypeFailures = {};
  }
};

var checkPropTypes_1 = checkPropTypes;

var react_development = createCommonjsModule(function (module, exports) {

  {
    (function () {

      var _assign = objectAssign;
      var checkPropTypes = checkPropTypes_1;
      var ReactVersion = '16.14.0'; // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
      // nor polyfill, then a plain number is used for performance.

      var hasSymbol = typeof Symbol === 'function' && Symbol.for;
      var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
      var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
      var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
      var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
      var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
      var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
      var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary

      var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
      var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
      var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
      var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
      var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
      var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
      var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
      var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
      var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
      var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
      var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
      var FAUX_ITERATOR_SYMBOL = '@@iterator';

      function getIteratorFn(maybeIterable) {
        if (maybeIterable === null || _typeof$1(maybeIterable) !== 'object') {
          return null;
        }

        var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];

        if (typeof maybeIterator === 'function') {
          return maybeIterator;
        }

        return null;
      }
      /**
       * Keeps track of the current dispatcher.
       */


      var ReactCurrentDispatcher = {
        /**
         * @internal
         * @type {ReactComponent}
         */
        current: null
      };
      /**
       * Keeps track of the current batch's configuration such as how long an update
       * should suspend for if it needs to.
       */

      var ReactCurrentBatchConfig = {
        suspense: null
      };
      /**
       * Keeps track of the current owner.
       *
       * The current owner is the component who should own any components that are
       * currently being constructed.
       */

      var ReactCurrentOwner = {
        /**
         * @internal
         * @type {ReactComponent}
         */
        current: null
      };
      var BEFORE_SLASH_RE = /^(.*)[\\\/]/;

      function describeComponentFrame(name, source, ownerName) {
        var sourceInfo = '';

        if (source) {
          var path = source.fileName;
          var fileName = path.replace(BEFORE_SLASH_RE, '');
          {
            // In DEV, include code for a common special case:
            // prefer "folder/index.js" instead of just "index.js".
            if (/^index\./.test(fileName)) {
              var match = path.match(BEFORE_SLASH_RE);

              if (match) {
                var pathBeforeSlash = match[1];

                if (pathBeforeSlash) {
                  var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
                  fileName = folderName + '/' + fileName;
                }
              }
            }
          }
          sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
        } else if (ownerName) {
          sourceInfo = ' (created by ' + ownerName + ')';
        }

        return '\n    in ' + (name || 'Unknown') + sourceInfo;
      }

      var Resolved = 1;

      function refineResolvedLazyComponent(lazyComponent) {
        return lazyComponent._status === Resolved ? lazyComponent._result : null;
      }

      function getWrappedName(outerType, innerType, wrapperName) {
        var functionName = innerType.displayName || innerType.name || '';
        return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
      }

      function getComponentName(type) {
        if (type == null) {
          // Host root, text node or just invalid type.
          return null;
        }

        {
          if (typeof type.tag === 'number') {
            error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
          }
        }

        if (typeof type === 'function') {
          return type.displayName || type.name || null;
        }

        if (typeof type === 'string') {
          return type;
        }

        switch (type) {
          case REACT_FRAGMENT_TYPE:
            return 'Fragment';

          case REACT_PORTAL_TYPE:
            return 'Portal';

          case REACT_PROFILER_TYPE:
            return "Profiler";

          case REACT_STRICT_MODE_TYPE:
            return 'StrictMode';

          case REACT_SUSPENSE_TYPE:
            return 'Suspense';

          case REACT_SUSPENSE_LIST_TYPE:
            return 'SuspenseList';
        }

        if (_typeof$1(type) === 'object') {
          switch (type.$$typeof) {
            case REACT_CONTEXT_TYPE:
              return 'Context.Consumer';

            case REACT_PROVIDER_TYPE:
              return 'Context.Provider';

            case REACT_FORWARD_REF_TYPE:
              return getWrappedName(type, type.render, 'ForwardRef');

            case REACT_MEMO_TYPE:
              return getComponentName(type.type);

            case REACT_BLOCK_TYPE:
              return getComponentName(type.render);

            case REACT_LAZY_TYPE:
              {
                var thenable = type;
                var resolvedThenable = refineResolvedLazyComponent(thenable);

                if (resolvedThenable) {
                  return getComponentName(resolvedThenable);
                }

                break;
              }
          }
        }

        return null;
      }

      var ReactDebugCurrentFrame = {};
      var currentlyValidatingElement = null;

      function setCurrentlyValidatingElement(element) {
        {
          currentlyValidatingElement = element;
        }
      }

      {
        // Stack implementation injected by the current renderer.
        ReactDebugCurrentFrame.getCurrentStack = null;

        ReactDebugCurrentFrame.getStackAddendum = function () {
          var stack = ''; // Add an extra top frame while an element is being validated

          if (currentlyValidatingElement) {
            var name = getComponentName(currentlyValidatingElement.type);
            var owner = currentlyValidatingElement._owner;
            stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
          } // Delegate to the injected renderer-specific implementation


          var impl = ReactDebugCurrentFrame.getCurrentStack;

          if (impl) {
            stack += impl() || '';
          }

          return stack;
        };
      }
      /**
       * Used by act() to track whether you're inside an act() scope.
       */

      var IsSomeRendererActing = {
        current: false
      };
      var ReactSharedInternals = {
        ReactCurrentDispatcher: ReactCurrentDispatcher,
        ReactCurrentBatchConfig: ReactCurrentBatchConfig,
        ReactCurrentOwner: ReactCurrentOwner,
        IsSomeRendererActing: IsSomeRendererActing,
        // Used by renderers to avoid bundling object-assign twice in UMD bundles:
        assign: _assign
      };
      {
        _assign(ReactSharedInternals, {
          // These should not be included in production.
          ReactDebugCurrentFrame: ReactDebugCurrentFrame,
          // Shim for React DOM 16.0.0 which still destructured (but not used) this.
          // TODO: remove in React 17.0.
          ReactComponentTreeHook: {}
        });
      } // by calls to these methods by a Babel plugin.
      //
      // In PROD (or in packages without access to React internals),
      // they are left as they are instead.

      function warn(format) {
        {
          for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
            args[_key - 1] = arguments[_key];
          }

          printWarning('warn', format, args);
        }
      }

      function error(format) {
        {
          for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
            args[_key2 - 1] = arguments[_key2];
          }

          printWarning('error', format, args);
        }
      }

      function printWarning(level, format, args) {
        // When changing this logic, you might want to also
        // update consoleWithStackDev.www.js as well.
        {
          var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n    in') === 0;

          if (!hasExistingStack) {
            var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
            var stack = ReactDebugCurrentFrame.getStackAddendum();

            if (stack !== '') {
              format += '%s';
              args = args.concat([stack]);
            }
          }

          var argsWithFormat = args.map(function (item) {
            return '' + item;
          }); // Careful: RN currently depends on this prefix

          argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
          // breaks IE9: https://github.com/facebook/react/issues/13610
          // eslint-disable-next-line react-internal/no-production-logging

          Function.prototype.apply.call(console[level], console, argsWithFormat);

          try {
            // --- Welcome to debugging React ---
            // This error was thrown as a convenience so that you can use this stack
            // to find the callsite that caused this warning to fire.
            var argIndex = 0;
            var message = 'Warning: ' + format.replace(/%s/g, function () {
              return args[argIndex++];
            });
            throw new Error(message);
          } catch (x) {}
        }
      }

      var didWarnStateUpdateForUnmountedComponent = {};

      function warnNoop(publicInstance, callerName) {
        {
          var _constructor = publicInstance.constructor;
          var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
          var warningKey = componentName + "." + callerName;

          if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
            return;
          }

          error("Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);
          didWarnStateUpdateForUnmountedComponent[warningKey] = true;
        }
      }
      /**
       * This is the abstract API for an update queue.
       */


      var ReactNoopUpdateQueue = {
        /**
         * Checks whether or not this composite component is mounted.
         * @param {ReactClass} publicInstance The instance we want to test.
         * @return {boolean} True if mounted, false otherwise.
         * @protected
         * @final
         */
        isMounted: function isMounted(publicInstance) {
          return false;
        },

        /**
         * Forces an update. This should only be invoked when it is known with
         * certainty that we are **not** in a DOM transaction.
         *
         * You may want to call this when you know that some deeper aspect of the
         * component's state has changed but `setState` was not called.
         *
         * This will not invoke `shouldComponentUpdate`, but it will invoke
         * `componentWillUpdate` and `componentDidUpdate`.
         *
         * @param {ReactClass} publicInstance The instance that should rerender.
         * @param {?function} callback Called after component is updated.
         * @param {?string} callerName name of the calling function in the public API.
         * @internal
         */
        enqueueForceUpdate: function enqueueForceUpdate(publicInstance, callback, callerName) {
          warnNoop(publicInstance, 'forceUpdate');
        },

        /**
         * Replaces all of the state. Always use this or `setState` to mutate state.
         * You should treat `this.state` as immutable.
         *
         * There is no guarantee that `this.state` will be immediately updated, so
         * accessing `this.state` after calling this method may return the old value.
         *
         * @param {ReactClass} publicInstance The instance that should rerender.
         * @param {object} completeState Next state.
         * @param {?function} callback Called after component is updated.
         * @param {?string} callerName name of the calling function in the public API.
         * @internal
         */
        enqueueReplaceState: function enqueueReplaceState(publicInstance, completeState, callback, callerName) {
          warnNoop(publicInstance, 'replaceState');
        },

        /**
         * Sets a subset of the state. This only exists because _pendingState is
         * internal. This provides a merging strategy that is not available to deep
         * properties which is confusing. TODO: Expose pendingState or don't use it
         * during the merge.
         *
         * @param {ReactClass} publicInstance The instance that should rerender.
         * @param {object} partialState Next partial state to be merged with state.
         * @param {?function} callback Called after component is updated.
         * @param {?string} Name of the calling function in the public API.
         * @internal
         */
        enqueueSetState: function enqueueSetState(publicInstance, partialState, callback, callerName) {
          warnNoop(publicInstance, 'setState');
        }
      };
      var emptyObject = {};
      {
        Object.freeze(emptyObject);
      }
      /**
       * Base class helpers for the updating state of a component.
       */

      function Component(props, context, updater) {
        this.props = props;
        this.context = context; // If a component has string refs, we will assign a different object later.

        this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the
        // renderer.

        this.updater = updater || ReactNoopUpdateQueue;
      }

      Component.prototype.isReactComponent = {};
      /**
       * Sets a subset of the state. Always use this to mutate
       * state. You should treat `this.state` as immutable.
       *
       * There is no guarantee that `this.state` will be immediately updated, so
       * accessing `this.state` after calling this method may return the old value.
       *
       * There is no guarantee that calls to `setState` will run synchronously,
       * as they may eventually be batched together.  You can provide an optional
       * callback that will be executed when the call to setState is actually
       * completed.
       *
       * When a function is provided to setState, it will be called at some point in
       * the future (not synchronously). It will be called with the up to date
       * component arguments (state, props, context). These values can be different
       * from this.* because your function may be called after receiveProps but before
       * shouldComponentUpdate, and this new state, props, and context will not yet be
       * assigned to this.
       *
       * @param {object|function} partialState Next partial state or function to
       *        produce next partial state to be merged with current state.
       * @param {?function} callback Called after state is updated.
       * @final
       * @protected
       */

      Component.prototype.setState = function (partialState, callback) {
        if (!(_typeof$1(partialState) === 'object' || typeof partialState === 'function' || partialState == null)) {
          {
            throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
          }
        }

        this.updater.enqueueSetState(this, partialState, callback, 'setState');
      };
      /**
       * Forces an update. This should only be invoked when it is known with
       * certainty that we are **not** in a DOM transaction.
       *
       * You may want to call this when you know that some deeper aspect of the
       * component's state has changed but `setState` was not called.
       *
       * This will not invoke `shouldComponentUpdate`, but it will invoke
       * `componentWillUpdate` and `componentDidUpdate`.
       *
       * @param {?function} callback Called after update is complete.
       * @final
       * @protected
       */


      Component.prototype.forceUpdate = function (callback) {
        this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
      };
      /**
       * Deprecated APIs. These APIs used to exist on classic React classes but since
       * we would like to deprecate them, we're not going to move them over to this
       * modern base class. Instead, we define a getter that warns if it's accessed.
       */


      {
        var deprecatedAPIs = {
          isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
          replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
        };

        var defineDeprecationWarning = function defineDeprecationWarning(methodName, info) {
          Object.defineProperty(Component.prototype, methodName, {
            get: function get() {
              warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
              return undefined;
            }
          });
        };

        for (var fnName in deprecatedAPIs) {
          if (deprecatedAPIs.hasOwnProperty(fnName)) {
            defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
          }
        }
      }

      function ComponentDummy() {}

      ComponentDummy.prototype = Component.prototype;
      /**
       * Convenience component with default shallow equality check for sCU.
       */

      function PureComponent(props, context, updater) {
        this.props = props;
        this.context = context; // If a component has string refs, we will assign a different object later.

        this.refs = emptyObject;
        this.updater = updater || ReactNoopUpdateQueue;
      }

      var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
      pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods.

      _assign(pureComponentPrototype, Component.prototype);

      pureComponentPrototype.isPureReactComponent = true; // an immutable object with a single mutable value

      function createRef() {
        var refObject = {
          current: null
        };
        {
          Object.seal(refObject);
        }
        return refObject;
      }

      var hasOwnProperty = Object.prototype.hasOwnProperty;
      var RESERVED_PROPS = {
        key: true,
        ref: true,
        __self: true,
        __source: true
      };
      var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs;
      {
        didWarnAboutStringRefs = {};
      }

      function hasValidRef(config) {
        {
          if (hasOwnProperty.call(config, 'ref')) {
            var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;

            if (getter && getter.isReactWarning) {
              return false;
            }
          }
        }
        return config.ref !== undefined;
      }

      function hasValidKey(config) {
        {
          if (hasOwnProperty.call(config, 'key')) {
            var getter = Object.getOwnPropertyDescriptor(config, 'key').get;

            if (getter && getter.isReactWarning) {
              return false;
            }
          }
        }
        return config.key !== undefined;
      }

      function defineKeyPropWarningGetter(props, displayName) {
        var warnAboutAccessingKey = function warnAboutAccessingKey() {
          {
            if (!specialPropKeyWarningShown) {
              specialPropKeyWarningShown = true;
              error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
            }
          }
        };

        warnAboutAccessingKey.isReactWarning = true;
        Object.defineProperty(props, 'key', {
          get: warnAboutAccessingKey,
          configurable: true
        });
      }

      function defineRefPropWarningGetter(props, displayName) {
        var warnAboutAccessingRef = function warnAboutAccessingRef() {
          {
            if (!specialPropRefWarningShown) {
              specialPropRefWarningShown = true;
              error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
            }
          }
        };

        warnAboutAccessingRef.isReactWarning = true;
        Object.defineProperty(props, 'ref', {
          get: warnAboutAccessingRef,
          configurable: true
        });
      }

      function warnIfStringRefCannotBeAutoConverted(config) {
        {
          if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) {
            var componentName = getComponentName(ReactCurrentOwner.current.type);

            if (!didWarnAboutStringRefs[componentName]) {
              error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://fb.me/react-strict-mode-string-ref', getComponentName(ReactCurrentOwner.current.type), config.ref);
              didWarnAboutStringRefs[componentName] = true;
            }
          }
        }
      }
      /**
       * Factory method to create a new React element. This no longer adheres to
       * the class pattern, so do not use new to call it. Also, instanceof check
       * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
       * if something is a React Element.
       *
       * @param {*} type
       * @param {*} props
       * @param {*} key
       * @param {string|object} ref
       * @param {*} owner
       * @param {*} self A *temporary* helper to detect places where `this` is
       * different from the `owner` when React.createElement is called, so that we
       * can warn. We want to get rid of owner and replace string `ref`s with arrow
       * functions, and as long as `this` and owner are the same, there will be no
       * change in behavior.
       * @param {*} source An annotation object (added by a transpiler or otherwise)
       * indicating filename, line number, and/or other information.
       * @internal
       */


      var ReactElement = function ReactElement(type, key, ref, self, source, owner, props) {
        var element = {
          // This tag allows us to uniquely identify this as a React Element
          $$typeof: REACT_ELEMENT_TYPE,
          // Built-in properties that belong on the element
          type: type,
          key: key,
          ref: ref,
          props: props,
          // Record the component responsible for creating this element.
          _owner: owner
        };
        {
          // The validation flag is currently mutative. We put it on
          // an external backing store so that we can freeze the whole object.
          // This can be replaced with a WeakMap once they are implemented in
          // commonly used development environments.
          element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
          // the validation flag non-enumerable (where possible, which should
          // include every environment we run tests in), so the test framework
          // ignores it.

          Object.defineProperty(element._store, 'validated', {
            configurable: false,
            enumerable: false,
            writable: true,
            value: false
          }); // self and source are DEV only properties.

          Object.defineProperty(element, '_self', {
            configurable: false,
            enumerable: false,
            writable: false,
            value: self
          }); // Two elements created in two different places should be considered
          // equal for testing purposes and therefore we hide it from enumeration.

          Object.defineProperty(element, '_source', {
            configurable: false,
            enumerable: false,
            writable: false,
            value: source
          });

          if (Object.freeze) {
            Object.freeze(element.props);
            Object.freeze(element);
          }
        }
        return element;
      };
      /**
       * Create and return a new ReactElement of the given type.
       * See https://reactjs.org/docs/react-api.html#createelement
       */


      function createElement(type, config, children) {
        var propName; // Reserved names are extracted

        var props = {};
        var key = null;
        var ref = null;
        var self = null;
        var source = null;

        if (config != null) {
          if (hasValidRef(config)) {
            ref = config.ref;
            {
              warnIfStringRefCannotBeAutoConverted(config);
            }
          }

          if (hasValidKey(config)) {
            key = '' + config.key;
          }

          self = config.__self === undefined ? null : config.__self;
          source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object

          for (propName in config) {
            if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
              props[propName] = config[propName];
            }
          }
        } // Children can be more than one argument, and those are transferred onto
        // the newly allocated props object.


        var childrenLength = arguments.length - 2;

        if (childrenLength === 1) {
          props.children = children;
        } else if (childrenLength > 1) {
          var childArray = Array(childrenLength);

          for (var i = 0; i < childrenLength; i++) {
            childArray[i] = arguments[i + 2];
          }

          {
            if (Object.freeze) {
              Object.freeze(childArray);
            }
          }
          props.children = childArray;
        } // Resolve default props


        if (type && type.defaultProps) {
          var defaultProps = type.defaultProps;

          for (propName in defaultProps) {
            if (props[propName] === undefined) {
              props[propName] = defaultProps[propName];
            }
          }
        }

        {
          if (key || ref) {
            var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;

            if (key) {
              defineKeyPropWarningGetter(props, displayName);
            }

            if (ref) {
              defineRefPropWarningGetter(props, displayName);
            }
          }
        }
        return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
      }

      function cloneAndReplaceKey(oldElement, newKey) {
        var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
        return newElement;
      }
      /**
       * Clone and return a new ReactElement using element as the starting point.
       * See https://reactjs.org/docs/react-api.html#cloneelement
       */


      function cloneElement(element, config, children) {
        if (!!(element === null || element === undefined)) {
          {
            throw Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + ".");
          }
        }

        var propName; // Original props are copied

        var props = _assign({}, element.props); // Reserved names are extracted


        var key = element.key;
        var ref = element.ref; // Self is preserved since the owner is preserved.

        var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a
        // transpiler, and the original source is probably a better indicator of the
        // true owner.

        var source = element._source; // Owner will be preserved, unless ref is overridden

        var owner = element._owner;

        if (config != null) {
          if (hasValidRef(config)) {
            // Silently steal the ref from the parent.
            ref = config.ref;
            owner = ReactCurrentOwner.current;
          }

          if (hasValidKey(config)) {
            key = '' + config.key;
          } // Remaining properties override existing props


          var defaultProps;

          if (element.type && element.type.defaultProps) {
            defaultProps = element.type.defaultProps;
          }

          for (propName in config) {
            if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
              if (config[propName] === undefined && defaultProps !== undefined) {
                // Resolve default props
                props[propName] = defaultProps[propName];
              } else {
                props[propName] = config[propName];
              }
            }
          }
        } // Children can be more than one argument, and those are transferred onto
        // the newly allocated props object.


        var childrenLength = arguments.length - 2;

        if (childrenLength === 1) {
          props.children = children;
        } else if (childrenLength > 1) {
          var childArray = Array(childrenLength);

          for (var i = 0; i < childrenLength; i++) {
            childArray[i] = arguments[i + 2];
          }

          props.children = childArray;
        }

        return ReactElement(element.type, key, ref, self, source, owner, props);
      }
      /**
       * Verifies the object is a ReactElement.
       * See https://reactjs.org/docs/react-api.html#isvalidelement
       * @param {?object} object
       * @return {boolean} True if `object` is a ReactElement.
       * @final
       */


      function isValidElement(object) {
        return _typeof$1(object) === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
      }

      var SEPARATOR = '.';
      var SUBSEPARATOR = ':';
      /**
       * Escape and wrap key so it is safe to use as a reactid
       *
       * @param {string} key to be escaped.
       * @return {string} the escaped key.
       */

      function escape(key) {
        var escapeRegex = /[=:]/g;
        var escaperLookup = {
          '=': '=0',
          ':': '=2'
        };
        var escapedString = ('' + key).replace(escapeRegex, function (match) {
          return escaperLookup[match];
        });
        return '$' + escapedString;
      }
      /**
       * TODO: Test that a single child and an array with one item have the same key
       * pattern.
       */


      var didWarnAboutMaps = false;
      var userProvidedKeyEscapeRegex = /\/+/g;

      function escapeUserProvidedKey(text) {
        return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
      }

      var POOL_SIZE = 10;
      var traverseContextPool = [];

      function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
        if (traverseContextPool.length) {
          var traverseContext = traverseContextPool.pop();
          traverseContext.result = mapResult;
          traverseContext.keyPrefix = keyPrefix;
          traverseContext.func = mapFunction;
          traverseContext.context = mapContext;
          traverseContext.count = 0;
          return traverseContext;
        } else {
          return {
            result: mapResult,
            keyPrefix: keyPrefix,
            func: mapFunction,
            context: mapContext,
            count: 0
          };
        }
      }

      function releaseTraverseContext(traverseContext) {
        traverseContext.result = null;
        traverseContext.keyPrefix = null;
        traverseContext.func = null;
        traverseContext.context = null;
        traverseContext.count = 0;

        if (traverseContextPool.length < POOL_SIZE) {
          traverseContextPool.push(traverseContext);
        }
      }
      /**
       * @param {?*} children Children tree container.
       * @param {!string} nameSoFar Name of the key path so far.
       * @param {!function} callback Callback to invoke with each child found.
       * @param {?*} traverseContext Used to pass information throughout the traversal
       * process.
       * @return {!number} The number of children in this subtree.
       */


      function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
        var type = _typeof$1(children);

        if (type === 'undefined' || type === 'boolean') {
          // All of the above are perceived as null.
          children = null;
        }

        var invokeCallback = false;

        if (children === null) {
          invokeCallback = true;
        } else {
          switch (type) {
            case 'string':
            case 'number':
              invokeCallback = true;
              break;

            case 'object':
              switch (children.$$typeof) {
                case REACT_ELEMENT_TYPE:
                case REACT_PORTAL_TYPE:
                  invokeCallback = true;
              }

          }
        }

        if (invokeCallback) {
          callback(traverseContext, children, // If it's the only child, treat the name as if it was wrapped in an array
          // so that it's consistent if the number of children grows.
          nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
          return 1;
        }

        var child;
        var nextName;
        var subtreeCount = 0; // Count of children found in the current subtree.

        var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;

        if (Array.isArray(children)) {
          for (var i = 0; i < children.length; i++) {
            child = children[i];
            nextName = nextNamePrefix + getComponentKey(child, i);
            subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
          }
        } else {
          var iteratorFn = getIteratorFn(children);

          if (typeof iteratorFn === 'function') {
            {
              // Warn about using Maps as children
              if (iteratorFn === children.entries) {
                if (!didWarnAboutMaps) {
                  warn('Using Maps as children is deprecated and will be removed in ' + 'a future major release. Consider converting children to ' + 'an array of keyed ReactElements instead.');
                }

                didWarnAboutMaps = true;
              }
            }
            var iterator = iteratorFn.call(children);
            var step;
            var ii = 0;

            while (!(step = iterator.next()).done) {
              child = step.value;
              nextName = nextNamePrefix + getComponentKey(child, ii++);
              subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
            }
          } else if (type === 'object') {
            var addendum = '';
            {
              addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
            }
            var childrenString = '' + children;
            {
              {
                throw Error("Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + ")." + addendum);
              }
            }
          }
        }

        return subtreeCount;
      }
      /**
       * Traverses children that are typically specified as `props.children`, but
       * might also be specified through attributes:
       *
       * - `traverseAllChildren(this.props.children, ...)`
       * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
       *
       * The `traverseContext` is an optional argument that is passed through the
       * entire traversal. It can be used to store accumulations or anything else that
       * the callback might find relevant.
       *
       * @param {?*} children Children tree object.
       * @param {!function} callback To invoke upon traversing each child.
       * @param {?*} traverseContext Context for traversal.
       * @return {!number} The number of children in this subtree.
       */


      function traverseAllChildren(children, callback, traverseContext) {
        if (children == null) {
          return 0;
        }

        return traverseAllChildrenImpl(children, '', callback, traverseContext);
      }
      /**
       * Generate a key string that identifies a component within a set.
       *
       * @param {*} component A component that could contain a manual key.
       * @param {number} index Index that is used if a manual key is not provided.
       * @return {string}
       */


      function getComponentKey(component, index) {
        // Do some typechecking here since we call this blindly. We want to ensure
        // that we don't block potential future ES APIs.
        if (_typeof$1(component) === 'object' && component !== null && component.key != null) {
          // Explicit key
          return escape(component.key);
        } // Implicit key determined by the index in the set


        return index.toString(36);
      }

      function forEachSingleChild(bookKeeping, child, name) {
        var func = bookKeeping.func,
            context = bookKeeping.context;
        func.call(context, child, bookKeeping.count++);
      }
      /**
       * Iterates through children that are typically specified as `props.children`.
       *
       * See https://reactjs.org/docs/react-api.html#reactchildrenforeach
       *
       * The provided forEachFunc(child, index) will be called for each
       * leaf child.
       *
       * @param {?*} children Children tree container.
       * @param {function(*, int)} forEachFunc
       * @param {*} forEachContext Context for forEachContext.
       */


      function forEachChildren(children, forEachFunc, forEachContext) {
        if (children == null) {
          return children;
        }

        var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
        traverseAllChildren(children, forEachSingleChild, traverseContext);
        releaseTraverseContext(traverseContext);
      }

      function mapSingleChildIntoContext(bookKeeping, child, childKey) {
        var result = bookKeeping.result,
            keyPrefix = bookKeeping.keyPrefix,
            func = bookKeeping.func,
            context = bookKeeping.context;
        var mappedChild = func.call(context, child, bookKeeping.count++);

        if (Array.isArray(mappedChild)) {
          mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
            return c;
          });
        } else if (mappedChild != null) {
          if (isValidElement(mappedChild)) {
            mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as
            // traverseAllChildren used to do for objects as children
            keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
          }

          result.push(mappedChild);
        }
      }

      function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
        var escapedPrefix = '';

        if (prefix != null) {
          escapedPrefix = escapeUserProvidedKey(prefix) + '/';
        }

        var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
        traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
        releaseTraverseContext(traverseContext);
      }
      /**
       * Maps children that are typically specified as `props.children`.
       *
       * See https://reactjs.org/docs/react-api.html#reactchildrenmap
       *
       * The provided mapFunction(child, key, index) will be called for each
       * leaf child.
       *
       * @param {?*} children Children tree container.
       * @param {function(*, int)} func The map function.
       * @param {*} context Context for mapFunction.
       * @return {object} Object containing the ordered map of results.
       */


      function mapChildren(children, func, context) {
        if (children == null) {
          return children;
        }

        var result = [];
        mapIntoWithKeyPrefixInternal(children, result, null, func, context);
        return result;
      }
      /**
       * Count the number of children that are typically specified as
       * `props.children`.
       *
       * See https://reactjs.org/docs/react-api.html#reactchildrencount
       *
       * @param {?*} children Children tree container.
       * @return {number} The number of children.
       */


      function countChildren(children) {
        return traverseAllChildren(children, function () {
          return null;
        }, null);
      }
      /**
       * Flatten a children object (typically specified as `props.children`) and
       * return an array with appropriately re-keyed children.
       *
       * See https://reactjs.org/docs/react-api.html#reactchildrentoarray
       */


      function toArray(children) {
        var result = [];
        mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
          return child;
        });
        return result;
      }
      /**
       * Returns the first child in a collection of children and verifies that there
       * is only one child in the collection.
       *
       * See https://reactjs.org/docs/react-api.html#reactchildrenonly
       *
       * The current implementation of this function assumes that a single child gets
       * passed without a wrapper, but the purpose of this helper function is to
       * abstract away the particular structure of children.
       *
       * @param {?object} children Child collection structure.
       * @return {ReactElement} The first and only `ReactElement` contained in the
       * structure.
       */


      function onlyChild(children) {
        if (!isValidElement(children)) {
          {
            throw Error("React.Children.only expected to receive a single React element child.");
          }
        }

        return children;
      }

      function createContext(defaultValue, calculateChangedBits) {
        if (calculateChangedBits === undefined) {
          calculateChangedBits = null;
        } else {
          {
            if (calculateChangedBits !== null && typeof calculateChangedBits !== 'function') {
              error('createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits);
            }
          }
        }

        var context = {
          $$typeof: REACT_CONTEXT_TYPE,
          _calculateChangedBits: calculateChangedBits,
          // As a workaround to support multiple concurrent renderers, we categorize
          // some renderers as primary and others as secondary. We only expect
          // there to be two concurrent renderers at most: React Native (primary) and
          // Fabric (secondary); React DOM (primary) and React ART (secondary).
          // Secondary renderers store their context values on separate fields.
          _currentValue: defaultValue,
          _currentValue2: defaultValue,
          // Used to track how many concurrent renderers this context currently
          // supports within in a single renderer. Such as parallel server rendering.
          _threadCount: 0,
          // These are circular
          Provider: null,
          Consumer: null
        };
        context.Provider = {
          $$typeof: REACT_PROVIDER_TYPE,
          _context: context
        };
        var hasWarnedAboutUsingNestedContextConsumers = false;
        var hasWarnedAboutUsingConsumerProvider = false;
        {
          // A separate object, but proxies back to the original context object for
          // backwards compatibility. It has a different $$typeof, so we can properly
          // warn for the incorrect usage of Context as a Consumer.
          var Consumer = {
            $$typeof: REACT_CONTEXT_TYPE,
            _context: context,
            _calculateChangedBits: context._calculateChangedBits
          }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here

          Object.defineProperties(Consumer, {
            Provider: {
              get: function get() {
                if (!hasWarnedAboutUsingConsumerProvider) {
                  hasWarnedAboutUsingConsumerProvider = true;
                  error('Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?');
                }

                return context.Provider;
              },
              set: function set(_Provider) {
                context.Provider = _Provider;
              }
            },
            _currentValue: {
              get: function get() {
                return context._currentValue;
              },
              set: function set(_currentValue) {
                context._currentValue = _currentValue;
              }
            },
            _currentValue2: {
              get: function get() {
                return context._currentValue2;
              },
              set: function set(_currentValue2) {
                context._currentValue2 = _currentValue2;
              }
            },
            _threadCount: {
              get: function get() {
                return context._threadCount;
              },
              set: function set(_threadCount) {
                context._threadCount = _threadCount;
              }
            },
            Consumer: {
              get: function get() {
                if (!hasWarnedAboutUsingNestedContextConsumers) {
                  hasWarnedAboutUsingNestedContextConsumers = true;
                  error('Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
                }

                return context.Consumer;
              }
            }
          }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty

          context.Consumer = Consumer;
        }
        {
          context._currentRenderer = null;
          context._currentRenderer2 = null;
        }
        return context;
      }

      function lazy(ctor) {
        var lazyType = {
          $$typeof: REACT_LAZY_TYPE,
          _ctor: ctor,
          // React uses these fields to store the result.
          _status: -1,
          _result: null
        };
        {
          // In production, this would just set it on the object.
          var defaultProps;
          var propTypes;
          Object.defineProperties(lazyType, {
            defaultProps: {
              configurable: true,
              get: function get() {
                return defaultProps;
              },
              set: function set(newDefaultProps) {
                error('React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
                defaultProps = newDefaultProps; // Match production behavior more closely:

                Object.defineProperty(lazyType, 'defaultProps', {
                  enumerable: true
                });
              }
            },
            propTypes: {
              configurable: true,
              get: function get() {
                return propTypes;
              },
              set: function set(newPropTypes) {
                error('React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
                propTypes = newPropTypes; // Match production behavior more closely:

                Object.defineProperty(lazyType, 'propTypes', {
                  enumerable: true
                });
              }
            }
          });
        }
        return lazyType;
      }

      function forwardRef(render) {
        {
          if (render != null && render.$$typeof === REACT_MEMO_TYPE) {
            error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');
          } else if (typeof render !== 'function') {
            error('forwardRef requires a render function but was given %s.', render === null ? 'null' : _typeof$1(render));
          } else {
            if (render.length !== 0 && render.length !== 2) {
              error('forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.');
            }
          }

          if (render != null) {
            if (render.defaultProps != null || render.propTypes != null) {
              error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?');
            }
          }
        }
        return {
          $$typeof: REACT_FORWARD_REF_TYPE,
          render: render
        };
      }

      function isValidElementType(type) {
        return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
        type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || _typeof$1(type) === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
      }

      function memo(type, compare) {
        {
          if (!isValidElementType(type)) {
            error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : _typeof$1(type));
          }
        }
        return {
          $$typeof: REACT_MEMO_TYPE,
          type: type,
          compare: compare === undefined ? null : compare
        };
      }

      function resolveDispatcher() {
        var dispatcher = ReactCurrentDispatcher.current;

        if (!(dispatcher !== null)) {
          {
            throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.");
          }
        }

        return dispatcher;
      }

      function useContext(Context, unstable_observedBits) {
        var dispatcher = resolveDispatcher();
        {
          if (unstable_observedBits !== undefined) {
            error('useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : '');
          } // TODO: add a more generic warning for invalid values.


          if (Context._context !== undefined) {
            var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs
            // and nobody should be using this in existing code.

            if (realContext.Consumer === Context) {
              error('Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?');
            } else if (realContext.Provider === Context) {
              error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');
            }
          }
        }
        return dispatcher.useContext(Context, unstable_observedBits);
      }

      function useState(initialState) {
        var dispatcher = resolveDispatcher();
        return dispatcher.useState(initialState);
      }

      function useReducer(reducer, initialArg, init) {
        var dispatcher = resolveDispatcher();
        return dispatcher.useReducer(reducer, initialArg, init);
      }

      function useRef(initialValue) {
        var dispatcher = resolveDispatcher();
        return dispatcher.useRef(initialValue);
      }

      function useEffect(create, deps) {
        var dispatcher = resolveDispatcher();
        return dispatcher.useEffect(create, deps);
      }

      function useLayoutEffect(create, deps) {
        var dispatcher = resolveDispatcher();
        return dispatcher.useLayoutEffect(create, deps);
      }

      function useCallback(callback, deps) {
        var dispatcher = resolveDispatcher();
        return dispatcher.useCallback(callback, deps);
      }

      function useMemo(create, deps) {
        var dispatcher = resolveDispatcher();
        return dispatcher.useMemo(create, deps);
      }

      function useImperativeHandle(ref, create, deps) {
        var dispatcher = resolveDispatcher();
        return dispatcher.useImperativeHandle(ref, create, deps);
      }

      function useDebugValue(value, formatterFn) {
        {
          var dispatcher = resolveDispatcher();
          return dispatcher.useDebugValue(value, formatterFn);
        }
      }

      var propTypesMisspellWarningShown;
      {
        propTypesMisspellWarningShown = false;
      }

      function getDeclarationErrorAddendum() {
        if (ReactCurrentOwner.current) {
          var name = getComponentName(ReactCurrentOwner.current.type);

          if (name) {
            return '\n\nCheck the render method of `' + name + '`.';
          }
        }

        return '';
      }

      function getSourceInfoErrorAddendum(source) {
        if (source !== undefined) {
          var fileName = source.fileName.replace(/^.*[\\\/]/, '');
          var lineNumber = source.lineNumber;
          return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
        }

        return '';
      }

      function getSourceInfoErrorAddendumForProps(elementProps) {
        if (elementProps !== null && elementProps !== undefined) {
          return getSourceInfoErrorAddendum(elementProps.__source);
        }

        return '';
      }
      /**
       * Warn if there's no key explicitly set on dynamic arrays of children or
       * object keys are not valid. This allows us to keep track of children between
       * updates.
       */


      var ownerHasKeyUseWarning = {};

      function getCurrentComponentErrorInfo(parentType) {
        var info = getDeclarationErrorAddendum();

        if (!info) {
          var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;

          if (parentName) {
            info = "\n\nCheck the top-level render call using <" + parentName + ">.";
          }
        }

        return info;
      }
      /**
       * Warn if the element doesn't have an explicit key assigned to it.
       * This element is in an array. The array could grow and shrink or be
       * reordered. All children that haven't already been validated are required to
       * have a "key" property assigned to it. Error statuses are cached so a warning
       * will only be shown once.
       *
       * @internal
       * @param {ReactElement} element Element that requires a key.
       * @param {*} parentType element's parent's type.
       */


      function validateExplicitKey(element, parentType) {
        if (!element._store || element._store.validated || element.key != null) {
          return;
        }

        element._store.validated = true;
        var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);

        if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
          return;
        }

        ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
        // property, it may be the creator of the child that's responsible for
        // assigning it a key.

        var childOwner = '';

        if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
          // Give the component that originally created this child.
          childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
        }

        setCurrentlyValidatingElement(element);
        {
          error('Each child in a list should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner);
        }
        setCurrentlyValidatingElement(null);
      }
      /**
       * Ensure that every element either is passed in a static location, in an
       * array with an explicit keys property defined, or in an object literal
       * with valid key property.
       *
       * @internal
       * @param {ReactNode} node Statically passed child of any type.
       * @param {*} parentType node's parent's type.
       */


      function validateChildKeys(node, parentType) {
        if (_typeof$1(node) !== 'object') {
          return;
        }

        if (Array.isArray(node)) {
          for (var i = 0; i < node.length; i++) {
            var child = node[i];

            if (isValidElement(child)) {
              validateExplicitKey(child, parentType);
            }
          }
        } else if (isValidElement(node)) {
          // This element was passed in a valid location.
          if (node._store) {
            node._store.validated = true;
          }
        } else if (node) {
          var iteratorFn = getIteratorFn(node);

          if (typeof iteratorFn === 'function') {
            // Entry iterators used to provide implicit keys,
            // but now we print a separate warning for them later.
            if (iteratorFn !== node.entries) {
              var iterator = iteratorFn.call(node);
              var step;

              while (!(step = iterator.next()).done) {
                if (isValidElement(step.value)) {
                  validateExplicitKey(step.value, parentType);
                }
              }
            }
          }
        }
      }
      /**
       * Given an element, validate that its props follow the propTypes definition,
       * provided by the type.
       *
       * @param {ReactElement} element
       */


      function validatePropTypes(element) {
        {
          var type = element.type;

          if (type === null || type === undefined || typeof type === 'string') {
            return;
          }

          var name = getComponentName(type);
          var propTypes;

          if (typeof type === 'function') {
            propTypes = type.propTypes;
          } else if (_typeof$1(type) === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
          // Inner props are checked in the reconciler.
          type.$$typeof === REACT_MEMO_TYPE)) {
            propTypes = type.propTypes;
          } else {
            return;
          }

          if (propTypes) {
            setCurrentlyValidatingElement(element);
            checkPropTypes(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
            setCurrentlyValidatingElement(null);
          } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
            propTypesMisspellWarningShown = true;
            error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
          }

          if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
            error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
          }
        }
      }
      /**
       * Given a fragment, validate that it can only be provided with fragment props
       * @param {ReactElement} fragment
       */


      function validateFragmentProps(fragment) {
        {
          setCurrentlyValidatingElement(fragment);
          var keys = Object.keys(fragment.props);

          for (var i = 0; i < keys.length; i++) {
            var key = keys[i];

            if (key !== 'children' && key !== 'key') {
              error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
              break;
            }
          }

          if (fragment.ref !== null) {
            error('Invalid attribute `ref` supplied to `React.Fragment`.');
          }

          setCurrentlyValidatingElement(null);
        }
      }

      function createElementWithValidation(type, props, children) {
        var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
        // succeed and there will likely be errors in render.

        if (!validType) {
          var info = '';

          if (type === undefined || _typeof$1(type) === 'object' && type !== null && Object.keys(type).length === 0) {
            info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
          }

          var sourceInfo = getSourceInfoErrorAddendumForProps(props);

          if (sourceInfo) {
            info += sourceInfo;
          } else {
            info += getDeclarationErrorAddendum();
          }

          var typeString;

          if (type === null) {
            typeString = 'null';
          } else if (Array.isArray(type)) {
            typeString = 'array';
          } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
            typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
            info = ' Did you accidentally export a JSX literal instead of a component?';
          } else {
            typeString = _typeof$1(type);
          }

          {
            error('React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
          }
        }

        var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used.
        // TODO: Drop this when these are no longer allowed as the type argument.

        if (element == null) {
          return element;
        } // Skip key warning if the type isn't valid since our key validation logic
        // doesn't expect a non-string/function type and can throw confusing errors.
        // We don't want exception behavior to differ between dev and prod.
        // (Rendering will throw with a helpful message and as soon as the type is
        // fixed, the key warnings will appear.)


        if (validType) {
          for (var i = 2; i < arguments.length; i++) {
            validateChildKeys(arguments[i], type);
          }
        }

        if (type === REACT_FRAGMENT_TYPE) {
          validateFragmentProps(element);
        } else {
          validatePropTypes(element);
        }

        return element;
      }

      var didWarnAboutDeprecatedCreateFactory = false;

      function createFactoryWithValidation(type) {
        var validatedFactory = createElementWithValidation.bind(null, type);
        validatedFactory.type = type;
        {
          if (!didWarnAboutDeprecatedCreateFactory) {
            didWarnAboutDeprecatedCreateFactory = true;
            warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.');
          } // Legacy hook: remove it


          Object.defineProperty(validatedFactory, 'type', {
            enumerable: false,
            get: function get() {
              warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
              Object.defineProperty(this, 'type', {
                value: type
              });
              return type;
            }
          });
        }
        return validatedFactory;
      }

      function cloneElementWithValidation(element, props, children) {
        var newElement = cloneElement.apply(this, arguments);

        for (var i = 2; i < arguments.length; i++) {
          validateChildKeys(arguments[i], newElement.type);
        }

        validatePropTypes(newElement);
        return newElement;
      }

      {
        try {
          var frozenObject = Object.freeze({});
          var testMap = new Map([[frozenObject, null]]);
          var testSet = new Set([frozenObject]); // This is necessary for Rollup to not consider these unused.
          // https://github.com/rollup/rollup/issues/1771
          // TODO: we can remove these if Rollup fixes the bug.

          testMap.set(0, 0);
          testSet.add(0);
        } catch (e) {}
      }
      var createElement$1 = createElementWithValidation;
      var cloneElement$1 = cloneElementWithValidation;
      var createFactory = createFactoryWithValidation;
      var Children = {
        map: mapChildren,
        forEach: forEachChildren,
        count: countChildren,
        toArray: toArray,
        only: onlyChild
      };
      exports.Children = Children;
      exports.Component = Component;
      exports.Fragment = REACT_FRAGMENT_TYPE;
      exports.Profiler = REACT_PROFILER_TYPE;
      exports.PureComponent = PureComponent;
      exports.StrictMode = REACT_STRICT_MODE_TYPE;
      exports.Suspense = REACT_SUSPENSE_TYPE;
      exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals;
      exports.cloneElement = cloneElement$1;
      exports.createContext = createContext;
      exports.createElement = createElement$1;
      exports.createFactory = createFactory;
      exports.createRef = createRef;
      exports.forwardRef = forwardRef;
      exports.isValidElement = isValidElement;
      exports.lazy = lazy;
      exports.memo = memo;
      exports.useCallback = useCallback;
      exports.useContext = useContext;
      exports.useDebugValue = useDebugValue;
      exports.useEffect = useEffect;
      exports.useImperativeHandle = useImperativeHandle;
      exports.useLayoutEffect = useLayoutEffect;
      exports.useMemo = useMemo;
      exports.useReducer = useReducer;
      exports.useRef = useRef;
      exports.useState = useState;
      exports.version = ReactVersion;
    })();
  }
});

var react = createCommonjsModule(function (module) {

  {
    module.exports = react_development;
  }
});

var allLocaleData = {};

/*
Copyright (c) 2014, Yahoo! Inc. All rights reserved.
Copyrights licensed under the New BSD License.
See the accompanying LICENSE file for terms.
*/

var extend_1 = extend;
var hop = Object.prototype.hasOwnProperty;

function extend(obj) {
  var sources = Array.prototype.slice.call(arguments, 1),
      i,
      len,
      source,
      key;

  for (i = 0, len = sources.length; i < len; i += 1) {
    source = sources[i];

    if (!source) {
      continue;
    }

    for (key in source) {
      if (hop.call(source, key)) {
        obj[key] = source[key];
      }
    }
  }

  return obj;
}

var hop_1 = hop;
var utils = {
  extend: extend_1,
  hop: hop_1
};

var es5$1 = createCommonjsModule(function (module, exports) {
  // Copyright 2013 Andy Earnshaw, MIT License

  var realDefineProp = function () {
    try {
      return !!Object.defineProperty({}, 'a', {});
    } catch (e) {
      return false;
    }
  }();
  var defineProperty = realDefineProp ? Object.defineProperty : function (obj, name, desc) {
    if ('get' in desc && obj.__defineGetter__) {
      obj.__defineGetter__(name, desc.get);
    } else if (!utils.hop.call(obj, name) || 'value' in desc) {
      obj[name] = desc.value;
    }
  };

  var objCreate = Object.create || function (proto, props) {
    var obj, k;

    function F() {}

    F.prototype = proto;
    obj = new F();

    for (k in props) {
      if (utils.hop.call(props, k)) {
        defineProperty(obj, k, props[k]);
      }
    }

    return obj;
  };

  exports.defineProperty = defineProperty, exports.objCreate = objCreate;
});

var compiler = createCommonjsModule(function (module, exports) {

  exports["default"] = Compiler;

  function Compiler(locales, formats, pluralFn) {
    this.locales = locales;
    this.formats = formats;
    this.pluralFn = pluralFn;
  }

  Compiler.prototype.compile = function (ast) {
    this.pluralStack = [];
    this.currentPlural = null;
    this.pluralNumberFormat = null;
    return this.compileMessage(ast);
  };

  Compiler.prototype.compileMessage = function (ast) {
    if (!(ast && ast.type === 'messageFormatPattern')) {
      throw new Error('Message AST is not of type: "messageFormatPattern"');
    }

    var elements = ast.elements,
        pattern = [];
    var i, len, element;

    for (i = 0, len = elements.length; i < len; i += 1) {
      element = elements[i];

      switch (element.type) {
        case 'messageTextElement':
          pattern.push(this.compileMessageText(element));
          break;

        case 'argumentElement':
          pattern.push(this.compileArgument(element));
          break;

        default:
          throw new Error('Message element does not have a valid type');
      }
    }

    return pattern;
  };

  Compiler.prototype.compileMessageText = function (element) {
    // When this `element` is part of plural sub-pattern and its value contains
    // an unescaped '#', use a `PluralOffsetString` helper to properly output
    // the number with the correct offset in the string.
    if (this.currentPlural && /(^|[^\\])#/g.test(element.value)) {
      // Create a cache a NumberFormat instance that can be reused for any
      // PluralOffsetString instance in this message.
      if (!this.pluralNumberFormat) {
        this.pluralNumberFormat = new Intl.NumberFormat(this.locales);
      }

      return new PluralOffsetString(this.currentPlural.id, this.currentPlural.format.offset, this.pluralNumberFormat, element.value);
    } // Unescape the escaped '#'s in the message text.


    return element.value.replace(/\\#/g, '#');
  };

  Compiler.prototype.compileArgument = function (element) {
    var format = element.format;

    if (!format) {
      return new StringFormat(element.id);
    }

    var formats = this.formats,
        locales = this.locales,
        pluralFn = this.pluralFn,
        options;

    switch (format.type) {
      case 'numberFormat':
        options = formats.number[format.style];
        return {
          id: element.id,
          format: new Intl.NumberFormat(locales, options).format
        };

      case 'dateFormat':
        options = formats.date[format.style];
        return {
          id: element.id,
          format: new Intl.DateTimeFormat(locales, options).format
        };

      case 'timeFormat':
        options = formats.time[format.style];
        return {
          id: element.id,
          format: new Intl.DateTimeFormat(locales, options).format
        };

      case 'pluralFormat':
        options = this.compileOptions(element);
        return new PluralFormat(element.id, format.ordinal, format.offset, options, pluralFn);

      case 'selectFormat':
        options = this.compileOptions(element);
        return new SelectFormat(element.id, options);

      default:
        throw new Error('Message element does not have a valid format type');
    }
  };

  Compiler.prototype.compileOptions = function (element) {
    var format = element.format,
        options = format.options,
        optionsHash = {}; // Save the current plural element, if any, then set it to a new value when
    // compiling the options sub-patterns. This conforms the spec's algorithm
    // for handling `"#"` syntax in message text.

    this.pluralStack.push(this.currentPlural);
    this.currentPlural = format.type === 'pluralFormat' ? element : null;
    var i, len, option;

    for (i = 0, len = options.length; i < len; i += 1) {
      option = options[i]; // Compile the sub-pattern and save it under the options's selector.

      optionsHash[option.selector] = this.compileMessage(option.value);
    } // Pop the plural stack to put back the original current plural value.


    this.currentPlural = this.pluralStack.pop();
    return optionsHash;
  }; // -- Compiler Helper Classes --------------------------------------------------


  function StringFormat(id) {
    this.id = id;
  }

  StringFormat.prototype.format = function (value) {
    if (!value && typeof value !== 'number') {
      return '';
    }

    return typeof value === 'string' ? value : String(value);
  };

  function PluralFormat(id, useOrdinal, offset, options, pluralFn) {
    this.id = id;
    this.useOrdinal = useOrdinal;
    this.offset = offset;
    this.options = options;
    this.pluralFn = pluralFn;
  }

  PluralFormat.prototype.getOption = function (value) {
    var options = this.options;
    var option = options['=' + value] || options[this.pluralFn(value - this.offset, this.useOrdinal)];
    return option || options.other;
  };

  function PluralOffsetString(id, offset, numberFormat, string) {
    this.id = id;
    this.offset = offset;
    this.numberFormat = numberFormat;
    this.string = string;
  }

  PluralOffsetString.prototype.format = function (value) {
    var number = this.numberFormat.format(value - this.offset);
    return this.string.replace(/(^|[^\\])#/g, '$1' + number).replace(/\\#/g, '#');
  };

  function SelectFormat(id, options) {
    this.id = id;
    this.options = options;
  }

  SelectFormat.prototype.getOption = function (value) {
    var options = this.options;
    return options[value] || options.other;
  };
});

var parser = createCommonjsModule(function (module, exports) {

  exports["default"] = function () {
    /*
     * Generated by PEG.js 0.9.0.
     *
     * http://pegjs.org/
     */

    function peg$subclass(child, parent) {
      function ctor() {
        this.constructor = child;
      }

      ctor.prototype = parent.prototype;
      child.prototype = new ctor();
    }

    function peg$SyntaxError(message, expected, found, location) {
      this.message = message;
      this.expected = expected;
      this.found = found;
      this.location = location;
      this.name = "SyntaxError";

      if (typeof Error.captureStackTrace === "function") {
        Error.captureStackTrace(this, peg$SyntaxError);
      }
    }

    peg$subclass(peg$SyntaxError, Error);

    function peg$parse(input) {
      var options = arguments.length > 1 ? arguments[1] : {},
          peg$FAILED = {},
          peg$startRuleFunctions = {
        start: peg$parsestart
      },
          peg$startRuleFunction = peg$parsestart,
          peg$c0 = function peg$c0(elements) {
        return {
          type: 'messageFormatPattern',
          elements: elements,
          location: location()
        };
      },
          peg$c1 = function peg$c1(text) {
        var string = '',
            i,
            j,
            outerLen,
            inner,
            innerLen;

        for (i = 0, outerLen = text.length; i < outerLen; i += 1) {
          inner = text[i];

          for (j = 0, innerLen = inner.length; j < innerLen; j += 1) {
            string += inner[j];
          }
        }

        return string;
      },
          peg$c2 = function peg$c2(messageText) {
        return {
          type: 'messageTextElement',
          value: messageText,
          location: location()
        };
      },
          peg$c3 = /^[^ \t\n\r,.+={}#]/,
          peg$c4 = {
        type: "class",
        value: "[^ \\t\\n\\r,.+={}#]",
        description: "[^ \\t\\n\\r,.+={}#]"
      },
          peg$c5 = "{",
          peg$c6 = {
        type: "literal",
        value: "{",
        description: "\"{\""
      },
          peg$c7 = ",",
          peg$c8 = {
        type: "literal",
        value: ",",
        description: "\",\""
      },
          peg$c9 = "}",
          peg$c10 = {
        type: "literal",
        value: "}",
        description: "\"}\""
      },
          peg$c11 = function peg$c11(id, format) {
        return {
          type: 'argumentElement',
          id: id,
          format: format && format[2],
          location: location()
        };
      },
          peg$c12 = "number",
          peg$c13 = {
        type: "literal",
        value: "number",
        description: "\"number\""
      },
          peg$c14 = "date",
          peg$c15 = {
        type: "literal",
        value: "date",
        description: "\"date\""
      },
          peg$c16 = "time",
          peg$c17 = {
        type: "literal",
        value: "time",
        description: "\"time\""
      },
          peg$c18 = function peg$c18(type, style) {
        return {
          type: type + 'Format',
          style: style && style[2],
          location: location()
        };
      },
          peg$c19 = "plural",
          peg$c20 = {
        type: "literal",
        value: "plural",
        description: "\"plural\""
      },
          peg$c21 = function peg$c21(pluralStyle) {
        return {
          type: pluralStyle.type,
          ordinal: false,
          offset: pluralStyle.offset || 0,
          options: pluralStyle.options,
          location: location()
        };
      },
          peg$c22 = "selectordinal",
          peg$c23 = {
        type: "literal",
        value: "selectordinal",
        description: "\"selectordinal\""
      },
          peg$c24 = function peg$c24(pluralStyle) {
        return {
          type: pluralStyle.type,
          ordinal: true,
          offset: pluralStyle.offset || 0,
          options: pluralStyle.options,
          location: location()
        };
      },
          peg$c25 = "select",
          peg$c26 = {
        type: "literal",
        value: "select",
        description: "\"select\""
      },
          peg$c27 = function peg$c27(options) {
        return {
          type: 'selectFormat',
          options: options,
          location: location()
        };
      },
          peg$c28 = "=",
          peg$c29 = {
        type: "literal",
        value: "=",
        description: "\"=\""
      },
          peg$c30 = function peg$c30(selector, pattern) {
        return {
          type: 'optionalFormatPattern',
          selector: selector,
          value: pattern,
          location: location()
        };
      },
          peg$c31 = "offset:",
          peg$c32 = {
        type: "literal",
        value: "offset:",
        description: "\"offset:\""
      },
          peg$c33 = function peg$c33(number) {
        return number;
      },
          peg$c34 = function peg$c34(offset, options) {
        return {
          type: 'pluralFormat',
          offset: offset,
          options: options,
          location: location()
        };
      },
          peg$c35 = {
        type: "other",
        description: "whitespace"
      },
          peg$c36 = /^[ \t\n\r]/,
          peg$c37 = {
        type: "class",
        value: "[ \\t\\n\\r]",
        description: "[ \\t\\n\\r]"
      },
          peg$c38 = {
        type: "other",
        description: "optionalWhitespace"
      },
          peg$c39 = /^[0-9]/,
          peg$c40 = {
        type: "class",
        value: "[0-9]",
        description: "[0-9]"
      },
          peg$c41 = /^[0-9a-f]/i,
          peg$c42 = {
        type: "class",
        value: "[0-9a-f]i",
        description: "[0-9a-f]i"
      },
          peg$c43 = "0",
          peg$c44 = {
        type: "literal",
        value: "0",
        description: "\"0\""
      },
          peg$c45 = /^[1-9]/,
          peg$c46 = {
        type: "class",
        value: "[1-9]",
        description: "[1-9]"
      },
          peg$c47 = function peg$c47(digits) {
        return parseInt(digits, 10);
      },
          peg$c48 = /^[^{}\\\0-\x1F \t\n\r]/,
          peg$c49 = {
        type: "class",
        value: "[^{}\\\\\\0-\\x1F\\x7f \\t\\n\\r]",
        description: "[^{}\\\\\\0-\\x1F\\x7f \\t\\n\\r]"
      },
          peg$c50 = "\\\\",
          peg$c51 = {
        type: "literal",
        value: "\\\\",
        description: "\"\\\\\\\\\""
      },
          peg$c52 = function peg$c52() {
        return '\\';
      },
          peg$c53 = "\\#",
          peg$c54 = {
        type: "literal",
        value: "\\#",
        description: "\"\\\\#\""
      },
          peg$c55 = function peg$c55() {
        return '\\#';
      },
          peg$c56 = "\\{",
          peg$c57 = {
        type: "literal",
        value: "\\{",
        description: "\"\\\\{\""
      },
          peg$c58 = function peg$c58() {
        return "{";
      },
          peg$c59 = "\\}",
          peg$c60 = {
        type: "literal",
        value: "\\}",
        description: "\"\\\\}\""
      },
          peg$c61 = function peg$c61() {
        return "}";
      },
          peg$c62 = "\\u",
          peg$c63 = {
        type: "literal",
        value: "\\u",
        description: "\"\\\\u\""
      },
          peg$c64 = function peg$c64(digits) {
        return String.fromCharCode(parseInt(digits, 16));
      },
          peg$c65 = function peg$c65(chars) {
        return chars.join('');
      },
          peg$currPos = 0,
          peg$savedPos = 0,
          peg$posDetailsCache = [{
        line: 1,
        column: 1,
        seenCR: false
      }],
          peg$maxFailPos = 0,
          peg$maxFailExpected = [],
          peg$silentFails = 0,
          peg$result;

      if ("startRule" in options) {
        if (!(options.startRule in peg$startRuleFunctions)) {
          throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
        }

        peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
      }

      function location() {
        return peg$computeLocation(peg$savedPos, peg$currPos);
      }

      function peg$computePosDetails(pos) {
        var details = peg$posDetailsCache[pos],
            p,
            ch;

        if (details) {
          return details;
        } else {
          p = pos - 1;

          while (!peg$posDetailsCache[p]) {
            p--;
          }

          details = peg$posDetailsCache[p];
          details = {
            line: details.line,
            column: details.column,
            seenCR: details.seenCR
          };

          while (p < pos) {
            ch = input.charAt(p);

            if (ch === "\n") {
              if (!details.seenCR) {
                details.line++;
              }

              details.column = 1;
              details.seenCR = false;
            } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
              details.line++;
              details.column = 1;
              details.seenCR = true;
            } else {
              details.column++;
              details.seenCR = false;
            }

            p++;
          }

          peg$posDetailsCache[pos] = details;
          return details;
        }
      }

      function peg$computeLocation(startPos, endPos) {
        var startPosDetails = peg$computePosDetails(startPos),
            endPosDetails = peg$computePosDetails(endPos);
        return {
          start: {
            offset: startPos,
            line: startPosDetails.line,
            column: startPosDetails.column
          },
          end: {
            offset: endPos,
            line: endPosDetails.line,
            column: endPosDetails.column
          }
        };
      }

      function peg$fail(expected) {
        if (peg$currPos < peg$maxFailPos) {
          return;
        }

        if (peg$currPos > peg$maxFailPos) {
          peg$maxFailPos = peg$currPos;
          peg$maxFailExpected = [];
        }

        peg$maxFailExpected.push(expected);
      }

      function peg$buildException(message, expected, found, location) {
        function cleanupExpected(expected) {
          var i = 1;
          expected.sort(function (a, b) {
            if (a.description < b.description) {
              return -1;
            } else if (a.description > b.description) {
              return 1;
            } else {
              return 0;
            }
          });

          while (i < expected.length) {
            if (expected[i - 1] === expected[i]) {
              expected.splice(i, 1);
            } else {
              i++;
            }
          }
        }

        function buildMessage(expected, found) {
          function stringEscape(s) {
            function hex(ch) {
              return ch.charCodeAt(0).toString(16).toUpperCase();
            }

            return s.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\x08/g, '\\b').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\f/g, '\\f').replace(/\r/g, '\\r').replace(/[\x00-\x07\x0B\x0E\x0F]/g, function (ch) {
              return '\\x0' + hex(ch);
            }).replace(/[\x10-\x1F\x80-\xFF]/g, function (ch) {
              return '\\x' + hex(ch);
            }).replace(/[\u0100-\u0FFF]/g, function (ch) {
              return "\\u0" + hex(ch);
            }).replace(/[\u1000-\uFFFF]/g, function (ch) {
              return "\\u" + hex(ch);
            });
          }

          var expectedDescs = new Array(expected.length),
              expectedDesc,
              foundDesc,
              i;

          for (i = 0; i < expected.length; i++) {
            expectedDescs[i] = expected[i].description;
          }

          expectedDesc = expected.length > 1 ? expectedDescs.slice(0, -1).join(", ") + " or " + expectedDescs[expected.length - 1] : expectedDescs[0];
          foundDesc = found ? "\"" + stringEscape(found) + "\"" : "end of input";
          return "Expected " + expectedDesc + " but " + foundDesc + " found.";
        }

        if (expected !== null) {
          cleanupExpected(expected);
        }

        return new peg$SyntaxError(message !== null ? message : buildMessage(expected, found), expected, found, location);
      }

      function peg$parsestart() {
        var s0;
        s0 = peg$parsemessageFormatPattern();
        return s0;
      }

      function peg$parsemessageFormatPattern() {
        var s0, s1, s2;
        s0 = peg$currPos;
        s1 = [];
        s2 = peg$parsemessageFormatElement();

        while (s2 !== peg$FAILED) {
          s1.push(s2);
          s2 = peg$parsemessageFormatElement();
        }

        if (s1 !== peg$FAILED) {
          peg$savedPos = s0;
          s1 = peg$c0(s1);
        }

        s0 = s1;
        return s0;
      }

      function peg$parsemessageFormatElement() {
        var s0;
        s0 = peg$parsemessageTextElement();

        if (s0 === peg$FAILED) {
          s0 = peg$parseargumentElement();
        }

        return s0;
      }

      function peg$parsemessageText() {
        var s0, s1, s2, s3, s4, s5;
        s0 = peg$currPos;
        s1 = [];
        s2 = peg$currPos;
        s3 = peg$parse_();

        if (s3 !== peg$FAILED) {
          s4 = peg$parsechars();

          if (s4 !== peg$FAILED) {
            s5 = peg$parse_();

            if (s5 !== peg$FAILED) {
              s3 = [s3, s4, s5];
              s2 = s3;
            } else {
              peg$currPos = s2;
              s2 = peg$FAILED;
            }
          } else {
            peg$currPos = s2;
            s2 = peg$FAILED;
          }
        } else {
          peg$currPos = s2;
          s2 = peg$FAILED;
        }

        if (s2 !== peg$FAILED) {
          while (s2 !== peg$FAILED) {
            s1.push(s2);
            s2 = peg$currPos;
            s3 = peg$parse_();

            if (s3 !== peg$FAILED) {
              s4 = peg$parsechars();

              if (s4 !== peg$FAILED) {
                s5 = peg$parse_();

                if (s5 !== peg$FAILED) {
                  s3 = [s3, s4, s5];
                  s2 = s3;
                } else {
                  peg$currPos = s2;
                  s2 = peg$FAILED;
                }
              } else {
                peg$currPos = s2;
                s2 = peg$FAILED;
              }
            } else {
              peg$currPos = s2;
              s2 = peg$FAILED;
            }
          }
        } else {
          s1 = peg$FAILED;
        }

        if (s1 !== peg$FAILED) {
          peg$savedPos = s0;
          s1 = peg$c1(s1);
        }

        s0 = s1;

        if (s0 === peg$FAILED) {
          s0 = peg$currPos;
          s1 = peg$parsews();

          if (s1 !== peg$FAILED) {
            s0 = input.substring(s0, peg$currPos);
          } else {
            s0 = s1;
          }
        }

        return s0;
      }

      function peg$parsemessageTextElement() {
        var s0, s1;
        s0 = peg$currPos;
        s1 = peg$parsemessageText();

        if (s1 !== peg$FAILED) {
          peg$savedPos = s0;
          s1 = peg$c2(s1);
        }

        s0 = s1;
        return s0;
      }

      function peg$parseargument() {
        var s0, s1, s2;
        s0 = peg$parsenumber();

        if (s0 === peg$FAILED) {
          s0 = peg$currPos;
          s1 = [];

          if (peg$c3.test(input.charAt(peg$currPos))) {
            s2 = input.charAt(peg$currPos);
            peg$currPos++;
          } else {
            s2 = peg$FAILED;

            if (peg$silentFails === 0) {
              peg$fail(peg$c4);
            }
          }

          if (s2 !== peg$FAILED) {
            while (s2 !== peg$FAILED) {
              s1.push(s2);

              if (peg$c3.test(input.charAt(peg$currPos))) {
                s2 = input.charAt(peg$currPos);
                peg$currPos++;
              } else {
                s2 = peg$FAILED;

                if (peg$silentFails === 0) {
                  peg$fail(peg$c4);
                }
              }
            }
          } else {
            s1 = peg$FAILED;
          }

          if (s1 !== peg$FAILED) {
            s0 = input.substring(s0, peg$currPos);
          } else {
            s0 = s1;
          }
        }

        return s0;
      }

      function peg$parseargumentElement() {
        var s0, s1, s2, s3, s4, s5, s6, s7, s8;
        s0 = peg$currPos;

        if (input.charCodeAt(peg$currPos) === 123) {
          s1 = peg$c5;
          peg$currPos++;
        } else {
          s1 = peg$FAILED;

          if (peg$silentFails === 0) {
            peg$fail(peg$c6);
          }
        }

        if (s1 !== peg$FAILED) {
          s2 = peg$parse_();

          if (s2 !== peg$FAILED) {
            s3 = peg$parseargument();

            if (s3 !== peg$FAILED) {
              s4 = peg$parse_();

              if (s4 !== peg$FAILED) {
                s5 = peg$currPos;

                if (input.charCodeAt(peg$currPos) === 44) {
                  s6 = peg$c7;
                  peg$currPos++;
                } else {
                  s6 = peg$FAILED;

                  if (peg$silentFails === 0) {
                    peg$fail(peg$c8);
                  }
                }

                if (s6 !== peg$FAILED) {
                  s7 = peg$parse_();

                  if (s7 !== peg$FAILED) {
                    s8 = peg$parseelementFormat();

                    if (s8 !== peg$FAILED) {
                      s6 = [s6, s7, s8];
                      s5 = s6;
                    } else {
                      peg$currPos = s5;
                      s5 = peg$FAILED;
                    }
                  } else {
                    peg$currPos = s5;
                    s5 = peg$FAILED;
                  }
                } else {
                  peg$currPos = s5;
                  s5 = peg$FAILED;
                }

                if (s5 === peg$FAILED) {
                  s5 = null;
                }

                if (s5 !== peg$FAILED) {
                  s6 = peg$parse_();

                  if (s6 !== peg$FAILED) {
                    if (input.charCodeAt(peg$currPos) === 125) {
                      s7 = peg$c9;
                      peg$currPos++;
                    } else {
                      s7 = peg$FAILED;

                      if (peg$silentFails === 0) {
                        peg$fail(peg$c10);
                      }
                    }

                    if (s7 !== peg$FAILED) {
                      peg$savedPos = s0;
                      s1 = peg$c11(s3, s5);
                      s0 = s1;
                    } else {
                      peg$currPos = s0;
                      s0 = peg$FAILED;
                    }
                  } else {
                    peg$currPos = s0;
                    s0 = peg$FAILED;
                  }
                } else {
                  peg$currPos = s0;
                  s0 = peg$FAILED;
                }
              } else {
                peg$currPos = s0;
                s0 = peg$FAILED;
              }
            } else {
              peg$currPos = s0;
              s0 = peg$FAILED;
            }
          } else {
            peg$currPos = s0;
            s0 = peg$FAILED;
          }
        } else {
          peg$currPos = s0;
          s0 = peg$FAILED;
        }

        return s0;
      }

      function peg$parseelementFormat() {
        var s0;
        s0 = peg$parsesimpleFormat();

        if (s0 === peg$FAILED) {
          s0 = peg$parsepluralFormat();

          if (s0 === peg$FAILED) {
            s0 = peg$parseselectOrdinalFormat();

            if (s0 === peg$FAILED) {
              s0 = peg$parseselectFormat();
            }
          }
        }

        return s0;
      }

      function peg$parsesimpleFormat() {
        var s0, s1, s2, s3, s4, s5, s6;
        s0 = peg$currPos;

        if (input.substr(peg$currPos, 6) === peg$c12) {
          s1 = peg$c12;
          peg$currPos += 6;
        } else {
          s1 = peg$FAILED;

          if (peg$silentFails === 0) {
            peg$fail(peg$c13);
          }
        }

        if (s1 === peg$FAILED) {
          if (input.substr(peg$currPos, 4) === peg$c14) {
            s1 = peg$c14;
            peg$currPos += 4;
          } else {
            s1 = peg$FAILED;

            if (peg$silentFails === 0) {
              peg$fail(peg$c15);
            }
          }

          if (s1 === peg$FAILED) {
            if (input.substr(peg$currPos, 4) === peg$c16) {
              s1 = peg$c16;
              peg$currPos += 4;
            } else {
              s1 = peg$FAILED;

              if (peg$silentFails === 0) {
                peg$fail(peg$c17);
              }
            }
          }
        }

        if (s1 !== peg$FAILED) {
          s2 = peg$parse_();

          if (s2 !== peg$FAILED) {
            s3 = peg$currPos;

            if (input.charCodeAt(peg$currPos) === 44) {
              s4 = peg$c7;
              peg$currPos++;
            } else {
              s4 = peg$FAILED;

              if (peg$silentFails === 0) {
                peg$fail(peg$c8);
              }
            }

            if (s4 !== peg$FAILED) {
              s5 = peg$parse_();

              if (s5 !== peg$FAILED) {
                s6 = peg$parsechars();

                if (s6 !== peg$FAILED) {
                  s4 = [s4, s5, s6];
                  s3 = s4;
                } else {
                  peg$currPos = s3;
                  s3 = peg$FAILED;
                }
              } else {
                peg$currPos = s3;
                s3 = peg$FAILED;
              }
            } else {
              peg$currPos = s3;
              s3 = peg$FAILED;
            }

            if (s3 === peg$FAILED) {
              s3 = null;
            }

            if (s3 !== peg$FAILED) {
              peg$savedPos = s0;
              s1 = peg$c18(s1, s3);
              s0 = s1;
            } else {
              peg$currPos = s0;
              s0 = peg$FAILED;
            }
          } else {
            peg$currPos = s0;
            s0 = peg$FAILED;
          }
        } else {
          peg$currPos = s0;
          s0 = peg$FAILED;
        }

        return s0;
      }

      function peg$parsepluralFormat() {
        var s0, s1, s2, s3, s4, s5;
        s0 = peg$currPos;

        if (input.substr(peg$currPos, 6) === peg$c19) {
          s1 = peg$c19;
          peg$currPos += 6;
        } else {
          s1 = peg$FAILED;

          if (peg$silentFails === 0) {
            peg$fail(peg$c20);
          }
        }

        if (s1 !== peg$FAILED) {
          s2 = peg$parse_();

          if (s2 !== peg$FAILED) {
            if (input.charCodeAt(peg$currPos) === 44) {
              s3 = peg$c7;
              peg$currPos++;
            } else {
              s3 = peg$FAILED;

              if (peg$silentFails === 0) {
                peg$fail(peg$c8);
              }
            }

            if (s3 !== peg$FAILED) {
              s4 = peg$parse_();

              if (s4 !== peg$FAILED) {
                s5 = peg$parsepluralStyle();

                if (s5 !== peg$FAILED) {
                  peg$savedPos = s0;
                  s1 = peg$c21(s5);
                  s0 = s1;
                } else {
                  peg$currPos = s0;
                  s0 = peg$FAILED;
                }
              } else {
                peg$currPos = s0;
                s0 = peg$FAILED;
              }
            } else {
              peg$currPos = s0;
              s0 = peg$FAILED;
            }
          } else {
            peg$currPos = s0;
            s0 = peg$FAILED;
          }
        } else {
          peg$currPos = s0;
          s0 = peg$FAILED;
        }

        return s0;
      }

      function peg$parseselectOrdinalFormat() {
        var s0, s1, s2, s3, s4, s5;
        s0 = peg$currPos;

        if (input.substr(peg$currPos, 13) === peg$c22) {
          s1 = peg$c22;
          peg$currPos += 13;
        } else {
          s1 = peg$FAILED;

          if (peg$silentFails === 0) {
            peg$fail(peg$c23);
          }
        }

        if (s1 !== peg$FAILED) {
          s2 = peg$parse_();

          if (s2 !== peg$FAILED) {
            if (input.charCodeAt(peg$currPos) === 44) {
              s3 = peg$c7;
              peg$currPos++;
            } else {
              s3 = peg$FAILED;

              if (peg$silentFails === 0) {
                peg$fail(peg$c8);
              }
            }

            if (s3 !== peg$FAILED) {
              s4 = peg$parse_();

              if (s4 !== peg$FAILED) {
                s5 = peg$parsepluralStyle();

                if (s5 !== peg$FAILED) {
                  peg$savedPos = s0;
                  s1 = peg$c24(s5);
                  s0 = s1;
                } else {
                  peg$currPos = s0;
                  s0 = peg$FAILED;
                }
              } else {
                peg$currPos = s0;
                s0 = peg$FAILED;
              }
            } else {
              peg$currPos = s0;
              s0 = peg$FAILED;
            }
          } else {
            peg$currPos = s0;
            s0 = peg$FAILED;
          }
        } else {
          peg$currPos = s0;
          s0 = peg$FAILED;
        }

        return s0;
      }

      function peg$parseselectFormat() {
        var s0, s1, s2, s3, s4, s5, s6;
        s0 = peg$currPos;

        if (input.substr(peg$currPos, 6) === peg$c25) {
          s1 = peg$c25;
          peg$currPos += 6;
        } else {
          s1 = peg$FAILED;

          if (peg$silentFails === 0) {
            peg$fail(peg$c26);
          }
        }

        if (s1 !== peg$FAILED) {
          s2 = peg$parse_();

          if (s2 !== peg$FAILED) {
            if (input.charCodeAt(peg$currPos) === 44) {
              s3 = peg$c7;
              peg$currPos++;
            } else {
              s3 = peg$FAILED;

              if (peg$silentFails === 0) {
                peg$fail(peg$c8);
              }
            }

            if (s3 !== peg$FAILED) {
              s4 = peg$parse_();

              if (s4 !== peg$FAILED) {
                s5 = [];
                s6 = peg$parseoptionalFormatPattern();

                if (s6 !== peg$FAILED) {
                  while (s6 !== peg$FAILED) {
                    s5.push(s6);
                    s6 = peg$parseoptionalFormatPattern();
                  }
                } else {
                  s5 = peg$FAILED;
                }

                if (s5 !== peg$FAILED) {
                  peg$savedPos = s0;
                  s1 = peg$c27(s5);
                  s0 = s1;
                } else {
                  peg$currPos = s0;
                  s0 = peg$FAILED;
                }
              } else {
                peg$currPos = s0;
                s0 = peg$FAILED;
              }
            } else {
              peg$currPos = s0;
              s0 = peg$FAILED;
            }
          } else {
            peg$currPos = s0;
            s0 = peg$FAILED;
          }
        } else {
          peg$currPos = s0;
          s0 = peg$FAILED;
        }

        return s0;
      }

      function peg$parseselector() {
        var s0, s1, s2, s3;
        s0 = peg$currPos;
        s1 = peg$currPos;

        if (input.charCodeAt(peg$currPos) === 61) {
          s2 = peg$c28;
          peg$currPos++;
        } else {
          s2 = peg$FAILED;

          if (peg$silentFails === 0) {
            peg$fail(peg$c29);
          }
        }

        if (s2 !== peg$FAILED) {
          s3 = peg$parsenumber();

          if (s3 !== peg$FAILED) {
            s2 = [s2, s3];
            s1 = s2;
          } else {
            peg$currPos = s1;
            s1 = peg$FAILED;
          }
        } else {
          peg$currPos = s1;
          s1 = peg$FAILED;
        }

        if (s1 !== peg$FAILED) {
          s0 = input.substring(s0, peg$currPos);
        } else {
          s0 = s1;
        }

        if (s0 === peg$FAILED) {
          s0 = peg$parsechars();
        }

        return s0;
      }

      function peg$parseoptionalFormatPattern() {
        var s0, s1, s2, s3, s4, s5, s6, s7, s8;
        s0 = peg$currPos;
        s1 = peg$parse_();

        if (s1 !== peg$FAILED) {
          s2 = peg$parseselector();

          if (s2 !== peg$FAILED) {
            s3 = peg$parse_();

            if (s3 !== peg$FAILED) {
              if (input.charCodeAt(peg$currPos) === 123) {
                s4 = peg$c5;
                peg$currPos++;
              } else {
                s4 = peg$FAILED;

                if (peg$silentFails === 0) {
                  peg$fail(peg$c6);
                }
              }

              if (s4 !== peg$FAILED) {
                s5 = peg$parse_();

                if (s5 !== peg$FAILED) {
                  s6 = peg$parsemessageFormatPattern();

                  if (s6 !== peg$FAILED) {
                    s7 = peg$parse_();

                    if (s7 !== peg$FAILED) {
                      if (input.charCodeAt(peg$currPos) === 125) {
                        s8 = peg$c9;
                        peg$currPos++;
                      } else {
                        s8 = peg$FAILED;

                        if (peg$silentFails === 0) {
                          peg$fail(peg$c10);
                        }
                      }

                      if (s8 !== peg$FAILED) {
                        peg$savedPos = s0;
                        s1 = peg$c30(s2, s6);
                        s0 = s1;
                      } else {
                        peg$currPos = s0;
                        s0 = peg$FAILED;
                      }
                    } else {
                      peg$currPos = s0;
                      s0 = peg$FAILED;
                    }
                  } else {
                    peg$currPos = s0;
                    s0 = peg$FAILED;
                  }
                } else {
                  peg$currPos = s0;
                  s0 = peg$FAILED;
                }
              } else {
                peg$currPos = s0;
                s0 = peg$FAILED;
              }
            } else {
              peg$currPos = s0;
              s0 = peg$FAILED;
            }
          } else {
            peg$currPos = s0;
            s0 = peg$FAILED;
          }
        } else {
          peg$currPos = s0;
          s0 = peg$FAILED;
        }

        return s0;
      }

      function peg$parseoffset() {
        var s0, s1, s2, s3;
        s0 = peg$currPos;

        if (input.substr(peg$currPos, 7) === peg$c31) {
          s1 = peg$c31;
          peg$currPos += 7;
        } else {
          s1 = peg$FAILED;

          if (peg$silentFails === 0) {
            peg$fail(peg$c32);
          }
        }

        if (s1 !== peg$FAILED) {
          s2 = peg$parse_();

          if (s2 !== peg$FAILED) {
            s3 = peg$parsenumber();

            if (s3 !== peg$FAILED) {
              peg$savedPos = s0;
              s1 = peg$c33(s3);
              s0 = s1;
            } else {
              peg$currPos = s0;
              s0 = peg$FAILED;
            }
          } else {
            peg$currPos = s0;
            s0 = peg$FAILED;
          }
        } else {
          peg$currPos = s0;
          s0 = peg$FAILED;
        }

        return s0;
      }

      function peg$parsepluralStyle() {
        var s0, s1, s2, s3, s4;
        s0 = peg$currPos;
        s1 = peg$parseoffset();

        if (s1 === peg$FAILED) {
          s1 = null;
        }

        if (s1 !== peg$FAILED) {
          s2 = peg$parse_();

          if (s2 !== peg$FAILED) {
            s3 = [];
            s4 = peg$parseoptionalFormatPattern();

            if (s4 !== peg$FAILED) {
              while (s4 !== peg$FAILED) {
                s3.push(s4);
                s4 = peg$parseoptionalFormatPattern();
              }
            } else {
              s3 = peg$FAILED;
            }

            if (s3 !== peg$FAILED) {
              peg$savedPos = s0;
              s1 = peg$c34(s1, s3);
              s0 = s1;
            } else {
              peg$currPos = s0;
              s0 = peg$FAILED;
            }
          } else {
            peg$currPos = s0;
            s0 = peg$FAILED;
          }
        } else {
          peg$currPos = s0;
          s0 = peg$FAILED;
        }

        return s0;
      }

      function peg$parsews() {
        var s0, s1;
        peg$silentFails++;
        s0 = [];

        if (peg$c36.test(input.charAt(peg$currPos))) {
          s1 = input.charAt(peg$currPos);
          peg$currPos++;
        } else {
          s1 = peg$FAILED;

          if (peg$silentFails === 0) {
            peg$fail(peg$c37);
          }
        }

        if (s1 !== peg$FAILED) {
          while (s1 !== peg$FAILED) {
            s0.push(s1);

            if (peg$c36.test(input.charAt(peg$currPos))) {
              s1 = input.charAt(peg$currPos);
              peg$currPos++;
            } else {
              s1 = peg$FAILED;

              if (peg$silentFails === 0) {
                peg$fail(peg$c37);
              }
            }
          }
        } else {
          s0 = peg$FAILED;
        }

        peg$silentFails--;

        if (s0 === peg$FAILED) {
          s1 = peg$FAILED;

          if (peg$silentFails === 0) {
            peg$fail(peg$c35);
          }
        }

        return s0;
      }

      function peg$parse_() {
        var s0, s1, s2;
        peg$silentFails++;
        s0 = peg$currPos;
        s1 = [];
        s2 = peg$parsews();

        while (s2 !== peg$FAILED) {
          s1.push(s2);
          s2 = peg$parsews();
        }

        if (s1 !== peg$FAILED) {
          s0 = input.substring(s0, peg$currPos);
        } else {
          s0 = s1;
        }

        peg$silentFails--;

        if (s0 === peg$FAILED) {
          s1 = peg$FAILED;

          if (peg$silentFails === 0) {
            peg$fail(peg$c38);
          }
        }

        return s0;
      }

      function peg$parsedigit() {
        var s0;

        if (peg$c39.test(input.charAt(peg$currPos))) {
          s0 = input.charAt(peg$currPos);
          peg$currPos++;
        } else {
          s0 = peg$FAILED;

          if (peg$silentFails === 0) {
            peg$fail(peg$c40);
          }
        }

        return s0;
      }

      function peg$parsehexDigit() {
        var s0;

        if (peg$c41.test(input.charAt(peg$currPos))) {
          s0 = input.charAt(peg$currPos);
          peg$currPos++;
        } else {
          s0 = peg$FAILED;

          if (peg$silentFails === 0) {
            peg$fail(peg$c42);
          }
        }

        return s0;
      }

      function peg$parsenumber() {
        var s0, s1, s2, s3, s4, s5;
        s0 = peg$currPos;

        if (input.charCodeAt(peg$currPos) === 48) {
          s1 = peg$c43;
          peg$currPos++;
        } else {
          s1 = peg$FAILED;

          if (peg$silentFails === 0) {
            peg$fail(peg$c44);
          }
        }

        if (s1 === peg$FAILED) {
          s1 = peg$currPos;
          s2 = peg$currPos;

          if (peg$c45.test(input.charAt(peg$currPos))) {
            s3 = input.charAt(peg$currPos);
            peg$currPos++;
          } else {
            s3 = peg$FAILED;

            if (peg$silentFails === 0) {
              peg$fail(peg$c46);
            }
          }

          if (s3 !== peg$FAILED) {
            s4 = [];
            s5 = peg$parsedigit();

            while (s5 !== peg$FAILED) {
              s4.push(s5);
              s5 = peg$parsedigit();
            }

            if (s4 !== peg$FAILED) {
              s3 = [s3, s4];
              s2 = s3;
            } else {
              peg$currPos = s2;
              s2 = peg$FAILED;
            }
          } else {
            peg$currPos = s2;
            s2 = peg$FAILED;
          }

          if (s2 !== peg$FAILED) {
            s1 = input.substring(s1, peg$currPos);
          } else {
            s1 = s2;
          }
        }

        if (s1 !== peg$FAILED) {
          peg$savedPos = s0;
          s1 = peg$c47(s1);
        }

        s0 = s1;
        return s0;
      }

      function peg$parsechar() {
        var s0, s1, s2, s3, s4, s5, s6, s7;

        if (peg$c48.test(input.charAt(peg$currPos))) {
          s0 = input.charAt(peg$currPos);
          peg$currPos++;
        } else {
          s0 = peg$FAILED;

          if (peg$silentFails === 0) {
            peg$fail(peg$c49);
          }
        }

        if (s0 === peg$FAILED) {
          s0 = peg$currPos;

          if (input.substr(peg$currPos, 2) === peg$c50) {
            s1 = peg$c50;
            peg$currPos += 2;
          } else {
            s1 = peg$FAILED;

            if (peg$silentFails === 0) {
              peg$fail(peg$c51);
            }
          }

          if (s1 !== peg$FAILED) {
            peg$savedPos = s0;
            s1 = peg$c52();
          }

          s0 = s1;

          if (s0 === peg$FAILED) {
            s0 = peg$currPos;

            if (input.substr(peg$currPos, 2) === peg$c53) {
              s1 = peg$c53;
              peg$currPos += 2;
            } else {
              s1 = peg$FAILED;

              if (peg$silentFails === 0) {
                peg$fail(peg$c54);
              }
            }

            if (s1 !== peg$FAILED) {
              peg$savedPos = s0;
              s1 = peg$c55();
            }

            s0 = s1;

            if (s0 === peg$FAILED) {
              s0 = peg$currPos;

              if (input.substr(peg$currPos, 2) === peg$c56) {
                s1 = peg$c56;
                peg$currPos += 2;
              } else {
                s1 = peg$FAILED;

                if (peg$silentFails === 0) {
                  peg$fail(peg$c57);
                }
              }

              if (s1 !== peg$FAILED) {
                peg$savedPos = s0;
                s1 = peg$c58();
              }

              s0 = s1;

              if (s0 === peg$FAILED) {
                s0 = peg$currPos;

                if (input.substr(peg$currPos, 2) === peg$c59) {
                  s1 = peg$c59;
                  peg$currPos += 2;
                } else {
                  s1 = peg$FAILED;

                  if (peg$silentFails === 0) {
                    peg$fail(peg$c60);
                  }
                }

                if (s1 !== peg$FAILED) {
                  peg$savedPos = s0;
                  s1 = peg$c61();
                }

                s0 = s1;

                if (s0 === peg$FAILED) {
                  s0 = peg$currPos;

                  if (input.substr(peg$currPos, 2) === peg$c62) {
                    s1 = peg$c62;
                    peg$currPos += 2;
                  } else {
                    s1 = peg$FAILED;

                    if (peg$silentFails === 0) {
                      peg$fail(peg$c63);
                    }
                  }

                  if (s1 !== peg$FAILED) {
                    s2 = peg$currPos;
                    s3 = peg$currPos;
                    s4 = peg$parsehexDigit();

                    if (s4 !== peg$FAILED) {
                      s5 = peg$parsehexDigit();

                      if (s5 !== peg$FAILED) {
                        s6 = peg$parsehexDigit();

                        if (s6 !== peg$FAILED) {
                          s7 = peg$parsehexDigit();

                          if (s7 !== peg$FAILED) {
                            s4 = [s4, s5, s6, s7];
                            s3 = s4;
                          } else {
                            peg$currPos = s3;
                            s3 = peg$FAILED;
                          }
                        } else {
                          peg$currPos = s3;
                          s3 = peg$FAILED;
                        }
                      } else {
                        peg$currPos = s3;
                        s3 = peg$FAILED;
                      }
                    } else {
                      peg$currPos = s3;
                      s3 = peg$FAILED;
                    }

                    if (s3 !== peg$FAILED) {
                      s2 = input.substring(s2, peg$currPos);
                    } else {
                      s2 = s3;
                    }

                    if (s2 !== peg$FAILED) {
                      peg$savedPos = s0;
                      s1 = peg$c64(s2);
                      s0 = s1;
                    } else {
                      peg$currPos = s0;
                      s0 = peg$FAILED;
                    }
                  } else {
                    peg$currPos = s0;
                    s0 = peg$FAILED;
                  }
                }
              }
            }
          }
        }

        return s0;
      }

      function peg$parsechars() {
        var s0, s1, s2;
        s0 = peg$currPos;
        s1 = [];
        s2 = peg$parsechar();

        if (s2 !== peg$FAILED) {
          while (s2 !== peg$FAILED) {
            s1.push(s2);
            s2 = peg$parsechar();
          }
        } else {
          s1 = peg$FAILED;
        }

        if (s1 !== peg$FAILED) {
          peg$savedPos = s0;
          s1 = peg$c65(s1);
        }

        s0 = s1;
        return s0;
      }

      peg$result = peg$startRuleFunction();

      if (peg$result !== peg$FAILED && peg$currPos === input.length) {
        return peg$result;
      } else {
        if (peg$result !== peg$FAILED && peg$currPos < input.length) {
          peg$fail({
            type: "end",
            description: "end of input"
          });
        }

        throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
      }
    }

    return {
      SyntaxError: peg$SyntaxError,
      parse: peg$parse
    };
  }();
});

var intlMessageformatParser = createCommonjsModule(function (module, exports) {

  exports = module.exports = parser['default'];
  exports['default'] = exports;
});

var core$1 = createCommonjsModule(function (module, exports) {

  exports["default"] = MessageFormat; // -- MessageFormat --------------------------------------------------------

  function MessageFormat(message, locales, formats) {
    // Parse string messages into an AST.
    var ast = typeof message === 'string' ? MessageFormat.__parse(message) : message;

    if (!(ast && ast.type === 'messageFormatPattern')) {
      throw new TypeError('A message must be provided as a String or AST.');
    } // Creates a new object with the specified `formats` merged with the default
    // formats.


    formats = this._mergeFormats(MessageFormat.formats, formats); // Defined first because it's used to build the format pattern.

    es5$1.defineProperty(this, '_locale', {
      value: this._resolveLocale(locales)
    }); // Compile the `ast` to a pattern that is highly optimized for repeated
    // `format()` invocations. **Note:** This passes the `locales` set provided
    // to the constructor instead of just the resolved locale.

    var pluralFn = this._findPluralRuleFunction(this._locale);

    var pattern = this._compilePattern(ast, locales, formats, pluralFn); // "Bind" `format()` method to `this` so it can be passed by reference like
    // the other `Intl` APIs.


    var messageFormat = this;

    this.format = function (values) {
      try {
        return messageFormat._format(pattern, values);
      } catch (e) {
        if (e.variableId) {
          throw new Error('The intl string context variable \'' + e.variableId + '\'' + ' was not provided to the string \'' + message + '\'');
        } else {
          throw e;
        }
      }
    };
  } // Default format options used as the prototype of the `formats` provided to the
  // constructor. These are used when constructing the internal Intl.NumberFormat
  // and Intl.DateTimeFormat instances.


  es5$1.defineProperty(MessageFormat, 'formats', {
    enumerable: true,
    value: {
      number: {
        'currency': {
          style: 'currency'
        },
        'percent': {
          style: 'percent'
        }
      },
      date: {
        'short': {
          month: 'numeric',
          day: 'numeric',
          year: '2-digit'
        },
        'medium': {
          month: 'short',
          day: 'numeric',
          year: 'numeric'
        },
        'long': {
          month: 'long',
          day: 'numeric',
          year: 'numeric'
        },
        'full': {
          weekday: 'long',
          month: 'long',
          day: 'numeric',
          year: 'numeric'
        }
      },
      time: {
        'short': {
          hour: 'numeric',
          minute: 'numeric'
        },
        'medium': {
          hour: 'numeric',
          minute: 'numeric',
          second: 'numeric'
        },
        'long': {
          hour: 'numeric',
          minute: 'numeric',
          second: 'numeric',
          timeZoneName: 'short'
        },
        'full': {
          hour: 'numeric',
          minute: 'numeric',
          second: 'numeric',
          timeZoneName: 'short'
        }
      }
    }
  }); // Define internal private properties for dealing with locale data.

  es5$1.defineProperty(MessageFormat, '__localeData__', {
    value: es5$1.objCreate(null)
  });
  es5$1.defineProperty(MessageFormat, '__addLocaleData', {
    value: function value(data) {
      if (!(data && data.locale)) {
        throw new Error('Locale data provided to IntlMessageFormat is missing a ' + '`locale` property');
      }

      MessageFormat.__localeData__[data.locale.toLowerCase()] = data;
    }
  }); // Defines `__parse()` static method as an exposed private.

  es5$1.defineProperty(MessageFormat, '__parse', {
    value: intlMessageformatParser["default"].parse
  }); // Define public `defaultLocale` property which defaults to English, but can be
  // set by the developer.

  es5$1.defineProperty(MessageFormat, 'defaultLocale', {
    enumerable: true,
    writable: true,
    value: undefined
  });

  MessageFormat.prototype.resolvedOptions = function () {
    // TODO: Provide anything else?
    return {
      locale: this._locale
    };
  };

  MessageFormat.prototype._compilePattern = function (ast, locales, formats, pluralFn) {
    var compiler$1 = new compiler["default"](locales, formats, pluralFn);
    return compiler$1.compile(ast);
  };

  MessageFormat.prototype._findPluralRuleFunction = function (locale) {
    var localeData = MessageFormat.__localeData__;
    var data = localeData[locale.toLowerCase()]; // The locale data is de-duplicated, so we have to traverse the locale's
    // hierarchy until we find a `pluralRuleFunction` to return.

    while (data) {
      if (data.pluralRuleFunction) {
        return data.pluralRuleFunction;
      }

      data = data.parentLocale && localeData[data.parentLocale.toLowerCase()];
    }

    throw new Error('Locale data added to IntlMessageFormat is missing a ' + '`pluralRuleFunction` for :' + locale);
  };

  MessageFormat.prototype._format = function (pattern, values) {
    var result = '',
        i,
        len,
        part,
        id,
        value,
        err;

    for (i = 0, len = pattern.length; i < len; i += 1) {
      part = pattern[i]; // Exist early for string parts.

      if (typeof part === 'string') {
        result += part;
        continue;
      }

      id = part.id; // Enforce that all required values are provided by the caller.

      if (!(values && utils.hop.call(values, id))) {
        err = new Error('A value must be provided for: ' + id);
        err.variableId = id;
        throw err;
      }

      value = values[id]; // Recursively format plural and select parts' option — which can be a
      // nested pattern structure. The choosing of the option to use is
      // abstracted-by and delegated-to the part helper object.

      if (part.options) {
        result += this._format(part.getOption(value), values);
      } else {
        result += part.format(value);
      }
    }

    return result;
  };

  MessageFormat.prototype._mergeFormats = function (defaults, formats) {
    var mergedFormats = {},
        type,
        mergedType;

    for (type in defaults) {
      if (!utils.hop.call(defaults, type)) {
        continue;
      }

      mergedFormats[type] = mergedType = es5$1.objCreate(defaults[type]);

      if (formats && utils.hop.call(formats, type)) {
        utils.extend(mergedType, formats[type]);
      }
    }

    return mergedFormats;
  };

  MessageFormat.prototype._resolveLocale = function (locales) {
    if (typeof locales === 'string') {
      locales = [locales];
    } // Create a copy of the array so we can push on the default locale.


    locales = (locales || []).concat(MessageFormat.defaultLocale);
    var localeData = MessageFormat.__localeData__;
    var i, len, localeParts, data; // Using the set of locales + the default locale, we look for the first one
    // which that has been registered. When data does not exist for a locale, we
    // traverse its ancestors to find something that's been registered within
    // its hierarchy of locales. Since we lack the proper `parentLocale` data
    // here, we must take a naive approach to traversal.

    for (i = 0, len = locales.length; i < len; i += 1) {
      localeParts = locales[i].toLowerCase().split('-');

      while (localeParts.length) {
        data = localeData[localeParts.join('-')];

        if (data) {
          // Return the normalized locale string; e.g., we return "en-US",
          // instead of "en-us".
          return data.locale;
        }

        localeParts.pop();
      }
    }

    var defaultLocale = locales.pop();
    throw new Error('No locale data has been added to IntlMessageFormat for: ' + locales.join(', ') + ', or the default locale: ' + defaultLocale);
  };
});

var en$1 = createCommonjsModule(function (module, exports) {

  exports["default"] = {
    "locale": "en",
    "pluralRuleFunction": function pluralRuleFunction(n, ord) {
      var s = String(n).split("."),
          v0 = !s[1],
          t0 = Number(s[0]) == n,
          n10 = t0 && s[0].slice(-1),
          n100 = t0 && s[0].slice(-2);
      if (ord) return n10 == 1 && n100 != 11 ? "one" : n10 == 2 && n100 != 12 ? "two" : n10 == 3 && n100 != 13 ? "few" : "other";
      return n == 1 && v0 ? "one" : "other";
    }
  };
});

var main$1 = createCommonjsModule(function (module, exports) {

  core$1["default"].__addLocaleData(en$1["default"]);

  core$1["default"].defaultLocale = 'en';
  exports["default"] = core$1["default"];
});

var intlMessageformat = createCommonjsModule(function (module, exports) {

  var IntlMessageFormat = main$1['default']; // Add all locale data to `IntlMessageFormat`. This module will be ignored when
  // bundling for the browser with Browserify/Webpack.
  // Re-export `IntlMessageFormat` as the CommonJS default exports with all the
  // locale data registered, and with English set as the default locale. Define
  // the `default` prop for use with other compiled ES6 Modules.

  exports = module.exports = IntlMessageFormat;
  exports['default'] = exports;
});

var diff = createCommonjsModule(function (module, exports) {
  /*
  Copyright (c) 2014, Yahoo! Inc. All rights reserved.
  Copyrights licensed under the New BSD License.
  See the accompanying LICENSE file for terms.
  */

  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  /* jslint esnext: true */

  var round = Math.round;

  function daysToYears(days) {
    // 400 years have 146097 days (taking into account leap year rules)
    return days * 400 / 146097;
  } // Thanks to date-fns
  // https://github.com/date-fns/date-fns
  // MIT © Sasha Koss


  var MILLISECONDS_IN_MINUTE = 60000;
  var MILLISECONDS_IN_DAY = 86400000;

  function startOfDay(dirtyDate) {
    var date = new Date(dirtyDate);
    date.setHours(0, 0, 0, 0);
    return date;
  }

  function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {
    var startOfDayLeft = startOfDay(dirtyDateLeft);
    var startOfDayRight = startOfDay(dirtyDateRight);
    var timestampLeft = startOfDayLeft.getTime() - startOfDayLeft.getTimezoneOffset() * MILLISECONDS_IN_MINUTE;
    var timestampRight = startOfDayRight.getTime() - startOfDayRight.getTimezoneOffset() * MILLISECONDS_IN_MINUTE; // Round the number of days to the nearest integer
    // because the number of milliseconds in a day is not constant
    // (e.g. it's different in the day of the daylight saving time clock shift)

    return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY);
  }

  function default_1(from, to) {
    // Convert to ms timestamps.
    from = +from;
    to = +to;
    var millisecond = round(to - from),
        second = round(millisecond / 1000),
        minute = round(second / 60),
        hour = round(minute / 60); // We expect a more precision in rounding when dealing with
    // days as it feels wrong when something happended 13 hours ago and
    // is regarded as "yesterday" even if the time was this morning.

    var day = differenceInCalendarDays(to, from);
    var week = round(day / 7);
    var rawYears = daysToYears(day),
        month = round(rawYears * 12),
        year = round(rawYears);
    return {
      millisecond: millisecond,
      second: second,
      'second-short': second,
      minute: minute,
      'minute-short': minute,
      hour: hour,
      'hour-short': hour,
      day: day,
      'day-short': day,
      week: week,
      'week-short': week,
      month: month,
      'month-short': month,
      year: year,
      'year-short': year
    };
  }

  exports.default = default_1;
});

var es5 = createCommonjsModule(function (module, exports) {
  /*
  Copyright (c) 2014, Yahoo! Inc. All rights reserved.
  Copyrights licensed under the New BSD License.
  See the accompanying LICENSE file for terms.
  */

  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  /* jslint esnext: true */
  // Purposely using the same implementation as the Intl.js `Intl` polyfill.
  // Copyright 2013 Andy Earnshaw, MIT License

  var hop = Object.prototype.hasOwnProperty;
  var toString = Object.prototype.toString;

  var realDefineProp = function () {
    try {
      return !!Object.defineProperty({}, 'a', {});
    } catch (e) {
      return false;
    }
  }();
  var defineProperty = realDefineProp ? Object.defineProperty : function (obj, name, desc) {
    if ('get' in desc && obj.__defineGetter__) {
      obj.__defineGetter__(name, desc.get);
    } else if (!hop.call(obj, name) || 'value' in desc) {
      obj[name] = desc.value;
    }
  };
  exports.defineProperty = defineProperty;

  var objCreate = Object.create || function (proto, props) {
    var obj, k;

    function F() {}

    F.prototype = proto;
    obj = new F();

    for (k in props) {
      if (hop.call(props, k)) {
        defineProperty(obj, k, props[k]);
      }
    }

    return obj;
  };

  exports.objCreate = objCreate;

  var arrIndexOf = Array.prototype.indexOf || function (search, fromIndex) {
    /*jshint validthis:true */
    var arr = this;

    if (!arr.length) {
      return -1;
    }

    for (var i = fromIndex || 0, max = arr.length; i < max; i++) {
      if (arr[i] === search) {
        return i;
      }
    }

    return -1;
  };

  exports.arrIndexOf = arrIndexOf;

  var isArray = Array.isArray || function (obj) {
    return toString.call(obj) === '[object Array]';
  };

  exports.isArray = isArray;

  var dateNow = Date.now || function () {
    return new Date().getTime();
  };

  exports.dateNow = dateNow;
});

var core = createCommonjsModule(function (module, exports) {
  /*
  Copyright (c) 2014, Yahoo! Inc. All rights reserved.
  Copyrights licensed under the New BSD License.
  See the accompanying LICENSE file for terms.
  */

  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  /* jslint esnext: true */

  exports.default = RelativeFormat; // -----------------------------------------------------------------------------

  var FIELDS = ['second', 'second-short', 'minute', 'minute-short', 'hour', 'hour-short', 'day', 'day-short', 'month', 'month-short', 'year', 'year-short'];
  var STYLES = ['best fit', 'numeric']; // -- RelativeFormat -----------------------------------------------------------

  function RelativeFormat(locales, options) {
    options = options || {}; // Make a copy of `locales` if it's an array, so that it doesn't change
    // since it's used lazily.

    if (es5.isArray(locales)) {
      locales = locales.concat();
    }

    es5.defineProperty(this, '_locale', {
      value: this._resolveLocale(locales)
    });
    es5.defineProperty(this, '_options', {
      value: {
        style: this._resolveStyle(options.style),
        units: this._isValidUnits(options.units) && options.units
      }
    });
    es5.defineProperty(this, '_locales', {
      value: locales
    });
    es5.defineProperty(this, '_fields', {
      value: this._findFields(this._locale)
    });
    es5.defineProperty(this, '_messages', {
      value: es5.objCreate(null)
    }); // "Bind" `format()` method to `this` so it can be passed by reference like
    // the other `Intl` APIs.

    var relativeFormat = this;

    this.format = function format(date, options) {
      return relativeFormat._format(date, options);
    };
  } // Define internal private properties for dealing with locale data.


  es5.defineProperty(RelativeFormat, '__localeData__', {
    value: es5.objCreate(null)
  });
  es5.defineProperty(RelativeFormat, '__addLocaleData', {
    value: function value() {
      for (var i = 0; i < arguments.length; i++) {
        var datum = arguments[i];

        if (!(datum && datum.locale)) {
          throw new Error('Locale data provided to IntlRelativeFormat is missing a ' + '`locale` property value');
        }

        RelativeFormat.__localeData__[datum.locale.toLowerCase()] = datum; // Add data to IntlMessageFormat.

        intlMessageformat.default.__addLocaleData(datum);
      }
    }
  }); // Define public `defaultLocale` property which can be set by the developer, or
  // it will be set when the first RelativeFormat instance is created by
  // leveraging the resolved locale from `Intl`.

  es5.defineProperty(RelativeFormat, 'defaultLocale', {
    enumerable: true,
    writable: true,
    value: undefined
  }); // Define public `thresholds` property which can be set by the developer, and
  // defaults to relative time thresholds from moment.js.

  es5.defineProperty(RelativeFormat, 'thresholds', {
    enumerable: true,
    value: {
      second: 45,
      'second-short': 45,
      minute: 45,
      'minute-short': 45,
      hour: 22,
      'hour-short': 22,
      day: 26,
      'day-short': 26,
      month: 11,
      'month-short': 11 // months to year

    }
  });

  RelativeFormat.prototype.resolvedOptions = function () {
    return {
      locale: this._locale,
      style: this._options.style,
      units: this._options.units
    };
  };

  RelativeFormat.prototype._compileMessage = function (units) {
    // `this._locales` is the original set of locales the user specified to the
    // constructor, while `this._locale` is the resolved root locale.
    var locales = this._locales;
    this._locale;
    var field = this._fields[units];
    var relativeTime = field.relativeTime;
    var future = '';
    var past = '';
    var i;

    for (i in relativeTime.future) {
      if (relativeTime.future.hasOwnProperty(i)) {
        future += ' ' + i + ' {' + relativeTime.future[i].replace('{0}', '#') + '}';
      }
    }

    for (i in relativeTime.past) {
      if (relativeTime.past.hasOwnProperty(i)) {
        past += ' ' + i + ' {' + relativeTime.past[i].replace('{0}', '#') + '}';
      }
    }

    var message = '{when, select, future {{0, plural, ' + future + '}}' + 'past {{0, plural, ' + past + '}}}'; // Create the synthetic IntlMessageFormat instance using the original
    // locales value specified by the user when constructing the the parent
    // IntlRelativeFormat instance.

    return new intlMessageformat.default(message, locales);
  };

  RelativeFormat.prototype._getMessage = function (units) {
    var messages = this._messages; // Create a new synthetic message based on the locale data from CLDR.

    if (!messages[units]) {
      messages[units] = this._compileMessage(units);
    }

    return messages[units];
  };

  RelativeFormat.prototype._getRelativeUnits = function (diff, units) {
    var field = this._fields[units];

    if (field.relative) {
      return field.relative[diff];
    }
  };

  RelativeFormat.prototype._findFields = function (locale) {
    var localeData = RelativeFormat.__localeData__;
    var data = localeData[locale.toLowerCase()]; // The locale data is de-duplicated, so we have to traverse the locale's
    // hierarchy until we find `fields` to return.

    while (data) {
      if (data.fields) {
        return data.fields;
      }

      data = data.parentLocale && localeData[data.parentLocale.toLowerCase()];
    }

    throw new Error('Locale data added to IntlRelativeFormat is missing `fields` for :' + locale);
  };

  RelativeFormat.prototype._format = function (date, options) {
    var now = options && options.now !== undefined ? options.now : es5.dateNow();

    if (date === undefined) {
      date = now;
    } // Determine if the `date` and optional `now` values are valid, and throw a
    // similar error to what `Intl.DateTimeFormat#format()` would throw.


    if (!isFinite(now)) {
      throw new RangeError('The `now` option provided to IntlRelativeFormat#format() is not ' + 'in valid range.');
    }

    if (!isFinite(date)) {
      throw new RangeError('The date value provided to IntlRelativeFormat#format() is not ' + 'in valid range.');
    }

    var diffReport = diff.default(now, date);

    var units = this._options.units || this._selectUnits(diffReport);

    var diffInUnits = diffReport[units];

    if (this._options.style !== 'numeric') {
      var relativeUnits = this._getRelativeUnits(diffInUnits, units);

      if (relativeUnits) {
        return relativeUnits;
      }
    }

    return this._getMessage(units).format({
      '0': Math.abs(diffInUnits),
      when: diffInUnits < 0 ? 'past' : 'future'
    });
  };

  RelativeFormat.prototype._isValidUnits = function (units) {
    if (!units || es5.arrIndexOf.call(FIELDS, units) >= 0) {
      return true;
    }

    if (typeof units === 'string') {
      var suggestion = /s$/.test(units) && units.substr(0, units.length - 1);

      if (suggestion && es5.arrIndexOf.call(FIELDS, suggestion) >= 0) {
        throw new Error('"' + units + '" is not a valid IntlRelativeFormat `units` ' + 'value, did you mean: ' + suggestion);
      }
    }

    throw new Error('"' + units + '" is not a valid IntlRelativeFormat `units` value, it ' + 'must be one of: "' + FIELDS.join('", "') + '"');
  };

  RelativeFormat.prototype._resolveLocale = function (locales) {
    if (typeof locales === 'string') {
      locales = [locales];
    } // Create a copy of the array so we can push on the default locale.


    locales = (locales || []).concat(RelativeFormat.defaultLocale);
    var localeData = RelativeFormat.__localeData__;
    var i, len, localeParts, data; // Using the set of locales + the default locale, we look for the first one
    // which that has been registered. When data does not exist for a locale, we
    // traverse its ancestors to find something that's been registered within
    // its hierarchy of locales. Since we lack the proper `parentLocale` data
    // here, we must take a naive approach to traversal.

    for (i = 0, len = locales.length; i < len; i += 1) {
      localeParts = locales[i].toLowerCase().split('-');

      while (localeParts.length) {
        data = localeData[localeParts.join('-')];

        if (data) {
          // Return the normalized locale string; e.g., we return "en-US",
          // instead of "en-us".
          return data.locale;
        }

        localeParts.pop();
      }
    }

    var defaultLocale = locales.pop();
    throw new Error('No locale data has been added to IntlRelativeFormat for: ' + locales.join(', ') + ', or the default locale: ' + defaultLocale);
  };

  RelativeFormat.prototype._resolveStyle = function (style) {
    // Default to "best fit" style.
    if (!style) {
      return STYLES[0];
    }

    if (es5.arrIndexOf.call(STYLES, style) >= 0) {
      return style;
    }

    throw new Error('"' + style + '" is not a valid IntlRelativeFormat `style` value, it ' + 'must be one of: "' + STYLES.join('", "') + '"');
  };

  RelativeFormat.prototype._selectUnits = function (diffReport) {
    var i, l, units;
    var fields = FIELDS.filter(function (field) {
      return field.indexOf('-short') < 1;
    });

    for (i = 0, l = fields.length; i < l; i += 1) {
      units = fields[i];

      if (Math.abs(diffReport[units]) < RelativeFormat.thresholds[units]) {
        break;
      }
    }

    return units;
  };
});

var en = createCommonjsModule(function (module, exports) {

  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  /* @generated */

  exports.default = {
    "locale": "en",
    "pluralRuleFunction": function pluralRuleFunction(n, ord) {
      var s = String(n).split('.'),
          v0 = !s[1],
          t0 = Number(s[0]) == n,
          n10 = t0 && s[0].slice(-1),
          n100 = t0 && s[0].slice(-2);
      if (ord) return n10 == 1 && n100 != 11 ? 'one' : n10 == 2 && n100 != 12 ? 'two' : n10 == 3 && n100 != 13 ? 'few' : 'other';
      return n == 1 && v0 ? 'one' : 'other';
    },
    "fields": {
      "year": {
        "displayName": "year",
        "relative": {
          "0": "this year",
          "1": "next year",
          "-1": "last year"
        },
        "relativeTime": {
          "future": {
            "one": "in {0} year",
            "other": "in {0} years"
          },
          "past": {
            "one": "{0} year ago",
            "other": "{0} years ago"
          }
        }
      },
      "year-short": {
        "displayName": "yr.",
        "relative": {
          "0": "this yr.",
          "1": "next yr.",
          "-1": "last yr."
        },
        "relativeTime": {
          "future": {
            "one": "in {0} yr.",
            "other": "in {0} yr."
          },
          "past": {
            "one": "{0} yr. ago",
            "other": "{0} yr. ago"
          }
        }
      },
      "month": {
        "displayName": "month",
        "relative": {
          "0": "this month",
          "1": "next month",
          "-1": "last month"
        },
        "relativeTime": {
          "future": {
            "one": "in {0} month",
            "other": "in {0} months"
          },
          "past": {
            "one": "{0} month ago",
            "other": "{0} months ago"
          }
        }
      },
      "month-short": {
        "displayName": "mo.",
        "relative": {
          "0": "this mo.",
          "1": "next mo.",
          "-1": "last mo."
        },
        "relativeTime": {
          "future": {
            "one": "in {0} mo.",
            "other": "in {0} mo."
          },
          "past": {
            "one": "{0} mo. ago",
            "other": "{0} mo. ago"
          }
        }
      },
      "week": {
        "displayName": "week",
        "relativePeriod": "the week of {0}",
        "relative": {
          "0": "this week",
          "1": "next week",
          "-1": "last week"
        },
        "relativeTime": {
          "future": {
            "one": "in {0} week",
            "other": "in {0} weeks"
          },
          "past": {
            "one": "{0} week ago",
            "other": "{0} weeks ago"
          }
        }
      },
      "week-short": {
        "displayName": "wk.",
        "relativePeriod": "the week of {0}",
        "relative": {
          "0": "this wk.",
          "1": "next wk.",
          "-1": "last wk."
        },
        "relativeTime": {
          "future": {
            "one": "in {0} wk.",
            "other": "in {0} wk."
          },
          "past": {
            "one": "{0} wk. ago",
            "other": "{0} wk. ago"
          }
        }
      },
      "day": {
        "displayName": "day",
        "relative": {
          "0": "today",
          "1": "tomorrow",
          "-1": "yesterday"
        },
        "relativeTime": {
          "future": {
            "one": "in {0} day",
            "other": "in {0} days"
          },
          "past": {
            "one": "{0} day ago",
            "other": "{0} days ago"
          }
        }
      },
      "day-short": {
        "displayName": "day",
        "relative": {
          "0": "today",
          "1": "tomorrow",
          "-1": "yesterday"
        },
        "relativeTime": {
          "future": {
            "one": "in {0} day",
            "other": "in {0} days"
          },
          "past": {
            "one": "{0} day ago",
            "other": "{0} days ago"
          }
        }
      },
      "hour": {
        "displayName": "hour",
        "relative": {
          "0": "this hour"
        },
        "relativeTime": {
          "future": {
            "one": "in {0} hour",
            "other": "in {0} hours"
          },
          "past": {
            "one": "{0} hour ago",
            "other": "{0} hours ago"
          }
        }
      },
      "hour-short": {
        "displayName": "hr.",
        "relative": {
          "0": "this hour"
        },
        "relativeTime": {
          "future": {
            "one": "in {0} hr.",
            "other": "in {0} hr."
          },
          "past": {
            "one": "{0} hr. ago",
            "other": "{0} hr. ago"
          }
        }
      },
      "minute": {
        "displayName": "minute",
        "relative": {
          "0": "this minute"
        },
        "relativeTime": {
          "future": {
            "one": "in {0} minute",
            "other": "in {0} minutes"
          },
          "past": {
            "one": "{0} minute ago",
            "other": "{0} minutes ago"
          }
        }
      },
      "minute-short": {
        "displayName": "min.",
        "relative": {
          "0": "this minute"
        },
        "relativeTime": {
          "future": {
            "one": "in {0} min.",
            "other": "in {0} min."
          },
          "past": {
            "one": "{0} min. ago",
            "other": "{0} min. ago"
          }
        }
      },
      "second": {
        "displayName": "second",
        "relative": {
          "0": "now"
        },
        "relativeTime": {
          "future": {
            "one": "in {0} second",
            "other": "in {0} seconds"
          },
          "past": {
            "one": "{0} second ago",
            "other": "{0} seconds ago"
          }
        }
      },
      "second-short": {
        "displayName": "sec.",
        "relative": {
          "0": "now"
        },
        "relativeTime": {
          "future": {
            "one": "in {0} sec.",
            "other": "in {0} sec."
          },
          "past": {
            "one": "{0} sec. ago",
            "other": "{0} sec. ago"
          }
        }
      }
    }
  };
});

var main = createCommonjsModule(function (module, exports) {
  /* jslint esnext: true */

  Object.defineProperty(exports, "__esModule", {
    value: true
  });

  core.default.__addLocaleData(en.default);

  core.default.defaultLocale = 'en';
  exports.default = core.default;
});

var intlRelativeformat = createCommonjsModule(function (module, exports) {

  var IntlRelativeFormat = main['default']; // Add all locale data to `IntlRelativeFormat`. This module will be ignored when
  // bundling for the browser with Browserify/Webpack.
  // Re-export `IntlRelativeFormat` as the CommonJS default exports with all the
  // locale data registered, and with English set as the default locale. Define
  // the `default` prop for use with other compiled ES6 Modules.

  exports = module.exports = IntlRelativeFormat;
  exports['default'] = exports;
});

var reactIs_development = createCommonjsModule(function (module, exports) {

  {
    (function () {
      // nor polyfill, then a plain number is used for performance.

      var hasSymbol = typeof Symbol === 'function' && Symbol.for;
      var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
      var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
      var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
      var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
      var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
      var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
      var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
      // (unstable) APIs that have been removed. Can we remove the symbols?

      var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
      var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
      var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
      var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
      var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
      var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
      var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
      var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
      var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
      var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
      var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;

      function isValidElementType(type) {
        return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
        type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || _typeof$1(type) === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
      }

      function typeOf(object) {
        if (_typeof$1(object) === 'object' && object !== null) {
          var $$typeof = object.$$typeof;

          switch ($$typeof) {
            case REACT_ELEMENT_TYPE:
              var type = object.type;

              switch (type) {
                case REACT_ASYNC_MODE_TYPE:
                case REACT_CONCURRENT_MODE_TYPE:
                case REACT_FRAGMENT_TYPE:
                case REACT_PROFILER_TYPE:
                case REACT_STRICT_MODE_TYPE:
                case REACT_SUSPENSE_TYPE:
                  return type;

                default:
                  var $$typeofType = type && type.$$typeof;

                  switch ($$typeofType) {
                    case REACT_CONTEXT_TYPE:
                    case REACT_FORWARD_REF_TYPE:
                    case REACT_LAZY_TYPE:
                    case REACT_MEMO_TYPE:
                    case REACT_PROVIDER_TYPE:
                      return $$typeofType;

                    default:
                      return $$typeof;
                  }

              }

            case REACT_PORTAL_TYPE:
              return $$typeof;
          }
        }

        return undefined;
      } // AsyncMode is deprecated along with isAsyncMode


      var AsyncMode = REACT_ASYNC_MODE_TYPE;
      var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
      var ContextConsumer = REACT_CONTEXT_TYPE;
      var ContextProvider = REACT_PROVIDER_TYPE;
      var Element = REACT_ELEMENT_TYPE;
      var ForwardRef = REACT_FORWARD_REF_TYPE;
      var Fragment = REACT_FRAGMENT_TYPE;
      var Lazy = REACT_LAZY_TYPE;
      var Memo = REACT_MEMO_TYPE;
      var Portal = REACT_PORTAL_TYPE;
      var Profiler = REACT_PROFILER_TYPE;
      var StrictMode = REACT_STRICT_MODE_TYPE;
      var Suspense = REACT_SUSPENSE_TYPE;
      var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated

      function isAsyncMode(object) {
        {
          if (!hasWarnedAboutDeprecatedIsAsyncMode) {
            hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint

            console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
          }
        }
        return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
      }

      function isConcurrentMode(object) {
        return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
      }

      function isContextConsumer(object) {
        return typeOf(object) === REACT_CONTEXT_TYPE;
      }

      function isContextProvider(object) {
        return typeOf(object) === REACT_PROVIDER_TYPE;
      }

      function isElement(object) {
        return _typeof$1(object) === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
      }

      function isForwardRef(object) {
        return typeOf(object) === REACT_FORWARD_REF_TYPE;
      }

      function isFragment(object) {
        return typeOf(object) === REACT_FRAGMENT_TYPE;
      }

      function isLazy(object) {
        return typeOf(object) === REACT_LAZY_TYPE;
      }

      function isMemo(object) {
        return typeOf(object) === REACT_MEMO_TYPE;
      }

      function isPortal(object) {
        return typeOf(object) === REACT_PORTAL_TYPE;
      }

      function isProfiler(object) {
        return typeOf(object) === REACT_PROFILER_TYPE;
      }

      function isStrictMode(object) {
        return typeOf(object) === REACT_STRICT_MODE_TYPE;
      }

      function isSuspense(object) {
        return typeOf(object) === REACT_SUSPENSE_TYPE;
      }

      exports.AsyncMode = AsyncMode;
      exports.ConcurrentMode = ConcurrentMode;
      exports.ContextConsumer = ContextConsumer;
      exports.ContextProvider = ContextProvider;
      exports.Element = Element;
      exports.ForwardRef = ForwardRef;
      exports.Fragment = Fragment;
      exports.Lazy = Lazy;
      exports.Memo = Memo;
      exports.Portal = Portal;
      exports.Profiler = Profiler;
      exports.StrictMode = StrictMode;
      exports.Suspense = Suspense;
      exports.isAsyncMode = isAsyncMode;
      exports.isConcurrentMode = isConcurrentMode;
      exports.isContextConsumer = isContextConsumer;
      exports.isContextProvider = isContextProvider;
      exports.isElement = isElement;
      exports.isForwardRef = isForwardRef;
      exports.isFragment = isFragment;
      exports.isLazy = isLazy;
      exports.isMemo = isMemo;
      exports.isPortal = isPortal;
      exports.isProfiler = isProfiler;
      exports.isStrictMode = isStrictMode;
      exports.isSuspense = isSuspense;
      exports.isValidElementType = isValidElementType;
      exports.typeOf = typeOf;
    })();
  }
});

var reactIs = createCommonjsModule(function (module) {

  {
    module.exports = reactIs_development;
  }
});

var printWarning = function printWarning() {};

{
  printWarning = function printWarning(text) {
    var message = 'Warning: ' + text;

    if (typeof console !== 'undefined') {
      console.error(message);
    }

    try {
      // --- Welcome to debugging React ---
      // This error was thrown as a convenience so that you can use this stack
      // to find the callsite that caused this warning to fire.
      throw new Error(message);
    } catch (x) {}
  };
}

function emptyFunctionThatReturnsNull() {
  return null;
}

var factoryWithTypeCheckers = function factoryWithTypeCheckers(isValidElement, throwOnDirectAccess) {
  /* global Symbol */
  var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.

  /**
   * Returns the iterator method function contained on the iterable object.
   *
   * Be sure to invoke the function with the iterable as context:
   *
   *     var iteratorFn = getIteratorFn(myIterable);
   *     if (iteratorFn) {
   *       var iterator = iteratorFn.call(myIterable);
   *       ...
   *     }
   *
   * @param {?object} maybeIterable
   * @return {?function}
   */

  function getIteratorFn(maybeIterable) {
    var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);

    if (typeof iteratorFn === 'function') {
      return iteratorFn;
    }
  }
  /**
   * Collection of methods that allow declaration and validation of props that are
   * supplied to React components. Example usage:
   *
   *   var Props = require('ReactPropTypes');
   *   var MyArticle = React.createClass({
   *     propTypes: {
   *       // An optional string prop named "description".
   *       description: Props.string,
   *
   *       // A required enum prop named "category".
   *       category: Props.oneOf(['News','Photos']).isRequired,
   *
   *       // A prop named "dialog" that requires an instance of Dialog.
   *       dialog: Props.instanceOf(Dialog).isRequired
   *     },
   *     render: function() { ... }
   *   });
   *
   * A more formal specification of how these methods are used:
   *
   *   type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
   *   decl := ReactPropTypes.{type}(.isRequired)?
   *
   * Each and every declaration produces a function with the same signature. This
   * allows the creation of custom validation functions. For example:
   *
   *  var MyLink = React.createClass({
   *    propTypes: {
   *      // An optional string or URI prop named "href".
   *      href: function(props, propName, componentName) {
   *        var propValue = props[propName];
   *        if (propValue != null && typeof propValue !== 'string' &&
   *            !(propValue instanceof URI)) {
   *          return new Error(
   *            'Expected a string or an URI for ' + propName + ' in ' +
   *            componentName
   *          );
   *        }
   *      }
   *    },
   *    render: function() {...}
   *  });
   *
   * @internal
   */


  var ANONYMOUS = '<<anonymous>>'; // Important!
  // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.

  var ReactPropTypes = {
    array: createPrimitiveTypeChecker('array'),
    bigint: createPrimitiveTypeChecker('bigint'),
    bool: createPrimitiveTypeChecker('boolean'),
    func: createPrimitiveTypeChecker('function'),
    number: createPrimitiveTypeChecker('number'),
    object: createPrimitiveTypeChecker('object'),
    string: createPrimitiveTypeChecker('string'),
    symbol: createPrimitiveTypeChecker('symbol'),
    any: createAnyTypeChecker(),
    arrayOf: createArrayOfTypeChecker,
    element: createElementTypeChecker(),
    elementType: createElementTypeTypeChecker(),
    instanceOf: createInstanceTypeChecker,
    node: createNodeChecker(),
    objectOf: createObjectOfTypeChecker,
    oneOf: createEnumTypeChecker,
    oneOfType: createUnionTypeChecker,
    shape: createShapeTypeChecker,
    exact: createStrictShapeTypeChecker
  };
  /**
   * inlined Object.is polyfill to avoid requiring consumers ship their own
   * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
   */

  /*eslint-disable no-self-compare*/

  function is(x, y) {
    // SameValue algorithm
    if (x === y) {
      // Steps 1-5, 7-10
      // Steps 6.b-6.e: +0 != -0
      return x !== 0 || 1 / x === 1 / y;
    } else {
      // Step 6.a: NaN == NaN
      return x !== x && y !== y;
    }
  }
  /*eslint-enable no-self-compare*/

  /**
   * We use an Error-like object for backward compatibility as people may call
   * PropTypes directly and inspect their output. However, we don't use real
   * Errors anymore. We don't inspect their stack anyway, and creating them
   * is prohibitively expensive if they are created too often, such as what
   * happens in oneOfType() for any type before the one that matched.
   */


  function PropTypeError(message, data) {
    this.message = message;
    this.data = data && _typeof$1(data) === 'object' ? data : {};
    this.stack = '';
  } // Make `instanceof Error` still work for returned errors.


  PropTypeError.prototype = Error.prototype;

  function createChainableTypeChecker(validate) {
    {
      var manualPropTypeCallCache = {};
      var manualPropTypeWarningCount = 0;
    }

    function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
      componentName = componentName || ANONYMOUS;
      propFullName = propFullName || propName;

      if (secret !== ReactPropTypesSecret_1) {
        if (throwOnDirectAccess) {
          // New behavior only for users of `prop-types` package
          var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use `PropTypes.checkPropTypes()` to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
          err.name = 'Invariant Violation';
          throw err;
        } else if (typeof console !== 'undefined') {
          // Old behavior for people using React.PropTypes
          var cacheKey = componentName + ':' + propName;

          if (!manualPropTypeCallCache[cacheKey] && // Avoid spamming the console because they are often not actionable except for lib authors
          manualPropTypeWarningCount < 3) {
            printWarning('You are manually calling a React.PropTypes validation ' + 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' + 'and will throw in the standalone `prop-types` package. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.');
            manualPropTypeCallCache[cacheKey] = true;
            manualPropTypeWarningCount++;
          }
        }
      }

      if (props[propName] == null) {
        if (isRequired) {
          if (props[propName] === null) {
            return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
          }

          return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
        }

        return null;
      } else {
        return validate(props, propName, componentName, location, propFullName);
      }
    }

    var chainedCheckType = checkType.bind(null, false);
    chainedCheckType.isRequired = checkType.bind(null, true);
    return chainedCheckType;
  }

  function createPrimitiveTypeChecker(expectedType) {
    function validate(props, propName, componentName, location, propFullName, secret) {
      var propValue = props[propName];
      var propType = getPropType(propValue);

      if (propType !== expectedType) {
        // `propValue` being instance of, say, date/regexp, pass the 'object'
        // check, but we can offer a more precise error message here rather than
        // 'of type `object`'.
        var preciseType = getPreciseType(propValue);
        return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'), {
          expectedType: expectedType
        });
      }

      return null;
    }

    return createChainableTypeChecker(validate);
  }

  function createAnyTypeChecker() {
    return createChainableTypeChecker(emptyFunctionThatReturnsNull);
  }

  function createArrayOfTypeChecker(typeChecker) {
    function validate(props, propName, componentName, location, propFullName) {
      if (typeof typeChecker !== 'function') {
        return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
      }

      var propValue = props[propName];

      if (!Array.isArray(propValue)) {
        var propType = getPropType(propValue);
        return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
      }

      for (var i = 0; i < propValue.length; i++) {
        var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);

        if (error instanceof Error) {
          return error;
        }
      }

      return null;
    }

    return createChainableTypeChecker(validate);
  }

  function createElementTypeChecker() {
    function validate(props, propName, componentName, location, propFullName) {
      var propValue = props[propName];

      if (!isValidElement(propValue)) {
        var propType = getPropType(propValue);
        return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
      }

      return null;
    }

    return createChainableTypeChecker(validate);
  }

  function createElementTypeTypeChecker() {
    function validate(props, propName, componentName, location, propFullName) {
      var propValue = props[propName];

      if (!reactIs.isValidElementType(propValue)) {
        var propType = getPropType(propValue);
        return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
      }

      return null;
    }

    return createChainableTypeChecker(validate);
  }

  function createInstanceTypeChecker(expectedClass) {
    function validate(props, propName, componentName, location, propFullName) {
      if (!(props[propName] instanceof expectedClass)) {
        var expectedClassName = expectedClass.name || ANONYMOUS;
        var actualClassName = getClassName(props[propName]);
        return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
      }

      return null;
    }

    return createChainableTypeChecker(validate);
  }

  function createEnumTypeChecker(expectedValues) {
    if (!Array.isArray(expectedValues)) {
      {
        if (arguments.length > 1) {
          printWarning('Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' + 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).');
        } else {
          printWarning('Invalid argument supplied to oneOf, expected an array.');
        }
      }

      return emptyFunctionThatReturnsNull;
    }

    function validate(props, propName, componentName, location, propFullName) {
      var propValue = props[propName];

      for (var i = 0; i < expectedValues.length; i++) {
        if (is(propValue, expectedValues[i])) {
          return null;
        }
      }

      var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
        var type = getPreciseType(value);

        if (type === 'symbol') {
          return String(value);
        }

        return value;
      });
      return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
    }

    return createChainableTypeChecker(validate);
  }

  function createObjectOfTypeChecker(typeChecker) {
    function validate(props, propName, componentName, location, propFullName) {
      if (typeof typeChecker !== 'function') {
        return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
      }

      var propValue = props[propName];
      var propType = getPropType(propValue);

      if (propType !== 'object') {
        return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
      }

      for (var key in propValue) {
        if (has$1(propValue, key)) {
          var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);

          if (error instanceof Error) {
            return error;
          }
        }
      }

      return null;
    }

    return createChainableTypeChecker(validate);
  }

  function createUnionTypeChecker(arrayOfTypeCheckers) {
    if (!Array.isArray(arrayOfTypeCheckers)) {
      printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') ;
      return emptyFunctionThatReturnsNull;
    }

    for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
      var checker = arrayOfTypeCheckers[i];

      if (typeof checker !== 'function') {
        printWarning('Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.');
        return emptyFunctionThatReturnsNull;
      }
    }

    function validate(props, propName, componentName, location, propFullName) {
      var expectedTypes = [];

      for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
        var checker = arrayOfTypeCheckers[i];
        var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1);

        if (checkerResult == null) {
          return null;
        }

        if (checkerResult.data && has$1(checkerResult.data, 'expectedType')) {
          expectedTypes.push(checkerResult.data.expectedType);
        }
      }

      var expectedTypesMessage = expectedTypes.length > 0 ? ', expected one of type [' + expectedTypes.join(', ') + ']' : '';
      return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));
    }

    return createChainableTypeChecker(validate);
  }

  function createNodeChecker() {
    function validate(props, propName, componentName, location, propFullName) {
      if (!isNode(props[propName])) {
        return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
      }

      return null;
    }

    return createChainableTypeChecker(validate);
  }

  function invalidValidatorError(componentName, location, propFullName, key, type) {
    return new PropTypeError((componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.');
  }

  function createShapeTypeChecker(shapeTypes) {
    function validate(props, propName, componentName, location, propFullName) {
      var propValue = props[propName];
      var propType = getPropType(propValue);

      if (propType !== 'object') {
        return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
      }

      for (var key in shapeTypes) {
        var checker = shapeTypes[key];

        if (typeof checker !== 'function') {
          return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
        }

        var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);

        if (error) {
          return error;
        }
      }

      return null;
    }

    return createChainableTypeChecker(validate);
  }

  function createStrictShapeTypeChecker(shapeTypes) {
    function validate(props, propName, componentName, location, propFullName) {
      var propValue = props[propName];
      var propType = getPropType(propValue);

      if (propType !== 'object') {
        return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
      } // We need to check all keys in case some are required but missing from props.


      var allKeys = objectAssign({}, props[propName], shapeTypes);

      for (var key in allKeys) {
        var checker = shapeTypes[key];

        if (has$1(shapeTypes, key) && typeof checker !== 'function') {
          return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
        }

        if (!checker) {
          return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + '\nBad object: ' + JSON.stringify(props[propName], null, '  ') + '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, '  '));
        }

        var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);

        if (error) {
          return error;
        }
      }

      return null;
    }

    return createChainableTypeChecker(validate);
  }

  function isNode(propValue) {
    switch (_typeof$1(propValue)) {
      case 'number':
      case 'string':
      case 'undefined':
        return true;

      case 'boolean':
        return !propValue;

      case 'object':
        if (Array.isArray(propValue)) {
          return propValue.every(isNode);
        }

        if (propValue === null || isValidElement(propValue)) {
          return true;
        }

        var iteratorFn = getIteratorFn(propValue);

        if (iteratorFn) {
          var iterator = iteratorFn.call(propValue);
          var step;

          if (iteratorFn !== propValue.entries) {
            while (!(step = iterator.next()).done) {
              if (!isNode(step.value)) {
                return false;
              }
            }
          } else {
            // Iterator will provide entry [k,v] tuples rather than values.
            while (!(step = iterator.next()).done) {
              var entry = step.value;

              if (entry) {
                if (!isNode(entry[1])) {
                  return false;
                }
              }
            }
          }
        } else {
          return false;
        }

        return true;

      default:
        return false;
    }
  }

  function isSymbol(propType, propValue) {
    // Native Symbol.
    if (propType === 'symbol') {
      return true;
    } // falsy value can't be a Symbol


    if (!propValue) {
      return false;
    } // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'


    if (propValue['@@toStringTag'] === 'Symbol') {
      return true;
    } // Fallback for non-spec compliant Symbols which are polyfilled.


    if (typeof Symbol === 'function' && propValue instanceof Symbol) {
      return true;
    }

    return false;
  } // Equivalent of `typeof` but with special handling for array and regexp.


  function getPropType(propValue) {
    var propType = _typeof$1(propValue);

    if (Array.isArray(propValue)) {
      return 'array';
    }

    if (propValue instanceof RegExp) {
      // Old webkits (at least until Android 4.0) return 'function' rather than
      // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
      // passes PropTypes.object.
      return 'object';
    }

    if (isSymbol(propType, propValue)) {
      return 'symbol';
    }

    return propType;
  } // This handles more types than `getPropType`. Only used for error messages.
  // See `createPrimitiveTypeChecker`.


  function getPreciseType(propValue) {
    if (typeof propValue === 'undefined' || propValue === null) {
      return '' + propValue;
    }

    var propType = getPropType(propValue);

    if (propType === 'object') {
      if (propValue instanceof Date) {
        return 'date';
      } else if (propValue instanceof RegExp) {
        return 'regexp';
      }
    }

    return propType;
  } // Returns a string that is postfixed to a warning about an invalid type.
  // For example, "undefined" or "of type array"


  function getPostfixForTypeWarning(value) {
    var type = getPreciseType(value);

    switch (type) {
      case 'array':
      case 'object':
        return 'an ' + type;

      case 'boolean':
      case 'date':
      case 'regexp':
        return 'a ' + type;

      default:
        return type;
    }
  } // Returns class name of the object, if any.


  function getClassName(propValue) {
    if (!propValue.constructor || !propValue.constructor.name) {
      return ANONYMOUS;
    }

    return propValue.constructor.name;
  }

  ReactPropTypes.checkPropTypes = checkPropTypes_1;
  ReactPropTypes.resetWarningCache = checkPropTypes_1.resetWarningCache;
  ReactPropTypes.PropTypes = ReactPropTypes;
  return ReactPropTypes;
};

var propTypes = createCommonjsModule(function (module) {
  /**
   * Copyright (c) 2013-present, Facebook, Inc.
   *
   * This source code is licensed under the MIT license found in the
   * LICENSE file in the root directory of this source tree.
   */
  {
    var ReactIs = reactIs; // By explicitly using `prop-types` you are opting into new development behavior.
    // http://fb.me/prop-types-in-prod

    var throwOnDirectAccess = true;
    module.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess);
  }
});

var FORWARD_REF_STATICS = {
  '$$typeof': true,
  render: true,
  defaultProps: true,
  displayName: true,
  propTypes: true
};
var MEMO_STATICS = {
  '$$typeof': true,
  compare: true,
  defaultProps: true,
  displayName: true,
  propTypes: true,
  type: true
};
var TYPE_STATICS = {};
TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
TYPE_STATICS[reactIs.Memo] = MEMO_STATICS;

/**
 * Use invariant() to assert state which your program assumes to be true.
 *
 * Provide sprintf-style format (only %s is supported) and arguments
 * to provide information about what broke and what you were
 * expecting.
 *
 * The invariant message will be stripped in production, but the invariant
 * will remain to ensure logic does not differ in production.
 */


var invariant = function invariant(condition, format, a, b, c, d, e, f) {
  {
    if (format === undefined) {
      throw new Error('invariant requires an error message argument');
    }
  }

  if (!condition) {
    var error;

    if (format === undefined) {
      error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
    } else {
      var args = [a, b, c, d, e, f];
      var argIndex = 0;
      error = new Error(format.replace(/%s/g, function () {
        return args[argIndex++];
      }));
      error.name = 'Invariant Violation';
    }

    error.framesToPop = 1; // we don't care about invariant's own frame

    throw error;
  }
};

var browser = invariant;

function getCacheId(inputs) {
  return JSON.stringify(inputs.map(function (input) {
    return input && _typeof$1(input) === 'object' ? orderedProps(input) : input;
  }));
}

function orderedProps(obj) {
  return Object.keys(obj).sort().map(function (k) {
    var _a;

    return _a = {}, _a[k] = obj[k], _a;
  });
}

var memoizeFormatConstructor = function memoizeFormatConstructor(FormatConstructor, cache) {
  if (cache === void 0) {
    cache = {};
  }

  return function () {
    var _a;

    var args = [];

    for (var _i = 0; _i < arguments.length; _i++) {
      args[_i] = arguments[_i];
    }

    var cacheId = getCacheId(args);
    var format = cacheId && cache[cacheId];

    if (!format) {
      format = new ((_a = FormatConstructor).bind.apply(_a, [void 0].concat(args)))();

      if (cacheId) {
        cache[cacheId] = format;
      }
    }

    return format;
  };
};

var defaultLocaleData = {
  "locale": "en",
  "pluralRuleFunction": function pluralRuleFunction(n, ord) {
    var s = String(n).split("."),
        v0 = !s[1],
        t0 = Number(s[0]) == n,
        n10 = t0 && s[0].slice(-1),
        n100 = t0 && s[0].slice(-2);
    if (ord) return n10 == 1 && n100 != 11 ? "one" : n10 == 2 && n100 != 12 ? "two" : n10 == 3 && n100 != 13 ? "few" : "other";
    return n == 1 && v0 ? "one" : "other";
  },
  "fields": {
    "year": {
      "displayName": "year",
      "relative": {
        "0": "this year",
        "1": "next year",
        "-1": "last year"
      },
      "relativeTime": {
        "future": {
          "one": "in {0} year",
          "other": "in {0} years"
        },
        "past": {
          "one": "{0} year ago",
          "other": "{0} years ago"
        }
      }
    },
    "year-short": {
      "displayName": "yr.",
      "relative": {
        "0": "this yr.",
        "1": "next yr.",
        "-1": "last yr."
      },
      "relativeTime": {
        "future": {
          "one": "in {0} yr.",
          "other": "in {0} yr."
        },
        "past": {
          "one": "{0} yr. ago",
          "other": "{0} yr. ago"
        }
      }
    },
    "month": {
      "displayName": "month",
      "relative": {
        "0": "this month",
        "1": "next month",
        "-1": "last month"
      },
      "relativeTime": {
        "future": {
          "one": "in {0} month",
          "other": "in {0} months"
        },
        "past": {
          "one": "{0} month ago",
          "other": "{0} months ago"
        }
      }
    },
    "month-short": {
      "displayName": "mo.",
      "relative": {
        "0": "this mo.",
        "1": "next mo.",
        "-1": "last mo."
      },
      "relativeTime": {
        "future": {
          "one": "in {0} mo.",
          "other": "in {0} mo."
        },
        "past": {
          "one": "{0} mo. ago",
          "other": "{0} mo. ago"
        }
      }
    },
    "day": {
      "displayName": "day",
      "relative": {
        "0": "today",
        "1": "tomorrow",
        "-1": "yesterday"
      },
      "relativeTime": {
        "future": {
          "one": "in {0} day",
          "other": "in {0} days"
        },
        "past": {
          "one": "{0} day ago",
          "other": "{0} days ago"
        }
      }
    },
    "day-short": {
      "displayName": "day",
      "relative": {
        "0": "today",
        "1": "tomorrow",
        "-1": "yesterday"
      },
      "relativeTime": {
        "future": {
          "one": "in {0} day",
          "other": "in {0} days"
        },
        "past": {
          "one": "{0} day ago",
          "other": "{0} days ago"
        }
      }
    },
    "hour": {
      "displayName": "hour",
      "relative": {
        "0": "this hour"
      },
      "relativeTime": {
        "future": {
          "one": "in {0} hour",
          "other": "in {0} hours"
        },
        "past": {
          "one": "{0} hour ago",
          "other": "{0} hours ago"
        }
      }
    },
    "hour-short": {
      "displayName": "hr.",
      "relative": {
        "0": "this hour"
      },
      "relativeTime": {
        "future": {
          "one": "in {0} hr.",
          "other": "in {0} hr."
        },
        "past": {
          "one": "{0} hr. ago",
          "other": "{0} hr. ago"
        }
      }
    },
    "minute": {
      "displayName": "minute",
      "relative": {
        "0": "this minute"
      },
      "relativeTime": {
        "future": {
          "one": "in {0} minute",
          "other": "in {0} minutes"
        },
        "past": {
          "one": "{0} minute ago",
          "other": "{0} minutes ago"
        }
      }
    },
    "minute-short": {
      "displayName": "min.",
      "relative": {
        "0": "this minute"
      },
      "relativeTime": {
        "future": {
          "one": "in {0} min.",
          "other": "in {0} min."
        },
        "past": {
          "one": "{0} min. ago",
          "other": "{0} min. ago"
        }
      }
    },
    "second": {
      "displayName": "second",
      "relative": {
        "0": "now"
      },
      "relativeTime": {
        "future": {
          "one": "in {0} second",
          "other": "in {0} seconds"
        },
        "past": {
          "one": "{0} second ago",
          "other": "{0} seconds ago"
        }
      }
    },
    "second-short": {
      "displayName": "sec.",
      "relative": {
        "0": "now"
      },
      "relativeTime": {
        "future": {
          "one": "in {0} sec.",
          "other": "in {0} sec."
        },
        "past": {
          "one": "{0} sec. ago",
          "other": "{0} sec. ago"
        }
      }
    }
  }
};
/*
 * Copyright 2015, Yahoo Inc.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */

function addLocaleData() {
  var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  var locales = Array.isArray(data) ? data : [data];
  locales.forEach(function (localeData) {
    if (localeData && localeData.locale) {
      intlMessageformat.__addLocaleData(localeData);

      intlRelativeformat.__addLocaleData(localeData);
    }
  });
}

function hasLocaleData(locale) {
  var localeParts = (locale || '').split('-');

  while (localeParts.length > 0) {
    if (hasIMFAndIRFLocaleData(localeParts.join('-'))) {
      return true;
    }

    localeParts.pop();
  }

  return false;
}

function hasIMFAndIRFLocaleData(locale) {
  var normalizedLocale = locale && locale.toLowerCase();
  return !!(intlMessageformat.__localeData__[normalizedLocale] && intlRelativeformat.__localeData__[normalizedLocale]);
}

var _typeof = typeof Symbol === "function" && _typeof$1(Symbol.iterator) === "symbol" ? function (obj) {
  return _typeof$1(obj);
} : function (obj) {
  return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof$1(obj);
};

var classCallCheck = function classCallCheck(instance, Constructor) {
  if (!(instance instanceof Constructor)) {
    throw new TypeError("Cannot call a class as a function");
  }
};

var createClass = function () {
  function 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);
    }
  }

  return function (Constructor, protoProps, staticProps) {
    if (protoProps) defineProperties(Constructor.prototype, protoProps);
    if (staticProps) defineProperties(Constructor, staticProps);
    return Constructor;
  };
}();

var _extends = Object.assign || function (target) {
  for (var i = 1; i < arguments.length; i++) {
    var source = arguments[i];

    for (var key in source) {
      if (Object.prototype.hasOwnProperty.call(source, key)) {
        target[key] = source[key];
      }
    }
  }

  return target;
};

var inherits = function inherits(subClass, superClass) {
  if (typeof superClass !== "function" && superClass !== null) {
    throw new TypeError("Super expression must either be null or a function, not " + _typeof$1(superClass));
  }

  subClass.prototype = Object.create(superClass && superClass.prototype, {
    constructor: {
      value: subClass,
      enumerable: false,
      writable: true,
      configurable: true
    }
  });
  if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};

var objectWithoutProperties = function objectWithoutProperties(obj, keys) {
  var target = {};

  for (var i in obj) {
    if (keys.indexOf(i) >= 0) continue;
    if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
    target[i] = obj[i];
  }

  return target;
};

var possibleConstructorReturn = function possibleConstructorReturn(self, call) {
  if (!self) {
    throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  }

  return call && (_typeof$1(call) === "object" || typeof call === "function") ? call : self;
};

var toConsumableArray = function toConsumableArray(arr) {
  if (Array.isArray(arr)) {
    for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
      arr2[i] = arr[i];
    }

    return arr2;
  } else {
    return Array.from(arr);
  }
};
/*
 * Copyright 2015, Yahoo Inc.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */


var bool = propTypes.bool;
var number = propTypes.number;
var string = propTypes.string;
var func = propTypes.func;
var object = propTypes.object;
var oneOf = propTypes.oneOf;
var shape = propTypes.shape;
var any = propTypes.any;
var oneOfType = propTypes.oneOfType;
var localeMatcher = oneOf(['best fit', 'lookup']);
var narrowShortLong = oneOf(['narrow', 'short', 'long']);
var numeric2digit = oneOf(['numeric', '2-digit']);
var funcReq = func.isRequired;
var intlConfigPropTypes = {
  locale: string,
  timeZone: string,
  formats: object,
  messages: object,
  textComponent: any,
  defaultLocale: string,
  defaultFormats: object,
  onError: func
};
var intlFormatPropTypes = {
  formatDate: funcReq,
  formatTime: funcReq,
  formatRelative: funcReq,
  formatNumber: funcReq,
  formatPlural: funcReq,
  formatMessage: funcReq,
  formatHTMLMessage: funcReq
};
var intlShape = shape(_extends({}, intlConfigPropTypes, intlFormatPropTypes, {
  formatters: object,
  now: funcReq
}));
var messageDescriptorPropTypes = {
  id: string.isRequired,
  description: oneOfType([string, object]),
  defaultMessage: string
};
var dateTimeFormatPropTypes = {
  localeMatcher: localeMatcher,
  formatMatcher: oneOf(['basic', 'best fit']),
  timeZone: string,
  hour12: bool,
  weekday: narrowShortLong,
  era: narrowShortLong,
  year: numeric2digit,
  month: oneOf(['numeric', '2-digit', 'narrow', 'short', 'long']),
  day: numeric2digit,
  hour: numeric2digit,
  minute: numeric2digit,
  second: numeric2digit,
  timeZoneName: oneOf(['short', 'long'])
};
var numberFormatPropTypes = {
  localeMatcher: localeMatcher,
  style: oneOf(['decimal', 'currency', 'percent']),
  currency: string,
  currencyDisplay: oneOf(['symbol', 'code', 'name']),
  useGrouping: bool,
  minimumIntegerDigits: number,
  minimumFractionDigits: number,
  maximumFractionDigits: number,
  minimumSignificantDigits: number,
  maximumSignificantDigits: number
};
var relativeFormatPropTypes = {
  style: oneOf(['best fit', 'numeric']),
  units: oneOf(['second', 'minute', 'hour', 'day', 'month', 'year', 'second-short', 'minute-short', 'hour-short', 'day-short', 'month-short', 'year-short'])
};
var pluralFormatPropTypes = {
  style: oneOf(['cardinal', 'ordinal'])
};
/*
HTML escaping and shallow-equals implementations are the same as React's
(on purpose.) Therefore, it has the following Copyright and Licensing:

Copyright 2013-2014, Facebook, Inc.
All rights reserved.

This source code is licensed under the BSD-style license found in the LICENSE
file in the root directory of React's source tree.
*/

var intlConfigPropNames = Object.keys(intlConfigPropTypes);
var ESCAPED_CHARS = {
  '&': '&amp;',
  '>': '&gt;',
  '<': '&lt;',
  '"': '&quot;',
  "'": '&#x27;'
};
var UNSAFE_CHARS_REGEX = /[&><"']/g;

function escape$1(str) {
  return ('' + str).replace(UNSAFE_CHARS_REGEX, function (match) {
    return ESCAPED_CHARS[match];
  });
}

function filterProps(props, whitelist) {
  var defaults$$1 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  return whitelist.reduce(function (filtered, name) {
    if (props.hasOwnProperty(name)) {
      filtered[name] = props[name];
    } else if (defaults$$1.hasOwnProperty(name)) {
      filtered[name] = defaults$$1[name];
    }

    return filtered;
  }, {});
}

function invariantIntlContext() {
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
      intl = _ref.intl;

  browser(intl, '[React Intl] Could not find required `intl` object. ' + '<IntlProvider> needs to exist in the component ancestry.');
}

function shallowEquals(objA, objB) {
  if (objA === objB) {
    return true;
  }

  if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) {
    return false;
  }

  var keysA = Object.keys(objA);
  var keysB = Object.keys(objB);

  if (keysA.length !== keysB.length) {
    return false;
  } // Test for A's keys different from B.


  var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);

  for (var i = 0; i < keysA.length; i++) {
    if (!bHasOwnProperty(keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
      return false;
    }
  }

  return true;
}

function shouldIntlComponentUpdate(_ref2, nextProps, nextState) {
  var props = _ref2.props,
      state = _ref2.state,
      _ref2$context = _ref2.context,
      context = _ref2$context === undefined ? {} : _ref2$context;
  var nextContext = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  var _context$intl = context.intl,
      intl = _context$intl === undefined ? {} : _context$intl;
  var _nextContext$intl = nextContext.intl,
      nextIntl = _nextContext$intl === undefined ? {} : _nextContext$intl;
  return !shallowEquals(nextProps, props) || !shallowEquals(nextState, state) || !(nextIntl === intl || shallowEquals(filterProps(nextIntl, intlConfigPropNames), filterProps(intl, intlConfigPropNames)));
}

function createError(message, exception) {
  var eMsg = exception ? '\n' + exception : '';
  return '[React Intl] ' + message + eMsg;
}

function defaultErrorHandler(error) {
  {
    console.error(error);
  }
}
/*
 * Copyright 2015, Yahoo Inc.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */
// This is a "hack" until a proper `intl-pluralformat` package is created.


function resolveLocale(locales) {
  // IntlMessageFormat#_resolveLocale() does not depend on `this`.
  return intlMessageformat.prototype._resolveLocale(locales);
}

function findPluralFunction(locale) {
  // IntlMessageFormat#_findPluralFunction() does not depend on `this`.
  return intlMessageformat.prototype._findPluralRuleFunction(locale);
}

var IntlPluralFormat = function IntlPluralFormat(locales) {
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  classCallCheck(this, IntlPluralFormat);
  var useOrdinal = options.style === 'ordinal';
  var pluralFn = findPluralFunction(resolveLocale(locales));

  this.format = function (value) {
    return pluralFn(value, useOrdinal);
  };
};
/*
 * Copyright 2015, Yahoo Inc.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */


var DATE_TIME_FORMAT_OPTIONS = Object.keys(dateTimeFormatPropTypes);
var NUMBER_FORMAT_OPTIONS = Object.keys(numberFormatPropTypes);
var RELATIVE_FORMAT_OPTIONS = Object.keys(relativeFormatPropTypes);
var PLURAL_FORMAT_OPTIONS = Object.keys(pluralFormatPropTypes);
var RELATIVE_FORMAT_THRESHOLDS = {
  second: 60,
  // seconds to minute
  minute: 60,
  // minutes to hour
  hour: 24,
  // hours to day
  day: 30,
  // days to month
  month: 12
};

function updateRelativeFormatThresholds(newThresholds) {
  var thresholds = intlRelativeformat.thresholds;
  thresholds.second = newThresholds.second;
  thresholds.minute = newThresholds.minute;
  thresholds.hour = newThresholds.hour;
  thresholds.day = newThresholds.day;
  thresholds.month = newThresholds.month;
  thresholds['second-short'] = newThresholds['second-short'];
  thresholds['minute-short'] = newThresholds['minute-short'];
  thresholds['hour-short'] = newThresholds['hour-short'];
  thresholds['day-short'] = newThresholds['day-short'];
  thresholds['month-short'] = newThresholds['month-short'];
}

function getNamedFormat(formats, type, name, onError) {
  var format = formats && formats[type] && formats[type][name];

  if (format) {
    return format;
  }

  onError(createError('No ' + type + ' format named: ' + name));
}

function formatDate(config, state, value) {
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  var locale = config.locale,
      formats = config.formats,
      timeZone = config.timeZone;
  var format = options.format;
  var onError = config.onError || defaultErrorHandler;
  var date = new Date(value);

  var defaults$$1 = _extends({}, timeZone && {
    timeZone: timeZone
  }, format && getNamedFormat(formats, 'date', format, onError));

  var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, defaults$$1);

  try {
    return state.getDateTimeFormat(locale, filteredOptions).format(date);
  } catch (e) {
    onError(createError('Error formatting date.', e));
  }

  return String(date);
}

function formatTime(config, state, value) {
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  var locale = config.locale,
      formats = config.formats,
      timeZone = config.timeZone;
  var format = options.format;
  var onError = config.onError || defaultErrorHandler;
  var date = new Date(value);

  var defaults$$1 = _extends({}, timeZone && {
    timeZone: timeZone
  }, format && getNamedFormat(formats, 'time', format, onError));

  var filteredOptions = filterProps(options, DATE_TIME_FORMAT_OPTIONS, defaults$$1);

  if (!filteredOptions.hour && !filteredOptions.minute && !filteredOptions.second) {
    // Add default formatting options if hour, minute, or second isn't defined.
    filteredOptions = _extends({}, filteredOptions, {
      hour: 'numeric',
      minute: 'numeric'
    });
  }

  try {
    return state.getDateTimeFormat(locale, filteredOptions).format(date);
  } catch (e) {
    onError(createError('Error formatting time.', e));
  }

  return String(date);
}

function formatRelative(config, state, value) {
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  var locale = config.locale,
      formats = config.formats;
  var format = options.format;
  var onError = config.onError || defaultErrorHandler;
  var date = new Date(value);
  var now = new Date(options.now);
  var defaults$$1 = format && getNamedFormat(formats, 'relative', format, onError);
  var filteredOptions = filterProps(options, RELATIVE_FORMAT_OPTIONS, defaults$$1); // Capture the current threshold values, then temporarily override them with
  // specific values just for this render.

  var oldThresholds = _extends({}, intlRelativeformat.thresholds);

  updateRelativeFormatThresholds(RELATIVE_FORMAT_THRESHOLDS);

  try {
    return state.getRelativeFormat(locale, filteredOptions).format(date, {
      now: isFinite(now) ? now : state.now()
    });
  } catch (e) {
    onError(createError('Error formatting relative time.', e));
  } finally {
    updateRelativeFormatThresholds(oldThresholds);
  }

  return String(date);
}

function formatNumber(config, state, value) {
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  var locale = config.locale,
      formats = config.formats;
  var format = options.format;
  var onError = config.onError || defaultErrorHandler;
  var defaults$$1 = format && getNamedFormat(formats, 'number', format, onError);
  var filteredOptions = filterProps(options, NUMBER_FORMAT_OPTIONS, defaults$$1);

  try {
    return state.getNumberFormat(locale, filteredOptions).format(value);
  } catch (e) {
    onError(createError('Error formatting number.', e));
  }

  return String(value);
}

function formatPlural(config, state, value) {
  var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  var locale = config.locale;
  var filteredOptions = filterProps(options, PLURAL_FORMAT_OPTIONS);
  var onError = config.onError || defaultErrorHandler;

  try {
    return state.getPluralFormat(locale, filteredOptions).format(value);
  } catch (e) {
    onError(createError('Error formatting plural.', e));
  }

  return 'other';
}

function formatMessage$2(config, state) {
  var messageDescriptor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  var values = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  var locale = config.locale,
      formats = config.formats,
      messages = config.messages,
      defaultLocale = config.defaultLocale,
      defaultFormats = config.defaultFormats;
  var id = messageDescriptor.id,
      defaultMessage = messageDescriptor.defaultMessage; // Produce a better error if the user calls `intl.formatMessage(element)`

  {
    browser(! /*#__PURE__*/react.isValidElement(config), '[React Intl] Don\'t pass React elements to ' + 'formatMessage(), pass `.props`.');
  } // `id` is a required field of a Message Descriptor.


  browser(id, '[React Intl] An `id` must be provided to format a message.');
  var message = messages && messages[id];
  var hasValues = Object.keys(values).length > 0; // Avoid expensive message formatting for simple messages without values. In
  // development messages will always be formatted in case of missing values.

  if (!hasValues && process.env.NODE_ENV === 'production') {
    return message || defaultMessage || id;
  }

  var formattedMessage = void 0;
  var onError = config.onError || defaultErrorHandler;

  if (message) {
    try {
      var formatter = state.getMessageFormat(message, locale, formats);
      formattedMessage = formatter.format(values);
    } catch (e) {
      onError(createError('Error formatting message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : ''), e));
    }
  } else {
    // This prevents warnings from littering the console in development
    // when no `messages` are passed into the <IntlProvider> for the
    // default locale, and a default message is in the source.
    if (!defaultMessage || locale && locale.toLowerCase() !== defaultLocale.toLowerCase()) {
      onError(createError('Missing message: "' + id + '" for locale: "' + locale + '"' + (defaultMessage ? ', using default message as fallback.' : '')));
    }
  }

  if (!formattedMessage && defaultMessage) {
    try {
      var _formatter = state.getMessageFormat(defaultMessage, defaultLocale, defaultFormats);

      formattedMessage = _formatter.format(values);
    } catch (e) {
      onError(createError('Error formatting the default message for: "' + id + '"', e));
    }
  }

  if (!formattedMessage) {
    onError(createError('Cannot format message: "' + id + '", ' + ('using message ' + (message || defaultMessage ? 'source' : 'id') + ' as fallback.')));
  }

  return formattedMessage || message || defaultMessage || id;
}

function formatHTMLMessage(config, state, messageDescriptor) {
  var rawValues = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; // Process all the values before they are used when formatting the ICU
  // Message string. Since the formatted message might be injected via
  // `innerHTML`, all String-based values need to be HTML-escaped.

  var escapedValues = Object.keys(rawValues).reduce(function (escaped, name) {
    var value = rawValues[name];
    escaped[name] = typeof value === 'string' ? escape$1(value) : value;
    return escaped;
  }, {});
  return formatMessage$2(config, state, messageDescriptor, escapedValues);
}

var format = Object.freeze({
  formatDate: formatDate,
  formatTime: formatTime,
  formatRelative: formatRelative,
  formatNumber: formatNumber,
  formatPlural: formatPlural,
  formatMessage: formatMessage$2,
  formatHTMLMessage: formatHTMLMessage
});
/*
 * Copyright 2015, Yahoo Inc.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */

var intlConfigPropNames$1 = Object.keys(intlConfigPropTypes);
var intlFormatPropNames = Object.keys(intlFormatPropTypes); // These are not a static property on the `IntlProvider` class so the intl
// config values can be inherited from an <IntlProvider> ancestor.

var defaultProps = {
  formats: {},
  messages: {},
  timeZone: null,
  textComponent: 'span',
  defaultLocale: 'en',
  defaultFormats: {},
  onError: defaultErrorHandler
};

var IntlProvider = function (_Component) {
  inherits(IntlProvider, _Component);

  function IntlProvider(props) {
    var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    classCallCheck(this, IntlProvider);

    var _this = possibleConstructorReturn(this, (IntlProvider.__proto__ || Object.getPrototypeOf(IntlProvider)).call(this, props, context));

    browser(typeof Intl !== 'undefined', '[React Intl] The `Intl` APIs must be available in the runtime, ' + 'and do not appear to be built-in. An `Intl` polyfill should be loaded.\n' + 'See: http://formatjs.io/guides/runtime-environments/');
    var intlContext = context.intl; // Used to stabilize time when performing an initial rendering so that
    // all relative times use the same reference "now" time.

    var initialNow = void 0;

    if (isFinite(props.initialNow)) {
      initialNow = Number(props.initialNow);
    } else {
      // When an `initialNow` isn't provided via `props`, look to see an
      // <IntlProvider> exists in the ancestry and call its `now()`
      // function to propagate its value for "now".
      initialNow = intlContext ? intlContext.now() : Date.now();
    } // Creating `Intl*` formatters is expensive. If there's a parent
    // `<IntlProvider>`, then its formatters will be used. Otherwise, this
    // memoize the `Intl*` constructors and cache them for the lifecycle of
    // this IntlProvider instance.


    var _ref = intlContext || {},
        _ref$formatters = _ref.formatters,
        formatters = _ref$formatters === undefined ? {
      getDateTimeFormat: memoizeFormatConstructor(Intl.DateTimeFormat),
      getNumberFormat: memoizeFormatConstructor(Intl.NumberFormat),
      getMessageFormat: memoizeFormatConstructor(intlMessageformat),
      getRelativeFormat: memoizeFormatConstructor(intlRelativeformat),
      getPluralFormat: memoizeFormatConstructor(IntlPluralFormat)
    } : _ref$formatters;

    _this.state = _extends({}, formatters, {
      // Wrapper to provide stable "now" time for initial render.
      now: function now() {
        return _this._didDisplay ? Date.now() : initialNow;
      }
    });
    return _this;
  }

  createClass(IntlProvider, [{
    key: 'getConfig',
    value: function getConfig() {
      var intlContext = this.context.intl; // Build a whitelisted config object from `props`, defaults, and
      // `context.intl`, if an <IntlProvider> exists in the ancestry.

      var config = filterProps(this.props, intlConfigPropNames$1, intlContext); // Apply default props. This must be applied last after the props have
      // been resolved and inherited from any <IntlProvider> in the ancestry.
      // This matches how React resolves `defaultProps`.

      for (var propName in defaultProps) {
        if (config[propName] === undefined) {
          config[propName] = defaultProps[propName];
        }
      }

      if (!hasLocaleData(config.locale)) {
        var _config = config,
            locale = _config.locale,
            defaultLocale = _config.defaultLocale,
            defaultFormats = _config.defaultFormats,
            onError = _config.onError;
        onError(createError('Missing locale data for locale: "' + locale + '". ' + ('Using default locale: "' + defaultLocale + '" as fallback.'))); // Since there's no registered locale data for `locale`, this will
        // fallback to the `defaultLocale` to make sure things can render.
        // The `messages` are overridden to the `defaultProps` empty object
        // to maintain referential equality across re-renders. It's assumed
        // each <FormattedMessage> contains a `defaultMessage` prop.

        config = _extends({}, config, {
          locale: defaultLocale,
          formats: defaultFormats,
          messages: defaultProps.messages
        });
      }

      return config;
    }
  }, {
    key: 'getBoundFormatFns',
    value: function getBoundFormatFns(config, state) {
      return intlFormatPropNames.reduce(function (boundFormatFns, name) {
        boundFormatFns[name] = format[name].bind(null, config, state);
        return boundFormatFns;
      }, {});
    }
  }, {
    key: 'getChildContext',
    value: function getChildContext() {
      var config = this.getConfig(); // Bind intl factories and current config to the format functions.

      var boundFormatFns = this.getBoundFormatFns(config, this.state);
      var _state = this.state,
          now = _state.now,
          formatters = objectWithoutProperties(_state, ['now']);
      return {
        intl: _extends({}, config, boundFormatFns, {
          formatters: formatters,
          now: now
        })
      };
    }
  }, {
    key: 'shouldComponentUpdate',
    value: function shouldComponentUpdate() {
      for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
        next[_key] = arguments[_key];
      }

      return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
    }
  }, {
    key: 'componentDidMount',
    value: function componentDidMount() {
      this._didDisplay = true;
    }
  }, {
    key: 'render',
    value: function render() {
      return react.Children.only(this.props.children);
    }
  }]);
  return IntlProvider;
}(react.Component);

IntlProvider.displayName = 'IntlProvider';
IntlProvider.contextTypes = {
  intl: intlShape
};
IntlProvider.childContextTypes = {
  intl: intlShape.isRequired
};
IntlProvider.propTypes = _extends({}, intlConfigPropTypes, {
  children: propTypes.element.isRequired,
  initialNow: propTypes.any
}) ;
/*
 * Copyright 2015, Yahoo Inc.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */

var FormattedDate = function (_Component) {
  inherits(FormattedDate, _Component);

  function FormattedDate(props, context) {
    classCallCheck(this, FormattedDate);

    var _this = possibleConstructorReturn(this, (FormattedDate.__proto__ || Object.getPrototypeOf(FormattedDate)).call(this, props, context));

    invariantIntlContext(context);
    return _this;
  }

  createClass(FormattedDate, [{
    key: 'shouldComponentUpdate',
    value: function shouldComponentUpdate() {
      for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
        next[_key] = arguments[_key];
      }

      return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
    }
  }, {
    key: 'render',
    value: function render() {
      var _context$intl = this.context.intl,
          formatDate = _context$intl.formatDate,
          Text = _context$intl.textComponent;
      var _props = this.props,
          value = _props.value,
          children = _props.children;
      var formattedDate = formatDate(value, this.props);

      if (typeof children === 'function') {
        return children(formattedDate);
      }

      return /*#__PURE__*/react.createElement(Text, null, formattedDate);
    }
  }]);
  return FormattedDate;
}(react.Component);

FormattedDate.displayName = 'FormattedDate';
FormattedDate.contextTypes = {
  intl: intlShape
};
FormattedDate.propTypes = _extends({}, dateTimeFormatPropTypes, {
  value: propTypes.any.isRequired,
  format: propTypes.string,
  children: propTypes.func
}) ;
/*
 * Copyright 2015, Yahoo Inc.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */

var FormattedTime = function (_Component) {
  inherits(FormattedTime, _Component);

  function FormattedTime(props, context) {
    classCallCheck(this, FormattedTime);

    var _this = possibleConstructorReturn(this, (FormattedTime.__proto__ || Object.getPrototypeOf(FormattedTime)).call(this, props, context));

    invariantIntlContext(context);
    return _this;
  }

  createClass(FormattedTime, [{
    key: 'shouldComponentUpdate',
    value: function shouldComponentUpdate() {
      for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
        next[_key] = arguments[_key];
      }

      return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
    }
  }, {
    key: 'render',
    value: function render() {
      var _context$intl = this.context.intl,
          formatTime = _context$intl.formatTime,
          Text = _context$intl.textComponent;
      var _props = this.props,
          value = _props.value,
          children = _props.children;
      var formattedTime = formatTime(value, this.props);

      if (typeof children === 'function') {
        return children(formattedTime);
      }

      return /*#__PURE__*/react.createElement(Text, null, formattedTime);
    }
  }]);
  return FormattedTime;
}(react.Component);

FormattedTime.displayName = 'FormattedTime';
FormattedTime.contextTypes = {
  intl: intlShape
};
FormattedTime.propTypes = _extends({}, dateTimeFormatPropTypes, {
  value: propTypes.any.isRequired,
  format: propTypes.string,
  children: propTypes.func
}) ;
/*
 * Copyright 2015, Yahoo Inc.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */

var SECOND = 1000;
var MINUTE = 1000 * 60;
var HOUR = 1000 * 60 * 60;
var DAY = 1000 * 60 * 60 * 24; // The maximum timer delay value is a 32-bit signed integer.
// See: https://mdn.io/setTimeout

var MAX_TIMER_DELAY = 2147483647;

function selectUnits(delta) {
  var absDelta = Math.abs(delta);

  if (absDelta < MINUTE) {
    return 'second';
  }

  if (absDelta < HOUR) {
    return 'minute';
  }

  if (absDelta < DAY) {
    return 'hour';
  } // The maximum scheduled delay will be measured in days since the maximum
  // timer delay is less than the number of milliseconds in 25 days.


  return 'day';
}

function getUnitDelay(units) {
  switch (units) {
    case 'second':
      return SECOND;

    case 'minute':
      return MINUTE;

    case 'hour':
      return HOUR;

    case 'day':
      return DAY;

    default:
      return MAX_TIMER_DELAY;
  }
}

function isSameDate(a, b) {
  if (a === b) {
    return true;
  }

  var aTime = new Date(a).getTime();
  var bTime = new Date(b).getTime();
  return isFinite(aTime) && isFinite(bTime) && aTime === bTime;
}

var FormattedRelative = function (_Component) {
  inherits(FormattedRelative, _Component);

  function FormattedRelative(props, context) {
    classCallCheck(this, FormattedRelative);

    var _this = possibleConstructorReturn(this, (FormattedRelative.__proto__ || Object.getPrototypeOf(FormattedRelative)).call(this, props, context));

    invariantIntlContext(context);
    var now = isFinite(props.initialNow) ? Number(props.initialNow) : context.intl.now(); // `now` is stored as state so that `render()` remains a function of
    // props + state, instead of accessing `Date.now()` inside `render()`.

    _this.state = {
      now: now
    };
    return _this;
  }

  createClass(FormattedRelative, [{
    key: 'scheduleNextUpdate',
    value: function scheduleNextUpdate(props, state) {
      var _this2 = this; // Cancel and pending update because we're scheduling a new update.


      clearTimeout(this._timer);
      var value = props.value,
          units = props.units,
          updateInterval = props.updateInterval;
      var time = new Date(value).getTime(); // If the `updateInterval` is falsy, including `0` or we don't have a
      // valid date, then auto updates have been turned off, so we bail and
      // skip scheduling an update.

      if (!updateInterval || !isFinite(time)) {
        return;
      }

      var delta = time - state.now;
      var unitDelay = getUnitDelay(units || selectUnits(delta));
      var unitRemainder = Math.abs(delta % unitDelay); // We want the largest possible timer delay which will still display
      // accurate information while reducing unnecessary re-renders. The delay
      // should be until the next "interesting" moment, like a tick from
      // "1 minute ago" to "2 minutes ago" when the delta is 120,000ms.

      var delay = delta < 0 ? Math.max(updateInterval, unitDelay - unitRemainder) : Math.max(updateInterval, unitRemainder);
      this._timer = setTimeout(function () {
        _this2.setState({
          now: _this2.context.intl.now()
        });
      }, delay);
    }
  }, {
    key: 'componentDidMount',
    value: function componentDidMount() {
      this.scheduleNextUpdate(this.props, this.state);
    }
  }, {
    key: 'componentWillReceiveProps',
    value: function componentWillReceiveProps(_ref) {
      var nextValue = _ref.value; // When the `props.value` date changes, `state.now` needs to be updated,
      // and the next update can be rescheduled.

      if (!isSameDate(nextValue, this.props.value)) {
        this.setState({
          now: this.context.intl.now()
        });
      }
    }
  }, {
    key: 'shouldComponentUpdate',
    value: function shouldComponentUpdate() {
      for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
        next[_key] = arguments[_key];
      }

      return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
    }
  }, {
    key: 'componentWillUpdate',
    value: function componentWillUpdate(nextProps, nextState) {
      this.scheduleNextUpdate(nextProps, nextState);
    }
  }, {
    key: 'componentWillUnmount',
    value: function componentWillUnmount() {
      clearTimeout(this._timer);
    }
  }, {
    key: 'render',
    value: function render() {
      var _context$intl = this.context.intl,
          formatRelative = _context$intl.formatRelative,
          Text = _context$intl.textComponent;
      var _props = this.props,
          value = _props.value,
          children = _props.children;
      var formattedRelative = formatRelative(value, _extends({}, this.props, this.state));

      if (typeof children === 'function') {
        return children(formattedRelative);
      }

      return /*#__PURE__*/react.createElement(Text, null, formattedRelative);
    }
  }]);
  return FormattedRelative;
}(react.Component);

FormattedRelative.displayName = 'FormattedRelative';
FormattedRelative.contextTypes = {
  intl: intlShape
};
FormattedRelative.defaultProps = {
  updateInterval: 1000 * 10
};
FormattedRelative.propTypes = _extends({}, relativeFormatPropTypes, {
  value: propTypes.any.isRequired,
  format: propTypes.string,
  updateInterval: propTypes.number,
  initialNow: propTypes.any,
  children: propTypes.func
}) ;
/*
 * Copyright 2015, Yahoo Inc.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */

var FormattedNumber = function (_Component) {
  inherits(FormattedNumber, _Component);

  function FormattedNumber(props, context) {
    classCallCheck(this, FormattedNumber);

    var _this = possibleConstructorReturn(this, (FormattedNumber.__proto__ || Object.getPrototypeOf(FormattedNumber)).call(this, props, context));

    invariantIntlContext(context);
    return _this;
  }

  createClass(FormattedNumber, [{
    key: 'shouldComponentUpdate',
    value: function shouldComponentUpdate() {
      for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
        next[_key] = arguments[_key];
      }

      return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
    }
  }, {
    key: 'render',
    value: function render() {
      var _context$intl = this.context.intl,
          formatNumber = _context$intl.formatNumber,
          Text = _context$intl.textComponent;
      var _props = this.props,
          value = _props.value,
          children = _props.children;
      var formattedNumber = formatNumber(value, this.props);

      if (typeof children === 'function') {
        return children(formattedNumber);
      }

      return /*#__PURE__*/react.createElement(Text, null, formattedNumber);
    }
  }]);
  return FormattedNumber;
}(react.Component);

FormattedNumber.displayName = 'FormattedNumber';
FormattedNumber.contextTypes = {
  intl: intlShape
};
FormattedNumber.propTypes = _extends({}, numberFormatPropTypes, {
  value: propTypes.any.isRequired,
  format: propTypes.string,
  children: propTypes.func
}) ;
/*
 * Copyright 2015, Yahoo Inc.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */

var FormattedPlural = function (_Component) {
  inherits(FormattedPlural, _Component);

  function FormattedPlural(props, context) {
    classCallCheck(this, FormattedPlural);

    var _this = possibleConstructorReturn(this, (FormattedPlural.__proto__ || Object.getPrototypeOf(FormattedPlural)).call(this, props, context));

    invariantIntlContext(context);
    return _this;
  }

  createClass(FormattedPlural, [{
    key: 'shouldComponentUpdate',
    value: function shouldComponentUpdate() {
      for (var _len = arguments.length, next = Array(_len), _key = 0; _key < _len; _key++) {
        next[_key] = arguments[_key];
      }

      return shouldIntlComponentUpdate.apply(undefined, [this].concat(next));
    }
  }, {
    key: 'render',
    value: function render() {
      var _context$intl = this.context.intl,
          formatPlural = _context$intl.formatPlural,
          Text = _context$intl.textComponent;
      var _props = this.props,
          value = _props.value,
          other = _props.other,
          children = _props.children;
      var pluralCategory = formatPlural(value, this.props);
      var formattedPlural = this.props[pluralCategory] || other;

      if (typeof children === 'function') {
        return children(formattedPlural);
      }

      return /*#__PURE__*/react.createElement(Text, null, formattedPlural);
    }
  }]);
  return FormattedPlural;
}(react.Component);

FormattedPlural.displayName = 'FormattedPlural';
FormattedPlural.contextTypes = {
  intl: intlShape
};
FormattedPlural.defaultProps = {
  style: 'cardinal'
};
FormattedPlural.propTypes = _extends({}, pluralFormatPropTypes, {
  value: propTypes.any.isRequired,
  other: propTypes.node.isRequired,
  zero: propTypes.node,
  one: propTypes.node,
  two: propTypes.node,
  few: propTypes.node,
  many: propTypes.node,
  children: propTypes.func
}) ;
/*
 * Copyright 2015, Yahoo Inc.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */

var defaultFormatMessage = function defaultFormatMessage(descriptor, values) {
  {
    console.error('[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry. Using default message as fallback.');
  }

  return formatMessage$2({}, {
    getMessageFormat: memoizeFormatConstructor(intlMessageformat)
  }, descriptor, values);
};

var FormattedMessage = function (_Component) {
  inherits(FormattedMessage, _Component);

  function FormattedMessage(props, context) {
    classCallCheck(this, FormattedMessage);

    var _this = possibleConstructorReturn(this, (FormattedMessage.__proto__ || Object.getPrototypeOf(FormattedMessage)).call(this, props, context));

    if (!props.defaultMessage) {
      invariantIntlContext(context);
    }

    return _this;
  }

  createClass(FormattedMessage, [{
    key: 'shouldComponentUpdate',
    value: function shouldComponentUpdate(nextProps) {
      var values = this.props.values;
      var nextValues = nextProps.values;

      if (!shallowEquals(nextValues, values)) {
        return true;
      } // Since `values` has already been checked, we know they're not
      // different, so the current `values` are carried over so the shallow
      // equals comparison on the other props isn't affected by the `values`.


      var nextPropsToCheck = _extends({}, nextProps, {
        values: values
      });

      for (var _len = arguments.length, next = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
        next[_key - 1] = arguments[_key];
      }

      return shouldIntlComponentUpdate.apply(undefined, [this, nextPropsToCheck].concat(next));
    }
  }, {
    key: 'render',
    value: function render() {
      var _ref = this.context.intl || {},
          _ref$formatMessage = _ref.formatMessage,
          formatMessage$$1 = _ref$formatMessage === undefined ? defaultFormatMessage : _ref$formatMessage,
          _ref$textComponent = _ref.textComponent,
          Text = _ref$textComponent === undefined ? 'span' : _ref$textComponent;

      var _props = this.props,
          id = _props.id,
          description = _props.description,
          defaultMessage = _props.defaultMessage,
          values = _props.values,
          _props$tagName = _props.tagName,
          Component$$1 = _props$tagName === undefined ? Text : _props$tagName,
          children = _props.children;
      var tokenDelimiter = void 0;
      var tokenizedValues = void 0;
      var elements = void 0;
      var hasValues = values && Object.keys(values).length > 0;

      if (hasValues) {
        // Creates a token with a random UID that should not be guessable or
        // conflict with other parts of the `message` string.
        var uid = Math.floor(Math.random() * 0x10000000000).toString(16);

        var generateToken = function () {
          var counter = 0;
          return function () {
            return 'ELEMENT-' + uid + '-' + (counter += 1);
          };
        }(); // Splitting with a delimiter to support IE8. When using a regex
        // with a capture group IE8 does not include the capture group in
        // the resulting array.


        tokenDelimiter = '@__' + uid + '__@';
        tokenizedValues = {};
        elements = {}; // Iterates over the `props` to keep track of any React Element
        // values so they can be represented by the `token` as a placeholder
        // when the `message` is formatted. This allows the formatted
        // message to then be broken-up into parts with references to the
        // React Elements inserted back in.

        Object.keys(values).forEach(function (name) {
          var value = values[name];

          if ( /*#__PURE__*/react.isValidElement(value)) {
            var token = generateToken();
            tokenizedValues[name] = tokenDelimiter + token + tokenDelimiter;
            elements[token] = value;
          } else {
            tokenizedValues[name] = value;
          }
        });
      }

      var descriptor = {
        id: id,
        description: description,
        defaultMessage: defaultMessage
      };
      var formattedMessage = formatMessage$$1(descriptor, tokenizedValues || values);
      var nodes = void 0;
      var hasElements = elements && Object.keys(elements).length > 0;

      if (hasElements) {
        // Split the message into parts so the React Element values captured
        // above can be inserted back into the rendered message. This
        // approach allows messages to render with React Elements while
        // keeping React's virtual diffing working properly.
        nodes = formattedMessage.split(tokenDelimiter).filter(function (part) {
          return !!part;
        }).map(function (part) {
          return elements[part] || part;
        });
      } else {
        nodes = [formattedMessage];
      }

      if (typeof children === 'function') {
        return children.apply(undefined, toConsumableArray(nodes));
      } // Needs to use `createElement()` instead of JSX, otherwise React will
      // warn about a missing `key` prop with rich-text message formatting.


      return react.createElement.apply(undefined, [Component$$1, null].concat(toConsumableArray(nodes)));
    }
  }]);
  return FormattedMessage;
}(react.Component);

FormattedMessage.displayName = 'FormattedMessage';
FormattedMessage.contextTypes = {
  intl: intlShape
};
FormattedMessage.defaultProps = {
  values: {}
};
FormattedMessage.propTypes = _extends({}, messageDescriptorPropTypes, {
  values: propTypes.object,
  tagName: propTypes.oneOfType([propTypes.string, propTypes.element]),
  children: propTypes.func
}) ;
/*
 * Copyright 2015, Yahoo Inc.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */

var FormattedHTMLMessage = function (_Component) {
  inherits(FormattedHTMLMessage, _Component);

  function FormattedHTMLMessage(props, context) {
    classCallCheck(this, FormattedHTMLMessage);

    var _this = possibleConstructorReturn(this, (FormattedHTMLMessage.__proto__ || Object.getPrototypeOf(FormattedHTMLMessage)).call(this, props, context));

    invariantIntlContext(context);
    return _this;
  }

  createClass(FormattedHTMLMessage, [{
    key: 'shouldComponentUpdate',
    value: function shouldComponentUpdate(nextProps) {
      var values = this.props.values;
      var nextValues = nextProps.values;

      if (!shallowEquals(nextValues, values)) {
        return true;
      } // Since `values` has already been checked, we know they're not
      // different, so the current `values` are carried over so the shallow
      // equals comparison on the other props isn't affected by the `values`.


      var nextPropsToCheck = _extends({}, nextProps, {
        values: values
      });

      for (var _len = arguments.length, next = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
        next[_key - 1] = arguments[_key];
      }

      return shouldIntlComponentUpdate.apply(undefined, [this, nextPropsToCheck].concat(next));
    }
  }, {
    key: 'render',
    value: function render() {
      var _context$intl = this.context.intl,
          formatHTMLMessage = _context$intl.formatHTMLMessage,
          Text = _context$intl.textComponent;
      var _props = this.props,
          id = _props.id,
          description = _props.description,
          defaultMessage = _props.defaultMessage,
          rawValues = _props.values,
          _props$tagName = _props.tagName,
          Component$$1 = _props$tagName === undefined ? Text : _props$tagName,
          children = _props.children;
      var descriptor = {
        id: id,
        description: description,
        defaultMessage: defaultMessage
      };
      var formattedHTMLMessage = formatHTMLMessage(descriptor, rawValues);

      if (typeof children === 'function') {
        return children(formattedHTMLMessage);
      } // Since the message presumably has HTML in it, we need to set
      // `innerHTML` in order for it to be rendered and not escaped by React.
      // To be safe, all string prop values were escaped when formatting the
      // message. It is assumed that the message is not UGC, and came from the
      // developer making it more like a template.
      //
      // Note: There's a perf impact of using this component since there's no
      // way for React to do its virtual DOM diffing.


      var html = {
        __html: formattedHTMLMessage
      };
      return /*#__PURE__*/react.createElement(Component$$1, {
        dangerouslySetInnerHTML: html
      });
    }
  }]);
  return FormattedHTMLMessage;
}(react.Component);

FormattedHTMLMessage.displayName = 'FormattedHTMLMessage';
FormattedHTMLMessage.contextTypes = {
  intl: intlShape
};
FormattedHTMLMessage.defaultProps = {
  values: {}
};
FormattedHTMLMessage.propTypes = _extends({}, messageDescriptorPropTypes, {
  values: propTypes.object,
  tagName: propTypes.string,
  children: propTypes.func
}) ;
/*
 * Copyright 2015, Yahoo Inc.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */

addLocaleData(defaultLocaleData);
/*
 * Copyright 2015, Yahoo Inc.
 * Copyrights licensed under the New BSD License.
 * See the accompanying LICENSE file for terms.
 */

addLocaleData(allLocaleData);

var img$1 = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAAF0CAYAAAD/4EcMAAAAAXNSR0IArs4c6QAAQABJREFUeAHsXQe4FOXVPrsXuJfee5EiKlhQ7F0UROwVjD3RJBpN7DGxxNijMSa/PXZjiUYTe8eGvSMioogiTZDeuXDv7v++O3fYuXunbp3ZPed5Zmfm6987szNnzjnfObEkSJQUgZAhMHOJyCtfiXw2W2TBCmNwXduKbNNHZNQQkX4dQzZgHY4ioAgoAhWKwJOTRO5515j8YcNEfr5zMCDufU/kic+NOr/YReTQrYLVD2vpZmEdmI6rMhGoS4jcjT/qC1+KJDJY/5mLRbg984XImM1FTsYfsVm8MnHSWSsCioAiUC4IZDzqy2VaogxW2VzK6E+EzNVlz4l8Psd9LmS8npssMhtSrksPUCbLHS3NVQQUAUWgsAh0apVuf87S9LHfo7mWOta2/NYPazn9/g/rlanAcVFy5cVcWWFhWdZRUgQUAUVAESgdApt1T/fN5/KKtelzryOWtT73rW151Q17vjJYYb9CFTI+2lxRLRiUWId1lRQBRUARMBGgyunr+SIvTTFTdF9IBLrBPnZQV6OH2jqR297y3xvLsg6JbbCtciFVEZbLlYz4PGjQnmlz5WdKrMO6tMdSUgQUgcpFYB1e0hMhPflwhrEtXWNg8fVPIr/dSyRWudAUZebjhotc/ZLR1dvTRYb1Fhk91L1rMsAsaxLbKCdSBqucrmaE58LVgtlSLnWz7VPrKQKKQOkRIBP10Q8iH8yAmgnPEFMSYh3Z+Kki9bDvPHOESFy5LCs0eT3eaYDI9hsZ14MN3zLBUP2dtrtI25rGXVEtSMmVlbliXbZRTqQMVjldzQjPxXTFkM0UcqmbTX9aRxFQBEqHwCyYBJChoqSK0ik/joZe/0aEi2jO3UeZrEJeufNGilzwpMiMRUYvZKDIAFOa1buDkUYjeNpcWZnh/p1FWLfcSBmscruiOh9FQBFQBMoQgfe+F7nvfZEfl2U3ube+NZis3+NFXqXWx9mB6FGrZXORaw8VuX58WpJFRupDMFnCzYYouSJzxbrlRnqbldsVjeh86EQ0W8qlbrZ9aj1FQBEoLgJvTsueuTJH+t53ItfATojSLKXCIEBG6ZIxIheOThu+2/VEg3aWYdlyZK44Z5Vg2V15TSs6AvTQTiei2RDrKikCikB5IzBtQX7mR2nK7bD/OWPP/LSnrdgjQHsqbj8hEsdUrOhcvNooRz9XdMVQTqsF7RFQBssJF00vMgIMf0MP7UFXEtJolXWVFAFFoHwRWAaj6HzaWm7Wo3yxCtvMyEhVAjNlh7uqCO1Q0bSiI8DYggx/E5RYR+MSBkVNyysC0UJgGozZ80UdIUHZa3C+WtN2FAFnBJTBcsZGc4qMAH1ZcbWJX2JZ9X/lFy0tpwhEF4F8MlgHbqnhtaJ7J0Rr5J4M1oRvDY+40ZqWjjaKCDBwM2MLHrCF+1JqqgVZRuMQRvEq65gVgeAI5Mv+qgYG2GOGBu9faygC2SDgauS+HHrvO94RGQAfFVccmE3zWkcRCIYAmaxf72aoC+mhnU5ETdsLrhakQTttrlQtGAxXLa0IRBmBfEmwRm0m0qY6ykjo2KOEgCuD9c+3RZbDUy495E6eK7JFryhNTccaZQTIQKn6L8pXUMeuCOQHgQUrRZbhPZQr0ffVwVvl2orWVwT8I+CoIqSnXDpmM+nBj8wj3SsCioAiUHgE1tWLMBTKj8tFvlso8uWPcF44ExJNvHCVKgeBzq1FfrmrSKsWuc2ZLgO65+BvL7fetXYlImArwVq1TuTWCY3hmIKH26ezRIb3bZyuZ4qAIqAIZIMAmaVXp4qsWY8NzxzuV1uOGT/OjrjE/jp4i1aqDARoc3kQDNN3HSRyJ0xW3kH4lWzosGHZ1NI6ikD2CNgyWHfhJl7S4BTM2vRDkGIpg2VFRI8VAUUgGwSSqHTPuyKMSxaUps4TeQn2eaPV/1lQ6CJdng4qLxiFD33YUdFR6DxINv3S0J4im3TzW1rLKQL5QaCJipBSqle/tm+choZUHSopAoqAIpALAgwCmw1zZfZ5P2LS0fmkUuUhwI/8m8eJjN1WpHmVv/mr9MofTloqvwg0YrAoor/lTfcOKMVSUgQUAUUgFwQe+zSX2iIraw0JWG6taO2oItACjNVx24vceJTIlr3dZ9Grg8gO/d3LaK4iUAgEGjFY9+Kr0MuAdMYiGL9nqQMvxAS0TUVAEYgWAowFx+dIrvT6NyJfYHWzUuUi0BvM01UHiZy9t0j7lvY4HIqVgzDjUlIEio7ABgaLD6qXpvjr/9+QYgWNGeevZS2lCCgC5Y7Af3KUXlnxuW2CSJ2DMby1nB6XNwIjNoFd1s9E9oMT0ZiFm2oHpmvvTct77jq78CKQYrDW1Ync9IZIkpanPmg2DFPfmOajoBZRBBQBRcCCwET41PtmviUhx0M+i/47McdGtHpZINC6hchv9jBWmNI5NumAzUWoTlRSBEqBQIrB+teHwVZkcKCPfCzitIy6FBPRPhUBRSD8CORTemXOtha2o0qKgInApt1F/n6k4aiYIbWUFIFSIRCfiq/JZ78I3j2XyI6HDxslRUARUAT8IECzgrV5Zoa2Ruik43bw07uWqSQE6DvrENhetauppFnrXMOGQPzGN7K3p3oUthRq/xC2S6rjUQTCiQBfepcjpumALvkZX7e2IufDLxLbVVIEFAFFIGwIxGcvyX5ICxGy4oUvs6+vNRUBRaCyEGCg3SvBZG3UKbd5t4CL5AtHi7RFe0qKgCKgCIQRAVtP7kEG+vhnhkdlPvDKhWg0+xqcrfZFwOE+HbBZ9jVlNM9yuV46j2gh0BZqmysPFvnjUyLZfuDRmHlgniRhUUHvpxUiNOlY3BBlg57NN4O9ESV5SoqAIhA+BHJmFxhS55nJIkdsHb7JZTOiSXNEHoTRPw34Z9lI97q0acp4kRHrgOXASoqAIuAPgfZgsui/6I9Pi8xd6q+OWYqGy3tjWX6l0Pvfi9AcY/oC+xkP6ioybrgIgxkrKQKKQHgQiN0yIZlMBVpFsFVroNVU4FWk1cKFgxfRkPDOY0VaNvcqGe78xatEznwcITjWBB8nVR+/2k1kr8HB62oNRaBSEViE/xwlWX7jyjGmHBmzqg0e/MoXOT6Drx8v8tEP/ua4/UYi542M/nPY32y1lCIQfgRiSZDbMLnyh390MmF2DJiZty3+3AMbfI+4tRfWPEqs+DXNQLLZEh/+fzkk29paTxGoTARoy/kHMFlUgblRp9ZYfn+ESEeoxsqd+Fy94MnGHu+roW8Y1luE3stJjOX4OSTu1o/g/ngGX3uoMlkGQvqrCJQWAU8Gq7TDK17vd74DVecXufVHD8J3HqM2EbmhqLUrEYH5YK4oySKzZUfN4CySkqshPexyyy/tihcaS652GyRy2u4w6oe2wEorEPD6trdEGDzbJEqyLhljnuleEVAESoVABQjavaFlbMVcmSv2Qlngm99696clFAFFoDEC3WGofRUM3ztDSmVHv9ylcpgr2lxZ1YKnw6D/96OaMlfEiQwX81jGJNZlG0qKgCJQWgQqnsGiIftNb+TvIrzxTf7a0pYUgUpCoGc7rC6ElCpTBbjPpiJjEPKkUogG7SZRcjV6qHnmvGcZljXJ2oaZpntFQBEoLgIVz2BB6JRXZ6lk2L5bWNyLqL0pAuWCAO2LrgCT1b5hVS5XyNElQ6UQ7dDM1YK0uaJa0C+xLOuQ2IaXTZtRUn8VAUWgUAhUPIPVDy4WDh+WX3hfn5bf9rQ1RaCSEOB/kkwWmS06E21eVTmzp58rk2jQnmlzZebZ7VmWdUyytmWm6V4RUASKh0DFM1iEety2Ir3wMM8XvQU7LK6+VFIEFIHsEOgPT+83jxXpCr9zlUSmE1HO2VwtGGT+1jrWtoK0oWUVAUUgPwgogwUc+YVsNRLNFdoEXD4sx+oeJUVAEcgegUrwdZU9OvY19bvOHhdNVQRKgYAyWA2ob9lLZORmuV8CBrK94Qj17J47ktqCIlB5CDD8jUn0cxWUrF7xrW0FbUfLKwKKQO4IKINlwfAXO6eNay3Jvg8ZquK6Q0UYTkdJEVAEFIGgCDC2oEl0Iko/V36JZVnHJGtbZpruFQFFoHgIKINlwZrhbn65qyUhwOFYxAKjQa65iidAVS2qCCgCikAKAQZu5spJEj2004moX2JZ06s729Ag0H6R03KKQGEQUAYrA9c9NhYZ3jcj0eW0BZZFM/7XcTu4FNIsRUARUAR8IsDAzSbRQ/tLU8wz5z3LWL25W9twrqU5ioAiUEgENFSODboM23HGf/A1uN4m05LE2GgX7yeyccMXpyVLD8scAcaufH+G4TH7W/gcYqBwEu8J3g9UF+/UvzKCEqcmrj95RUBD5eQVTm2swhCgDzi6KTFX0tIekSrzYkt1lcFyuPGe/FzknvccMpHMlyiZK75QlSoLAYYhufd9kR+Xuc+7Z3uRn+9kMFvuJTVXEWiMgAZ7boyHnikCfhDgs5lRDExnvZl1qDqndJcfwMUgZbAcUKYfq3P/iwtl45V9d6gRzxwh0qKCHCA6wFRRyVwCfz8Yq/9NDDbtw7cWORGMVixYNS1d4QiQybp+fOO4hG6QMMgzzRVaNncrpXmKQPkhENb/ijJYLvcamavz/idCdRAphjfkMdsZjkmNFP2tJATuy4K5MvEhk3USmCwlRSAoAmH7Kg86fi2vCBQSgTBLe5XB8rjyVBNSXViNr8Jz9hbZuUiiRY9haXaREeBL7uqXGndKhnvfISKjNhPpB8/jpJmLRV6ZKvLyVyJJirwsxFWmxRJNW7rVwzJBICx2JWUCp06jTBAIs72iMlgeNxmXPV/6nMivdhMZ2NmjsGaXJQKUYP7m0cY2V7S9O2cfka3goNaOJs2Fw9lX08bvLEObrFvHqeG7HV6apggoAopAUAQyP3wZkWX0UPdWuOL2lgnpMoX88FU3DWmcbY/o1+ovhyhzZQtOhSRytaDVoJ2SKzfmirCQ8WIZljWJbbAtJUVAEVAEFIHcEaBBu0m7DfJmrliWDBjLmmRtw0zL114ZrHwhqe2ULQL8SrIS1YJOkitrOZZhWStltmXN02NFQBFQBBQBfwhQZW6uFqQg5LTd/dVjKZY1nYKzDbZVCFIGqxCoaptlhQD9XFmJNld+KbNsZlt+29FyioAioAgoAmkE6OfKpGG9RdrWmGfee5ZlHZOsbZlp+dgrg5UPFLWNskbAdCJqTtI0aDfP3faZZTPbcqureYqAIqAIKAL2CJhORJnbu4N9GbdUax1rW251guYpgxUUMS2vCCgCioAioAgoApFGIGORd0HmAs2lkiKgCLghwBWDc5amS9AVwybd0uduRyxrJfX8b0VDjxUBRSAXBBasFFm0SiSOxTRVEJdwv2GznFvzqlgGec2rou0sm+FvTLI+n800r/1cyzPd2pZXvSD5ymAFQUvLViQCDItk/QPTz5VfBotlraRxK61o6LEi4I7Ap7MMz/RDeriXq9Tct74VoQPkbGjEJiJn751NzXDUYWxBkz6fI7JirX87LJZlHZOsbZlp+diDj1VSBBQBNwQynYPSiSj9XHkRy7CslTLbsubpsSKgCDRGYN5ykQueRNiy/4lMADNhRtVoXKpyz9q3zH7ulGpFmRi4mbEFSfRXedtbxrGfX5ZlHRLbKFQQ6IhDbACkv4pAIRHYqb/hJNTsgx7a6UTUjckyHY1avbnT0SjbUlIEFAF/CJiqm2k/GXEZT3lY5L8TRVbW+qtf7qXaWRgsxqAc2EWkPxxic3FNnw4ivfDM6d5OpGsbkc4wdegItRrrtKkuj5iVDNxs0tvTRehE1ItYhmVNsrZhpuVrr57c84WktlPWCGR6DOZkNVROWV9ynVwIECBjRelVJjF02d5QcR28ZXYryDLbi+r5N8CH8XJJg2EX+rfDjeNK+tVQOZV0tSM4V4rd6yGVaQGjRyVnBDTYszM2mqMIFAKBhTDg/sUDzi3zI2d4X5FDthLZuo9zuXLNmQ8Hmb98yJgd1Vx3HVuuM3WeV5iDPauRu/N1q5ic174R+c+nIqfsIrJj/4qZduCJnriTUeV/UFEEocO3FjHrBqmnZRWBSkegI9RZZKKoauf+d3uJPPsFPHgvNJBh+iczjW0jqMUOBqO112BjhVwlYNfO4lxzGQy3K5GoGr32UEOF/NEPBgK0r/qQxw3nmbhsvxEkfyMLryZVFWEm8hV2jueTnPZvkbmIk0fi1yADW1N3r2SPANWF92LljjU+oV1J2lz9HEyZGrbboaNpioA/BE64X2TpGqPsfSeI0C7ryx9FnpqEl+gMkQQfYhaijdGYoSL7b27YHFmyyvLwiDtF1tcbU3v8FGgiKlhswmczYwuaIXQyLzgN2mlzVaxnsjJYmVegws5p7HfdK40nTf8oFLmP3VakpoL/rI1RaXxGter7M7DhD83wN6aHdvq5oisG/oFp0B71lTqNZ61nikDxETjzcZHvGyRWfz8Sq75gyG0SVWTPQKI1fqrI6nVmqrHnc4xBfQ8ZBuPvzo3zyunsFw+KLIQ/LNLdxxkG7cZZ5f4ytiDD35ge2smU0xVDoVYLOiGtDJYTMhWSfhYeXt81PLwyp9y5DewfdhbZHQ8pJUVAEVAESoHAZc8bKkD2fckYEap3Mol2OHSJ8uxkkfnLM3NFtkDgdX407tAfqsam2ZFOORvPcFNlesMRxgdepCdURoNX+UQZXcygU6ETP5O5qoEe++L9RB7+WGQKxO+kRfgq+iukWy9iWeuvoTbs19FI119FQBFQBIqFAN0LmGRKis1zc087HDJQB2FV4QczDPWh+RxjmcnwScetRzujzMjNCm9/Y46t0Hurq4blFWqHVWiMs21f/WBli1xI6tEWiA74sqHHP0vXGj1EZKveIn85ROScfWDnYHmofTFH5MzHsELl3aZi+HQLeqQIKAKKQP4RoO8mk0yVj3meuWeYmJ2hnudzjNKcveDKoVlVuhQdl975DmwjH4A67b20s8l0iegdWZ2NLmuwVYveLMpzxMpgRfi60v7gaRh6Xj9e5MKnRWYs9j8Z6qf5RUfiA+hQ2CmYxFU4tx0tchjSzIcTbY7Y12mPiLz6tVlS94qAIqAIFBYB68eeF4NlHQltIc/ZG8/Hw+2lVYORX10GOpxGDJZKsKy3QMmPlcEq+SXIfgBPwF2AGTqCzBJ18fw6W5Vh7GnXw+OfplNHgKGyiuGZQ5H7z2F/deNRIsP6pMsuWS3yf6+LXPlCOk2PFAFFQBEoFAKmN3e276QidOp74myRy54ToY2WSZt0xzMMz7U9NjZTor1vX5Me/3KVYKXBCMFRGfDvIUCxBEPgsuXxGZIkMltcUUOVIf0ujdzUfmA/QNKV8hGCbIrUD9/GvhxTGW7higNF3v0OInWoCBm9nWRnaGrk6K8ioAgoAvlDwPrx51eCxWfhgx+J0GedGa6KfrTok+647cO9updBiBmKKw7xB5/PVdgaHfPckmZVC1qP83cFtKVsEVAGK1vkSlyP6rp1dcYgBnQR6dBS5LNZxjn/ZDdCysSYSzROp6jcSlbbq50HItREe2uu/fEuKLddPzgk/Qwx+PAA2Bd+ZpQUAUVAESg0Ao1ssFZ590Y7q7+OF2GYHZPYBm1Lh8HONOzE5zo1BdlQpTobzQarYtRRBqsYKOe5D/p7ef7LdKPHbGd4YH8PPpkoZaIPENLXsLNinKpRMGA/YQeRthAl027LGujySBfpldFK+pcO7Pj1l8SGDyglRUARUAQKjgCZI9ObOz8e6ViUEhw7emOayO1vNV6Ms91GImeNQJBjiyrNrm5Y0jIdpwYZl6oIg6BV+LLKYBUeY9ceqNKjAzQG6vRLz4G5Mp3qMWr6jv2Nmlw9sy2kTLSvYsR5evfln5WSrHfgUPR4MFnfLUrbbW3Tt7HTPr/9Ozzb/FbXcoqAIqAI+EaAzBQl9JTq8HlG8wirXRYboo0VGavXv0k3S0ejJ+5ohM9Jp4b/iM/wf52IuULNyfkyTmyjY55b0xrKMa2SvbiH8coqg1XCqzIDzM49WCrMP8aozSBlwsPA6ytrHZimZ6AeNOkI2BRYiQGbj4GEaR+0d+fbaVurlbVYGYgHkJWOCiC9stbTY0VAEVAEiokApVim2oyG7lYGi5EUuJLaDPfFcfXuIHL+qGh6cG8G2ysylErRR0AZrBJeQ/qwMlcB0gsxDcmPBXM0ZnNnEfgrKGfG5aLb/z0H20+gO/IuHmN4QObKQuvDhzUoNaN3YyVFQBFQBMKOAF01mE6RrYbuT34Oac+HInX48DSJTkRpe1oOLhjMOek+mgiAV1YqFQK/2aNx0ElKmf4JqdPZ/xX5al7TUVHS9QQeKCbRT5WTLYJZhuLmm8cZ6sHq5maqyBEqvUqDoUeKgCIQagSsEqslkGDxI/PS5wwNgMlctWphSK1+t5cyV6G+mBU0OI1FGIKLzZA1d1DKtLTxYOiF+Odwt2CuoqEBJ5fvkuhcjoE9qRL0SwvxYKIR/OwlIjeN9VtLyykCioAiUFoEHobLhUc+McZA21EGfzYl+UylRP7ckSKU3CspAmFBQBmskFyJOhgqUtz9Hxior4XBpkn8KjsaqwQP3AIrYR4XmQkfVqTjdxTJ1oaKjkhbo10lRSBbBGhUTEe3jINGZp82I9x3xNamRleZZour1rNHgPFQb53QNI8SfErjaVrhJc1vWltTFIHCIqAMVmHxDdz6IkiZaPj+1reNq9IGwfRiTKbrHkivuFdSBEqBAF92fOnZURUMD7hYw2S6UgwYjJR5PqCzyHBIIJQUgSAI0DFyZvQIOiA9ex/EUFVb0iBQatkiIqBG7kUE209XfGicD1H3fkOhNoQ9Fr2uk0zmisf7b67MFXFQKg0C9DTtxFxxRFy4wRVf5qov6yhpB3gvPg7aVFtTK/tYpYHe199qg8XSO2yEAPQjDN9+3rW1hCJQGgSUwSoN7p69bomvMsbLehZ+sh7+OO33in5ODt7Ks7oWUAQKggCZgRvfyL7pWtQncxbEwW32vUWj5r2QWDsxrCoNNK6hyWDRtxVjpNJkQkkRCDsCeWWwaITdtY3IkB6qD8/HhadNAZmpPQaL3Pe+4USP8QXVR0o+0NU2skGAzMACRAPIhegolytgyTxUOqk00N8d0AEqZjpVPg8qwf5QMyspAlFAIK82WHz40o0AbYO27mPYWgyHm4AuUHsp5Y7A1PkiVCGSiVVSBIqNwMTZIn96Nj+9njcSHw4b56etqLZCaeAZ/8mNYaVz4kqRBnIhEJ1wKikCUUEgrwzWRzBEvOKFplPnl8e2MGwls7V5T/2TNEVIUxSBcCOQD2bAOkOGhvrb4daUyjt2WyjgF43O+Ni66xiVBvrFS8spAsVEIK8qwqFgnqjWokNMK9G1ADdKt2jkylUfXElEhqtnO2tJPVYEFIEwIvDIx7lJWjLnNO0nw5kuzQkqkSgNdLK7CoLHopWIM/qdSgODYKZlFYFiIZBXBou+lagfN0Ma9EI8qIV4AKyrS0+HRq6UdHEj9WxvBCgmw0XGS4NVGrjoryIQJgQYkunZyUYA8XyN62ks4KhEBovSwJvezBeKIk8hNmmlq1vzh6a2pAjkD4G8MlgcFuPbmQzWbgNFxm4rMnmuEROPHsvnZHgr/3GZsVKOq+W4QoQqREq2yHD165i/iWpLioAikD0CA7uInISoAoxrmS/6GB9Ztfj4qrSYcSoNzNcdpO0oAuFGIK82WJzqe9+LXPOSMWmqDP9ySGMA5q8QIaP16UyRSXNE+DXnRDTmNpmtYb3V95MTTpquCBQLgStfFPlwRu69UVL9h31FtsPHVKURP0DPfyK/0sBdB4lcMKrSkNT5KgLhRiDvDNaKtSLH3S+ShB0WJVL//oVzvDyuCpmCoMafgeH6BAzXjEXOYHFJNw3lL8BDme0qKQKKQPERWFELB4+PGar/bHuvaS5y8ZjK9sD9DCT2+ZQGUgr44EmVJw3M9h7UeopAMRAA25JfaosQGX0bVHvr60W+hmsBJ+KSW9pdnYilxjfCqeZ9J4j8boTIbvgaa4mHsJXMmHzKXFlR0WNFoLgItK2GL6KR2a9aa436lx9Y2cwVr9hBW8Ibef/8XDtKA/nhWWmq1vygp60oAoVDIO8MFoe6BVSDJtH+yi/RWy8daTJMDIRbG4iONa86WGTjrhuS9EARUARKhMBQrPw7GraVQYmBoa86SGSz7kFrlmd5hnrpAjOIXIjSwD/tX5mq1lxw07qKQDEQKAyDBamUSV/+aB7521NVeDl8aXG1IYlBjq+GHVd/+NJSUgQUgXAgwMUrW8Eu0i/xf3wNPpJoLK9kIKDSQL0TKgGBn2B3PeFbkSex2pUbj5lWCQThcv6JKwFNoorQrwfe92Eg/9fxaeNPGrlfiYey+soy0dS9IhAOBGIYxjn7QKUPe6zla9zH1LUt/seQXOn/uClOpjTwoY+a5rmlUBp4+QHKsLphpHmlRYDv80c/FZm+wH4cg6CRGjdcZKcB9vnlkFoQCVZHqProA4vEZdh0KuhFb00XufaVNHPVox1WIB6qD2Uv3DRfESgVAlTpnw01V4zclgPxOXAtJNDKXDkAhGSVBjpjoznRQ4CeARjR5eqXnJkrzoqMF8uwrJs3geghkB5xQRgsNt/IDstDTfjaNwibAclVfYPhVR88lOneQWPupS+UHikCYURg234ih25lP7KNoNbn/zhXOyP71ssn1ZQGUirlRZQGXgNMzYVEXuU1XxEoJgJklC54Mu1InH1z8cUOGxkB3hnkncfWBRl0Os465chk5d1Ng3kx35gmcsOrxhmdhv4Z4mw7emmKyK1vGW4dmM+H8hVQJ9CwXUkRUATCjwA/jH6PB6RVUs0FKZdhtSDtjJT8IWDan9LFjR1RGnglMFWG1Q4dTQsDApRGmVFaOB56BDhtdzwH4F3ASnTndBve+29Dc2XS9mC8LhljnpXHvmASLKsd1lfwdZUZn5DwMVTGLRPSzNUgGMDSoF2Zq/K4uXQWlYEAfdT9Hk4u6UqFRAfDtLlS5srAw++vSgP9IqXlwogAba6szNXpexjPhUzmimNnGp8ZLGMS67KNcqKCMVhU73WDOJtE0V+modt/JyIK/DtGPn837W4YtOtDOY2JHikCUUGgO/7rZ+wpMqwPJFeQVpvMVlTGH5ZxnrCjyOBujUdDaaB+eDbGRM/ChwAN2k2i5Gr0UPPMec8yLGuStQ0zLcr7gjFYBMUqxbK6a3j4Y5H730/DxnJ0Pshg0UqKgCIQTQT4oCRzZbWviOZMSjdqlQaWDnvtOXsE6HbBFKLw/0+1oF9iWfOZwTbKyYVDQRksBn42yXQ4eh8YKwY7Ncn84s303G7m614RUASig0DcZUVhdGZR2pGqNLC0+GvvwRGYOj9dh3GD7dSC6RKNj1iWdUyytmWmRXVfED9YJhhWBosxB++ASvBZ2F2ZtB2M2v6IEA8a/sZERPd2CKxaJ/LBDJH5y40QLWPhO0VJEShnBCgN3GWgiDKs5XyVy2dui1en59IbizGCUqoObLBI1raMlOj+FpTBou8benBevEpkZW1j5mpnPDzOHynCeIRKioAbArx3/vGaUaIz7idlsNzQ0rxyQUCZq3K5kjoPLwSSXgUiml9w9sbqD8vEaI+N4fcCKwiUuTIR0b0bAlwwQdsUEr9uGBlASRFQBBQBRSAcCNDpsElzlppH/vdzLXWsbflvIZwlC85gbW6xwyIEIzcTOReSK/06C+cNEcZR8V4xff/QR1A5GUGGEW8dkyKgCCgCQRCwBnD/fI4I/Vz5JZZlHZOsbZlpUd0XnMGySrDGbI7YZXshtEZU0dJxlwwB0+UHBzC/QgKFlgxs7VgRUAQUgQAI8PnM2IIkhsejE1G/xLKsQ2Ib1me9kRrd34IzWAzp0B5e2Q9BOI0gSzejC6mOvBAIcGWVSTR2V1IEFAFFQBEIDwIM3GwSPbQzSosXsYzVm7u1Da+6UcgvqJG7CcA5+4hsAweESopAtgh0x4IJk1RFaCKhe0VAEVAEwoHATgNEGO7G9ObOKC1U/QUJlcM2yomKwmApc1VOt0xp5tJIgqUqwtJcBO1VEVAEFAEXBM6DfTUDN89YZBSidIoMF/1cme4baARPxstUC7Jk/84irFtuVBQGq9xA0/kUHwErgzVPVYTFvwDaoyKgCCgCHgjQYfi1h4pcPz4tySIj9SGYLOFmQ5R6kbkqR2fjymDZXHBNCh8CVgbLr4qQAcb5JcVg4/QOzAUXfuJjhW/2OiJFQBFQBKKBABmlS8YYgZsZW9AMoZM5ehq00+aq3NSC1nkqg2VFQ49DiwAd1tLj//p6kWVrRNbiq6gm4+5dAYekZKS+BkP1FfbTfkI5BBo3qQXqK4NloqF7RUARUAQKhwAZJ278IOZz2fTQTj9XdMVQTqsFnVDMeEU5FdN0RaD0CPAPaTqxo5qQ/rGmNkinuJ9tcVZnN1q/ki+7upqmCCgCioAiEBwBPrcrgZmyQ0YZLDtUNC2UCFgZrHP/a0izvAZqhmpiOfWf5YWW5isCioAioAjkCwFlsPKFpLZTcASsrhqoKswkqhAHdYH4uYchgua+bbXIkXeJ0AP8gpUitMvSKAKZyOm5IqAIKAKKQL4RUAYr34hqewVDwGrozk46UpcPJmoI9PncbwyjSbv4lizHgOP1iGG4EExWpYqrC3ZhtGFFQBFQBBSBJggog9UEEk0IKwKDu4nsv0WaocpkuJzGzXJksEi0w1IGy8BCfxUBRUARUAQKh4AyWIXDVlvOMwJbIXA4t6BE1SJdNZBohwUeTUkRUAQUAUVAESgoAgWPRVjQ0WvjioAPBKySLo1j6AMwLaIIKAKKgCKQMwLKYOUMoXMDK9Y652lO8RCwqgR1JWHxcNeeFAFFQBGoZASUwSrQ1X/8MwS5fERk1hL/HUxfKELPt0r5RcC6+jAog8XVilQv/rgsv2PS1hQBRUARUATKGwG1wSrA9SWT9NCHRsN/elbkL4jNZFVT2XX55Y8iV7wgsnqdSBUcaB65jV0pTcsGASv2XgwWjeHpBd50YEqmtw5M1kk7iRy+dTa9ax1FQBFQBBSBSkRAGawCXPXt+ok8MdFglhbhhU0miwEwO7S07+yjmch/WWQdwr+QnvwcIV2GwIdTjXGuv7kh0LUNmFbIaummgQxUHfZ058Dz7xcZYRxS8QohqaKvLDtSL/B2qGiaIqAIKAKKgBMCymA5IZNDOp1dMtjlpc8ZTBPVS2SyrjlEpHWLxg2/OU3kH68bL3vmdEbMvcsPVOaqMUq5ndGxKHElk0SHo3e8bYTVYaxCRnr3Q16SLz9taBlFQBEIDwIzYb7xylcin83GhxWeDaSucOmyTR+RUfjA7dfRSNNfRSBbBGJJULaVtZ47ApRMXf1imnmiM8wrwDxVN7C1L3wpcjte9uYV6NneyLcaZbv3oLl+EbjoGZEv5niXZiT4TeBva1Ncq46QOP4T14fUp4PIrUcbx/qrCJQjAmsQGJ2S93a479tjo8Sde/4P2kCaju+UsiBKsO9+V4TPX0Z2sCN+lI3ZXOTkXeydF9vV0TRFIBMBZbAyEcnzOSVUN7yWZqK26WtIt/gge6DBTotd9u9sSK6c1Ih5HlbFNXfjGyLjpzaddg/4yDK9wZOp6t8pHUqHL5xxdxt1WoApfvyUpvU1RREoFwRunSDy4hT72VDF3g5Mlsl0pRgwREjg+QA8u4bjuRYFInN1GTQLn/v42OJ8hvWGJuIAZbKicG3DOEa8NpQKicCegw1brNveMnr5bJbIGY+KzIXa0CS+4C/dv6n60MzXfe4IcCUhYxUynI7JUHHvxtBSmsWXyvK1hqp3yWojPE/uo9EWFIFwIUCGw4m54khpr8j7n1smVeN/cu9xkHIh7mfYiZIrv8wV58KyrPPr3cI+Mx1fGBFQBqsIV4Wi5pW1aYmVlbmiROvC0Wm1YRGGU5FdHLiFyBFbB/8SJWNGBotEOyzGNVRSBMoJAUpqKeHNlmpRn8xZ2Fc+0+aKasGgxDp8hqtNVlDktDwEv0rFQOAwvNx7wcbKSjynMbxpk2XN0+P8IsDFBXaBoL16sdrDqRd4L7Q0P4oI3Pte2sg72/E/ByaEUq4wEw3anWyu3MbNOqyrpAgERUAZrKCIZVGeK9Xo48oquWIzPKctllJ4EQjiQyu8s9CRKQL2CEyc7a4atK/VNHXRSpF3vmuaHqYUrhbMlnKpm22fWi/6CCiDVeBruAqOQy+BiwbaXplklWTR0D0bsbXZlu4Li4DVC7z6wios1tp6cRGgavCmN/PX51OT8tdWIVoyXTFk03YudbPpT+uUBwJqg1XA67h0jeH/agacWZp03A6GR3BKtEymi64aWkGFRYN4pXAh0EiCtTxcY8v3aA6+PfcWnz419za0heIg8MjHuasGrSOlXzk67B2CxSNKioAigBXpCkJhEKC044InRUzmKga/KqftLjJ2uGELRMN2rmIj0Q8WnY3Sb5ZSuBBoxGDhmiopAuWCAD/ouLI2n/T0F/lsLb9t0YlotpRL3Wz71HrRR0AZrAJcQwZ4JnNlBgimD5lz9jZWopjd0bCdrhno/4pEA1GGy2FMQqXwIEAjdzLHJIbRycZI1qitv4pAuBAY2MWIsZnPUX38g//oCPns109b9NCeLeVSN9s+tV70EVAGK8/XcAWW9P/xKRHGICTRQeWF+9mr/7iyjWFx6MGdxFiEVB0ywLBSOBDgF77pmoFMsHldwzE6HYUikBsCB20pskP/3Nowa/NZd8G+4V0VzfA39NAelFiHdZUUgaAIKIMVFDGP8gzQfOgwoxDtqi6DF+Dt+zlXoqNLhs9hrDzSahjFfzzTONbfcCDQtwNC5SAu2ba4jnX14RiTjkIRyBcCZ44Q6dImt9Zq4Gz0T5DIM9B9WIl+rOjPKiipD6ygiGl5EwENlWMikef9o58aDxsGfvZDVCtS8kXmLOwO+/zMR8tEDwE1co/eNcvXiKfAOP2ip7PzZdW62jB32Kx7vkZTuHY0VE7hsNWWmyKgDFZTTEqWQvUiJWBKikApEFAGqxSoh6fPRz8ReeijYONhYOjLIaWnPVdUSIM9R+VKRX+c0JorhQUBZa7CciV0HIpA5SEwdluRL+aKTEL8PT/UCWYNNG/oC9VblIgRHRhbkKo/eminE1HTzxVXC9KgnTZXGhonSlc1nGNVBiuc10VHpQgoAopAURGg/fc5+4j87jHE31zj3jUZkSsPwgIdxOqMKpGBOnmXqI5exx0FBNTIPQpXSceoCCgCikAREOjUSuRsGL2brknsuuyFRR/XHhJt5spuXpqmCOQbAWWw8o2otqcIKAKKQIQR4GrZQ7eyn8BGnUT+AuYq11WH9q1rqiJQXghUpIrwi8UidyD6+9SlImvhe0opGgg0x+fAwPYix8ID9Yje0RizjlIRiCICJ+woMhlOjxn+xqSNu8LtDGyu2mLVoJIioAh4I1BxEqwvFomcMUFk4kJlrrxvj3CVWJ8Q+XoJ/O18KPL8D+Eam45GESgnBBh94vejjBipnNfQnobNlTJX5XSVdS6FRqDiGKx/TtFwJ4W+qYrR/m2QQCopAopA4RBgHM4z9hQZhlV1dJhMx8lKioAi4B+BilMRfg21oFL0EVhaKzIfK526ww+PkiKgCBQGgd0GiewyMLsQM4UZkbaqCEQHgYpjsNTmKjo3p9dI9Vp6IaT52SLw0wrYaM4XWbzaaIGr6+ipnMG/K42yid9XaRjpfBUBOwQqjsGyA0HTFAFFQBEgAu9/L8IwV9MX2OMxCIbe44aL7DTAPl9TFYGwITB3mUgvLA5SKj4CFRcqZ/cnig+y9lgYBB4cKbJRBUoUCoNmZbe6Zr3I9eNFPvK5eGL7jUTOw/3XEkGOlRSBsCLw34kiD2JREBcs7Ozzo2AFzC/enCZy4BZhnZX7uJLIZmzfXDzxs/4tWAx38X4ibXJYNVtxRu7ul0ZzFQFFoNIQIHN1wZONmatqyPZ3ABN12DBj4zHTTCIjxjqsq6QIhBGBZyeL3P++EcCbHw9fwu2GFy1YadzXd7wtQuYsakSzkStfAEMJQcoMuGPKhijxu/gZkSnA65qXswuAbvarEiwTCd1HDgGVYEXukoVywFfggWyVXNGw+7TdmwZeZzD2294SeXt6ehqUZF0yJn2uR4pAWBCgJIofAbMhjSG1hiSGTmLpLNaOyJBc9pzIolVGLl113DIuWurFq18y1PycAcM5/e1wkQ4BFkLNWy7yx6eBARhNk0ZuhvBRe5lnwfYqwQqGl5ZWBBSBMkKANldW5ur0PQx1il3gdaZR1cIyJrEu21BSBMKGAH2W0b1G59bGyFaB4fozGKiFFubBHDOlW398Ks1cNa8y7vWo2W4dv4PBSHJeDOB95Ysi6+rNWbrvubDlIkiurMwVa4yfmr00Txksd8w1VxFQBMoYARq0m0TJ1eih5pnznmVY1iRrG2aa7hWBMCDQtY3IpWCyKL0iUTr1JzBZlG6Z9B4+EP70rAgZMBLLXn6gf5sto1Y4fvsigPcF+Aii9I30DVYC/+M149jtdyFwoVqQTBmpGraVDBll0r8+ECFOQUlVhEER0/KhQcBRRZhMSvLtJyU55X1JLnVYDhaaWRRoIMm1kkxA3t0xIbJFW4kNbviMLVB3UWx2Pb5sZzaoT/g87tcp/WD2mk89YJ0JlQp2KaJBLb/6lRSBMCJAW8EfYVuUbBhcDewJe7YHowW1N5kuM70Z/gg924m0sNgbes4n3lpiLYZIvN2xcJiGRkNAL8Ch+G0T0gMZO1zkOEi37IiuWC6E9I62VyTOnWr/LXoazOgXc4x0Ml3XHCzCkFF+SRksv0hpudAh4MRgJe74gyQmwUpTKY3AHjjcKX2qR4qAIqAI5BOBWFVnqepxF75SAnAg+RxARlt3vSvy9KR04tl7I4btJulzHi1dA+bq6bSdGj+SLsLKweF9jXIrIdU7/wmROUuN8074TqVdl6l2NVKdf/nhpqQIlA0CyYlvKnNldzXJby63y9A0RUARUARyRyBZv0gSS2/JvaE8tfCLnUW4CMWkm9/EysB55pkhvbsEakFzEUAzMFd/2DfNXLEkXTT8CdIs0yZzMaR9XBTj18m1MlhpvPWoDBBIfvtZGcyiAFOgLqtB1F2A1rVJRUARUAQkufaT0KDACAT0VTegszEkmgRcDaN3rhSkZOpi2J39ADU/iTZb56OslSEzcgxV6oWjRciAkb5baPjMM9WqRqr9rzJY9rhoalQRWNmgSI/q+As5btgaKCkCioAiUCgEkvVLCtV0Vu3SETDtqToi1BVpOWzOLn/eMOr/HowSiczVufu4G/VvDnss6+rhD2eI3PNeqrrrTzPXXM10RaBP9WxpU2WseV2fbC6za/tIbQIyxQJT26oV0rP6R4nDxDYpMVm4vossWt/Apuex797Vc4R9La9vJ3Nre+WxZW1KEVAEFAFFoCwRmDk1Pa0aGC117SMSgzipRNQFKynpkZ22VrVwRDq7wZ6Kw6GU68wRjVcFOw1zn00NW6zHG5QkT30u0qe9+8rjkjNYXNlAAKK0AmePjm/K2f2ulw7NGnPraxMt5aEfT5AH5x3vdI1ySq+O18o5/f4qozq/DLbKXL9kNDl9zWC55vuLZPqajXPqg5X37PiGnNn3BunYvEF+irTFYOD+PvM8eXvp7jm3rw0oAoqAIqAIlCcCdded0mhisVbtJH74GRLbaf9G6cU8GdxN5Ky9Ra57BSsmG3R75PnO2Etkr8H+R3LCjsZqw3e/M+rc+77IroOcw+mUVEVInejlMBj77WMik+f6n2QpS27RZrL8eeAlTZgrjqkmvkZO7v1POaLb4wUZ4h/6Xy37dn6xCXPFzga1nCbXb3K2tGuWmyXzsDafp+ZnZa7Yfqfmi+TyQRcJ56+kCCgCioAioAj4QSC5ernUP3i1JCe95ad4wcrsOrCxqwZGaxgJqVRQOgeMGhk2rii88iBn5ortlpTBehT2cFz+OBcbXdxHIa7Xz3o8aMvgWC/SST3vkZZgtvJJQ1p/JXt1fNW1SUrUDugCy70c6BjML+0VpXFDlJpx/kqKgCKgCCgCikAQBBIvPxCkeEHKHrWNCFV9v9pNZD8fToXtBkE/WVQ5Xn+4t0+skjFYMxY1dj9/Inz0RCEy/cCa6XaYN0prAynSQV2fapSW68nPuj/kq4mBLb/1Vc6p0KBW05yyUumDcmzftXHNVAQUAUVAEShPBObk9m7KFyi0uTpwi9xao9F8F0iwvKgkDFYCOtCb3kxHqd4C9tOjh3gNNRz5tIPyQ2O7PyLNYrCoywP1rZklu3Wc4Kul6tg6X+WcCnnV9zt/p/bzmU5PvU2knq3bw54SynUlRUARUAQUgdAgkFyf27spNBMJMJCSMFhPfyEy7SdjlBS3nbFngBFHpGjn5gtT9lL5GO647g97qiXz0U/U2vgCdnuMFm9lsuJHnSVVf31Jqs68SaoOOEVinbG+VkkRUAQUAUVAESgyAkVnsOavEHnoo/Qsj95WJGoRu9Ojdz86OsUY+XFH5txOZxiX79sJBmpKtghQ1Xz9+IysmlaIvbeNxMacJFUXPSDxITtkFCjiKf9hFCUzegQ9abTEpqQIKAKKgCJQ9ghAflRcugWqwVoEniQN6CJy+NbGcTn+9q2ZKbtDtTdhSfYiuiO7PSrN45UnWg1yP3z0g8j73yPU3gCbWi1qJH7cRZK8bKwk1/lT79q04j+J/ygs25X+2DbC1gFbJpHnXoAN45YZDRvTlBQBRUARUATKBoGiSrBe/Vpk4mwDO3pP/d1ehqOvskHTZiLH9Mh+5UTrqlVycJ6N5W2GGNmkFt0REwo+1NZXizz4qcs02kN01HczlwJ5yMIYUsGUT8X+EGzDsNkxV0iGvlcEy3xle2xHYTsF25bYivpvRH9KioAioAgoAgVDoGiP9GVwUW91LX8wXiiDIMEqd9q01VQZ3u6TrKZ5SNcnpBWYLCV7BBbCj9oaqN9WgpH5HHfybycgOrqDsC/WvoA3W2+M72Rse2DD6pLA1BE1EM5BjsPmxJQFblQrKAKKgCKgCJQSgaIxWHe8bUSv5mR7tBM5ll/vFULHdn8w8Eybx9fDYeljgetVcoWJsMe61k2SVQhwYEMoP8MGSVrO1AMtnICtf84taQOKgCKgCCgCJUagKAwWbWTesrjAOH1PEa4erBQa3u4j2bQV9KMBaL9Oz6e8pweookWBwAfz4f6jWPZMm6PDfbDl819Ug/YOw0YVopIioAgoAopAZBEoOJvDJfS3vZXGh4zVD4tFhuJrPUrxB9MzyO6IHtD//N0VvirHEMJ5XI9/+yqrhRojsB4hGtdha1nVOD3vZ33QItV6hSBEgJcjsN2PbXUhOghZm1XdJVYNz39VXSUWh3ibm9QhoMBaSSZWwMhutiTrZmH/PdILyT2DU8Y4Ys36YSydJIYtRYnVkqyfh0UScDK8jh9KGFtOFJNYq5GY81DY45Gj9kuYe2I5xoIYqHXzJVn7Gc6X+a2ce7nqrSTecjdcn7bodw36nyjJNRNyb5ctVPWQWOt9gD3/WHmm5Hpcu2mSXPUSGnawIfDbJe9R4CBVnXF/wLYzBhuFJO4PXBdZ950k1+P+qIcoPQ8Ua7k7+toafVSj3e8xfsSVQ19ZE8feapTEmvfFGJdKYu17WHE2KevmtKI3AgVnsObi/9/C8rJbh2fTXe+IPPG5yLjhIqNge0yD93InBojuUz1bZtd6P0AYbLk3yiqFFAEaqY/CVsj7Fu8w2Rnbq9jKkZr1knibI/HA3wMvVepGvSlZvww818d40byIPV4O+aIWW4JnOAy8zk54aZK5c6ZkYhWYinclseJ/eKF+4VzQMadKqrr9A31t41jCb0Yyya+JbySx8knj5SswSiwQxdqdKFUdfpnR+lhJrHpVEosuzUgPdhqr3kbiXa8Fc52NAaP/vpJtj5L6+aeBSQlo1xprI7G2R0qc92qLTTw7TNZOlcTqlyW58mn0BePjLCje+U8Sb71vo5rJdj/D+H+dHQPXYgjuu78D47QtQ7z98eCz7pDk8n816kdP8odAIV8RqVHSkP3Wo2GAvBdcAfGl0UCLViJ9gshpj4i89g0+iAr5YWp2WsI94/gd3eMhXyPwGxbHV2NaKP8IUDXYNWCztSiP92EgwsertA9UI/yF4+0l3vlSqer5CARVY30zV5xYrAp1IeWo6vbXVH1pwQuRAzXrK/Eu10izHrelXmZezBV7isVbo+woow5eWJhMoAHE2hyaF+YqNZZYHMKNzSBM+YNU9YIz4poCGbZCohdv/wvbefJ6xFruYZvnNzHe6YKCM1cpvFoMxDxO8jsslGsGxmocsP0PmEs4LfbBXKX64TXp+DvUezwlMQrQYaooGf1M5irVLj5E4u1PDdpcqnxVp3MbMVdmI/H2J2OavcxT3ecZgYIzWBxvHF/8lFT982cip+5uRKE25zEPktV/vAZv7o+KvD3dTC3P/ejOLwodh7rRtm0/lk1aT3UronmlRmBHnwNYjHJPYbsZ2/9huwHbvdjexAZJridR8pu7oMOzm2IViFUPB2N0f4pBiYE5yIVizfuA0boRdgaDs2om1moEtFL3QSqBB1KWFAdDU9Xzbojood70SbEacs35p1iz3pACXQ+GAA/ZPFO8zUEIP2VRQ2S0H2tzSEZKgNN4R6isvKX6AVp0LZpS77mWaMiMd5Cq7jeCUfqtp1TTqblYFdrocqnEO/wWRZzxy6zvNsZYzVaZxb3PoWKU5vaSN17XWID717szLWFFILennLUlH8fN0Nv++Oi84xiRX0D90a5lutLspSLXvSJy5mMwVJ6RTi+no2ax9XJUd3CSLnSMTymXSxOaVUgEKFHyI7SYiHL3YPsam2k2QQnWAmwfYKN9Fe55TxrkWSIaBWBLEu8GBqAqf+4yYvFqqPaODDz/WLuTIHi6HF/0ePHkSJxPVfebYYpzoL+WYoVTg/FlWdXxdDBZR/kbi69SkJJBYudGsZrtUjZJbmUc82Bjl4SNVLEoWc+vHg9q1h/M912GrZVHUT/Z8XbjcO9D2kl7LT/kpirN5v6JtQSD7PKqd+vPz3i1jCMCLqg71sk5gzZZhw6DLdaxcP2zA1a4W55z30PAc9WLIuf+T+SzMjRDOrjLk9K2aoUthpulfGZ9ZJuniSFBwA/DQyElPhZcVYIsM97HnMjMtfNRLsxFYLhc1fUveMi3yP8om3UL1GYMdl8pdU8eA4LHYs0k3uk8SLIgpg8BxTucAeYgP6LPWM0OnkxxSgrSanSWM68zbJWyrB20WnIlXixuBJVvVbcbAqmu3Zoz8+I1w3GPnG2e6r5CECgJg2ViWwMT+7EwdL8TjNbYbbHyq7mZYwSDvvTZxs5J07nRPWpZtVrO3ghf8hmroVpWrZFzNrouuhOrlJHDe7wnfYwSfmwKv0O5WZ6tRd5lQxz2KFbjWh8z9l9k/Uz/ZWnMDpVPIYhMVlXnS9B0AZjIgAMmw0PM80Gx1vv5aibus5xdY4klt2Bx5KNYiRfQ+NyuMYe0ZN2PUr/wUticu3/AVnW9EsxVMKbdocsmycQoV3u1Jo1qQqgRKPgqQj+zb41n0nGwzzxkS0ivXhKZ8qNRiy4d9sNK5nKjER1flU6bLpL//XSULFjXTfrXfJ8ygO9X80O5TbX85uNHwxPkMs4FRH09YLKo0j1Kumfz/UXbryL+61MrxFru4j4u5CbWfGi8/OrokmE+DDeh1oBBfMpdQouheDHtAklKh0btJOuXw0sBjdr8UBxNneNqS2S2ksTSdY5H6n+CWqc5Xri9YEC+M2xVBppFbPex5hvB3ubXklh6k22+38TE6teMVYrryX1Tr9xAcI8Qaz4gZSSfMpYHU+dEsRaDgdleWPH4hlMR7w5WZR0AAEAASURBVHSoo+gqwA+lsGmxKVY1UicelNYZmBE32D4BdKMBGvE32wgqz7GwldvNs9FkEtKw5Q9iBd8EXLsF6fJUQSZXps8djmKt94fkDy8hD0rCDUNy9VtwnYAvJLpNqOqG6zLIWBGL+8WN4p3Ol/ofJ+Gy+rEPcGtJ86KAgPM/tASjX43/wfSF6Y6PhlSrF21eypCGtZko3JQihkBrH+PFwg3ftNhHST99+mhG3kch8A3SBVsPbIOx+VF5oli2FMtYap7ZDpmpxOK/2EoWTCFgUp5ENTA6rfbEBv9RzbqkfFIllt3n+0WVYtDAdLhREgxN/aKrwCRMblTMGMdtYGx2warDi8H4OetsU/ZPeMlLYkmjNvyeJLC0P7H4OvviaDNZNxNM05sIi/GEoXalTyMHirXeOycGK9Zq70B2apTQJLJisCwTyGA8UsxM7aewe/wzFkeMtBRsephYdAX4nVebZvhMibc/0bVkMpkEQ38PmLiHUG5do7Kpe2RJZ6gBz3dlBmNVHWE3CPcWy+5oVF9PyhOBUDFYdNtQCyaLNAAvgcO3No71VxEIDQLPYiRVLqPhk9YidHApaWQ13O+u5Ro+6F3L+M3k2CCYSW34kBZ8xKS80WNXCIq13NWxWUoc6hf+Ce+qLx3LpDPgLHL1+NSWTvN/5GWEnlIh0UdSxgve2kNy7btSP+80GEDfAcbDnutNGRNDkiW1WTJYS++2dul8XPcDmMHLYGB/O6Ry9o9x2k9BJIQtyA2Z7jLeekz6xMcRmV9ZcjNK1vsoHaxIYtndrgxWEqriXJgrSlq5EtONEkv+6m4vllgkiYV/BDNIH1ajnJtq7i4Jda6oOVFDgP++UBB9YX3WYI9Cx6O/3ROPhny+WEIxSx1E5BGgxInaB6fNIoH1Nde2Pkqt9FEm2yKfoGKhtBUwGN7gDd1mfMlVL/tkrmwqB0rCUnSudHOhxKKrXZmrDVXB2CSW3rLhNPMgtSIOXsOzIao84bXTf9V1U1NOT50qpOze6G08G6rqCa/2WwWqSelMrOXOger4LgxP/m6rDZPrp/tuyq6g17gTq992Z642NAop1+LrIWl0fhAkfX1QbGhQDyKMQCgYrGVrRe5+N43iwVCDb9w1fa5HikDZIgBhhyet8CyRW4EA7/RAHXm83Iv2ooFtUCxe4zj0ZO0UI+yMY4nGGfTQnVj5QuPEhrMkPbwH9RS+oSUayAWjpJdKzgz3E6xZeBQYDclY8C9cv0bxAYdjFKfneidK5iY187K9SlDt65dw/esXXgSGsLZJDTJeqZA3TXI0oRwRCAWDdcfbMCkAk0Xq0U7k2O2NY/1VBMoagU6YXX8fM6TUrJCU27vJcWT0vO5KCH1TDPIKxeO1ssxujLQbS6z4L+ICLsWLNJmSWNQvvcsw1rarUKi0hJd401596DWcbFcFplTCjFUYNWoGiZ0DJRGLUtZNcch1SIaUKrHgQiMGIo3vE7WI/fcR1k38BhpUZ+mWQ2uW5OBM74ZFA5ZW9LA4CGT378vj2D6aKfLWt+kGT4dqkKsHlRSBskdgBGbo9YkzB2WCGM2HCDSvZfcMPZLTKje/c/WSpKWCSPttzCxXDzv2v8PmCFsJiasFXakeKzKDEtxZZOtdPcZVlwgo7OlvKuiYCloeTAs8yjvS+h+Q5SI9c6iYXPsBbPY+cMjNMpkraxEb0c+qyA09eNiWbSinB3lHwOvxnvcOrQ2ugYHvbRPSKSPhp2+Yu51hurAeKQJRRoDG5X5W8E2O8CRdDMY5q1jbI7BgwI9jsdwwiHkxWHQLEQZKvTwtXpe9xsQgxIhb50RcRABLeKdsx/R4G3++r5wayFb65dRewdOBO32HOVEyGybVqbEc06m2jSF0URCKtzk4SHEtm0cESspg3Q/mfmGDhLtDSyN8Th7npk0pAuFEoB+GRemVF1FyFVAz4dVkUfPr5kE14qzC4ko8xnvzMkDPecxx6mJdKFEcVaXLCFJZhkf0vb2KNeTHUt7j6bLCiejPC6IOp2yHdEqg/I7BvolY9VD4WuNNHhHyYMDhBTVUE4l3+FXKNxj+OO7jgqqWcRDjbfZ3L6e5BUOgZMq4r+aJvGBZnf0r+JGzhswp2Iy1YUWglAhQE3EoNj+fNlhkJ5DyRpcS8G81ES9s/LkdiEvjq7r9w7BVgY0KmYJkHfSi66kbXedQK2Cyi4F7qqXkmoANFq54vONZkoDNT8rXlW03UGe12BwxB8+EU8whtiXMxOTKp8xD3/sYgl/H8mBDlfKJFRVfT16MCm2wQkRUw1bBU3+yw+kNEkobJhoSuXzG/QzR9CM1lJIwWHVQZ9/0Jr6tGu6LzWFfuJsfdUmkoNXBKgIZCPCD80hsHh+eqVpf4fe71FGkf5KrnhFxYbDMyaU8j6fsiY5JJdFwnJ7UDWbrO4MBo6FxVvZSHtyszWovc1zF3qekel2vgvE8VHtwfIpF/xuGkGJ8mveDOstbjZik9HA1HrIBKV+rAFPtLLsTvdu8/AOOqfDFve6PPDH6eZ5ISq1ZoLA+eR5qzs19ju+tl/FMPGIbkYGdc26uaA2UhMF67FOR2UvSc/wSoXEue94I/DzIWeKdrqBHioADAlxZ3gxb6IjPcEquKMHyIi4yesmrUDTyk2veAXP0NcLMIIxKAEq5CGjWHc4fYaOFQLkmJSHZosPRxIr/wO54mZnssfd6gYZPTJiyG4PqKptb2XDg+mdgAhusIIQwNYZzUudK9NWVXP8tpFwo6xI6iPH8YjXbQoL5sXNjYclBSB43cvO/5VZP83JHYHmDC6fXvzHaegfuzvbGo4Sh9TrZ+/rNvdM8tlASBmtfSLaXQCo/fioeAQ1LxD+ZKcJt54GGm4Z+fl5EeQQi301NWjlMHpl3jMxau5H0rJ4rx/R4ULZuC87SJ723dFd5cfH+srK+jWze+ks5ott/pH2zQnmE9DmoCBTbGItsmrs/L0szi33RrR+zFLrOeQJbOD+as8KufuGf4f38TryUsfopR4o17y0xhDRhSJrE0juwmOpxHy163RBRkLL4mCaKpMK5LLkR989kfxUspRjWyMkrPIslVjwOzG9FJw03Z/UwqepyFVRRHSytpA8pxYoCgwVrtvSgbY/K5/6wnV5IE18Bf3Df+2kXThxmApeCfMNbYLQOH2ZEe6kuCRfjDzSvO8tfKwFLdQbn+ZvdsYLwaIMbped2k96DWuR3+Dj926sic/1+oJqVQ7J/d9lucs43N8p7y3aV2bV95KPlO8jZqXNnWxTr0P8z/2i5cPq1MmHJnvLp8m3lgR9PkNOm3imL1qt4z4pT5nHbFiLnbZ2ZGoLzHTCGrXyMg89xaNTEIt31USv8ReCFO7HgjzB4z5+xcCzeCsGbz4Kh90Xe8/d0mJlWw3k3Ft4SycQahGqBg8uV/8tqkG6hcZK1k+GW4h9p5oo91H6OtL859hVruSeWimL1UujJS05YHvdH6C9DwwBnQ47wx6dgRvRGY+aqv0U1yJB6/4Zw9Nf/Fnn16/Aqoi2sTfHh795W5KwRIjePFdl9Y/wXG+5zcqlvThM5/VGRGwHyTyuKP7Zcerxp1llSn2y67Pf6H34v65LVrk3PAUN2x5zTmpT5sban3D/3503SKzmhBl8uW+BPdwTs9y7eTuSx0SJDHSSfySXzSwMV7mvBe8YXvYZS+MAoR0rWfgafQKfA2eIneZ1evM0Yibf/hXubprGnY6mSPgYdRxUkg84w6386C8bxE4JUS5dFfDw3n1qJVS+ky1qOkqvfAOO82pKSPozFW2KBw17phNAe8cvGjbwYMLe6mucXgfXQZj30kciZj4nQbMgkOh+//EDwAkeJXHUwvNtY5AyLV4n83+vgIyDInjTXrBGefSiEa707iJw/UuQomFo89KHIBzMMgOrx4UBx4BtgtvbdTGQs8sOud128vrPMq+1he4UXr++UUhue0PNe23wm3jf3ZFvmjHkTVwKAElOr+GqpitU7jrGYw7tzLzhCB5PuSYvwz5uFz5xiUzd0eBA2P89niLwlv7xHsWfr3V/dXEn8dKYkq7eFiu8w2OjsDLWh+weHd6OAtx0+PFaDsYBtkD2V/ws0ufJJqAW/tJ++j1RP31V1CxxaAbb1i7EqtpVtfgwBo8MeGsa6kMB2Er7+wPY1C5marIeou242urC7v/GB37w//l9QF0WAaMROn5hWrVUzTOEwqAHHbYuFsw3yii17idxwpAhtsh4Ar7BopTG57xfiI/tpg0c4jhqDkFAoGCwTi/6dRC7aT+Rb/JcJnhn8mXZaz+PZMR7vyDGbgxHbRqRdjVkrXPsVde5v/HvBQPWtmSkjOkIHmkHPLjhExi8elZGaPl26HpxoialFvFY2bfW1TFk1tMQj8ce3yKrlUn/vZViNBplyMakNOjsCW3MfndIWebyPcmVSJFn7CdwxgJuE+ihWvQWenpulpCexZn2wQgE2VgFfCjSIj7c/Ceqxix0QwgPElRqe3q5lipeZTKyF7dIHqVWUsRZDgREeeh6URODn7CmO2IM0EnQhLlJY+27TAjB2F5eVbLFqPKzpTDZEzjqbTsKOQUmX4mo99xLpssU4YoSExKJrfERBgFNS2CrGO5wB7VA4pbSZRuwmfkN7woxoD5it2mgk+L269ybwPDBQ5H+fY5uIW9N8vPv5mDU7KcI+VAyWOV8Ger7sAPhYnCfyIBityRBAkNbhRfTsF9C4bBxeBssYqfvvld9dKq91GClDWk+RajAsq+pbw9ZqO/kchvFRoNP73ihnfn2z1CVDefvgs2auJGdOleS38Kn08cv4gl5eXFgJy+HY3Hnt9Jgm4XBZ+rRijuB/KhUHkP6vrJNOvbTBaNElQYshUDPt4enTJ9YST2P6b0qssLbUcNyo9ab5dHuQbPgUbppb1JTk+tlSv+AcSCYaHnroPdbuJKnqcIr7OKooLs2OYjXbe+Ibb3u41K/GR2HdTEsnYGw7nIaXdwtLWuPDlOdxBI5OLv9X44wwnbkFkeY4fbjFKOZ0Ektu8sFccUSIkYnVtkkwuLF244o5RF992Rmx0xfmiTuJjB7i3QRD6h0N6dZ3kF69/71R3o4h826pcCVC+oY0JjwUmrYL9oUh28PQADQsXDloSxEyYFGmBFatvL1099QWxXkMbT1Zbh/yS6E07ptVm8raRDBxYhISh5V1FPHknxIPXi2J95/Pf8NBWsTHgdhrie1baXg42GdWYCpD7KxDEGWovFLqpaW34EV+KvinoxzB4Bd6rHorvHjeaVqGIWPciGpKmCOEgRKLr2vEXHFMyeX3SaJ5f4m3Huk4xHjr/aV+xaMs7VjGKcOP76tYVUesBL0dL+yncF0mp6RS8VYjoOaFhMqDaDxfH2YGy8ubb4gYrCSYQbopCUKJ1S9LPGQM1t3viTwF6ZOV9hwscvIuIozqEoRmWRYF9e0YpGbhy4aaweL073w7zVzR2I3+L5RKj8CgltPkykF/yHogS+s6ysuLRsvdc38l6xLOX8CBOyi2KjBzgBCkyKaZiR7nsz3yKz0bjkATS/4Pqqi+Em+Jz1sHojrNlsGirYobxfFgkbluJYqSl8Q8k1iZZ0cJeEWPkaFxiJlHn1SxViPx8n3FrrpzWqwVNLW8ab0pBpxi7Y/3LphRIta8b8r7fC42YhlN5ve0Hgy9G6XuD7cCRcyj77fk2mAdhiXWpmXU1EaZxPc61YFb9zFT/O/ptHxeg4IiDvVgH2isw0ThVMw2IPQxpNETvk3DxYtAsaBS9BHo0GyJjO3+iFzU//LoT8acAU1lnN//Zqmmey8ToaY1KjIl4SUFcfDHlEzACNuFvIJBu1TNbxZsa2CsZN8mVIbJVS/Z5zWkxtufgqNg9mQppi0PCw1cB4ZMNxcQXnULnk8jfTfyilXoVlfzbBFobfmmHg1z3myYKzZMlw5cDEfqDkatebDb36hYwN/QMlhrYLTGVQUm7QOpQLYXwWxD9+FDYI+Ob6SM5sM3soAj6o3yWKCRFYXMMDOrORSjkleYHCdJA8POuBGN67OhFltAdfk7iXe+BPvf4Ok+IJtWfNdJLL8fjkQdGDC0knLC2uZA3+2xYLEYn1jrvdGbnxUfgYafp8LrXX20pRZfZNMTbAJjbX8GX20XYvs9FhKMQSv6ZyeUrSwM1qrabMA16oRZPcgRhpbB+tcHIgsa7E6pk6VuVqk8Edi09dRoT6w9hk+j9my/njpHe/qhGT0cbdpSPaxgXShWDcPOgBRruRcWx90G25axYFJGY38MzuGtHgbjBSMEwU6uetm1+ThdVrgYnTeqXNVDBN7Yi0Ep9aKPmJTFGIttH3XO9wjD/qRWQtpWdEiE6rWq280Iyny6xNvsj+1gqep8EZjxP6NCtg8Kh74imGxlsEz76mymMcsifAybgTvnE0oGa+p8wy2DCfivdhPh6oIw0Ir6tq7D8Mp3reyRuSbREv6n3HWkufafa32PKdhm2zlltS0YxkTel0diw0dA1rRx1jXzU9HyNZmfBgvTSqwFdbAu5MBIMRZiKni0Q1X645J4AOvY5hunpFapeImWNmPxGkgqLkJK4aQUVJO6SrGadZFYmyMso3I+pHF75hycS+ee48eYPvdesmvBy82FIX3y33a8y6Xgcwc1qRBvvU/Klq5JRoUlNGKwoK3KlmZazCv7dcq2lcLVCx2DRaO1m96AHV/DYpgdNoK/i6b3aeEQ8Wh5yir3h7xXvkfzrtl0i/DN6k1cy+Ta/5ce83PtPMvMKSvdMc2y2cJX47/nEGy5SqBggyDufHPh5kLmCoKMghNXYjXrB94jW06UPn0Ocx1m0uLaoFFBhuhxdEKKIcEGKd7pvEZVnE+qIIn4o6OD1BgYHGnh/h91bttHDsIOea0ii7c7DpNq5dmYp3NRzxaCFYjV7AhGNmRWyA1TYKQBN4rTuJ/3rw8iMxZvuatjyZhLnmOlMsuw2mCtVhVh8a7ufz6F0+0GrpRc7ml7FK9vPz3RNcFq+K2yI66Me3ge/ogFpNtnn4EV5fYi5m9XD5YXF43JqXeu6ltT7/1wzqkTS+VnFxws368trO2Kpbv8Ho5Ec/3z0CTfOXj3FJ1oErM/tmBeNgIOk05AfyVVfV6UZr0exv5ZMDMXwhxnYIB2WkDAdK7rS4tSneSadx3bTHgZiLfaE32cg/r2/61Uw2AO412vg2QCBqFuZAZDdiuTQ15i2X34AMWXqAPFqtpDZfkzh9yGZNiPxZo7254Rz8Syf8Ed17FSN2u09zbnCKlf9BdJeRd36JmBpD0dmjrULXSyEfLHQcWMzmP4QKjqdgOYrP6uQ+FKTtpbuVLQVYCujUUz0yrBWrUuuznQuN30/M4we2FbQchZleq72RZRivset3xInIiXDgNDh4l+WtddfvnVvXJan1tkizaTpE3VSllW1x5OQreW22ednjou5HgnrdxKfjv1Vjm5152yCTyq11StlQXrusoHy3eSO+ecmnMIG4b54fxO7XOrbN76C2nbbEXep5NIxmVWbV+4adhPHps/Lu/tF6XBbdHL1nnsiQzWbGw/5LHNzKbISPXERokVN0iHhRKsAlKs7TgwWCds6IEvqljKJmV/uCRAAOE176ekS0mu5KIxOje8iKUKqq6qrimbphjsV2IOKwTNhpO1+DJzWS1If1rJ9j939RJPZ5qxmu3gqxTOGdd+CH9UP2Es4EKb9YLgbWfY0RyJoUFC5UKck3gZ47vU95XVIMVyY1aIu6z4LzDBMisb8pJeJZb8Hb5Xn7Sp6ZBUvwr2Yc9KPXyXVfW4FwyJ/asl5RML+IaO6PR21fOQkjqrV2PNekgVwpwlVz4tCTpdXfcdVC1rjHu1xca4rw/HRwD/yM5Exjix8jnnAhWSY2Wwlqw2gjq3DfihR+bKXEHYDZY71fa3XEkRDc2QqBG8+Q080xoWydBVPsPihJHm1vaSS6ZfVbKhUQ147rR/FKz/ObW9Szq/gk0sXw2TSRmRr8Ya2uE/kc92Pnu/bkjL945aCzKGRSS3QMwMk1PFUDk5Eu2rKNVxJfgPSiy7G0bHv3MtRu/xVb7VhY2bYoib+kXFeS5wvpSWOIVAiSE2YKzNQXBS+kDjQTacxSCxc6Jk3Y9gIp5yynZPB3NJQ3wy0XaUCigNhtXqqd6uXCnSEsvuAqajwMy3c+w+BoabTFjchRFzrIyMJJ3B0lFrhZOVwSKjdPz9cB/YXWR7fPTt0N8+RE4mZFb7q7A5GDXHGhobLHKiBJjOwujL4rfO/39z7LpXBEqDwH7othD/HDJZh2A7CltvbFGnWBtIjFoVfBbJlU+IODjotHaeXPE4JGYfWJPyepxYehsYh1kebdY553t5nLfWRMiaJKUoLhRzUsPGasBEdHSsmVw1Hnn85M2OvJydxqr4hZINuVhDJ13y/HaFMEuJxVe5ql/9NmVXLgnmM7H0Trusxmkurjigg21c1s+Z133lle+nj4BlrAwWqyZwu301T4TeA84AD/rLh0XueEdk4mz8pcAb2JFpSsS8sDJYoZFgNcMLi64Y9thYZAa0Bb072EGqaYpAiRHoj/67FngMA9A+t7XY8F+QT7B9hS1qhPh+yfVzUv6ZCjX0BOIYJhBKxx9BPbPwEol1v8nbjspfgxtKJVa/DakPVHJetO5brDjd1bZU0sUQ366CIcXCqjSHQL7JdVPsqoF3Wofg5wug7rS/kRlaJRdKrv0UfMAiMHGdmzRDaaPjYoQmpTMS1k2HveCwjETjNLkeeXkgRgJg1IB4x7OAK77280TJxGqpX3gFWvM2OHKbS9B7JDV8/g+h7k65m7CZj1t/NsXzktQWa15uPVrkwxkiH/0gQs8BprqPHczHuhTGHebWElr6bfoa0q3tIOFq36BKtDJYYXTRwHkU4juc7WZNg+FyZNRmWVfXiopAYREYVNjmG7XOBwm0KYL/RFSJIV7c3ArkMq/E6rck8dPvwTDU+m8miRfd/NNhQ/Om/zoeJRPL/w3G7UKPUkZ2YsVjtobgSUgREsvu8dXGhkJ1P4C5vHXDqfUguR4SrlWvWJMsx2A00Zed64qUfVDONmQwkF96u6W/9CHttKT+x3RCgCOq8OyM+5N181J2UQGaci1KRjmx8GI4H+UXTu7Ea1E/7xTY5n3jqzFKEJPrZzQpa9wj9zZJ95OQWGYvOUswdue60ny90Sj98K1FroHU/oETRc7dR2R3CFhag/myEp2Ovwtzt/97HYGg7xc5HwLrxz4V+XZBulRYGazQSLDSUOmRIhBiBHqEeGwhHBrVWAmsmop3OAOSLHyG5oGSiB1HqVUqEHQ27WE8iYUXSbLd8Vhtd3zWaswkHJsmFl8DVd1r/kcBo/P6eb+A4f/JkKINTRn0J9d/B4YHb4710/y301AyueIRLGxZDWensHmq6gRmE17Ja780GBwHA3dWTa56RhKwS6NLAcYxlHrYqK1+3bARCjyKphV4beqhcou15cKAnpCgzIc9OKR8ORi405VC/fzTcM2Ow73U35DE1X4B7O7C8eqmg8ghJbnmTfQ1Fy45LgA+2X/xJ1ZPkMSiKwOOb50xT94j1eBAsDAkpV6kPV2WzNCG6wFDfHr8T11vrLpNLn8oB5TyV5V+LhnsmRvVhV+CB/8Qki1Kt+YuTffDvK8h7eJmpT7OGm9rsaIfx/AVgyFXDu0O7lepPBB4cCQWwmH1iJUS910miY9fsSbl9/gUNIf3WFHpA/T2Zh56xBdisY3c06OGHysGK25zKN4XW0H90iyd5fMouR4Sm5XPgjmAFAQv77wQHIzSED8GBoX+sPwQJRvJVc9JYjkMReoznvR+GtAykUIg5XqB9wgWQPilZO0U3B9wCgumsuLoOucZN7s5OB5zYARPRovqRNppWVWJ7KlrG5G7j3Pus5Q5wZ9ypRyt9q0IlBqB0CnVSw2I3/5hewNJT0raAyeYDCkTo0NOSLVizSDZiuMpCePr1EY/UmSgsFFVQlsiw/1BcAmP5+gSS2Bz8zeRpbDLqt4O7hh2wZj6GfZDlAiRGISZaijYSCXXfobtfUgkAqgljVb0N6II0LFrPTb6wIq12hX3yTDj/ojj/ojDjxBdNUACSEkkPcKnmKq62RGdbfiG3bs9bLK3EjkUG31mfTLTYLi4X4m/YVgN3ImkMljhu590RIpAeSMAdQ5VMNxCQzT8XguVCTYlRcAWgTow+8uxSTjUarZjLPNEeoDnQjhu5srD2rrwTloZrPBeGx2ZIqAIKAKKgCKgCNggQJdOm2fr8cOmvUIkVZzCowoXRak8EOAfTEkRUAQUAUVAEQgjAhUnwerfTmQ6jOaUoo1AdRU8GJQijBINzmEqVFSaW9TetDNFQBFQBBSBPCBQcQzWYQNErp+YB+S0iZIicHB/rEovhQTr85JOWztXBBQBRUARiAgCFaciPAQM1ilwP0PP8UrRROBgXMNTcw9hF83J66gVAUVAEVAEIoFAxUmweFVO3FRk7MYi30FVuKY+EtdJBwkEmoMpHggVb9vmCocioAgoAoqAIhBuBCqSweIlaQkbns2L7TAy3PeCjk4RUAQUAUVAEVAE8oSAKsryBKQ2owgoAoqAIqAIKAKKgIlAxUqwTACisp+5ROQVxOT8bLbIgoYoIV0RJmabPgiOPUQkrMEuo4KvjlMRUAQUAUVAEcgnAspg5RPNArRVl0CcJTiXfuFLw3OttYuZi0W4PfOFyJjNRU5GlA813rcipMeKgCKgCCgCikBpEFAGqzS4++qVzNVlz4l8Pse9OEMGPDdZZDakXJceoEyWO1qaqwgoAoqAIqAIFB6B+Iq1he9Ee8gOAUquvJgra8ssyzpKioAioAgoAoqAIlBaBOKnPSIyC5IPvzR9ocijn/otreWyRYA2V1QLBiXWYV0lRUARUAQUAUVAESgdAvHlkGD96VmR+Q2G025D+fJHkYueFnnoQ5HHP3MrqXm5IkCDdqr+ghLrsK6SIqAIKAKKgCKgCJQOgZSbhkWrDCZr6RrngXw0E/Y9sAdavc4o8yRChqh60RmvXHO4WjBbyqVutn1qPUVAEVAEFIEKR8CFh6hEZOItGszcf4RXc0qyVjUwUFYw3pwmcvWLIuvqjNTOCLJ7zSHwqF3soLfWQZX5semKIZtp5lI3m/60jiKgCCgCioAiILMUAysC8Qv2RdDcBnejMxZh1drzIrUNjBQL0qbnhtdE6rGijdSzvci1h4r07Wic668ioAgoAoqAIqAIVDgCXDD3eoVjkDH9Ztv3EzlrhMFEJWG/M3UepFUviVwyRuSJiSIPwN7KpP6dRS4/UKRDSzNF94VCgE5E6eMqG2JdJUWgCQIU3y9tkqoJioAioAhkjwC1XnOxvYfNhy139h1Fr2ZKQbjnYMO26ra3jAl8BjHfGY8CM6gNTdqsB2yw9hdp3cJM0X0hEaCH9mwZLNZVUgSaIEAXHtyUFAFFQBFQBAqOwIZYhPQEfvwO6f6szNU2fUWugORKmas0PoU+YvibeCx4L6zDuhVLsSxAq1iwdOKKgCKgCBQHgVh8A7tRnA5D0EujGR+2tUgv2FhZiedUF1arz3crLAU/ZmxBMr1BiXUqOi5hVxXfBb1ntLwioAgoAgVHoBvskSqMNjBYNGy/4oXGakFiQUkWbbGUio8AYwsO6+2/X5ZlnUqm+DYjJFalXwOVfA/o3BUBRSB8CMR3GB2+QRV4RCkGi64ZLoGLBtpemWSVZNHQPRuv4mZbus8OAQZuZmzBA7ZwVxdSLcgylRCHcAoWYayodcGz5wCJ/+z3EmtR7VJIsxQBRUARUASKhUB8h/0kNvKYYnUXmn5iS1Ynk/R/RRcNJtEWi+pCSrRMpoumLefsLUKDeKXiI8DwN/TQTieipp8rrhakQTttripBLfgDVlX+8SmRn++MOW/mcQ2WLpDktxC9LlvoUbDMsuvrJTlrqsh6fDWR2nSQWBeINpvr6hQDEP1VBKKDwMMfw23S+qbjpWulmuaG6U4NBPY04UltlrQBXdw/zJu2WoCU6lYS6z9UpE9lMg6xXz2cTNLJKIlM1Km7pW1/qDakZIuuG0i8qBfuJ0LXDkqKQDER+AnLfy94UoRRB4Zj0cWfIdlTUgQUAUWgnBG4EKHpJs81ZvgrvJt3GiDSDsJ500F4Oc+9HObWzGSuyDzRH5ZVQkWOmK4ZKDWghIvORq99Gc5I8XLbvGc5TF/nEAUEGC+TYZrIXJEm4YGzEmrCNqoFNADRX0UggggcfHvug3761NzbCHML/TqlGaz19SJdWod5tDq2TATAVhncMCVTVubKLEjXDHQuSg/uJIbLoepweoVpXozZ62+xEViL+43RBeYsTfdchwfNBzPS53qkCCgCikA5IrBRx/SsaCKhFC0E4q3AQFEi5ab2o+d2+sFiDEISAz5/PNM41l9FoFAIUGJ6zUsi035q2sPb05umaYoioAgoAuWEACVYJmXreNqsr/viIxC/6mB/6r5uMKimJKtdjcgJO4qMG178wWqPlYXAPxDXylxkwZmP2zY9/0lz7AOTp0vokSKgCCgC0UZgIwuDNQsLnRDNTilCCDQbhJUGfokBnm87WqQtmCwlRaCQCNz1rsib09I9HIeVrWPB1HMV5TfzsUgOasIPZ4iM2CRdphyOdLVoOVxFnYMikB8EaGfaCZqjxbA/5aKzecthrtMuP21rK4VHAGbswUiZq2B4aengCDz+mcjTk9L16OOLzBVp14EGg8Xjd6AmLBcGqw7q0LvBVNLfXCLjM5WqAW7PfGGs8KUzWfpIU1IEFIHyR4AueMhgkfgcUAbLwCIKv/qYjsJVqqAxjv9a5F8fpCe8+8YiXJ5s0i5gsEyiNGuNjY8YMz8qezJXlz0n8tzkpsyVdQ5kvFiGZVlHSRFQBMofAauaUO2wonW9lcGK1vUq69F++IPILW+mpzisj8jZe8M/WzpJusMWcOOuRgLVhB/MsGRG9JCSq89hU+aXWJZ1lBQBRaD8EbAauutKwmhdb2WwonW9yna0X80T+esrhq81TnIQmKgLR9urwnYdlIbh3e/Sx1E8os1VNmGoWId1lRQBRaC8EbBKsJTBita1VgYrWterLEdLRoG+1WjESWIcTHpqb9ncOM/8pR2WSZ8ifmaU1YQMf5Rpc2XOzW3POqyrpAgoAuWJAM0Alq7BykGLTeacZemP0PKcdXnNKrCRe3lNX2dTagQWrDS8tNMzO6ljK9gYwR1Ie5eVqj3aiQzE6tfvFhqObz+CanEP2GpFkWhHli3lUjfbPrWeIqAIZI/AktUilEIxYP1yME/cr0CkCkar4D6V3nBMf5OZRCfLc8FkcUW/UvgRUAYr/NeobEfIB8qlzyIEDpgskun0lnZWXkQ1IRksEtWEUWWwzMDdxkyC/eZSN1hPWloRUATygQD99/3t1dxaIoOmDFZuGBartjJYxUJa+2mEANWBl70gMrshBE7zKpGL9xPp37lRMccTqgkfaFht+MlMQ73I2JlKioAioAiEFQGrPZXXGBkfuC38YNE1Ejc6+U5tiKyiFA0E9JUUjetUVqM0Q+DQYSgpjmWC540U2aKXce7nl3ZaA8CMfb/IYK6oJtzNYvzup40wlOkKaV22S69ZV0kRUASig0AfqPbIOPEZSDpsayOAs8lAkaFqBwaKe0r0laKNgDJY0b5+kRw9Q+DQON2kfTYVGd7XPPO/3wUMFRks0jtQE0aRwdoGriiyZbBYV0kRUASigwAdBPfEx+FsLOwh0bQhSDQVo5b+RgUBXG4lRaB4CNB/kzUEDnt+ZarI0feInPkY/GBNMM5nwM7Aa3WddTUhg4+va1iFWLzZ5N7TqCGGBC9oS5T6sa6SIqAIRAsBemY3Sd0umEiU514lWOV5XUM5K7pj+HaBSDXcL9RmeGCnyJzSKG4vTTGGX4NydCo6uJvIptg2wdalTXpqfTqI0KaBDym2RybL6uk9XTK8R3zYjtnc8NAeZJSsY31QB6mrZRUBRaB0CPCZZfrvy1Z6XbrRa89BEFAGKwhaWjYnBMgQXHOIIZnig+Xrn0SmYfsatlg0djftEsxO1oJpmjzX2Mw0unEgo5XauotsDTWZ+RVINWHUGCzOi7EFqTLw6819WG+jjomJ7hWBKCLw9KlRHHXuY7YaupvPrtxb1RbCiEAsCQrjwHRMlYXAWqj3pkO69U0Dw0XGiz6yghAdkz5wkkgLrEiMGrkFezbnQrUgJVca7NlERPeKQPQQmIOPydMeMcbdFRL5u4+L3hx0xP4QUAbLH05aqgQI0CkfGa6UlAt7qhdXNTgkdRoOw+vsNMApN/zpVKPSQzudiJp+rrhakAbttLlStWD4r6GOUBFwQ4C2pUfdJcJYqqRHT3aOWmGU0N+oIqAMVlSvXIWOm6pEMl2pDapFGsPTu7FJew4WOXcf80z3ioAioAiEDwEu6DFXQP/1MNiYwtyhHIjMIxcy0X62UyuRzq3TWwecUwpfSaQ2WJV0tctgrjRs57b3JsZk+BVIj+4m00VbJqrbuBxaSRFQBBSBMCLQD4buJoNFO6xyYbAe+VjkmS/sEaf/rw4twXg1MF3mnkxYz3YiQ3rY14tyqjJYUb56OnahB3g+nMrlAaWXVBFQBMofgXI0dOdH7mOfOV87LmJatMrYpmUUo2Trn8eI+AmTllE11Kf6nR/qy6ODUwQUgUIisA4S0MWw9aPUU0kRKBYClGCZVA6uGuiD8IbXmq4EN+fotadq8YUvvUpFL7/iJVg/rRCZClsePmRJ1BtvBolINxgWKykCikD5IfDjcpHxcG77wYy0F/0YvqC5gIDRAA7aUsOUlN9VL/yMyKQzgP0KLMRZvqZhz/OGbbm5R/5iSHJM4sKWqNM974nMhX1sLkSH08duLymtRC7thKluxTJY73+P1RufGq4B7C7IoK4i44ZHe0Wa3bw0TRGoRASonnh/hsiLU0QmzRHJdE7Dc9rCcHtmMmJjYqEEfawpKQJ+EMDtI0fe6R19wq4trpYmE8Z4hFEkhj17Pg/SJ2Iw4VsRhk4rF6o4FeEaOK+84gWRq19yZq54cemTiWVYlnWUFAFFILoIXPCUyLUvw5nr7KbMVbuMFxulD5c9L8IA4kqKgB8EuDiuTbWfko3LUHLKevMgVY0irYQ07sY38jfy5/BxU05UURIsMkoXPIml/QjHYlI1EKBn7N5YmUaiEzh61K6FTpnEhyzrXHuo+ioxENFfRSB6COy4EVaawhSAxNVM2/YT2XeIyNAexguOap0PZ4hQ1cEvaUq8/vaqyK3jjFVPqYr6owi4IMAoE7y3KIlqC6apHVbMpfY8b9jIzFvTyFxF2XXB05Maqztd4PGVRV+HNJZnpI5yoIryg0VplPWrlPYWp+1u3PzWi8kH7G1vibw9PZ26PR7Ql4xJn+uRIqAIRAcBqmH4oUT1w6jNnJkmljvnv8ZKJ86OnvP5jFBSBBSBpggsw7vyt4+KLIXUN180Ai54zt47X62Vtp2KURHS5srKXJ2+h8jvRzVlrng5+LXBPJYxiXXZhpIioAhEDwFKF+7AMvBx2zozV5wVy51m+d+/Y/nIit6sdcSKQGERaI935Zkj8tsHBRur1+W3zVK1VjEMFg3aTaLkavRQ88x5zzIsa5K1DTNN94qAIlBeCOwAaTVjxJG48ouG70qKgCJgjwDV7QdsYZ+XTeoxWEnYqkU2NcNXpyIYLLpioNE6iTZXQUT+LMs6JLbBtpQUAUWgvBEwbTI5SxryKikCioAzAj/fGW5OOjnn+8mh/dpv9xI5Yms/paNRpiIYLPq5MokG7UGWw7Is65hkbctM070ioAiUFwL1yfR8omyEnJ6FHikChUOgRZURA5aRNbIh1qNZDu0jy4kqgsEynYjywlm/TP1eSGsda1t+62s5RUARiBYC9Ext0vqEeaR7RUARcEJgQGeR43d0ynVOpzrw0gNEdh7gXCaqORXBYOV6cSwfs7k2pfUVAUUgAggwEK1JP1jcuphpulcEFIGmCBy6FTQ+ARz00pXFlQeJbNWraVvlkFIRDBbD35hEP1dByRoCwNpW0Ha0vCKgCEQDAevX9BOf/397ZwImRXXt8aPIJrKI7IsOyCIKIi4IIogKKoKAoqJi/NTo+0RNfCrBJIq7iRC393BL3OJL1A8Td1AQVBbFDUFEcUEIsimyuAECgrzz58617vR0z1R3T1fX8j/fN13V1ffeqvpV99Spc849RwTpG1IFhWsnamLEu2eI3PmqyJM6kWatbqOQQJIJXK6zCv2E4TSua/JLtmscX1qJSDSK2oJWkEQ0m7IEaIs+Vtyx7DYuSYAE4kWgTzuRx981GbbXbtD4EM2hdVo3kQOam5mFr3wq8tpnIj9tL3veT8wR6dVW5GJN9RCXmVBlz5DvSKBiArD+XnqUyJ+nZG7XWut+3jhIZC/HUpy5dXQ/SUyi0cs1eaCdSYjUCwio8yPjpnoJR1Gf8M5hfnqxDQmQQNQJvL9C5JbJXlWHbM6nUzNzA7EzkLPpy7YkEAcC46eLoIBzqrTXLO3XD1Qrl2axj7skwkWIi4jCzVaQyGzKQvsu8xJt3Gzu7hiZe/ETEiCBOBBAseebND6kohpzsGhf0MtYrI5Qy5WdcfjxVyJ3vRYHCjwHEsiNwIVHirSoX7YvflO3DE6GcoUzT4wFCyfLUjmgQCEBEsiGAOoUTtaHrXnLtfC7ZpiuroEVbXXG1AkHiJSk5P6ZpQ9vt08T+VlnxkDZemCEl7Q0m32yLQnEgcCir417HbU9e6nn6MpjRXZLjFknYQpWLsWe8SUv0X+mLPYch587z4EECk/ADSvAtHXEblFIIKkEdk7+0DhGlKDSZ45ESaIsWLiyULJu0ydMty5hRVccRZ5H9ROpXb2iVvyMBEiABAyBKR+L3KMzCyFDdNr6r48w63wlgSQSUGNu4hQre53V2J0sgaI0ZoAp3IzagjbwPZUCAtoRc9WjTeonfE8CJEACmQm4LpCtKbMMM/fiJyQQTwJJs1q5VzFxCpY9eShO+ENtQZS/sRnakecKgatNNEcHhQRIgASyJeCmbtisFnMKCZBAMgkkVsGylxuKFJUpS4NLEiCBfAm4WeCXrs93NPYnARKIKoHEK1hRvXA8bhIggXAS6KJlP5DaYYPOPvzPWhEkJT22Y9lj3aazqmYsEpmzTASVIraoK7GRJl3srH37thdpVq9se74jARKIHoHEBblH7xLxiEmABKJGABnd8QdBuoZBXUR6txOpWU1krqZ7QIkdZIhPJ9V0Gjvan6szELFOIQESiCYBKljRvG48ahIggRAT2KT5sq6dJPKZxnfmKl1bilynGa/doPlcx2I/EiCB4AlQwQqeOfdIAiSQAAJbtpl6bLBYpRPUYTtGXYeHl5hp7Ku+M5atTx2lDMlML+6drje3kQAJhJ0AFaywXyEeHwmQQKQJvL3UlNxaqbFW1dVFWL+2KlYdRLqXeKV13BN8+E2RZ+ebLbuoe/He4SItG7gtuE4CJBAFAlSwonCVeIwkQAKJIoAi01DMIAPUijWSViwDg68kECECDKGM0MXioZIACSSDwCkHeef5iRaOppAACUSPANM0RO+a8YhJgARiTgCVJOAe3KF1RlaoazHK5UYQW9aifswvGE8vMQSWfSMy9WMt/r5CZI0mKoc01nya3VqJ9O8ksveeZhteqWB5LLhGAiRAAqEgUENjtWrqf2dkgkdmeATM14rgf+un3hf55zsio/uL9NTKGX7kB80fhhxhgzr7ac02JBAMAeSue2i2yEsfifyMJx5HlmlCYfy9sMC49FF/FLN/6SJ0IHGVBEiABMJCAAqWla2qYEVNkOvr0bdEtuuN6bZpIh99WfkZrNHcYFc9K/K310WgnFFIIAwEoFzdoGlXJul3OlW5co8Pn6EN2qIPFSyXDtdJgARIICQEXAULFqyoyVGakb5VqbsEVribNXD/C33KzyQoKzT6GXWJqgsGAssX3IsUEig2AViu5q/0fxRoiz5UsPwzY0sSIAESCIxADceCFUUFq25NfZLXRKnI9wXZqK6/6/XJHlaqVIF16w/PiazbaD5BOgu4FRm7lUqK74MmgJgruAWzFfShgpUtNbYnARIggQAIIGbpOA2aRdmc3asHsMMC7KLxHiYbfR1VtiBQoK6bJII4Kytv/kez3k80Chi2oe2Ng/zHbNlxuCSBQhBAQHtFbsFM+0Qf5sHKRIfbSYAESIAEqoQALFRQouAqhOzXVF2GJ4lM00LYiLeyNzBYu65Xq9c+DU07vpJAsQlc+qQJYM/lOKhg5UKNfUiABEiABLIiAEvV2Jc9ZQruPzfGCvFaN6py1UitXhQSCAuB4Q+J/KizeXMRughzocY+gRDYqAVzMRODQgIkEH0CcHn+15HeebjKFSxaY4dSufLocC0OBKhgxeEqxvQc7p8lAvPsB6tieoIROK3H3hV5Sy0PFBKoCgL9OpYPXG9Rz7gLERRPIYGwEUAS0VyFClau5NivoATeX2GSDa76VmTMC+oDL526XdCdcvByBJYr9z9NEblVXTvfbCr3MTeQgG8CCGy/RuOwXMsVOq/63sRi+R6IDUkgQALI0J6rUMHKlRz7ZU3Ar5KEQNj71HplBfl03PIDdjuXhSdgYw9mLxG5ZIKWiPik8PvkHuJHYK2mZkACUbeuopuCAYHu+I5RSCBsBFD+ZlctW5WtoA8VrGypsX1OBODm+426++54VeS7zRUPMeE9kS9LEwzuoW4DlB2gFIcA4uCsbFALxPjpaoVQi+KXanWgkIAfAkgu+rtnvASiuPFc1Fvkf0/T2YTNzAiYRXj7K/6yvfvZJ9uQQFURwMP9gAOyHw19qGBlz409siSAQPV7Z5rCtdM/Exn5RGZLCFxST8/3dnBeT5H6tbz3XAuWwCZHwbJ7/kCzFP9WleVn9DrZ6fX2My5JwCWA9Ay/f658AtET9eaDRKpjBpTP9o6M7hQSCBMBPOR3ben/iNAWfahg+WfGljkSQBbq9o29ztYSgn+8UKhcuUcVsW3qIoTs31yrk+9n1vlaHALpFCwcCa7pI2+KXPm0yJJ1xTk27jXcBDIlED2irXfcCGxHagY32zvquKXL9u714hoJBEsAhZuv0+/pQC1AXpG7EJ+hDdqiD/NgBXudEr03BK4jtsq6/wBjNy2JccpBIsMPFnlNrVt3zzCIsP1/ThVpvWeikRX95E9/SGRzJTlgquk/kpO7ipx5qAhKnFBIAIHsiNlDoWcIFCjcdEoyJBCFGxEPXCinA2nVQNM2nCzCmYWGB1/DQwCxxMjuPk/vZ2t+MMeFmYYIhke8lhsvTAUr4OsGd5nNZlw7ouUv8kGGc0eMFdyA1lKF8ZrW09isH72b+emHiJx9WD57Yt98CcD9N/Sv/kdpoTfFS/uIdG7hvw9bxpfAU++LPPqWUZZu0NI3KJtTkaRme0fOrEFqDaCQQFQJUMEK4Mphivt7y0S2qnKxQ29aVmCl6dBEpE87U3MMJsWkCFyDcAcu1BiNVGmiTwP3nUFrSCqXoN/DlXvWI9ntdRc1kaN+3nk9tH5ejez6snX8CEz8UASzgP1aouBWHDdVH666iwxTyzaFBKJMgApWAFcPeYQqS9bYTC04Vx0nsm+jAA4oRLt4WU2tD872LFc4tFpq2buwV3zirwbfnz/w5y/Kf4xsR/hazd8XPJZtL9O+obqELlILRI82ufUPay9Y9R6fI3Jwa40RLJ0BF9Zjjepxwb3opnCI6nnwuEkgQTaT4l1sNy4F63iyr6kzaFz5Sqe9//5Zkc++drfGf/3oDiL1UmYJIuZn/HQTk5EaBB9/IuE5w0wB7n6OcP1GL0Hpt+r6jYOs10SrSFHxpLq48XulFIYAlavCcOWowRNIuc0HfwBJ2ONlfUUuO9q4vNSD8ousVgvBG4tFntB/2FtUqcDMLFi74B5LSnzWhLkisJRAYLmqX1tkdenNC+7Dy/7tBcG7iqrpwddCEtik38l8ZcEqEbh9Buyf70jF7T93ucidr5o4QRyJ/Y4W96i4dxIggTAToAUrgKuDfC811HLlKlfYbVONNcIMuruGefEqePJ/RoNDkyA7c1455wq34L3DRRDgjvg0CALhYTFATULMQqQER8BNMprtXuvo9PuzdJLCgyOirVzBJfh/b4vc8KKnXIEFHo4oJEACJFARASpYFdEJ6LOWDUzMkd3dq5quIAmSLucVrFSYPYgUDciDZQWpHa6daLI953Pjt+NxWTmBH7dW3ia1Bdzfw1VBhmJ1hi6jbIldpw87f3xe5N/zyk5OwTnTgpV65fmeBEgglQAVrFQiRXrfu51ntYHLDJasOAtq2tkZhLBWXaLT+11B/qtbh2h5nb4iKJdjZdGa8vFr9jMuq5ZANoos3LundhN5QBWrEaog11FFK8oyZ5m6p//lfUdxLvs19c7IurW9LVwjARIggbIEGINVlkfR3sGFiARlS9aaQ0BALWZixVFQixBZwK3ATZopoSgyuXcvEXlotsiMRSIXqyKWpHQWllExln6C3DFZAzW3hqlyFYeSRtYliDJANqUKEqkibcCQA1WJfMCUB4J1C0k08RmFBEiABNIRoIKVjkqRtm3WIHcrrtXGbovLEsoScixBmtc3WdzNu/SvuHFfcYyxkLhZctO35taqIlCRggVX7gkauA6r1Z67V9UeizvO2g0mB9Mnq73jQHLMUf1EOpWmZEBGcpRxgSKGJdKrUEiABEggHQEqWOmoFGEbpn3bEjK4ednaXEU4lILuEmUGUPDZysje/hOKUrmy1IJZpnMRwp0Lq+LpB8frO/rOFzrZRGcJWsUfhLvvo25CVezdJJmoOGDr5CHQnQpWMN9F7oUEokiAClZIrhoSblqXBFxicU1JACXp5sE6W3CmKQB9UKuQXAAeRjkCbpA7XGHHdjQB7JWVPCk3UIg3wM33d50l+Jy6BK1AiTxHXYJDu9ot3hJVBqwwDsuS4JIESCAdASpY6agUYRvii6wcozeyOMuBLbSo8+km71eczzPq5wYLFhQrlDrBjMC4WWugII2bpsl9HZcgFKjf9Rfp2CT91UNqFSucSWhJcBklAurdFqTIyccjYEudXXNC2UlIUeIQxLFSwQqCciX7wI3Muh0QNHxQy0o6xOBjBKrvFvGZZjG4DBWeQlf9Hp7fM55lS5D8dPz0si5BlPVBQuCKZkC6Fizmwqrw68MPQ0gAcb5/mSqCwtq3DhUpaZj9QaKUESoafLNJ5M8vi9w4kJM9MlHU2xyl2AS2qZviF9FspHF1D/5yjlyJBIGTusRPucJv7YE39MagFRNsvBV+bxf00pxXx1esXOGiuVY8KliR+BrzIB0Cd7wi8q7GG2ICy00viWRbxgqxwleXKlcYdsFKEeQzpKQnQAUrPZdAt2KWHBI0QlAy5/M1Zp2vJEACVUcAN4fRz4i8sMAbEwrTWH2SH6zKpB8pY8HS8SgkECUCv9LYQlRZgKxRF/nNk0W2arUMPwKXOpSrdTp71pVpmtPwqffdLVy3BCKpYCGPEvLQ/KBT/RGkGgfp0847i/tmeU/X3laukQAJ5ErgjSUi/611Ld2Hl646weKuU0XaNfY/Kmb32txXePr/yefNyf8e2JIECkcA+Qav0hhD+x1G/CFmz1Yma/V+C7cglDJIzeoih+xt1vGKclJwu1PKEqh2vUrZTeF/d88MLaXymsjTqjXjC7NPDn7ksJ3lvo1EXlxoFEZkcZ+1WAT+csRmfaj+8neWliYhVRdiI83NQ4kOgSfm5H+sZx6a/xhJHeEDdWOM07iTzWoddgV5rxBPgjxermXKbZO6vov+/l791HsAOrqDSD21QFNIICoEYLWtX1tkjroKIUidA0PFgS3N+9RXJL2++nlNI1RqsUVt3TEDTA68hV+J2Nm07y4TObh1fBNkp3Lx8z6SCtb0RSIrvjWnh39wrRqIK7n8AAAOCUlEQVT4OdVwt6mtLkI8Hb+33CQxROA7bgx4KnhPv7gISpy3QgQlZt7SbR2bxifBY7ivTP5HRwUrf4b5jIDcVcg2D0UICpXN74W0KJgN9YoqTPid4akeD2z26T7TPvGwY+OvDtvHJMvN1JbbSSCMBNqr1Ra/g0/VggXB/QWKV5u9zHv7Cist3IIrS++3iFe8+gSRbmr93VUfNg4v0fvRUvUmqVcJShqULJR9syEvdpykLnfZoRK1k79+kshcVUQgNwwyF9u8i/7rh6s0JkSftr/TL3ZFAj/6dSeWrY9WUXt+RgIkYB5eEOQ7cYHIfH2ASRVUUEAi1RM7i7gpGdx2d88QQd46yMg+qrxpRnsKCUSNAKoR3DLZBL3j2KE83XSSyP7NzJlAaUKx8y/Wm/fID/eH40TwUOEKEmSP0thGtIe0VW8MZijWUktX0iWSFqyXP/HMksd38m/ej8LFhqti8IHGQoV/9njS6NxCpIuab/GEsUrNtHhSQOzH6+pGhAWPTwtRuLI8xjAQgIsPFm/kmjtyX3NEsIbbmbwI+EWpnEkfmniterXLzhxEj6V6w4F1GYLwBCbLNSz4Gi0C+C10LzEeEliqoHDBOntEW3Me10zU7/o6sw6r7uj+xmJltnivddUyjELoMz43YyB9A5QyWLJ0F4mWSFqwrnxaZNHX5rrdMSy7INWoX224JsaoyRYzoiCoB4cCyBQSIIHcCGDK+jR1E774kT7AlLpC3JGgkMGihUz2taubouO3v2JaQEnDjYdCAlElgFhE3FOhGEHwfa+l33M7IQTK1ZXHeg8kplX5V7jaERttZUhXkV/3tO+SuVR00ZOtGvxtBQF3SRK4LS7q7Z0xZ254LLhGArkQgAUYaRruP0Pk+oEih6oLBE/3VmDh+tvrIuf9Q+SvunSntdtYLNuWSxKIGgFMmkJGdiS5huD7bpUrxFkh+a619poW6V/xAILi71ZQfmrKQvsumctIqifuP7ga1ZJ34TBTA9NkkTOrslit5NHhGZNA7gTw28IfZky9qG5CWLY2bjHjwdIF16ErVLBcGlyPKoH2TTSNyTFmtq2NysZDxqV9Rfq2939W5xxuJpLMXmL6PPKWSC+18iLcJYlCC1YEr7q6ysW9cK5FL4Knw0MmgdARaF5P3RtHaCHoXxkXfKZUMN9r7ArSqVBIIOoEerUVObu7dxYje4v0U6tUtnKFKmpQ2BrqrPibT0qucgVuobJgIXgbCQFhqoTrD9Ypd91uc/PZJNGCtfBLkR/VegVpXt+wMu/4SgIkUJUE8P8HcY74W6AzfCeqBeudpWaiid0P8gDlUzjXjsMlCRSbwGnq4kMc4r46uQrf+VwE92m4HLerJaCRKllJFkURHoEJ/rZp2R3PhY+b6aBW+cJyp1KmypldR50xlKOJi0x2/Np46qCQAAkUnkCXFjqbV/8QFIyAeMxmhgVrtboTqWAVnj/3EAwBxFzlK0jeSwmZBWvL9uwvCeIjbIxEpt7n9sj0STS32xxgOPoebaJ5DjxqEogqAQQFI9YE2fVn6tT0yhKTRvU8edwkQAL5EQiVBQuJzo7SgLotGtOAuCIEs7vr2IZ4h8oUqlQksGTFReAatAndcF4d1NdNIQESCJ4A/l9h5hSFBEiABNIRCJXqATce8m1UJBvUYnXWI6ZFHZ1e/cAIo4zB+oXkm1DCdiplzvruOuMuLrKbRrdjdgdmeuxUQvV846RAxuU68TxIgARIgASSTSBUCpafSwGlwgqSoe2c/pmgKaB4aka8hy1fgNqEAzUJIoUESIAEkkoAEw2QgR+FiSENNQYI2cX9FvE2vfhKAlVLIHIKlhunlVTLzVDNkGsz5v79bZEG+s+Ewe5V+8PgaCRAAuEngML3E+aKLF6T/lgxG274wYxVTU+HWwtNIHKlcpZ9o8nPJhgsyE0z/vRCIwrf+KgZ9ZsnRZYrCysttLwBsryjQvo6neWEwpzN9P0he2vx2k4icKdSSIAESCAOBBCLihnnKNztR1CgeFQ/U+rIT3u2IYGqIBA5BQsp/K94ypw6kpndfkpVYIjeGOs3auXzyZmf3NwzqqMu1PN7qqK1n7uV6yRAAiQQPQJQrq561itEjDNAap6uLUVa6oMmZKXmcpq/0sTjmi0iJXuJjB1KJcvy4LLwBKLnInRisPCjSqogS+7YISKPqotw1uciqIaeSTDrcvx0EcQpjDgsUytuJwESIIHwE4Dlauk67zhRJw9Zx+um5DrEbOv7Zom8vti0RR/0HTPA68s1EigkgcipKEmvQ+h+GRCDdmEvU9IDlj1kwkeNQsw0RJHOecu1dtpHJjMv+k14zzzFMV7Lpch1EiCBqBBAzJXrFrykj8jx+6c/eihco/sby9Y9M00b9MUYzB+Ynhm3Vi0BvRVHS9xZhEkNck+9YlCmkA+rUzORtmoGxyzDVmoqP6mLyJ3DRDpr9mkrD88W2aaKGIUESIAEokYAAe1WYLnKpFzZNliiDdpaccew27gkgUIQiJyChRxXVpLsIrQMKlvWVosWTOK7lwa5r9EA+HkrKuvFz0mABEggXAQQ4mBnC+J/P9yCfgVt7f0CY2AsCgkUmkDkXIRwb3U7V4MXt4sgJxSlcgJQsjCT8Ln5pu2ClSKH6exCCgmQAAlEhQDyXFlBQHtqzJX9LN0SbdHnndJZhxiLObLSkeK2qiQQOQULdb/wY6lblRQSMFZHdSFaqSgg3rbhkgRIgATCRMAmEcUx2dmC2Rzfzj6lCpY7VjZjsC0JZEMgci7CbE6ObT0CbtzVz4zB8sBwjQRIIBEENH0ghQQCJUAFK1DcxdvZoq+9fSNBK4UESIAEokQA5W+sIM9VtrLK6eOOle04bE8CfglQwfJLKuLt3l7qnUAHrdFFIQESIIEoEUBtQStIIoo8V34FbdHHijuW3cYlCVQ1ASpYVU00hOMtXuvNmkFx7C5O2oYQHi4PiQRIgATKEUBQOmoLQjCbHElE/Qra2hnoGIMB7n7JsV0+BKhg5UMvIn3fXOIdaPcSk4TU28I1EiABEogGARRutoIM7VMW2neZl2hjs7mjlTtG5l78hATyJ0AFK3+GoR9htmYuttKzjV3jkgRIgASiRQAZ2FG42QoytI+bmt5dCLcgPrNZ3NEHfZnF3dLjstAEIlfsudBA4jg+yujMVisWSueMO5n5w+J4jXlOJJAUAiz2nJQrHf3zpIIV/WvIMyABEiCBRBGAkoXCzW5dwooAwHI1qp8Iki5TSCAoAlSwgiLN/ZAACZAACVQpARRuRm1BW0IndXAEtCPmim7BVDJ8HwQBKlhBUOY+SIAESCCEBDbrbLxakavnUR4kagui/I3N0I48V0jFwNmC5VlxS3AEqGAFx5p7IgESIIGiE0Dw9zUTRVZ/bwogP3pO0Q+JB0ACsSQQg2eXWF4XnhQJkAAJFIRAHc2Ft2y9yHYtmYVYpp+2c+JLQUBz0MQTYJqGxH8FCIAESCBJBHbdRaTxHuaMd+zwkhAniQHPlQSCIEAFKwjK3AcJkAAJhIhAU82KbmW1xi9RSIAEqp4AXYRVz5QjkgAJkECoCTStp4dXWpuPClaoL1ViDy4OExeoYCX268sTJwESSCqBMhYsDXankEBYCMQp9QYVrLB8q3gcJEACJBAQgZ0WrNJ9fUUFKyDq3E1FBPwmj0XOsz9NMWWPwp48lgpWRVecnwVGIA7m4MBgcUckkCeBVnt6AyxYJbJV82HV4N3Ag8K1QAnkUv4IWfyvelZk7NDwZujnTyrQrxF3lkogTubg1HPjexIIK4G2e4nspTMJ120whZInLxQZfGBYj5bHFXcCKHu0dJ13lkfuKzKyt0jdWt42rCGH232zRF5fbLajD/qOGVC2XVjeMdFoWK5Ewo7DrznYYmEtMUuCSxKoGgL/mifyj7fNWNV0Pvlv+4oc3aFqxuYoJOCXAB6y4fKzckkfkeP3t+/SL6foA8E9M73P/nh8OMshUcHyrhHXAiKQizkYh1aiT91hNgcHhI+7IYEqIYAEo3CxfK4xLVbaae2+Xmo9qK4K18atpvQMcmU1ry/SrZVI20a2JZckUDUELn/KqyUJy9Xo/v7GHTfVs2Sh5uSdw/z1C7IVFawgaXNfOwnc9JII/OdW/JqD0R6WrLCag+35cEkCUSGAh50bXhRZ+KW/I+7UTF03amEoaeivPVuRQEUEEHt7wWOmRU0NWHr47PJuwUz94S48/58iW7aZFg+OCF/tSSYazXT1uL0gBGAOdpUrmIPxxJLqa8fOsQ2foY0V9MUYFBIggfwJ1K4ucuNAkeM6icBNWJl8/JXIqKf1N7ysspb8nAQqJ4AC3Va6tkx/H7Cfpy5xf0AfK+5YdluxlwxyL/YVSNj+J8z1ThiWq8p87WiNNvNXeuZgjNGjjTcO10iABHIngNmDlx4lcuah5uFn2Tcim9Wy1XB3DYSvI7JJ15esFXlDA4t/3mFmHI59WeQOdcns7cxGzP0I2DOpBNZv8s68ZQNv3e/azj6l3hB3LL/9C92OClahCXP8XwjAHIwcJhCYgzFLxK+gLaxXMAdjDIzVxCn34XcctiMBEkhPAMrUCRUEF59xiMi1k8zMQ6R1uHemyK1D0o/FrSQQBAHV90MtPozCoT5+HlyECLgm3DiagyN0KXioJJA1gdZqrbruRA2Ar2a6Im5rsVq2KCSQKwFYSa2s/Nau+V+ucvq4Y/kfobAtqWAVli9Hdwi4JtyczcGl47ljObvgKgmQQAEJILi9W2tvB/NXeOtcI4FsCezX1OuBMBAErvsVtEUfK+5Ydluxl/8PydJQRfl8OswAAAAASUVORK5CYII=";

var img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAAsTAAALEwEAmpwYAAABWWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyI+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgpMwidZAAAKxklEQVR4Ae1cXWwcVxU+++f/dWK7TuzESVqj1nFSaAAlEmA10CoKpDwgtS8QqaCiiL4VeKGPVFQ8gKASlcIDT4iWAgLRF9RKVYqAKIKmpSSkSYjj1G7s2I7tOI69a3vXu8v33dljZtez9szObInVudHOz73n3HPOd88592esRNpP/aQgYakagWjVnCGjQSAE0KcjhACGAPpEwCd76IEhgD4R8MkeemAIoE8EfLKHHhgC6BMBn+yhB4YA+kTAJ3vogSGAPhHwyR56YAigTwR8soceGALoEwGf7PFq+PkNYAU/798CyBEpirQ/F6sq3pxoK9WxE8rQdr2Xdk4KGq/alLa6f/MEIIURuCaI7YzGJIZnVU/vbkVXoq9U77ZfJzr2yWKHNYf3m/mcLMECtcMQeby4BpDCsxDWIlEILMj5zDzQU9U8Sr0byCMR2RNvgiURWca12snANYD0PIJ3o2AF75PJHtkSjUvOqOA3ECxEdTice/Pum8qhd0rJQ98E7JjJZ+Xl1KREI1HpxC+DNme5lm6Vrq4ApAIMW3oeg/aN/i/L4a69qCmYmmoEV1Ko1vW0wERONCrHx96TY5dfkwgATKCaruG1uAKQHTPnMWyfbO2Rw917JQGhm70MdPfJoyP/kFOLM9ITrQOABl5PZrkCkH7GRMuR2xKJS6SQh79HJZfPY/Q2k/9ZYcowjkH/POxphWPQrmqtcAUgxerYMOepuCjA22wA0g8iagyeORvb7TOvHi6u41BHCJCtjpZNDw8i7y5StatarVx6oPvu6Z9c3VAxAkwvdVMYTnbK9Ty7QAEovLL7/w2pqf5QL4ECaAyiOUUkFBCrfn273ALNXhRcL/2vL7361sAAtDJjRCYW78ifb7wn6eyy3Ne6DTN2PxK2mlpZ0b/fHJKLs9cljrXlQFef9CY76csl3qXv1+an5W/jF6Up3iCP7NwvHfXNa2grS3Ju2VhDZ77AAGQY0dN+ePkNefH6GZH6rSKZOfnLwRPyMABhiJZ7GWfxGNZjF2bH5DPv/goxCTOyC3Jsep/89uBxaYnXrfKpdy/lV+TE+Vflzbn3sXBLyU+XHpPv7DtSArSzqWtrCZoFXAEL7OqK60lkve5pHEsmtyJX0rPS1bxDBho7RBo65ecjb0mmkDPgKR1pmccIHssfrr8LS+LyaNM26QfvhUxKZjNp06YXzXu3UX8xsyAPg04au+Qa5GW4rEKx9698691JTwDb4PVNiBJuVS1A1+MqbQsEQO2SkdqMddUEtkn/XlmS++P18pvbw/LO1LAhyRcN5QvXYixX5ibl+9P/kbpYg4zmM3IplzGL9HJvNcS40NObIGMEdAI58eIgaLuXO8GazGVldumWDKK/Ldjied3SBQoglV8xM2REWoEmN+kSickr1/9p1ltcvDKP8R+fWV6/cQGuuyD9sTrJkhd8G+0IljEQ9RwtgGnEmZ7cX3RwkkgRrxx4XF4/cFweb+40A8h9sZctXeAA2s1Iw7oeJPoXb12VczMjpimfB0iW88kHqVvyzMR5SSSa5Y7NO4vN9q5q8kxv3t3SIUcxEX23dwCjvyjNqOO+2G2pGYAEIYtfMz0Nif/V0fMmUceikdXwPTV+SWRpVh6K1csY86RbrQOkyxUHrg3phh7N88EEPduljJrrTIU6cO72g6lLMjg3YZRk+M4sp+SZ0XdEEkmZAnh1aHGrtEvbXJFFARZLrpgLCAhTjNtSUwCp2hwU68YsJ0jSLw1zRrZmzN+PvC3zy7flQeS+mwAQRxRudQ6UTqGyS2douy2BrQMrCeQIjQOg3chzz8MLJ88uSAtAe2H2muxItMgo2njW6CVxV5IVVL2C6qa/mgPIsaTPLSAsduPM7RdzI4iRguzE5LKM+pqGgBsEfNLUHEBOJApiiiACOIKWAogEkODyfbMCWTMACRpX9juxDqwHhHyeRP6bB3Bs4zncdkwmSbyl0TZuW8ag6UMr1IWlNGxL3ywK52vNAMxBh60A50o2Be0AF8DqwWy8CD2Y79rQdjWL7VoefojQ3h5vdNawQq2a6GXGdOqKe3QediR4Ml0s1iSiErTW+V6jyOHRf1TGsJ17vvuT8q9D35STewZkFO/0yPswKw9j0frstv3y1sGn5Ec9B7GlymApo/7grKy9Vim5DNF9Mu/mB3+y/7PzlT/rfvzinUnTRB249NL+y+nL3wP3QDNuAIn74Y6GVnm677B01DXLg2075XJqWn42/rYI9r2HWrrle/uPytZEg3y8rUfO3ZmQlxcmXIFID9G9dAZP8aL36Bat3MjykyCCyz54yPHXG5fk9PT78tzMoLRgVTCFVEIb/m8AGuURErPYfRyrSyI0rDFigDzbf0T2NXXIErztSz0HDHgr+OuABgDQC1opjEl9NGEMKAfB/s6wmQTfPQj7k/Pj8m14z/2t282EVG4438uBhaOaQ980DhKOXH0TM9pN2d3QIWkQ0/u8hGXgHmgZYI2hbpNoPL2gu3GLfGvvF/hqCsNNvSdbNJ+TzUYGsH0e9B0Aezq7JN8490d5rP1ec0BBcOg+xkvhTY2g+cquT8i9LfeY8NbTbCrA8P8azi1/vQI/Bg/zNgeaXbgtgQJI5RkeSYRwCgpxiaL5iYoTRFSbYuw0JypagRrkzS6YRT7SOhUTjmjohgx+IdyLZdEZfK8+M3p2LTnAk+VZGULqeOHTT0gc/as+JKaEeUQK9+o8NaJuzlJJ7VwCAVBBYUKOImTn+XczUGprskvqY3q2YZ1Iq4LqZTSI4MbioMNp9DAMeQB5sRlHTfaiWPOUGr3LFGXgEEK4/GEORF4tN/9jAHAINLcwYZmzSABYXqzwVgvKWzd+DwRAijHhCAWfe+AR2TF02njR072fM/lNkzbpKqn6VO9nZRk5aSa7KF/fc0ja65pIbvuAZJ2QJAHu7/qOyksfnEV4xgAMYdNhMSzmQmCoUwGDeAJ61GFgdbB4D6oEBqDmlofad8nJ9q+W6Getq0qqVl/IR3P4EenHn3rCPNtBdnr+PP4k4zB+K/A+lbvaITsrMhEo+5+grKFdZar+ITAAVQUdZb6bfKWxpwQOd9qrfPZnB1JTpbR2cFZpSxC3XpR+lSbAB9cAqtMzXJxCRnWyPMqiLl8+KI3TXT2RAbmRp9hlrOnL5oFWG/x/nUFUu9b047LCJYA6e2LZgTynh5AcWSpQroQ6gS52XeqikYf8Wd7j2h5UxtqWcoVKP1mSTyODz9Y5pNrn2Nu6la4AJGDLTLyY1Qaxt01jhk0iges2qJIxlerX1QiN1fJV6re8v3jRIzNYjA9hhubyiUunaoorAEnEQ9E+rLleS0/JLwdPyxd37DdCa5lfqjHIOG85YraOqC8L/zL1T/hOc27ptuzCEmjRhdfbull9jLj9j3colr8W/EZ5isLvsVizbb4CKwCeYMlEi7pxQsRzyWqLKw9k5zqoOJySfuxbs1hCVPMlv1pFg+RjuNZj4c58PsGjNhS1z7x4uLgGUIXQCym0EXnEHCV5EHa3kBKsFAxJww4+Vwse7fEEIBlU2GIxl7Bus5a1GzvvlngGUEUokPr+Ub0HMQgfVeyM3SGAPoc/BDAE0CcCPtlDDwwB9ImAT/bQA0MAfSLgkz30wBBAnwj4ZA89MATQJwI+2UMPDAH0iYBP9tADQwB9IuCTPfTAEECfCPhk/y8H+GxGFyHo7AAAAABJRU5ErkJggg==";

var translationMap = {
  'ja': {
    'gui.extension.ml2scratch.description': '機械学習を使う'
  },
  'ja-Hira': {
    'gui.extension.ml2scratch.description': 'きかいがくしゅうをつかう'
  }
};
var entry = {
  name: 'ML2Scratch',
  extensionId: 'ml2scratch',
  extensionURL: 'https://champierre.github.io/ml2scratch/ml2scratch.mjs',
  collaborator: 'champierre',
  iconURL: img$1,
  insetIconURL: img,
  description: /*#__PURE__*/react.createElement(FormattedMessage, {
    defaultMessage: "ML2Scratch Blocks.",
    description: "Description for ML2Scratch Blocks.",
    id: "gui.extension.ml2scratch.description"
  }),
  featured: true,
  disabled: false,
  bluetoothRequired: false,
  internetConnectionRequired: true,
  helpLink: 'https://github.com/champierre/ml2scratch/',
  translationMap: translationMap
};

/**
 * Block argument types
 * @enum {string}
 */
var ArgumentType = {
  /**
   * Numeric value with angle picker
   */
  ANGLE: 'angle',

  /**
   * Boolean value with hexagonal placeholder
   */
  BOOLEAN: 'Boolean',

  /**
   * Numeric value with color picker
   */
  COLOR: 'color',

  /**
   * Numeric value with text field
   */
  NUMBER: 'number',

  /**
   * String value with text field
   */
  STRING: 'string',

  /**
   * String value with matrix field
   */
  MATRIX: 'matrix',

  /**
   * MIDI note number with note picker (piano) field
   */
  NOTE: 'note',

  /**
   * Inline image on block (as part of the label)
   */
  IMAGE: 'image'
};
var argumentType = ArgumentType;

/**
 * Types of block
 * @enum {string}
 */
var BlockType = {
  /**
   * Boolean reporter with hexagonal shape
   */
  BOOLEAN: 'Boolean',

  /**
   * A button (not an actual block) for some special action, like making a variable
   */
  BUTTON: 'button',

  /**
   * Command block
   */
  COMMAND: 'command',

  /**
   * Specialized command block which may or may not run a child branch
   * The thread continues with the next block whether or not a child branch ran.
   */
  CONDITIONAL: 'conditional',

  /**
   * Specialized hat block with no implementation function
   * This stack only runs if the corresponding event is emitted by other code.
   */
  EVENT: 'event',

  /**
   * Hat block which conditionally starts a block stack
   */
  HAT: 'hat',

  /**
   * Specialized command block which may or may not run a child branch
   * If a child branch runs, the thread evaluates the loop block again.
   */
  LOOP: 'loop',

  /**
   * General reporter with numeric or string value
   */
  REPORTER: 'reporter'
};
var blockType = BlockType;

var Color = /*#__PURE__*/function () {
  function Color() {
    _classCallCheck(this, Color);
  }

  _createClass(Color, null, [{
    key: "RGB_BLACK",
    get:
    /**
     * @typedef {object} RGBObject - An object representing a color in RGB format.
     * @property {number} r - the red component, in the range [0, 255].
     * @property {number} g - the green component, in the range [0, 255].
     * @property {number} b - the blue component, in the range [0, 255].
     */

    /**
     * @typedef {object} HSVObject - An object representing a color in HSV format.
     * @property {number} h - hue, in the range [0-359).
     * @property {number} s - saturation, in the range [0,1].
     * @property {number} v - value, in the range [0,1].
     */

    /** @type {RGBObject} */
    function get() {
      return {
        r: 0,
        g: 0,
        b: 0
      };
    }
    /** @type {RGBObject} */

  }, {
    key: "RGB_WHITE",
    get: function get() {
      return {
        r: 255,
        g: 255,
        b: 255
      };
    }
    /**
     * Convert a Scratch decimal color to a hex string, #RRGGBB.
     * @param {number} decimal RGB color as a decimal.
     * @return {string} RGB color as #RRGGBB hex string.
     */

  }, {
    key: "decimalToHex",
    value: function decimalToHex(decimal) {
      if (decimal < 0) {
        decimal += 0xFFFFFF + 1;
      }

      var hex = Number(decimal).toString(16);
      hex = "#".concat('000000'.substr(0, 6 - hex.length)).concat(hex);
      return hex;
    }
    /**
     * Convert a Scratch decimal color to an RGB color object.
     * @param {number} decimal RGB color as decimal.
     * @return {RGBObject} rgb - {r: red [0,255], g: green [0,255], b: blue [0,255]}.
     */

  }, {
    key: "decimalToRgb",
    value: function decimalToRgb(decimal) {
      var a = decimal >> 24 & 0xFF;
      var r = decimal >> 16 & 0xFF;
      var g = decimal >> 8 & 0xFF;
      var b = decimal & 0xFF;
      return {
        r: r,
        g: g,
        b: b,
        a: a > 0 ? a : 255
      };
    }
    /**
     * Convert a hex color (e.g., F00, #03F, #0033FF) to an RGB color object.
     * CC-BY-SA Tim Down:
     * https://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb
     * @param {!string} hex Hex representation of the color.
     * @return {RGBObject} null on failure, or rgb: {r: red [0,255], g: green [0,255], b: blue [0,255]}.
     */

  }, {
    key: "hexToRgb",
    value: function hexToRgb(hex) {
      var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
      hex = hex.replace(shorthandRegex, function (m, r, g, b) {
        return r + r + g + g + b + b;
      });
      var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
      return result ? {
        r: parseInt(result[1], 16),
        g: parseInt(result[2], 16),
        b: parseInt(result[3], 16)
      } : null;
    }
    /**
     * Convert an RGB color object to a hex color.
     * @param {RGBObject} rgb - {r: red [0,255], g: green [0,255], b: blue [0,255]}.
     * @return {!string} Hex representation of the color.
     */

  }, {
    key: "rgbToHex",
    value: function rgbToHex(rgb) {
      return Color.decimalToHex(Color.rgbToDecimal(rgb));
    }
    /**
     * Convert an RGB color object to a Scratch decimal color.
     * @param {RGBObject} rgb - {r: red [0,255], g: green [0,255], b: blue [0,255]}.
     * @return {!number} Number representing the color.
     */

  }, {
    key: "rgbToDecimal",
    value: function rgbToDecimal(rgb) {
      return (rgb.r << 16) + (rgb.g << 8) + rgb.b;
    }
    /**
    * Convert a hex color (e.g., F00, #03F, #0033FF) to a decimal color number.
    * @param {!string} hex Hex representation of the color.
    * @return {!number} Number representing the color.
    */

  }, {
    key: "hexToDecimal",
    value: function hexToDecimal(hex) {
      return Color.rgbToDecimal(Color.hexToRgb(hex));
    }
    /**
     * Convert an HSV color to RGB format.
     * @param {HSVObject} hsv - {h: hue [0,360), s: saturation [0,1], v: value [0,1]}
     * @return {RGBObject} rgb - {r: red [0,255], g: green [0,255], b: blue [0,255]}.
     */

  }, {
    key: "hsvToRgb",
    value: function hsvToRgb(hsv) {
      var h = hsv.h % 360;
      if (h < 0) h += 360;
      var s = Math.max(0, Math.min(hsv.s, 1));
      var v = Math.max(0, Math.min(hsv.v, 1));
      var i = Math.floor(h / 60);
      var f = h / 60 - i;
      var p = v * (1 - s);
      var q = v * (1 - s * f);
      var t = v * (1 - s * (1 - f));
      var r;
      var g;
      var b;

      switch (i) {
        default:
        case 0:
          r = v;
          g = t;
          b = p;
          break;

        case 1:
          r = q;
          g = v;
          b = p;
          break;

        case 2:
          r = p;
          g = v;
          b = t;
          break;

        case 3:
          r = p;
          g = q;
          b = v;
          break;

        case 4:
          r = t;
          g = p;
          b = v;
          break;

        case 5:
          r = v;
          g = p;
          b = q;
          break;
      }

      return {
        r: Math.floor(r * 255),
        g: Math.floor(g * 255),
        b: Math.floor(b * 255)
      };
    }
    /**
     * Convert an RGB color to HSV format.
     * @param {RGBObject} rgb - {r: red [0,255], g: green [0,255], b: blue [0,255]}.
     * @return {HSVObject} hsv - {h: hue [0,360), s: saturation [0,1], v: value [0,1]}
     */

  }, {
    key: "rgbToHsv",
    value: function rgbToHsv(rgb) {
      var r = rgb.r / 255;
      var g = rgb.g / 255;
      var b = rgb.b / 255;
      var x = Math.min(Math.min(r, g), b);
      var v = Math.max(Math.max(r, g), b); // For grays, hue will be arbitrarily reported as zero. Otherwise, calculate

      var h = 0;
      var s = 0;

      if (x !== v) {
        var f = r === x ? g - b : g === x ? b - r : r - g;
        var i = r === x ? 3 : g === x ? 5 : 1;
        h = (i - f / (v - x)) * 60 % 360;
        s = (v - x) / v;
      }

      return {
        h: h,
        s: s,
        v: v
      };
    }
    /**
     * Linear interpolation between rgb0 and rgb1.
     * @param {RGBObject} rgb0 - the color corresponding to fraction1 <= 0.
     * @param {RGBObject} rgb1 - the color corresponding to fraction1 >= 1.
     * @param {number} fraction1 - the interpolation parameter. If this is 0.5, for example, mix the two colors equally.
     * @return {RGBObject} the interpolated color.
     */

  }, {
    key: "mixRgb",
    value: function mixRgb(rgb0, rgb1, fraction1) {
      if (fraction1 <= 0) return rgb0;
      if (fraction1 >= 1) return rgb1;
      var fraction0 = 1 - fraction1;
      return {
        r: fraction0 * rgb0.r + fraction1 * rgb1.r,
        g: fraction0 * rgb0.g + fraction1 * rgb1.g,
        b: fraction0 * rgb0.b + fraction1 * rgb1.b
      };
    }
  }]);

  return Color;
}();

var color$1 = Color;

/**
 * @fileoverview
 * Utilities for casting and comparing Scratch data-types.
 * Scratch behaves slightly differently from JavaScript in many respects,
 * and these differences should be encapsulated below.
 * For example, in Scratch, add(1, join("hello", world")) -> 1.
 * This is because "hello world" is cast to 0.
 * In JavaScript, 1 + Number("hello" + "world") would give you NaN.
 * Use when coercing a value before computation.
 */

var Cast = /*#__PURE__*/function () {
  function Cast() {
    _classCallCheck(this, Cast);
  }

  _createClass(Cast, null, [{
    key: "toNumber",
    value:
    /**
     * Scratch cast to number.
     * Treats NaN as 0.
     * In Scratch 2.0, this is captured by `interp.numArg.`
     * @param {*} value Value to cast to number.
     * @return {number} The Scratch-casted number value.
     */
    function toNumber(value) {
      // If value is already a number we don't need to coerce it with
      // Number().
      if (typeof value === 'number') {
        // Scratch treats NaN as 0, when needed as a number.
        // E.g., 0 + NaN -> 0.
        if (Number.isNaN(value)) {
          return 0;
        }

        return value;
      }

      var n = Number(value);

      if (Number.isNaN(n)) {
        // Scratch treats NaN as 0, when needed as a number.
        // E.g., 0 + NaN -> 0.
        return 0;
      }

      return n;
    }
    /**
     * Scratch cast to boolean.
     * In Scratch 2.0, this is captured by `interp.boolArg.`
     * Treats some string values differently from JavaScript.
     * @param {*} value Value to cast to boolean.
     * @return {boolean} The Scratch-casted boolean value.
     */

  }, {
    key: "toBoolean",
    value: function toBoolean(value) {
      // Already a boolean?
      if (typeof value === 'boolean') {
        return value;
      }

      if (typeof value === 'string') {
        // These specific strings are treated as false in Scratch.
        if (value === '' || value === '0' || value.toLowerCase() === 'false') {
          return false;
        } // All other strings treated as true.


        return true;
      } // Coerce other values and numbers.


      return Boolean(value);
    }
    /**
     * Scratch cast to string.
     * @param {*} value Value to cast to string.
     * @return {string} The Scratch-casted string value.
     */

  }, {
    key: "toString",
    value: function toString(value) {
      return String(value);
    }
    /**
     * Cast any Scratch argument to an RGB color array to be used for the renderer.
     * @param {*} value Value to convert to RGB color array.
     * @return {Array.<number>} [r,g,b], values between 0-255.
     */

  }, {
    key: "toRgbColorList",
    value: function toRgbColorList(value) {
      var color = Cast.toRgbColorObject(value);
      return [color.r, color.g, color.b];
    }
    /**
     * Cast any Scratch argument to an RGB color object to be used for the renderer.
     * @param {*} value Value to convert to RGB color object.
     * @return {RGBOject} [r,g,b], values between 0-255.
     */

  }, {
    key: "toRgbColorObject",
    value: function toRgbColorObject(value) {
      var color;

      if (typeof value === 'string' && value.substring(0, 1) === '#') {
        color = color$1.hexToRgb(value); // If the color wasn't *actually* a hex color, cast to black

        if (!color) color = {
          r: 0,
          g: 0,
          b: 0,
          a: 255
        };
      } else {
        color = color$1.decimalToRgb(Cast.toNumber(value));
      }

      return color;
    }
    /**
     * Determine if a Scratch argument is a white space string (or null / empty).
     * @param {*} val value to check.
     * @return {boolean} True if the argument is all white spaces or null / empty.
     */

  }, {
    key: "isWhiteSpace",
    value: function isWhiteSpace(val) {
      return val === null || typeof val === 'string' && val.trim().length === 0;
    }
    /**
     * Compare two values, using Scratch cast, case-insensitive string compare, etc.
     * In Scratch 2.0, this is captured by `interp.compare.`
     * @param {*} v1 First value to compare.
     * @param {*} v2 Second value to compare.
     * @returns {number} Negative number if v1 < v2; 0 if equal; positive otherwise.
     */

  }, {
    key: "compare",
    value: function compare(v1, v2) {
      var n1 = Number(v1);
      var n2 = Number(v2);

      if (n1 === 0 && Cast.isWhiteSpace(v1)) {
        n1 = NaN;
      } else if (n2 === 0 && Cast.isWhiteSpace(v2)) {
        n2 = NaN;
      }

      if (isNaN(n1) || isNaN(n2)) {
        // At least one argument can't be converted to a number.
        // Scratch compares strings as case insensitive.
        var s1 = String(v1).toLowerCase();
        var s2 = String(v2).toLowerCase();

        if (s1 < s2) {
          return -1;
        } else if (s1 > s2) {
          return 1;
        }

        return 0;
      } // Handle the special case of Infinity


      if (n1 === Infinity && n2 === Infinity || n1 === -Infinity && n2 === -Infinity) {
        return 0;
      } // Compare as numbers.


      return n1 - n2;
    }
    /**
     * Determine if a Scratch argument number represents a round integer.
     * @param {*} val Value to check.
     * @return {boolean} True if number looks like an integer.
     */

  }, {
    key: "isInt",
    value: function isInt(val) {
      // Values that are already numbers.
      if (typeof val === 'number') {
        if (isNaN(val)) {
          // NaN is considered an integer.
          return true;
        } // True if it's "round" (e.g., 2.0 and 2).


        return val === parseInt(val, 10);
      } else if (typeof val === 'boolean') {
        // `True` and `false` always represent integer after Scratch cast.
        return true;
      } else if (typeof val === 'string') {
        // If it contains a decimal point, don't consider it an int.
        return val.indexOf('.') < 0;
      }

      return false;
    }
  }, {
    key: "LIST_INVALID",
    get: function get() {
      return 'INVALID';
    }
  }, {
    key: "LIST_ALL",
    get: function get() {
      return 'ALL';
    }
    /**
     * Compute a 1-based index into a list, based on a Scratch argument.
     * Two special cases may be returned:
     * LIST_ALL: if the block is referring to all of the items in the list.
     * LIST_INVALID: if the index was invalid in any way.
     * @param {*} index Scratch arg, including 1-based numbers or special cases.
     * @param {number} length Length of the list.
     * @param {boolean} acceptAll Whether it should accept "all" or not.
     * @return {(number|string)} 1-based index for list, LIST_ALL, or LIST_INVALID.
     */

  }, {
    key: "toListIndex",
    value: function toListIndex(index, length, acceptAll) {
      if (typeof index !== 'number') {
        if (index === 'all') {
          return acceptAll ? Cast.LIST_ALL : Cast.LIST_INVALID;
        }

        if (index === 'last') {
          if (length > 0) {
            return length;
          }

          return Cast.LIST_INVALID;
        } else if (index === 'random' || index === 'any') {
          if (length > 0) {
            return 1 + Math.floor(Math.random() * length);
          }

          return Cast.LIST_INVALID;
        }
      }

      index = Math.floor(Cast.toNumber(index));

      if (index < 1 || index > length) {
        return Cast.LIST_INVALID;
      }

      return index;
    }
  }]);

  return Cast;
}();

var cast = Cast;

function M() {
  this._events = {};
}

M.prototype = {
  on: function on(ev, cb) {
    this._events || (this._events = {});
    var e = this._events;
    (e[ev] || (e[ev] = [])).push(cb);
    return this;
  },
  removeListener: function removeListener(ev, cb) {
    var e = this._events[ev] || [],
        i;

    for (i = e.length - 1; i >= 0 && e[i]; i--) {
      if (e[i] === cb || e[i].cb === cb) {
        e.splice(i, 1);
      }
    }
  },
  removeAllListeners: function removeAllListeners(ev) {
    if (!ev) {
      this._events = {};
    } else {
      this._events[ev] && (this._events[ev] = []);
    }
  },
  listeners: function listeners(ev) {
    return this._events ? this._events[ev] || [] : [];
  },
  emit: function emit(ev) {
    this._events || (this._events = {});
    var args = Array.prototype.slice.call(arguments, 1),
        i,
        e = this._events[ev] || [];

    for (i = e.length - 1; i >= 0 && e[i]; i--) {
      e[i].apply(this, args);
    }

    return this;
  },
  when: function when(ev, cb) {
    return this.once(ev, cb, true);
  },
  once: function once(ev, cb, when) {
    if (!cb) return this;

    function c() {
      if (!when) this.removeListener(ev, c);
      if (cb.apply(this, arguments) && when) this.removeListener(ev, c);
    }

    c.cb = cb;
    this.on(ev, c);
    return this;
  }
};

M.mixin = function (dest) {
  var o = M.prototype,
      k;

  for (k in o) {
    o.hasOwnProperty(k) && (dest.prototype[k] = o[k]);
  }
};

var microee = M;

function Transform() {}

microee.mixin(Transform); // The write() signature is different from Node's
// --> makes it much easier to work with objects in logs.
// One of the lessons from v1 was that it's better to target
// a good browser rather than the lowest common denominator
// internally.
// If you want to use external streams, pipe() to ./stringify.js first.

Transform.prototype.write = function (name, level, args) {
  this.emit('item', name, level, args);
};

Transform.prototype.end = function () {
  this.emit('end');
  this.removeAllListeners();
};

Transform.prototype.pipe = function (dest) {
  var s = this; // prevent double piping

  s.emit('unpipe', dest); // tell the dest that it's being piped to

  dest.emit('pipe', s);

  function onItem() {
    dest.write.apply(dest, Array.prototype.slice.call(arguments));
  }

  function onEnd() {
    !dest._isStdio && dest.end();
  }

  s.on('item', onItem);
  s.on('end', onEnd);
  s.when('unpipe', function (from) {
    var match = from === dest || typeof from == 'undefined';

    if (match) {
      s.removeListener('item', onItem);
      s.removeListener('end', onEnd);
      dest.emit('unpipe');
    }

    return match;
  });
  return dest;
};

Transform.prototype.unpipe = function (from) {
  this.emit('unpipe', from);
  return this;
};

Transform.prototype.format = function (dest) {
  throw new Error(['Warning: .format() is deprecated in Minilog v2! Use .pipe() instead. For example:', 'var Minilog = require(\'minilog\');', 'Minilog', '  .pipe(Minilog.backends.console.formatClean)', '  .pipe(Minilog.backends.console);'].join('\n'));
};

Transform.mixin = function (dest) {
  var o = Transform.prototype,
      k;

  for (k in o) {
    o.hasOwnProperty(k) && (dest.prototype[k] = o[k]);
  }
};

var transform = Transform;

var levelMap = {
  debug: 1,
  info: 2,
  warn: 3,
  error: 4
};

function Filter() {
  this.enabled = true;
  this.defaultResult = true;
  this.clear();
}

transform.mixin(Filter); // allow all matching, with level >= given level

Filter.prototype.allow = function (name, level) {
  this._white.push({
    n: name,
    l: levelMap[level]
  });

  return this;
}; // deny all matching, with level <= given level


Filter.prototype.deny = function (name, level) {
  this._black.push({
    n: name,
    l: levelMap[level]
  });

  return this;
};

Filter.prototype.clear = function () {
  this._white = [];
  this._black = [];
  return this;
};

function test(rule, name) {
  // use .test for RegExps
  return rule.n.test ? rule.n.test(name) : rule.n == name;
}

Filter.prototype.test = function (name, level) {
  var i,
      len = Math.max(this._white.length, this._black.length);

  for (i = 0; i < len; i++) {
    if (this._white[i] && test(this._white[i], name) && levelMap[level] >= this._white[i].l) {
      return true;
    }

    if (this._black[i] && test(this._black[i], name) && levelMap[level] <= this._black[i].l) {
      return false;
    }
  }

  return this.defaultResult;
};

Filter.prototype.write = function (name, level, args) {
  if (!this.enabled || this.test(name, level)) {
    return this.emit('item', name, level, args);
  }
};

var filter = Filter;

var minilog$1 = createCommonjsModule(function (module, exports) {
  var log = new transform(),
      slice = Array.prototype.slice;

  exports = module.exports = function create(name) {
    var o = function o() {
      log.write(name, undefined, slice.call(arguments));
      return o;
    };

    o.debug = function () {
      log.write(name, 'debug', slice.call(arguments));
      return o;
    };

    o.info = function () {
      log.write(name, 'info', slice.call(arguments));
      return o;
    };

    o.warn = function () {
      log.write(name, 'warn', slice.call(arguments));
      return o;
    };

    o.error = function () {
      log.write(name, 'error', slice.call(arguments));
      return o;
    };

    o.log = o.debug; // for interface compliance with Node and browser consoles

    o.suggest = exports.suggest;
    o.format = log.format;
    return o;
  }; // filled in separately


  exports.defaultBackend = exports.defaultFormatter = null;

  exports.pipe = function (dest) {
    return log.pipe(dest);
  };

  exports.end = exports.unpipe = exports.disable = function (from) {
    return log.unpipe(from);
  };

  exports.Transform = transform;
  exports.Filter = filter; // this is the default filter that's applied when .enable() is called normally
  // you can bypass it completely and set up your own pipes

  exports.suggest = new filter();

  exports.enable = function () {
    if (exports.defaultFormatter) {
      return log.pipe(exports.suggest) // filter
      .pipe(exports.defaultFormatter) // formatter
      .pipe(exports.defaultBackend); // backend
    }

    return log.pipe(exports.suggest) // filter
    .pipe(exports.defaultBackend); // formatter
  };
});

var hex = {
  black: '#000',
  red: '#c23621',
  green: '#25bc26',
  yellow: '#bbbb00',
  blue: '#492ee1',
  magenta: '#d338d3',
  cyan: '#33bbc8',
  gray: '#808080',
  purple: '#708'
};

function color(fg, isInverse) {
  if (isInverse) {
    return 'color: #fff; background: ' + hex[fg] + ';';
  } else {
    return 'color: ' + hex[fg] + ';';
  }
}

var util = color;

var colors$1 = {
  debug: ['cyan'],
  info: ['purple'],
  warn: ['yellow', true],
  error: ['red', true]
},
    logger$4 = new transform();

logger$4.write = function (name, level, args) {
  var fn = console.log;

  if (console[level] && console[level].apply) {
    fn = console[level];
    fn.apply(console, ['%c' + name + ' %c' + level, util('gray'), util.apply(util, colors$1[level])].concat(args));
  }
}; // NOP, because piping the formatted logs can only cause trouble.


logger$4.pipe = function () {};

var color_1 = logger$4;

var colors = {
  debug: ['gray'],
  info: ['purple'],
  warn: ['yellow', true],
  error: ['red', true]
},
    logger$3 = new transform();

logger$3.write = function (name, level, args) {
  var fn = console.log;

  if (level != 'debug' && console[level]) {
    fn = console[level];
  }

  var i = 0;

  if (level != 'info') {
    for (; i < args.length; i++) {
      if (typeof args[i] != 'string') break;
    }

    fn.apply(console, ['%c' + name + ' ' + args.slice(0, i).join(' '), util.apply(util, colors[level])].concat(args.slice(i)));
  } else {
    fn.apply(console, ['%c' + name, util.apply(util, colors[level])].concat(args));
  }
}; // NOP, because piping the formatted logs can only cause trouble.


logger$3.pipe = function () {};

var minilog = logger$3;

var newlines = /\n+$/,
    logger$2 = new transform();

logger$2.write = function (name, level, args) {
  var i = args.length - 1;

  if (typeof console === 'undefined' || !console.log) {
    return;
  }

  if (console.log.apply) {
    return console.log.apply(console, [name, level].concat(args));
  } else if (JSON && JSON.stringify) {
    // console.log.apply is undefined in IE8 and IE9
    // for IE8/9: make console.log at least a bit less awful
    if (args[i] && typeof args[i] == 'string') {
      args[i] = args[i].replace(newlines, '');
    }

    try {
      for (i = 0; i < args.length; i++) {
        args[i] = JSON.stringify(args[i]);
      }
    } catch (e) {}

    console.log(args.join(' '));
  }
};

logger$2.formatters = ['color', 'minilog'];
logger$2.color = color_1;
logger$2.minilog = minilog;
var console_1 = logger$2;

var cache$1 = [];
var logger$1 = new transform();

logger$1.write = function (name, level, args) {
  cache$1.push([name, level, args]);
}; // utility functions


logger$1.get = function () {
  return cache$1;
};

logger$1.empty = function () {
  cache$1 = [];
};

var array = logger$1;

var cache = false;
var logger = new transform();

logger.write = function (name, level, args) {
  if (typeof window == 'undefined' || typeof JSON == 'undefined' || !JSON.stringify || !JSON.parse) return;

  try {
    if (!cache) {
      cache = window.localStorage.minilog ? JSON.parse(window.localStorage.minilog) : [];
    }

    cache.push([new Date().toString(), name, level, args]);
    window.localStorage.minilog = JSON.stringify(cache);
  } catch (e) {}
};

var localstorage = logger;

var cid = new Date().valueOf().toString(36);

function AjaxLogger(options) {
  this.url = options.url || '';
  this.cache = [];
  this.timer = null;
  this.interval = options.interval || 30 * 1000;
  this.enabled = true;
  this.jQuery = window.jQuery;
  this.extras = {};
}

transform.mixin(AjaxLogger);

AjaxLogger.prototype.write = function (name, level, args) {
  if (!this.timer) {
    this.init();
  }

  this.cache.push([name, level].concat(args));
};

AjaxLogger.prototype.init = function () {
  if (!this.enabled || !this.jQuery) return;
  var self = this;
  this.timer = setTimeout(function () {
    var i,
        logs = [],
        ajaxData,
        url = self.url;
    if (self.cache.length == 0) return self.init(); // Test each log line and only log the ones that are valid (e.g. don't have circular references).
    // Slight performance hit but benefit is we log all valid lines.

    for (i = 0; i < self.cache.length; i++) {
      try {
        JSON.stringify(self.cache[i]);
        logs.push(self.cache[i]);
      } catch (e) {}
    }

    if (self.jQuery.isEmptyObject(self.extras)) {
      ajaxData = JSON.stringify({
        logs: logs
      });
      url = self.url + '?client_id=' + cid;
    } else {
      ajaxData = JSON.stringify(self.jQuery.extend({
        logs: logs
      }, self.extras));
    }

    self.jQuery.ajax(url, {
      type: 'POST',
      cache: false,
      processData: false,
      data: ajaxData,
      contentType: 'application/json',
      timeout: 10000
    }).success(function (data, status, jqxhr) {
      if (data.interval) {
        self.interval = Math.max(1000, data.interval);
      }
    }).error(function () {
      self.interval = 30000;
    }).always(function () {
      self.init();
    });
    self.cache = [];
  }, this.interval);
};

AjaxLogger.prototype.end = function () {}; // wait until jQuery is defined. Useful if you don't control the load order.


AjaxLogger.jQueryWait = function (onDone) {
  if (typeof window !== 'undefined' && (window.jQuery || window.$)) {
    return onDone(window.jQuery || window.$);
  } else if (typeof window !== 'undefined') {
    setTimeout(function () {
      AjaxLogger.jQueryWait(onDone);
    }, 200);
  }
};

var jquery_simple = AjaxLogger;

var web = createCommonjsModule(function (module, exports) {
  var oldEnable = minilog$1.enable,
      oldDisable = minilog$1.disable,
      isChrome = typeof navigator != 'undefined' && /chrome/i.test(navigator.userAgent); // Use a more capable logging backend if on Chrome

  minilog$1.defaultBackend = isChrome ? console_1.minilog : console_1; // apply enable inputs from localStorage and from the URL

  if (typeof window != 'undefined') {
    try {
      minilog$1.enable(JSON.parse(window.localStorage['minilogSettings']));
    } catch (e) {}

    if (window.location && window.location.search) {
      var match = RegExp('[?&]minilog=([^&]*)').exec(window.location.search);
      match && minilog$1.enable(decodeURIComponent(match[1]));
    }
  } // Make enable also add to localStorage


  minilog$1.enable = function () {
    oldEnable.call(minilog$1, true);

    try {
      window.localStorage['minilogSettings'] = JSON.stringify(true);
    } catch (e) {}

    return this;
  };

  minilog$1.disable = function () {
    oldDisable.call(minilog$1);

    try {
      delete window.localStorage.minilogSettings;
    } catch (e) {}

    return this;
  };

  exports = module.exports = minilog$1;
  exports.backends = {
    array: array,
    browser: minilog$1.defaultBackend,
    localStorage: localstorage,
    jQuery: jquery_simple
  };
});

web.enable();
web('vm');

var ml5_min=createCommonjsModule(function(module,exports){!function(t,e){module.exports=e();}(window,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports;}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r});},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0});},n.n=function(t){var e=t&&t.__esModule?function(){return t.default;}:function(){return t;};return n.d(e,"a",e),e;},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e);},n.p="/",n(n.s=581);}([function(t,e,n){n.r(e),function(t,r,i,o){n.d(e,"AdadeltaOptimizer",function(){return Dh;}),n.d(e,"AdagradOptimizer",function(){return Fh;}),n.d(e,"AdamOptimizer",function(){return Th;}),n.d(e,"AdamaxOptimizer",function(){return Nh;}),n.d(e,"Add",function(){return Er;}),n.d(e,"AddN",function(){return Cr;}),n.d(e,"BroadcastTo",function(){return Tr;}),n.d(e,"DataStorage",function(){return ho;}),n.d(e,"Div",function(){return Ar;}),n.d(e,"ENV",function(){return h;}),n.d(e,"Environment",function(){return l;}),n.d(e,"FromPixels",function(){return jr;}),n.d(e,"FusedBatchNorm",function(){return Or;}),n.d(e,"Identity",function(){return Ir;}),n.d(e,"KernelBackend",function(){return po;}),n.d(e,"MaxPoolWithArgmax",function(){return Br;}),n.d(e,"MomentumOptimizer",function(){return Rh;}),n.d(e,"NonMaxSuppressionV5",function(){return Fr;}),n.d(e,"OneHot",function(){return Nr;}),n.d(e,"Optimizer",function(){return Sh;}),n.d(e,"PadV2",function(){return Mr;}),n.d(e,"RMSPropOptimizer",function(){return Mh;}),n.d(e,"Rank",function(){return Ot;}),n.d(e,"Reduction",function(){return pl;}),n.d(e,"SGDOptimizer",function(){return Ih;}),n.d(e,"Square",function(){return Sr;}),n.d(e,"SquaredDifference",function(){return _r;}),n.d(e,"Tensor",function(){return At;}),n.d(e,"TensorBuffer",function(){return wt;}),n.d(e,"Tile",function(){return Rr;}),n.d(e,"Transpose",function(){return Dr;}),n.d(e,"Variable",function(){return Tt;}),n.d(e,"abs",function(){return Wr;}),n.d(e,"acos",function(){return Vr;}),n.d(e,"acosh",function(){return qr;}),n.d(e,"add",function(){return Pr;}),n.d(e,"addN",function(){return Ps;}),n.d(e,"addStrict",function(){return ki;}),n.d(e,"all",function(){return Ic;}),n.d(e,"any",function(){return Rc;}),n.d(e,"argMax",function(){return Mc;}),n.d(e,"argMin",function(){return jc;}),n.d(e,"asin",function(){return $r;}),n.d(e,"asinh",function(){return Hr;}),n.d(e,"atan",function(){return Gr;}),n.d(e,"atan2",function(){return Ei;}),n.d(e,"atanh",function(){return Kr;}),n.d(e,"avgPool",function(){return kc;}),n.d(e,"avgPool3d",function(){return Ac;}),n.d(e,"backend",function(){return mn;}),n.d(e,"backend_util",function(){return To;}),n.d(e,"basicLSTMCell",function(){return Qc;}),n.d(e,"batchNorm",function(){return qs;}),n.d(e,"batchNorm2d",function(){return Gs;}),n.d(e,"batchNorm3d",function(){return Ys;}),n.d(e,"batchNorm4d",function(){return Zs;}),n.d(e,"batchNormalization",function(){return Vs;}),n.d(e,"batchNormalization2d",function(){return Hs;}),n.d(e,"batchNormalization3d",function(){return Xs;}),n.d(e,"batchNormalization4d",function(){return Qs;}),n.d(e,"batchToSpaceND",function(){return sr;}),n.d(e,"booleanMaskAsync",function(){return Yu;}),n.d(e,"broadcastTo",function(){return tu;}),n.d(e,"browser",function(){return wh;}),n.d(e,"buffer",function(){return or;}),n.d(e,"cast",function(){return ur;}),n.d(e,"ceil",function(){return Xr;}),n.d(e,"clipByValue",function(){return Yr;}),n.d(e,"clone",function(){return eu;}),n.d(e,"complex",function(){return In;}),n.d(e,"concat",function(){return Zn;}),n.d(e,"concat1d",function(){return tr;}),n.d(e,"concat2d",function(){return er;}),n.d(e,"concat3d",function(){return nr;}),n.d(e,"concat4d",function(){return rr;}),n.d(e,"conv1d",function(){return tc;}),n.d(e,"conv2d",function(){return ec;}),n.d(e,"conv2dTranspose",function(){return cc;}),n.d(e,"conv3d",function(){return nc;}),n.d(e,"conv3dTranspose",function(){return lc;}),n.d(e,"cos",function(){return Jr;}),n.d(e,"cosh",function(){return Qr;}),n.d(e,"cumsum",function(){return cr;}),n.d(e,"customGrad",function(){return so;}),n.d(e,"deprecationWarn",function(){return Qe;}),n.d(e,"depthToSpace",function(){return lr;}),n.d(e,"depthwiseConv2d",function(){return oc;}),n.d(e,"diag",function(){return fl;}),n.d(e,"disableDeprecationWarnings",function(){return Je;}),n.d(e,"dispose",function(){return on;}),n.d(e,"disposeVariables",function(){return Ze;}),n.d(e,"div",function(){return Li;}),n.d(e,"divNoNan",function(){return uu;}),n.d(e,"divStrict",function(){return Ci;}),n.d(e,"dot",function(){return hc;}),n.d(e,"dropout",function(){return hl;}),n.d(e,"elu",function(){return qc;}),n.d(e,"enableDebugMode",function(){return Ye;}),n.d(e,"enableProdMode",function(){return Xe;}),n.d(e,"engine",function(){return tn;}),n.d(e,"env",function(){return f;}),n.d(e,"equal",function(){return Ru;}),n.d(e,"equalStrict",function(){return Mu;}),n.d(e,"erf",function(){return Zr;}),n.d(e,"exp",function(){return ti;}),n.d(e,"expandDims",function(){return fr;}),n.d(e,"expm1",function(){return ei;}),n.d(e,"eye",function(){return lu;}),n.d(e,"fft",function(){return il;}),n.d(e,"fill",function(){return Kn;}),n.d(e,"findBackend",function(){return hn;}),n.d(e,"findBackendFactory",function(){return dn;}),n.d(e,"floor",function(){return ni;}),n.d(e,"floorDiv",function(){return Ai;}),n.d(e,"frame",function(){return vl;}),n.d(e,"fused",function(){return Yl;}),n.d(e,"gather",function(){return Ku;}),n.d(e,"gatherND",function(){return ll;}),n.d(e,"gather_util",function(){return Ui;}),n.d(e,"getBackend",function(){return ln;}),n.d(e,"getGradient",function(){return g;}),n.d(e,"getKernel",function(){return m;}),n.d(e,"getKernelsForBackend",function(){return v;}),n.d(e,"grad",function(){return no;}),n.d(e,"grads",function(){return ro;}),n.d(e,"greater",function(){return ju;}),n.d(e,"greaterEqual",function(){return Bu;}),n.d(e,"greaterEqualStrict",function(){return Pu;}),n.d(e,"greaterStrict",function(){return Lu;}),n.d(e,"hammingWindow",function(){return gl;}),n.d(e,"hannWindow",function(){return ml;}),n.d(e,"ifft",function(){return ol;}),n.d(e,"imag",function(){return Mn;}),n.d(e,"image",function(){return Wl;}),n.d(e,"inTopKAsync",function(){return xl;}),n.d(e,"io",function(){return vh;}),n.d(e,"irfft",function(){return sl;}),n.d(e,"isFinite",function(){return pi;}),n.d(e,"isInf",function(){return di;}),n.d(e,"isNaN",function(){return hi;}),n.d(e,"keep",function(){return an;}),n.d(e,"leakyRelu",function(){return $c;}),n.d(e,"less",function(){return zu;}),n.d(e,"lessEqual",function(){return Uu;}),n.d(e,"lessEqualStrict",function(){return Wu;}),n.d(e,"lessStrict",function(){return Vu;}),n.d(e,"linalg",function(){return Ml;}),n.d(e,"linspace",function(){return Xn;}),n.d(e,"localResponseNormalization",function(){return Yc;}),n.d(e,"log",function(){return ri;}),n.d(e,"log1p",function(){return ii;}),n.d(e,"logSigmoid",function(){return oi;}),n.d(e,"logSoftmax",function(){return lo;}),n.d(e,"logSumExp",function(){return Bc;}),n.d(e,"logicalAnd",function(){return nu;}),n.d(e,"logicalNot",function(){return ru;}),n.d(e,"logicalOr",function(){return iu;}),n.d(e,"logicalXor",function(){return ou;}),n.d(e,"losses",function(){return Fl;}),n.d(e,"matMul",function(){return fc;}),n.d(e,"math",function(){return bh;}),n.d(e,"max",function(){return Pc;}),n.d(e,"maxPool",function(){return wc;}),n.d(e,"maxPool3d",function(){return Cc;}),n.d(e,"maxPoolWithArgmax",function(){return Oc;}),n.d(e,"maximum",function(){return Oi;}),n.d(e,"maximumStrict",function(){return _i;}),n.d(e,"mean",function(){return Lc;}),n.d(e,"memory",function(){return en;}),n.d(e,"min",function(){return zc;}),n.d(e,"minimum",function(){return Si;}),n.d(e,"minimumStrict",function(){return Di;}),n.d(e,"mod",function(){return Fi;}),n.d(e,"modStrict",function(){return Ti;}),n.d(e,"moments",function(){return Uc;}),n.d(e,"movingAverage",function(){return tl;}),n.d(e,"mul",function(){return Ni;}),n.d(e,"mulStrict",function(){return Ii;}),n.d(e,"multiRNNCell",function(){return Zc;}),n.d(e,"multinomial",function(){return fu;}),n.d(e,"neg",function(){return ai;}),n.d(e,"nextFrame",function(){return Lh;}),n.d(e,"norm",function(){return Jc;}),n.d(e,"notEqual",function(){return qu;}),n.d(e,"notEqualStrict",function(){return $u;}),n.d(e,"oneHot",function(){return hu;}),n.d(e,"ones",function(){return Hn;}),n.d(e,"onesLike",function(){return Jn;}),n.d(e,"op",function(){return Nn;}),n.d(e,"outerProduct",function(){return dc;}),n.d(e,"pad",function(){return du;}),n.d(e,"pad1d",function(){return pu;}),n.d(e,"pad2d",function(){return mu;}),n.d(e,"pad3d",function(){return gu;}),n.d(e,"pad4d",function(){return vu;}),n.d(e,"pool",function(){return Ec;}),n.d(e,"pow",function(){return Ri;}),n.d(e,"powStrict",function(){return Mi;}),n.d(e,"prelu",function(){return Hc;}),n.d(e,"print",function(){return ar;}),n.d(e,"prod",function(){return Vc;}),n.d(e,"profile",function(){return nn;}),n.d(e,"rand",function(){return yu;}),n.d(e,"randomGamma",function(){return Su;}),n.d(e,"randomNormal",function(){return Du;}),n.d(e,"randomUniform",function(){return Fu;}),n.d(e,"range",function(){return Yn;}),n.d(e,"ready",function(){return cn;}),n.d(e,"real",function(){return Rn;}),n.d(e,"reciprocal",function(){return si;}),n.d(e,"registerBackend",function(){return pn;}),n.d(e,"registerGradient",function(){return b;}),n.d(e,"registerKernel",function(){return y;}),n.d(e,"relu",function(){return Gc;}),n.d(e,"relu6",function(){return Kc;}),n.d(e,"removeBackend",function(){return fn;}),n.d(e,"reshape",function(){return hr;}),n.d(e,"reverse",function(){return pc;}),n.d(e,"reverse1d",function(){return mc;}),n.d(e,"reverse2d",function(){return gc;}),n.d(e,"reverse3d",function(){return vc;}),n.d(e,"reverse4d",function(){return yc;}),n.d(e,"rfft",function(){return al;}),n.d(e,"round",function(){return ui;}),n.d(e,"rsqrt",function(){return ci;}),n.d(e,"scalar",function(){return Pn;}),n.d(e,"scatterND",function(){return rl;}),n.d(e,"scatter_util",function(){return Gi;}),n.d(e,"selu",function(){return Xc;}),n.d(e,"separableConv2d",function(){return uc;}),n.d(e,"serialization",function(){return Ah;}),n.d(e,"setBackend",function(){return un;}),n.d(e,"setPlatform",function(){return gn;}),n.d(e,"setdiff1dAsync",function(){return vr;}),n.d(e,"sigmoid",function(){return li;}),n.d(e,"sign",function(){return fi;}),n.d(e,"signal",function(){return bl;}),n.d(e,"sin",function(){return mi;}),n.d(e,"sinh",function(){return gi;}),n.d(e,"slice",function(){return _c;}),n.d(e,"slice1d",function(){return Sc;}),n.d(e,"slice2d",function(){return Dc;}),n.d(e,"slice3d",function(){return Fc;}),n.d(e,"slice4d",function(){return Tc;}),n.d(e,"slice_util",function(){return eo;}),n.d(e,"softmax",function(){return co;}),n.d(e,"softplus",function(){return vi;}),n.d(e,"spaceToBatchND",function(){return dr;}),n.d(e,"sparseToDense",function(){return cl;}),n.d(e,"spectral",function(){return ul;}),n.d(e,"split",function(){return ir;}),n.d(e,"sqrt",function(){return yi;}),n.d(e,"square",function(){return Tu;}),n.d(e,"squaredDifference",function(){return Nu;}),n.d(e,"squaredDifferenceStrict",function(){return ji;}),n.d(e,"squeeze",function(){return pr;}),n.d(e,"stack",function(){return mr;}),n.d(e,"step",function(){return bi;}),n.d(e,"stft",function(){return yl;}),n.d(e,"stridedSlice",function(){return el;}),n.d(e,"sub",function(){return Bi;}),n.d(e,"subStrict",function(){return Pi;}),n.d(e,"sum",function(){return Wc;}),n.d(e,"sumOutType",function(){return Rt;}),n.d(e,"tan",function(){return xi;}),n.d(e,"tanh",function(){return wi;}),n.d(e,"tensor",function(){return jn;}),n.d(e,"tensor1d",function(){return Ln;}),n.d(e,"tensor2d",function(){return zn;}),n.d(e,"tensor3d",function(){return Un;}),n.d(e,"tensor4d",function(){return Wn;}),n.d(e,"tensor5d",function(){return Vn;}),n.d(e,"tensor6d",function(){return qn;}),n.d(e,"tensor_util",function(){return Lt;}),n.d(e,"test_util",function(){return Cu;}),n.d(e,"tidy",function(){return rn;}),n.d(e,"tile",function(){return cu;}),n.d(e,"time",function(){return sn;}),n.d(e,"topk",function(){return nl;}),n.d(e,"train",function(){return Bh;}),n.d(e,"transpose",function(){return fo;}),n.d(e,"truncatedNormal",function(){return Iu;}),n.d(e,"unregisterGradient",function(){return w;}),n.d(e,"unregisterKernel",function(){return x;}),n.d(e,"unsortedSegmentSum",function(){return Xu;}),n.d(e,"unstack",function(){return gr;}),n.d(e,"util",function(){return ht;}),n.d(e,"valueAndGrad",function(){return io;}),n.d(e,"valueAndGrads",function(){return oo;}),n.d(e,"variable",function(){return $n;}),n.d(e,"variableGrads",function(){return ao;}),n.d(e,"version_core",function(){return Oh;}),n.d(e,"webgl",function(){return _h;}),n.d(e,"where",function(){return au;}),n.d(e,"whereAsync",function(){return su;}),n.d(e,"zeros",function(){return Gn;}),n.d(e,"zerosLike",function(){return Qn;});/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var _a2=function a(t,e){return (_a2=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e;}||function(t,e){for(var n in e){e.hasOwnProperty(n)&&(t[n]=e[n]);}})(t,e);};function s(t,e){function n(){this.constructor=t;}_a2(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n());}function u(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});}function c(t,e){var n,r,i,o,a={label:0,sent:function sent(){if(1&i[0])throw i[1];return i[1];},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this;}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;){try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue;}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break;}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break;}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break;}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(t,a);}catch(t){o=[6,t],r=0;}finally{n=i=0;}}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:!0};}([o,s]);};}}var l=function(){function t(t){this.global=t,this.flags={},this.flagRegistry={},this.urlFlags={},this.populateURLFlags();}return t.prototype.setPlatform=function(t,e){null!=this.platform&&console.warn("Platform "+this.platformName+" has already been set. Overwriting the platform with "+e+"."),this.platformName=t,this.platform=e;},t.prototype.registerFlag=function(t,e,n){if(this.flagRegistry[t]={evaluationFn:e,setHook:n},null!=this.urlFlags[t]){var r=this.urlFlags[t];console.warn("Setting feature override from URL "+t+": "+r+"."),this.set(t,r);}},t.prototype.get=function(t){return t in this.flags?this.flags[t]:(this.flags[t]=this.evaluateFlag(t),this.flags[t]);},t.prototype.getNumber=function(t){return this.get(t);},t.prototype.getBool=function(t){return this.get(t);},t.prototype.getFlags=function(){return this.flags;},Object.defineProperty(t.prototype,"features",{get:function get(){return this.flags;},enumerable:!0,configurable:!0}),t.prototype.set=function(t,e){if(null==this.flagRegistry[t])throw new Error("Cannot set flag "+t+" as it has not been registered.");this.flags[t]=e,null!=this.flagRegistry[t].setHook&&this.flagRegistry[t].setHook(e);},t.prototype.evaluateFlag=function(t){if(null==this.flagRegistry[t])throw new Error("Cannot evaluate flag '"+t+"': no evaluation function found.");return this.flagRegistry[t].evaluationFn();},t.prototype.setFlags=function(t){this.flags=Object.assign({},t);},t.prototype.reset=function(){this.flags={},this.urlFlags={},this.populateURLFlags();},t.prototype.populateURLFlags=function(){var t=this;if(void 0!==this.global&&void 0!==this.global.location&&void 0!==this.global.location.search){var e,n,r=(e=this.global.location.search,n={},e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,function(t){for(var e=[],r=1;r<arguments.length;r++){e[r-1]=arguments[r];}return function(t,e,n){t[decodeURIComponent(e)]=decodeURIComponent(n||"");}(n,e[0],e[1]),e.join("=");}),n);"tfjsflags"in r&&r.tfjsflags.split(",").forEach(function(e){var n=e.split(":"),r=n[0],i=n[1];t.urlFlags[r]=function(t,e){if("true"===(e=e.toLowerCase())||"false"===e)return "true"===e;if(""+ +e===e)return +e;throw new Error("Could not parse value flag value "+e+" for flag "+t+".");}(r,i);});}},t;}();function f(){return h;}var h=null,d=new Map(),p=new Map();function m(t,e){var n=k(t,e);return d.get(n);}function g(t){return p.get(t);}function v(t){for(var e=d.entries(),n=[];;){var r=e.next(),i=r.done,o=r.value;if(i)break;var a=o[0],s=o[1];a.split("_")[0]===t&&n.push(s);}return n;}function y(t){var e=t.kernelName,n=t.backendName,r=k(e,n);if(d.has(r))throw new Error("The kernel '"+e+"' for backend '"+n+"' is already registered");d.set(r,t);}function b(t){var e=t.kernelName;p.has(e)&&console.warn("Overriding the gradient for '"+e+"'"),p.set(e,t);}function x(t,e){var n=k(t,e);if(!d.has(n))throw new Error("The kernel '"+t+"' for backend '"+e+"' is not registered");d.delete(n);}function w(t){if(!p.has(t))throw new Error("The gradient '"+t+"' for backend is not registered");p.delete(t);}function k(t,e){return e+"_"+t;}function E(t){for(var e=t.length,n=0,r=0;e>0;){r=Math.random()*e|0,n=t[--e],t[e]=t[r],t[r]=n;}}function C(t,e,n){return Math.max(t,Math.min(e,n));}function A(t){return t%2==0?t:t+1;}function O(t){for(var e=0,n=0;n<t.length;n++){e+=t[n];}return e;}function _(t,e){if(!t)throw new Error("string"==typeof e?e:e());}function S(t,e,n){void 0===n&&(n=""),_(N(t,e),function(){return n+" Shapes "+t+" and "+e+" must match";});}function D(t){_(null!=t,function(){return "The input to the tensor constructor must be a non-null value.";});}function F(t,e,n){if(void 0===e&&(e=[]),void 0===n&&(n=!1),null==e&&(e=[]),Array.isArray(t)||H(t)&&!n)for(var r=0;r<t.length;++r){F(t[r],e,n);}else e.push(t);return e;}function T(t){if(0===t.length)return 1;for(var e=t[0],n=1;n<t.length;n++){e*=t[n];}return e;}function N(t,e){if(t===e)return !0;if(null==t||null==e)return !1;if(t.length!==e.length)return !1;for(var n=0;n<t.length;n++){if(t[n]!==e[n])return !1;}return !0;}function I(t){return t%1==0;}function R(t){if(null!=Math.tanh)return Math.tanh(t);if(t===1/0)return 1;if(t===-1/0)return -1;var e=Math.exp(2*t);return (e-1)/(e+1);}function M(t){var e=Math.ceil(Math.sqrt(t));return [e,Math.ceil(t/e)];}function j(t,e){return e<=t.length?t:t+" ".repeat(e-t.length);}function B(t,e,n){return void 0===e&&(e=function e(t){return 0;}),new Promise(function(r,i){var o=0,a=function a(){if(t())r();else {var s=e(++o);null!=n&&o>=n?i():setTimeout(a,s);}};a();});}function P(t,e){for(var n=1,r=-1,i=0;i<t.length;++i){if(t[i]>=0)n*=t[i];else if(-1===t[i]){if(-1!==r)throw Error("Shapes can only have 1 implicit size. Found -1 at dim "+r+" and dim "+i);r=i;}else if(t[i]<0)throw Error("Shapes can not be < 0. Found "+t[i]+" at dim "+i);}if(-1===r){if(e>0&&e!==n)throw Error("Size("+e+") must match the product of shape "+t);return t;}if(0===n)throw Error("Cannot infer the missing size in ["+t+"] when there are 0 elements");if(e%n!=0)throw Error("The implicit shape can't be a fractional number. Got "+e+" / "+n);var o=t.slice();return o[r]=e/n,o;}function L(t,e){var n=e.length;return _((t=null==t?e.map(function(t,e){return e;}):[].concat(t)).every(function(t){return t>=-n&&t<n;}),function(){return "All values in axis param must be in range [-"+n+", "+n+") but got axis "+t;}),_(t.every(function(t){return I(t);}),function(){return "All values in axis param must be integers but got axis "+t;}),t.map(function(t){return t<0?n+t:t;});}function z(t,e){for(var n=[],r=[],i=null!=e&&Array.isArray(e)&&0===e.length,o=null==e||i?null:L(e,t).sort(),a=0,s=0;s<t.length;++s){if(null!=o){if(o[a]===s&&1!==t[s])throw new Error("Can't squeeze axis "+s+" since its dim '"+t[s]+"' is not 1");(null==o[a]||o[a]>s)&&1===t[s]&&(n.push(t[s]),r.push(s)),o[a]<=s&&a++;}1!==t[s]&&(n.push(t[s]),r.push(s));}return {newShape:n,keptDims:r};}function U(t,e){var n=null;if(null==t||"float32"===t)n=new Float32Array(e);else if("int32"===t)n=new Int32Array(e);else {if("bool"!==t)throw new Error("Unknown data type "+t);n=new Uint8Array(e);}return n;}function W(t,e){var n=null;if(null==t||"float32"===t)n=new Float32Array(e);else if("int32"===t)n=new Int32Array(e);else if("bool"===t)n=new Uint8Array(e);else {if("string"!==t)throw new Error("Unknown data type "+t);n=new Array(e);}return n;}function V(t,e){for(var n=0;n<t.length;n++){var r=t[n];if(isNaN(r)||!isFinite(r))throw Error("A tensor of type "+e+" being uploaded contains "+r+".");}}function q(t){return "bool"===t||"complex64"===t||"float32"===t||"int32"===t||"string"===t;}function $(t,e){return !("complex64"===e||"float32"===e&&"complex64"!==t||"int32"===e&&"float32"!==t&&"complex64"!==t||"bool"===e&&"bool"===t);}function H(t){return t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array;}function G(t){if("float32"===t||"int32"===t)return 4;if("complex64"===t)return 8;if("bool"===t)return 1;throw new Error("Unknown dtype "+t);}function K(t){if(null==t)return 0;var e=0;return t.forEach(function(t){return e+=t.length;}),e;}function X(t){return "string"==typeof t||t instanceof String;}function Y(t){return "boolean"==typeof t;}function J(t){return "number"==typeof t;}function Q(t){return Array.isArray(t)?Q(t[0]):t instanceof Float32Array?"float32":t instanceof Int32Array||t instanceof Uint8Array?"int32":J(t)?"float32":X(t)?"string":Y(t)?"bool":"float32";}function Z(t){return !!(t&&t.constructor&&t.call&&t.apply);}function tt(t,e){for(var n=e;n<t;++n){if(t%n==0)return n;}return t;}function et(t){var e=t.length;if(e<2)return [];var n=new Array(e-1);n[e-2]=t[e-1];for(var r=e-3;r>=0;--r){n[r]=n[r+1]*t[r+1];}return n;}function nt(t,e,n){if("string"===e)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(t)&&(t=F(t)),n&&V(t,e),function(t,e){return t instanceof Float32Array&&"float32"===e||t instanceof Int32Array&&"int32"===e||t instanceof Uint8Array&&"bool"===e;}(t,e))return t;if(null==e||"float32"===e||"complex64"===e)return new Float32Array(t);if("int32"===e)return new Int32Array(t);if("bool"===e){for(var r=new Uint8Array(t.length),i=0;i<r.length;++i){0!==Math.round(t[i])&&(r[i]=1);}return r;}throw new Error("Unknown data type "+e);}function rt(t,e){if(0===t.length)return e[0];var n=t.reduce(function(t,e){return t*e;});if(0===n)return [];if(n!==e.length)throw new Error("["+t+"] does not match the input size.");return function t(e,n,r){var i=new Array();if(1===n.length)for(var o=n[0],a=0;a<o;a++){i[a]=r[e+a];}else {o=n[0];var s=n.slice(1),u=s.reduce(function(t,e){return t*e;});for(a=0;a<o;a++){i[a]=t(e+a*u,s,r);}}return i;}(0,t,e);}function it(t,e){for(var n=ot(t,e),r=0;r<n.length;r++){n[r]=1;}return n;}function ot(t,e){if(null==e||"float32"===e||"complex64"===e)return new Float32Array(t);if("int32"===e)return new Int32Array(t);if("bool"===e)return new Uint8Array(t);throw new Error("Unknown data type "+e);}function at(){return f().platform.now();}function st(t){t.forEach(function(e){_(Number.isInteger(e)&&e>=0,function(){return "Tensor must have a shape comprised of positive integers but got shape ["+t+"].";});});}function ut(t,e){return void 0===e&&(e="utf-8"),e=e||"utf-8",f().platform.encode(t,e);}function ct(t,e){return void 0===e&&(e="utf-8"),e=e||"utf-8",f().platform.decode(t,e);}function lt(t,e,n){if(0===e)return 0;if(1===e)return t[0];for(var r=t[t.length-1],i=0;i<t.length-1;++i){r+=n[i]*t[i];}return r;}function ft(t,e,n){if(0===e)return [];if(1===e)return [t];for(var r=new Array(e),i=0;i<r.length-1;++i){r[i]=Math.floor(t/n[i]),t-=r[i]*n[i];}return r[r.length-1]=t,r;}var ht=Object.freeze({shuffle:E,clamp:C,nearestLargerEven:A,sum:O,randUniform:function randUniform(t,e){var n=Math.random();return e*n+(1-n)*t;},distSquared:function distSquared(t,e){for(var n=0,r=0;r<t.length;r++){var i=Number(t[r])-Number(e[r]);n+=i*i;}return n;},assert:_,assertShapesMatch:S,assertNonNull:D,flatten:F,sizeFromShape:T,isScalarShape:function isScalarShape(t){return 0===t.length;},arraysEqual:N,isInt:I,tanh:R,sizeToSquarishShape:M,createShuffledIndices:function createShuffledIndices(t){for(var e=new Uint32Array(t),n=0;n<t;++n){e[n]=n;}return E(e),e;},rightPad:j,repeatedTry:B,inferFromImplicitShape:P,parseAxisParam:L,squeezeShape:z,getTypedArrayFromDType:U,getArrayFromDType:W,checkConversionForErrors:V,isValidDtype:q,hasEncodingLoss:$,isTypedArray:H,bytesPerElement:G,bytesFromStringArray:K,isString:X,isBoolean:Y,isNumber:J,inferDtype:Q,isFunction:Z,nearestDivisor:tt,computeStrides:et,toTypedArray:nt,toNestedArray:rt,makeOnesTypedArray:it,makeZerosTypedArray:ot,now:at,assertNonNegativeIntegerDimensions:st,fetch:function fetch(t,e){return f().platform.fetch(t,e);},encodeString:ut,decodeString:ct,locToIndex:lt,indexToLoc:ft}),dt=function(){function t(t,e){this.backendTimer=t,this.logger=e,null==e&&(this.logger=new pt());}return t.prototype.profileKernel=function(t,e,n){var r,i=this,o=this.backendTimer.time(function(){r=n();});return r.forEach(function(n){n.data().then(function(r){!function(t,e,n){if("float32"!==e)return !1;for(var r=0;r<t.length;r++){var i=t[r];if(isNaN(i)||!isFinite(i))return console.warn("Found "+i+" in the result of '"+n+"'"),!0;}}(r,n.dtype,t),o.then(function(o){var a="";null!=o.getExtraProfileInfo&&(a=o.getExtraProfileInfo()),i.logger.logKernelProfile(t,n,r,o.kernelMs,e,a);});});}),r;},t;}(),pt=function(){function t(){}return t.prototype.logKernelProfile=function(t,e,n,r,i,o){var a="number"==typeof r?j(r+"ms",9):r.error,s=j(t,25),u=e.rank,c=e.size,l=j(e.shape.toString(),14),f="";for(var h in i){var d=i[h].shape||e.shape,p=d.length;f+=h+": "+p+"D "+(p>0?d:"")+" ";}console.log("%c"+s+"\t%c"+a+"\t%c"+u+"D "+l+"\t%c"+c+"\t%c"+f+"\t%c"+o,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue");},t;}(),mt=20,gt=3,vt=7;function yt(t,e,n){return j(Array.isArray(t)?parseFloat(t[0].toFixed(vt))+" + "+parseFloat(t[1].toFixed(vt))+"j":X(t)?"'"+t+"'":"bool"===n?bt(t):parseFloat(t.toFixed(vt)).toString(),e);}function bt(t){return 0===t?"false":"true";}function xt(t){for(var e=[],n=0;n<t.length;n+=2){e.push([t[n],t[n+1]]);}return e;}var wt=function(){function t(t,e,n){var r=this;if(this.dtype=e,this.shape=t.slice(),this.size=T(t),null!=n){var i=n.length;_(i===this.size,function(){return "Length of values '"+i+"' does not match the size inferred by the shape '"+r.size+"'.";});}if("complex64"===e)throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||W(e,this.size),this.strides=et(t);}return t.prototype.set=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++){n[r-1]=arguments[r];}0===n.length&&(n=[0]),_(n.length===this.rank,function(){return "The number of provided coordinates ("+n.length+") must match the rank ("+e.rank+")";});var i=this.locToIndex(n);this.values[i]=t;},t.prototype.get=function(){for(var t=[],e=0;e<arguments.length;e++){t[e]=arguments[e];}0===t.length&&(t=[0]);for(var n=0,r=0,i=t;r<i.length;r++){var o=i[r];if(o<0||o>=this.shape[n]){var a="Requested out of range element at "+t+".   Buffer shape="+this.shape;throw new Error(a);}n++;}for(var s=t[t.length-1],u=0;u<t.length-1;++u){s+=this.strides[u]*t[u];}return this.values[s];},t.prototype.locToIndex=function(t){if(0===this.rank)return 0;if(1===this.rank)return t[0];for(var e=t[t.length-1],n=0;n<t.length-1;++n){e+=this.strides[n]*t[n];}return e;},t.prototype.indexToLoc=function(t){if(0===this.rank)return [];if(1===this.rank)return [t];for(var e=new Array(this.shape.length),n=0;n<e.length-1;++n){e[n]=Math.floor(t/this.strides[n]),t-=e[n]*this.strides[n];}return e[e.length-1]=t,e;},Object.defineProperty(t.prototype,"rank",{get:function get(){return this.shape.length;},enumerable:!0,configurable:!0}),t.prototype.toTensor=function(){return kt().makeTensor(this.values,this.shape,this.dtype);},t;}(),kt=null,Et=null,Ct=null,At=function(){function t(t,e,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=t.slice(),this.dtype=e||"float32",this.size=T(t),this.strides=et(t),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher";}return t.prototype.flatten=function(){return this.throwIfDisposed(),this.as1D();},t.prototype.asScalar=function(){return this.throwIfDisposed(),_(1===this.size,function(){return "The array must have only 1 element.";}),this.reshape([]);},t.prototype.as1D=function(){return this.throwIfDisposed(),this.reshape([this.size]);},t.prototype.as2D=function(t,e){return this.throwIfDisposed(),this.reshape([t,e]);},t.prototype.as3D=function(t,e,n){return this.throwIfDisposed(),this.reshape([t,e,n]);},t.prototype.as4D=function(t,e,n,r){return this.throwIfDisposed(),this.reshape([t,e,n,r]);},t.prototype.as5D=function(t,e,n,r,i){return this.throwIfDisposed(),this.reshape([t,e,n,r,i]);},t.prototype.asType=function(t){return this.throwIfDisposed(),Et.cast(this,t);},Object.defineProperty(t.prototype,"rank",{get:function get(){return this.shape.length;},enumerable:!0,configurable:!0}),t.prototype.buffer=function(){return u(this,void 0,void 0,function(){var t;return c(this,function(e){switch(e.label){case 0:return [4,this.data()];case 1:return t=e.sent(),[2,Et.buffer(this.shape,this.dtype,t)];}});});},t.prototype.bufferSync=function(){return Et.buffer(this.shape,this.dtype,this.dataSync());},t.prototype.array=function(){return u(this,void 0,void 0,function(){var t;return c(this,function(e){switch(e.label){case 0:return [4,this.data()];case 1:return t=e.sent(),[2,rt(this.shape,t)];}});});},t.prototype.arraySync=function(){return rt(this.shape,this.dataSync());},t.prototype.data=function(){return u(this,void 0,void 0,function(){var t,e;return c(this,function(n){switch(n.label){case 0:return this.throwIfDisposed(),t=kt().read(this.dataId),"string"!==this.dtype?[3,2]:[4,t];case 1:e=n.sent();try{return [2,e.map(function(t){return ct(t);})];}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().");}n.label=2;case 2:return [2,t];}});});},t.prototype.dataSync=function(){this.throwIfDisposed();var t=kt().readSync(this.dataId);if("string"===this.dtype)try{return t.map(function(t){return ct(t);});}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().");}return t;},t.prototype.bytes=function(){return u(this,void 0,void 0,function(){var t;return c(this,function(e){switch(e.label){case 0:return this.throwIfDisposed(),[4,kt().read(this.dataId)];case 1:return t=e.sent(),"string"===this.dtype?[2,t]:[2,new Uint8Array(t.buffer)];}});});},t.prototype.dispose=function(){this.isDisposed||(kt().disposeTensor(this),this.isDisposedInternal=!0);},Object.defineProperty(t.prototype,"isDisposed",{get:function get(){return this.isDisposedInternal;},enumerable:!0,configurable:!0}),t.prototype.throwIfDisposed=function(){if(this.isDisposed)throw new Error("Tensor is disposed.");},t.prototype.toFloat=function(){return this.asType("float32");},t.prototype.toInt=function(){return this.asType("int32");},t.prototype.toBool=function(){return this.asType("bool");},t.prototype.print=function(t){return void 0===t&&(t=!1),Et.print(this,t);},t.prototype.reshape=function(t){return this.throwIfDisposed(),Et.reshape(this,t);},t.prototype.reshapeAs=function(t){return this.throwIfDisposed(),this.reshape(t.shape);},t.prototype.expandDims=function(t){return void 0===t&&(t=0),Et.expandDims(this,t);},t.prototype.cumsum=function(t,e,n){return void 0===t&&(t=0),void 0===e&&(e=!1),void 0===n&&(n=!1),Et.cumsum(this,t,e,n);},t.prototype.squeeze=function(t){return this.throwIfDisposed(),Et.squeeze(this,t);},t.prototype.clone=function(){return this.throwIfDisposed(),Et.clone(this);},t.prototype.toString=function(t){return void 0===t&&(t=!1),function(t,e,n,r){var i=et(e),o=function(t,e,n,r){var i=T(e),o=r[r.length-1],a=new Array(o).fill(0),s=e.length,u="complex64"===n?xt(t):t;if(s>1)for(var c=0;c<i/o;c++){for(var l=c*o,f=0;f<o;f++){a[f]=Math.max(a[f],yt(u[l+f],0,n).length);}}return a;}(t,e,n,i),a=e.length,s=function t(e,n,r,i,o,a){void 0===a&&(a=!0);var s="complex64"===r?2:1,u=n[0],c=n.length;if(0===c)return "complex64"===r?[yt(xt(e)[0],0,r)]:"bool"===r?[bt(e[0])]:[e[0].toString()];if(1===c){if(u>mt){var l=gt*s,f=Array.from(e.slice(0,l)),h=Array.from(e.slice((u-gt)*s,u*s));return "complex64"===r&&(f=xt(f),h=xt(h)),["["+f.map(function(t,e){return yt(t,o[e],r);}).join(", ")+", ..., "+h.map(function(t,e){return yt(t,o[u-gt+e],r);}).join(", ")+"]"];}return ["["+("complex64"===r?xt(e):Array.from(e)).map(function(t,e){return yt(t,o[e],r);}).join(", ")+"]"];}var d=n.slice(1),p=i.slice(1),m=i[0]*s,g=[];if(u>mt){for(var v=0;v<gt;v++){var y=(b=v*m)+m;g.push.apply(g,t(e.slice(b,y),d,r,p,o,!1));}for(g.push("..."),v=u-gt;v<u;v++){y=(b=v*m)+m,g.push.apply(g,t(e.slice(b,y),d,r,p,o,v===u-1));}}else for(v=0;v<u;v++){var b;y=(b=v*m)+m,g.push.apply(g,t(e.slice(b,y),d,r,p,o,v===u-1));}var x=2===c?",":"";for(g[0]="["+g[0]+x,v=1;v<g.length-1;v++){g[v]=" "+g[v]+x;}var w=",\n";for(v=2;v<c;v++){w+="\n";}return g[g.length-1]=" "+g[g.length-1]+"]"+(a?"":w),g;}(t,e,n,i,o),u=["Tensor"];return r&&(u.push("  dtype: "+n),u.push("  rank: "+a),u.push("  shape: ["+e+"]"),u.push("  values:")),u.push(s.map(function(t){return "    "+t;}).join("\n")),u.join("\n");}(this.dataSync(),this.shape,this.dtype,t);},t.prototype.gather=function(t,e){return void 0===e&&(e=0),this.throwIfDisposed(),Et.gather(this,t,e);},t.prototype.matMul=function(t,e,n){return void 0===e&&(e=!1),void 0===n&&(n=!1),this.throwIfDisposed(),Et.matMul(this,t,e,n);},t.prototype.dot=function(t){return this.throwIfDisposed(),Et.dot(this,t);},t.prototype.norm=function(t,e,n){return void 0===t&&(t="euclidean"),void 0===e&&(e=null),void 0===n&&(n=!1),this.throwIfDisposed(),Et.norm(this,t,e,n);},t.prototype.slice=function(t,e){return this.throwIfDisposed(),Et.slice(this,t,e);},t.prototype.reverse=function(t){return this.throwIfDisposed(),Et.reverse(this,t);},t.prototype.concat=function(e,n){return void 0===n&&(n=0),this.throwIfDisposed(),e instanceof t&&(e=[e]),Et.concat([this].concat(e),n);},t.prototype.split=function(t,e){return void 0===e&&(e=0),this.throwIfDisposed(),Et.split(this,t,e);},t.prototype.stack=function(t,e){return void 0===e&&(e=0),Et.stack([this,t],e);},t.prototype.unstack=function(t){return void 0===t&&(t=0),Et.unstack(this,t);},t.prototype.batchNormalization=function(t,e,n,r,i){return void 0===n&&(n=.001),Ct("tf.batchNormalization() is going away. Use tf.batchNorm() instead, and note the positional argument change of scale, offset, and varianceEpsilon"),this.batchNorm(t,e,i,r,n);},t.prototype.all=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),Et.all(this,t,e);},t.prototype.any=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),Et.any(this,t,e);},t.prototype.logSumExp=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),Et.logSumExp(this,t,e);},t.prototype.sum=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),Et.sum(this,t,e);},t.prototype.prod=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),Et.prod(this,t,e);},t.prototype.mean=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),Et.mean(this,t,e);},t.prototype.min=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),Et.min(this,t,e);},t.prototype.max=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),Et.max(this,t,e);},t.prototype.argMin=function(t){return void 0===t&&(t=null),this.throwIfDisposed(),Et.argMin(this,t);},t.prototype.argMax=function(t){return void 0===t&&(t=null),this.throwIfDisposed(),Et.argMax(this,t);},t.prototype.cast=function(t){return this.throwIfDisposed(),Et.cast(this,t);},t.prototype.addStrict=function(t){return this.throwIfDisposed(),Et.addStrict(this,t);},t.prototype.atan2=function(t){return this.throwIfDisposed(),Et.atan2(this,t);},t.prototype.sub=function(t){return this.throwIfDisposed(),Et.sub(this,t);},t.prototype.subStrict=function(t){return this.throwIfDisposed(),Et.subStrict(this,t);},t.prototype.pow=function(t){return this.throwIfDisposed(),Et.pow(this,t);},t.prototype.powStrict=function(t){return this.throwIfDisposed(),Et.powStrict(this,t);},t.prototype.mul=function(t){return this.throwIfDisposed(),Et.mul(this,t);},t.prototype.mulStrict=function(t){return this.throwIfDisposed(),Et.mulStrict(this,t);},t.prototype.floorDiv=function(t){return this.throwIfDisposed(),Et.floorDiv(this,t);},t.prototype.divStrict=function(t){return this.throwIfDisposed(),Et.divStrict(this,t);},t.prototype.minimum=function(t){return this.throwIfDisposed(),Et.minimum(this,t);},t.prototype.minimumStrict=function(t){return this.throwIfDisposed(),Et.minimumStrict(this,t);},t.prototype.maximum=function(t){return this.throwIfDisposed(),Et.maximum(this,t);},t.prototype.maximumStrict=function(t){return this.throwIfDisposed(),Et.maximumStrict(this,t);},t.prototype.mod=function(t){return this.throwIfDisposed(),Et.mod(this,t);},t.prototype.modStrict=function(t){return this.throwIfDisposed(),Et.modStrict(this,t);},t.prototype.squaredDifferenceStrict=function(t){return this.throwIfDisposed(),Et.squaredDifferenceStrict(this,t);},t.prototype.notEqual=function(t){return this.throwIfDisposed(),Et.notEqual(this,t);},t.prototype.notEqualStrict=function(t){return this.throwIfDisposed(),Et.notEqualStrict(this,t);},t.prototype.less=function(t){return this.throwIfDisposed(),Et.less(this,t);},t.prototype.lessStrict=function(t){return this.throwIfDisposed(),Et.lessStrict(this,t);},t.prototype.equal=function(t){return this.throwIfDisposed(),Et.equal(this,t);},t.prototype.equalStrict=function(t){return this.throwIfDisposed(),Et.equalStrict(this,t);},t.prototype.lessEqual=function(t){return this.throwIfDisposed(),Et.lessEqual(this,t);},t.prototype.lessEqualStrict=function(t){return this.throwIfDisposed(),Et.lessEqualStrict(this,t);},t.prototype.greater=function(t){return this.throwIfDisposed(),Et.greater(this,t);},t.prototype.greaterStrict=function(t){return this.throwIfDisposed(),Et.greaterStrict(this,t);},t.prototype.greaterEqual=function(t){return this.throwIfDisposed(),Et.greaterEqual(this,t);},t.prototype.greaterEqualStrict=function(t){return this.throwIfDisposed(),Et.greaterEqualStrict(this,t);},t.prototype.logicalAnd=function(t){return this.throwIfDisposed(),Et.logicalAnd(this,t);},t.prototype.logicalOr=function(t){return this.throwIfDisposed(),Et.logicalOr(this,t);},t.prototype.logicalNot=function(){return this.throwIfDisposed(),Et.logicalNot(this);},t.prototype.logicalXor=function(t){return this.throwIfDisposed(),Et.logicalXor(this,t);},t.prototype.where=function(t,e){return this.throwIfDisposed(),Et.where(t,this,e);},t.prototype.neg=function(){return this.throwIfDisposed(),Et.neg(this);},t.prototype.ceil=function(){return this.throwIfDisposed(),Et.ceil(this);},t.prototype.floor=function(){return this.throwIfDisposed(),Et.floor(this);},t.prototype.sign=function(){return this.throwIfDisposed(),Et.sign(this);},t.prototype.isNaN=function(){return this.throwIfDisposed(),Et.isNaN(this);},t.prototype.isInf=function(){return this.throwIfDisposed(),Et.isInf(this);},t.prototype.isFinite=function(){return this.throwIfDisposed(),Et.isFinite(this);},t.prototype.exp=function(){return this.throwIfDisposed(),Et.exp(this);},t.prototype.expm1=function(){return this.throwIfDisposed(),Et.expm1(this);},t.prototype.log=function(){return this.throwIfDisposed(),Et.log(this);},t.prototype.log1p=function(){return this.throwIfDisposed(),Et.log1p(this);},t.prototype.sqrt=function(){return this.throwIfDisposed(),Et.sqrt(this);},t.prototype.rsqrt=function(){return this.throwIfDisposed(),Et.rsqrt(this);},t.prototype.square=function(){return this.throwIfDisposed(),Et.square(this);},t.prototype.reciprocal=function(){return this.throwIfDisposed(),Et.reciprocal(this);},t.prototype.abs=function(){return this.throwIfDisposed(),Et.abs(this);},t.prototype.clipByValue=function(t,e){return this.throwIfDisposed(),Et.clipByValue(this,t,e);},t.prototype.relu=function(){return this.throwIfDisposed(),Et.relu(this);},t.prototype.relu6=function(){return this.throwIfDisposed(),Et.relu6(this);},t.prototype.elu=function(){return this.throwIfDisposed(),Et.elu(this);},t.prototype.selu=function(){return this.throwIfDisposed(),Et.selu(this);},t.prototype.leakyRelu=function(t){return void 0===t&&(t=.2),this.throwIfDisposed(),Et.leakyRelu(this,t);},t.prototype.prelu=function(t){return this.throwIfDisposed(),Et.prelu(this,t);},t.prototype.sigmoid=function(){return this.throwIfDisposed(),Et.sigmoid(this);},t.prototype.logSigmoid=function(){return this.throwIfDisposed(),Et.logSigmoid(this);},t.prototype.softplus=function(){return this.throwIfDisposed(),Et.softplus(this);},t.prototype.zerosLike=function(){return this.throwIfDisposed(),Et.zerosLike(this);},t.prototype.onesLike=function(){return this.throwIfDisposed(),Et.onesLike(this);},t.prototype.sin=function(){return this.throwIfDisposed(),Et.sin(this);},t.prototype.cos=function(){return this.throwIfDisposed(),Et.cos(this);},t.prototype.tan=function(){return this.throwIfDisposed(),Et.tan(this);},t.prototype.asin=function(){return this.throwIfDisposed(),Et.asin(this);},t.prototype.acos=function(){return this.throwIfDisposed(),Et.acos(this);},t.prototype.atan=function(){return this.throwIfDisposed(),Et.atan(this);},t.prototype.sinh=function(){return this.throwIfDisposed(),Et.sinh(this);},t.prototype.cosh=function(){return this.throwIfDisposed(),Et.cosh(this);},t.prototype.tanh=function(){return this.throwIfDisposed(),Et.tanh(this);},t.prototype.asinh=function(){return this.throwIfDisposed(),Et.asinh(this);},t.prototype.acosh=function(){return this.throwIfDisposed(),Et.acosh(this);},t.prototype.atanh=function(){return this.throwIfDisposed(),Et.atanh(this);},t.prototype.erf=function(){return this.throwIfDisposed(),Et.erf(this);},t.prototype.round=function(){return this.throwIfDisposed(),Et.round(this);},t.prototype.step=function(t){return void 0===t&&(t=0),this.throwIfDisposed(),Et.step(this,t);},t.prototype.softmax=function(t){return void 0===t&&(t=-1),this.throwIfDisposed(),Et.softmax(this,t);},t.prototype.logSoftmax=function(t){return void 0===t&&(t=-1),this.throwIfDisposed(),Et.logSoftmax(this,t);},t.prototype.resizeBilinear=function(t,e){return void 0===e&&(e=!1),this.throwIfDisposed(),Et.image.resizeBilinear(this,t,e);},t.prototype.resizeNearestNeighbor=function(t,e){return void 0===e&&(e=!1),this.throwIfDisposed(),Et.image.resizeNearestNeighbor(this,t,e);},t.prototype.conv1d=function(t,e,n,r,i,o){return void 0===r&&(r="NWC"),void 0===i&&(i=1),this.throwIfDisposed(),Et.conv1d(this,t,e,n,r,i,o);},t.prototype.conv2d=function(t,e,n,r,i,o){return void 0===r&&(r="NHWC"),void 0===i&&(i=[1,1]),this.throwIfDisposed(),Et.conv2d(this,t,e,n,r,i,o);},t.prototype.conv2dTranspose=function(t,e,n,r,i){return this.throwIfDisposed(),Et.conv2dTranspose(this,t,e,n,r,i);},t.prototype.depthwiseConv2D=function(t,e,n,r,i,o){return void 0===r&&(r="NHWC"),void 0===i&&(i=[1,1]),this.throwIfDisposed(),Et.depthwiseConv2d(this,t,e,n,r,i,o);},t.prototype.separableConv2d=function(t,e,n,r,i,o){return void 0===i&&(i=[1,1]),void 0===o&&(o="NHWC"),this.throwIfDisposed(),Et.separableConv2d(this,t,e,n,r,i,o);},t.prototype.avgPool=function(t,e,n,r){return this.throwIfDisposed(),Et.avgPool(this,t,e,n,r);},t.prototype.maxPool=function(t,e,n,r){return this.throwIfDisposed(),Et.maxPool(this,t,e,n,r);},t.prototype.localResponseNormalization=function(t,e,n,r){return void 0===t&&(t=5),void 0===e&&(e=1),void 0===n&&(n=1),void 0===r&&(r=.5),Et.localResponseNormalization(this,t,e,n,r);},t.prototype.pool=function(t,e,n,r,i){return this.throwIfDisposed(),Et.pool(this,t,e,n,r,i);},t.prototype.variable=function(t,e,n){return void 0===t&&(t=!0),this.throwIfDisposed(),kt().makeVariable(this,t,e,n);},t.prototype.unsortedSegmentSum=function(t,e){return this.throwIfDisposed(),Et.unsortedSegmentSum(this,t,e);},t.prototype.batchToSpaceND=function(t,e){return this.throwIfDisposed(),Et.batchToSpaceND(this,t,e);},t.prototype.spaceToBatchND=function(t,e){return this.throwIfDisposed(),Et.spaceToBatchND(this,t,e);},t.prototype.topk=function(t,e){return void 0===t&&(t=1),void 0===e&&(e=!0),this.throwIfDisposed(),Et.topk(this,t,e);},t.prototype.stridedSlice=function(t,e,n,r,i,o,a,s){return void 0===r&&(r=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===a&&(a=0),void 0===s&&(s=0),this.throwIfDisposed(),Et.stridedSlice(this,t,e,n,r,i,o,a,s);},t.prototype.depthToSpace=function(t,e){return this.throwIfDisposed(),Et.depthToSpace(this,t,e);},t.prototype.fft=function(){return this.throwIfDisposed(),Et.spectral.fft(this);},t.prototype.ifft=function(){return this.throwIfDisposed(),Et.spectral.ifft(this);},t.prototype.rfft=function(){return this.throwIfDisposed(),Et.spectral.rfft(this);},t.prototype.irfft=function(){return this.throwIfDisposed(),Et.spectral.irfft(this);},t;}();Object.defineProperty(At,Symbol.hasInstance,{value:function value(t){return !!t&&null!=t.dataId&&null!=t.shape&&null!=t.dtype;}});var Ot,_t,St,Dt,Ft,Tt=function(t){function e(e,n,r,i){var o=t.call(this,e.shape,e.dtype,e.dataId,i)||this;return o.trainable=n,o.name=r,o;}return s(e,t),e.prototype.assign=function(t){if(t.dtype!==this.dtype)throw new Error("dtype of the new value ("+t.dtype+") and previous value ("+this.dtype+") must match");if(!N(t.shape,this.shape))throw new Error("shape of the new value ("+t.shape+") and previous value ("+this.shape+") must match");kt().disposeTensor(this),this.dataId=t.dataId,kt().incRef(this,null);},e.prototype.dispose=function(){kt().disposeVariable(this),this.isDisposedInternal=!0;},e;}(At);Object.defineProperty(Tt,Symbol.hasInstance,{value:function value(t){return t instanceof At&&null!=t.assign&&t.assign instanceof Function;}}),function(t){t.R0="R0",t.R1="R1",t.R2="R2",t.R3="R3",t.R4="R4",t.R5="R5",t.R6="R6";}(Ot||(Ot={})),function(t){t.float32="float32",t.int32="int32",t.bool="int32",t.complex64="complex64";}(_t||(_t={})),function(t){t.float32="float32",t.int32="int32",t.bool="bool",t.complex64="complex64";}(St||(St={})),function(t){t.float32="float32",t.int32="float32",t.bool="float32",t.complex64="complex64";}(Dt||(Dt={})),function(t){t.float32="complex64",t.int32="complex64",t.bool="complex64",t.complex64="complex64";}(Ft||(Ft={}));var Nt={float32:Dt,int32:_t,bool:St,complex64:Ft};function It(t,e){if("string"===t||"string"===e){if("string"===t&&"string"===e)return "string";throw new Error("Can not upcast "+t+" with "+e);}return Nt[t][e];}function Rt(t){return It(t,"int32");}function Mt(t,e){if(t.dtype===e.dtype)return [t,e];var n=It(t.dtype,e.dtype);return [t.cast(n),e.cast(n)];}function jt(t,e){_(t.dtype===e.dtype,function(){return "The dtypes of the first("+t.dtype+") and second("+e.dtype+") input must match";});}function Bt(t){var e=[];return function t(e,n,r){if(null!=e)if(e instanceof At)n.push(e);else if(i=e,Array.isArray(i)||"object"==_typeof$1(i)){var i,o=e;for(var a in o){var s=o[a];r.has(s)||(r.add(s),t(s,n,r));}}}(t,e,new Set()),e;}var Pt,Lt=Object.freeze({makeTypesMatch:Mt,assertTypesMatch:jt,isTensorInList:function isTensorInList(t,e){return e.some(function(e){return e.id===t.id;});},getTensorsInContainer:Bt}),zt=function(){function t(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap(),this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null};}return t.prototype.dispose=function(){for(var t in this.registeredVariables){this.registeredVariables[t].dispose();}},t;}(),Ut=function(){function t(t){this.ENV=t,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new zt();}return t.prototype.ready=function(){return u(this,void 0,void 0,function(){var t,e,n;return c(this,function(r){switch(r.label){case 0:if(null!=this.pendingBackendInit)return [2,this.pendingBackendInit.then(function(){})];if(null!=this.backendInstance)return [2];t=this.getSortedBackends(),e=0,r.label=1;case 1:return e<t.length?(n=t[e],[4,this.initializeBackend(n).success]):[3,5];case 2:return r.sent()?[4,this.setBackend(n)]:[3,4];case 3:return r.sent(),[2];case 4:return e++,[3,1];case 5:throw new Error("Could not initialize any backends, all backend initializations failed.");}});});},Object.defineProperty(t.prototype,"backend",{get:function get(){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");if(null==this.backendInstance){var t=this.initializeBackendsAndReturnBest(),e=t.name;if(t.asyncInit)throw new Error("The highest priority backend '"+e+"' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods");this.setBackend(e);}return this.backendInstance;},enumerable:!0,configurable:!0}),t.prototype.backendNames=function(){return Object.keys(this.registryFactory);},t.prototype.findBackend=function(t){if(!(t in this.registry)){if(!(t in this.registryFactory))return null;if(this.initializeBackend(t).asyncInit)return null;}return this.registry[t];},t.prototype.findBackendFactory=function(t){return t in this.registryFactory?this.registryFactory[t].factory:null;},t.prototype.registerBackend=function(t,e,n){return void 0===n&&(n=1),t in this.registryFactory?(console.warn(t+" backend was already registered. Reusing existing backend factory."),!1):(this.registryFactory[t]={factory:e,priority:n},!0);},t.prototype.setBackend=function(t){return u(this,void 0,void 0,function(){var e,n,r;return c(this,function(i){switch(i.label){case 0:if(null==this.registryFactory[t])throw new Error("Backend name '"+t+"' not found in registry");return this.backendName=t,null!=this.registry[t]?[3,4]:(this.backendInstance=null,e=this.initializeBackend(t),n=e.success,e.asyncInit?[4,n]:[3,2]);case 1:return r=i.sent(),[3,3];case 2:r=n,i.label=3;case 3:if(!r)return [2,!1];i.label=4;case 4:return this.backendInstance=this.registry[t],this.setupRegisteredKernels(),this.profiler=new dt(this.backendInstance),[2,!0];}});});},t.prototype.setupRegisteredKernels=function(){var t=this;v(this.backendName).forEach(function(e){null!=e.setupFunc&&e.setupFunc(t.backendInstance);});},t.prototype.disposeRegisteredKernels=function(t){var e=this;v(t).forEach(function(n){null!=n.disposeFunc&&n.disposeFunc(e.registry[t]);});},t.prototype.initializeBackend=function(t){var e=this,n=this.registryFactory[t];if(null==n)throw new Error("Cannot initialize backend "+t+", no registration found.");try{var r=n.factory();if(Promise.resolve(r)===r){var i=++this.pendingBackendInitId,o=r.then(function(n){return !(i<e.pendingBackendInitId||(e.registry[t]=n,e.pendingBackendInit=null,0));}).catch(function(n){return !(i<e.pendingBackendInitId||(e.pendingBackendInit=null,console.warn("Initialization of backend "+t+" failed"),console.warn(n.stack||n.message),1));});return this.pendingBackendInit=o,{success:o,asyncInit:!0};}return this.registry[t]=r,{success:!0,asyncInit:!1};}catch(e){return console.warn("Initialization of backend "+t+" failed"),console.warn(e.stack||e.message),{success:!1,asyncInit:!1};}},t.prototype.removeBackend=function(t){if(!(t in this.registryFactory))throw new Error(t+" backend not found in registry");this.backendName===t&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,t in this.registry&&(this.disposeRegisteredKernels(t),this.registry[t].dispose(),delete this.registry[t]),delete this.registryFactory[t],this.backendName===t&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null);},t.prototype.getSortedBackends=function(){var t=this;if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort(function(e,n){return t.registryFactory[n].priority-t.registryFactory[e].priority;});},t.prototype.initializeBackendsAndReturnBest=function(){for(var t=this.getSortedBackends(),e=0;e<t.length;e++){var n=t[e],r=this.initializeBackend(n),i=r.success,o=r.asyncInit;if(o||i)return {name:n,asyncInit:o};}throw new Error("Could not initialize any backends, all backend initializations failed.");},t.prototype.moveData=function(t,e){var n=this.state.tensorInfo.get(e),r=n.backend,i=this.readSync(e);r.disposeData(e),n.backend=t,t.move(e,i,n.shape,n.dtype),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++;},t.prototype.tidy=function(t,e){var n,r=this,i=null;if(null==e){if("function"!=typeof t)throw new Error("Please provide a function to tidy()");e=t;}else {if("string"!=typeof t&&!(t instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof e)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");i=t;}return this.scopedRun(function(){return r.startScope(i);},function(){return r.endScope(n);},function(){return (n=e())instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n;});},t.prototype.scopedRun=function(t,e,n){t();try{var r=n();return e(),r;}catch(t){throw e(),t;}},t.prototype.nextTensorId=function(){return t.nextTensorId++;},t.prototype.nextVariableId=function(){return t.nextVariableId++;},t.prototype.clone=function(t){var e=this.makeTensorFromDataId(t.dataId,t.shape,t.dtype),n={x:t};return this.addTapeNode(this.state.activeScope.name,n,[e],function(t){return {x:function x(){return t.toFloat();}};},[],{}),e;},t.prototype.runKernel=function(t,e,n,r,i){return this.runKernelFunc(null,e,null,t,n,r,i);},t.prototype.shouldCheckForMemLeaks=function(){return this.ENV.getBool("IS_TEST");},t.prototype.checkKernelForMemLeak=function(t,e,n){var r=this.backend.numDataIds(),i=0;n.forEach(function(t){i+="complex64"===t.dtype?3:1;});var o=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],a=r-e-i-o;if(a>0)throw new Error("Backend '"+this.backendName+"' has an internal memory leak ("+a+" data ids) after running '"+t+"'");},t.prototype.runKernelFunc=function(t,e,n,r,i,o,a){var s,u=this,c=[],l=this.isTapeOn();null==r&&(r=null!=this.state.activeScope?this.state.activeScope.name:"");var f,h=this.state.numBytes,d=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);var p,g=m(r,this.backendName);if(null!=g)f=function f(){var t=u.backend.numDataIds();p=g.kernelFunc({inputs:e,attrs:i,backend:u.backend});var n=Array.isArray(p)?p:[p];u.shouldCheckForMemLeaks()&&u.checkKernelForMemLeak(r,t,n);var s=n.map(function(t){var e=t.dataId,n=t.shape,r=t.dtype;return u.makeTensorFromDataId(e,n,r);});if(l){var f=u.getTensorsForGradient(r,e,s);if(null==f){null==a&&(a=[]);var h=s.filter(function(t,e){return a[e];});f=(o||[]).slice().concat(h);}c=u.saveTensorsForBackwardMode(f);}return s;};else {var v=function v(t){l&&(c=t.map(function(t){return u.keep(u.clone(t));}));};f=function f(){var e=u.backend.numDataIds();p=u.tidy(function(){return t(u.backend,v);});var n=Array.isArray(p)?p:[p];return u.shouldCheckForMemLeaks()&&u.checkKernelForMemLeak(r,e,n),n;};}return this.scopedRun(function(){return u.state.kernelDepth++;},function(){return u.state.kernelDepth--;},function(){s=u.ENV.getBool("DEBUG")?u.profiler.profileKernel(r,e,function(){return f();}):f();}),l&&this.addTapeNode(r,e,s,n,c,i),this.state.profiling&&this.state.activeProfile.kernels.push({name:r,bytesAdded:this.state.numBytes-h,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-d,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(e).map(function(t){return e[t].shape;}),outputShapes:s.map(function(t){return t.shape;})}),Array.isArray(p)?s:s[0];},t.prototype.saveTensorsForBackwardMode=function(t){var e=this;return t.map(function(t){return e.keep(e.clone(t));});},t.prototype.getTensorsForGradient=function(t,e,n){var r=g(t);if(null!=r){var i=r.inputsToSave||[],o=r.outputsToSave||[],a=void 0;r.saveAllInputs?(_(Array.isArray(e),function(){return "saveAllInputs is true, expected inputs to be an array.";}),a=Object.keys(e).map(function(t){return e[t];})):a=i.map(function(t){return e[t];});var s=n.filter(function(t,e){return o[e];});return a.concat(s);}return null;},t.prototype.makeTensor=function(t,e,n,r){if(null==t)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;var i=t;"string"===n&&X(t[0])&&(i=t.map(function(t){return ut(t);}));var o=r.write(i,e,n),a=new At(e,n,o,this.nextTensorId());if(this.incRef(a,r),"string"===n){var s=this.state.tensorInfo.get(o),u=K(i);this.state.numBytes+=u-s.bytes,s.bytes=u;}return a;},t.prototype.makeTensorFromDataId=function(t,e,n,r){var i=new At(e,n=n||"float32",t,this.nextTensorId());return this.incRef(i,r),i;},t.prototype.makeVariable=function(t,e,n,r){void 0===e&&(e=!0),n=n||this.nextVariableId().toString(),null!=r&&r!==t.dtype&&(t=t.asType(r));var i=new Tt(t,e,n,this.nextTensorId());if(null!=this.state.registeredVariables[i.name])throw new Error("Variable with name "+i.name+" was already registered");return this.state.registeredVariables[i.name]=i,this.incRef(i,this.backend),i;},t.prototype.incRef=function(t,e){var n=this.state.tensorInfo.has(t.dataId)?this.state.tensorInfo.get(t.dataId).refCount:0;if(this.state.numTensors++,"string"===t.dtype&&this.state.numStringTensors++,0===n){this.state.numDataBuffers++;var r=0;"complex64"!==t.dtype&&"string"!==t.dtype&&(r=t.size*G(t.dtype)),this.state.tensorInfo.set(t.dataId,{backend:e||this.backend,dtype:t.dtype,shape:t.shape,bytes:r,refCount:0}),this.state.numBytes+=r;}this.state.tensorInfo.get(t.dataId).refCount++,t instanceof Tt||this.track(t);},t.prototype.disposeTensor=function(t){if(this.state.tensorInfo.has(t.dataId)){this.state.numTensors--,"string"===t.dtype&&this.state.numStringTensors--;var e=this.state.tensorInfo.get(t.dataId);e.refCount<=1?("complex64"!==t.dtype&&(this.state.numBytes-=e.bytes),this.state.numDataBuffers--,e.backend.disposeData(t.dataId),this.state.tensorInfo.delete(t.dataId)):this.state.tensorInfo.get(t.dataId).refCount--;}},t.prototype.disposeVariables=function(){for(var t in this.state.registeredVariables){var e=this.state.registeredVariables[t];this.disposeVariable(e);}},t.prototype.disposeVariable=function(t){this.disposeTensor(t),null!=this.state.registeredVariables[t.name]&&delete this.state.registeredVariables[t.name];},t.prototype.memory=function(){var t=this.backend.memory();return t.numTensors=this.state.numTensors,t.numDataBuffers=this.state.numDataBuffers,t.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(t.unreliable=!0,null==t.reasons&&(t.reasons=[]),t.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),t;},t.prototype.profile=function(t){return u(this,void 0,void 0,function(){var e,n;return c(this,function(r){return this.state.profiling=!0,e=this.state.numBytes,n=this.state.numTensors,this.state.activeProfile.kernels=[],this.state.activeProfile.result=t(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max.apply(Math,this.state.activeProfile.kernels.map(function(t){return t.totalBytesSnapshot;})),this.state.activeProfile.newBytes=this.state.numBytes-e,this.state.activeProfile.newTensors=this.state.numTensors-n,[2,this.state.activeProfile];});});},t.prototype.isTapeOn=function(){return this.state.gradientDepth>0&&0===this.state.kernelDepth;},t.prototype.addTapeNode=function(t,e,n,r,i,o){var a=this,s={id:this.state.nextTapeNodeId++,kernelName:t,inputs:e,outputs:n,saved:i},u=g(t);null!=u&&(r=u.gradFunc),null!=r&&(s.gradient=function(t){return t=t.map(function(t,e){if(null==t){var r=n[e],i=ot(r.size,r.dtype);return a.makeTensor(i,r.shape,r.dtype);}return t;}),r(t.length>1?t:t[0],i,o);}),this.state.activeTape.push(s);},t.prototype.keep=function(t){return t.kept=!0,t;},t.prototype.startTape=function(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++;},t.prototype.endTape=function(){this.state.gradientDepth--;},t.prototype.startScope=function(t){var e={track:[],name:"unnamed scope",id:this.state.nextScopeId++};t&&(e.name=t),this.state.scopeStack.push(e),this.state.activeScope=e;},t.prototype.endScope=function(t){for(var e=this,n=Bt(t),r=new Set(n.map(function(t){return t.id;})),i=0;i<this.state.activeScope.track.length;i++){var o=this.state.activeScope.track[i];o.kept||r.has(o.id)||o.dispose();}var a=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],n.forEach(function(t){t.kept||t.scopeId!==a.id||e.track(t);});},t.prototype.gradients=function(t,e,n,r){var i=this;if(void 0===r&&(r=!1),_(e.length>0,function(){return "gradients() received an empty list of xs.";}),null!=n&&"float32"!==n.dtype)throw new Error("dy must have 'float32' dtype, but has '"+n.dtype+"'");var o=this.scopedRun(function(){return i.startTape();},function(){return i.endTape();},function(){return i.tidy("forward",t);});_(o instanceof At,function(){return "The result y returned by f() must be a tensor.";});var a=function(t,e,n){for(var r={},i={},o=0;o<e.length;o++){r[e[o].id]=!0;}for(o=0;o<t.length;o++){var a=(p=t[o]).inputs;for(var s in a){for(var u=a[s],c=!1,l=0;l<e.length;l++){if(r[u.id]){p.outputs.forEach(function(t){return r[t.id]=!0;}),c=!0,i[p.id]=!0;break;}}if(c)break;}}var f={};f[n.id]=!0;var h={};for(o=t.length-1;o>=0;o--){for(a=(p=t[o]).inputs,l=0;l<p.outputs.length;l++){if(f[p.outputs[l].id]){for(var s in a){f[a[s].id]=!0,h[p.id]=!0;}break;}}}var d=[];for(o=0;o<t.length;o++){var p;if(i[(p=t[o]).id]&&h[p.id]){var m={};for(var s in p.inputs){var g=p.inputs[s];r[g.id]&&(m[s]=g);}var v=Object.assign({},p);v.inputs=m,v.outputs=p.outputs,d.push(v);}}return d;}(this.state.activeTape,e,o);if(!r&&0===a.length&&e.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",function(){var t,r,s={};s[o.id]=null==n?(r=it(T(t=o.shape),"float32"),Wt.makeTensor(r,t,"float32")):n,function(t,e,n){for(var r=function r(_r2){var i=e[_r2],o=[];if(i.outputs.forEach(function(e){var n=t[e.id];null!=n?o.push(n):o.push(null);}),null==i.gradient)throw new Error("Cannot compute gradient: gradient function not found for "+i.kernelName+".");var a=i.gradient(o),s=function s(e){if(!(e in a))throw new Error("Cannot backprop through input "+e+". Available gradients found: "+Object.keys(a)+".");var r=n(function(){return a[e]();});if("float32"!==r.dtype)throw new Error("Error in gradient for op "+i.kernelName+". The gradient of input "+e+" must have 'float32' dtype, but has '"+r.dtype+"'");var o=i.inputs[e];if(!N(r.shape,o.shape))throw new Error("Error in gradient for op "+i.kernelName+". The gradient of input '"+e+"' has shape '"+r.shape+"', which does not match the shape of the input '"+o.shape+"'");if(null==t[o.id])t[o.id]=r;else {var s=t[o.id];t[o.id]=s.add(r),s.dispose();}};for(var u in i.inputs){s(u);}},i=e.length-1;i>=0;i--){r(i);}}(s,a,function(t){return i.tidy(t);});var u=e.map(function(t){return s[t.id];});return 0===i.state.gradientDepth&&(i.state.activeTape.forEach(function(t){for(var e=0,n=t.saved;e<n.length;e++){n[e].dispose();}}),i.state.activeTape=null),{value:o,grads:u};});},t.prototype.customGrad=function(t){var e=this;return _(Z(t),function(){return "The f passed in customGrad(f) must be a function.";}),function(){for(var n,r=[],i=0;i<arguments.length;i++){r[i]=arguments[i];}_(r.every(function(t){return t instanceof At;}),function(){return "The args passed in customGrad(f)(x1, x2,...) must all be tensors";});var o={};return r.forEach(function(t,e){o[e]=t;}),e.runKernelFunc(function(e,i){return _((n=t.apply(void 0,r.concat([i]))).value instanceof At,function(){return "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor";}),_(Z(n.gradFunc),function(){return "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.";}),n.value;},o,function(t,e){var i=n.gradFunc(t,e),o=Array.isArray(i)?i:[i];_(o.length===r.length,function(){return "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...).";}),_(o.every(function(t){return t instanceof At;}),function(){return "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.";});var a={};return o.forEach(function(t,e){a[e]=function(){return t;};}),a;});};},t.prototype.readSync=function(t){return this.state.tensorInfo.get(t).backend.readSync(t);},t.prototype.read=function(t){return this.state.tensorInfo.get(t).backend.read(t);},t.prototype.time=function(t){return u(this,void 0,void 0,function(){var e,n;return c(this,function(r){switch(r.label){case 0:return e=at(),[4,this.backend.time(t)];case 1:return (n=r.sent()).wallMs=at()-e,[2,n];}});});},t.prototype.track=function(t){return null!=this.state.activeScope&&(t.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(t)),t;},Object.defineProperty(t.prototype,"registeredVariables",{get:function get(){return this.state.registeredVariables;},enumerable:!0,configurable:!0}),t.prototype.reset=function(){for(var t in this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new zt(),this.registry){this.disposeRegisteredKernels(t),this.registry[t].dispose(),delete this.registry[t];}this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null;},t.nextTensorId=0,t.nextVariableId=0,t;}(),Wt=function(){var e=function(){if(null==Pt){var e=void 0;if("undefined"!=typeof window)e=window;else if(void 0!==t)e=t;else if(void 0!==r)e=r;else {if("undefined"==typeof self)throw new Error("Could not find a global object");e=self;}Pt=e;}return Pt;}();if(null==e._tfengine){var n=new l(e);e._tfengine=new Ut(n);}return function(t){h=t;}(e._tfengine.ENV),kt=function kt(){return e._tfengine;},e._tfengine;}();function Vt(){return "undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope;}var qt=f();qt.registerFlag("DEBUG",function(){return !1;},function(t){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.");}),qt.registerFlag("IS_BROWSER",function(){return Vt();}),qt.registerFlag("IS_NODE",function(){return void 0!==r&&void 0!==r.versions&&void 0!==r.versions.node;}),qt.registerFlag("IS_CHROME",function(){return "undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor);}),qt.registerFlag("PROD",function(){return !1;}),qt.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",function(){return qt.getBool("DEBUG");}),qt.registerFlag("DEPRECATION_WARNINGS_ENABLED",function(){return !0;}),qt.registerFlag("IS_TEST",function(){return !1;});var $t,Ht,Gt,Kt={},Xt={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function Yt(t,e){Kt[t]=e;}function Jt(t){t in Kt||(Kt[t]=function(t){if(1!==t&&2!==t)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");var e=function(t){if("undefined"!=typeof OffscreenCanvas&&2===t)return new OffscreenCanvas(300,150);if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context");}(t);return e.addEventListener("webglcontextlost",function(e){e.preventDefault(),delete Kt[t];},!1),1===t?e.getContext("webgl",Xt)||e.getContext("experimental-webgl",Xt):e.getContext("webgl2",Xt);}(t));var e=Kt[t];return e.isContextLost()?(delete Kt[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),Kt[t]);}function Qt(t,e){return [e,t];}function Zt(t){var e=T(t);return M(Math.ceil(e/4));}function te(t,e){return [Math.max(1,Math.ceil(e/2)),Math.max(1,Math.ceil(t/2))];}function ee(t,e){var n,r,i,o,a,s,u,c,l,h=t;return 2===f().getNumber("WEBGL_VERSION")?(n=h.R32F,r=h.R16F,i=h.RGBA16F,o=h.RGBA32F,a=h.RED,s=4,u=1,c=h.HALF_FLOAT,l=h.FLOAT):(n=t.RGBA,r=t.RGBA,i=t.RGBA,o=h.RGBA,a=t.RGBA,s=4,u=4,c=null!=e?e.HALF_FLOAT_OES:null,l=t.FLOAT),{internalFormatFloat:n,internalFormatHalfFloat:r,internalFormatPackedHalfFloat:i,internalFormatPackedFloat:o,textureFormatFloat:a,downloadTextureFormat:t.RGBA,downloadUnpackNumChannels:s,defaultNumChannels:u,textureTypeHalfFloat:c,textureTypeFloat:l};}function ne(t,e,n){var r=n();return e&&function(t){var e=t.getError();if(e!==t.NO_ERROR)throw new Error("WebGL Error: "+ae(t,e));}(t),r;}!function(t){t[t.DENSE=0]="DENSE",t[t.SHARED_BATCH=1]="SHARED_BATCH";}($t||($t={})),function(t){t[t.RENDER=0]="RENDER",t[t.UPLOAD=1]="UPLOAD",t[t.PIXELS=2]="PIXELS",t[t.DOWNLOAD=3]="DOWNLOAD";}(Ht||(Ht={})),function(t){t[t.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",t[t.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",t[t.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",t[t.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",t[t.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16";}(Gt||(Gt={}));var re=5.96e-8,ie=65504;function oe(t){return !!(f().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===t||re<Math.abs(t)&&Math.abs(t)<ie);}function ae(t,e){switch(e){case t.NO_ERROR:return "NO_ERROR";case t.INVALID_ENUM:return "INVALID_ENUM";case t.INVALID_VALUE:return "INVALID_VALUE";case t.INVALID_OPERATION:return "INVALID_OPERATION";case t.INVALID_FRAMEBUFFER_OPERATION:return "INVALID_FRAMEBUFFER_OPERATION";case t.OUT_OF_MEMORY:return "OUT_OF_MEMORY";case t.CONTEXT_LOST_WEBGL:return "CONTEXT_LOST_WEBGL";default:return "Unknown error code "+e;}}function se(t,e,n){return Fe(t,e,function(){return t.getExtension(n);},'Extension "'+n+'" not supported on this browser.');}function ue(t,e,n){var r=Fe(t,e,function(){return t.createShader(t.VERTEX_SHADER);},"Unable to create vertex WebGLShader.");if(ne(t,e,function(){return t.shaderSource(r,n);}),ne(t,e,function(){return t.compileShader(r);}),!1===t.getShaderParameter(r,t.COMPILE_STATUS))throw console.log(t.getShaderInfoLog(r)),new Error("Failed to compile vertex shader.");return r;}function ce(t,e,n){var r=Fe(t,e,function(){return t.createShader(t.FRAGMENT_SHADER);},"Unable to create fragment WebGLShader.");if(ne(t,e,function(){return t.shaderSource(r,n);}),ne(t,e,function(){return t.compileShader(r);}),!1===t.getShaderParameter(r,t.COMPILE_STATUS))throw function(t,e){var n=he.exec(e);if(null==n)return console.log("Couldn't parse line number in error: "+e),void console.log(t);for(var r=+n[1],i=t.split("\n"),o=i.length.toString().length+2,a=i.map(function(t,e){return j((e+1).toString(),o)+t;}),s=0,u=0;u<a.length;u++){s=Math.max(a[u].length,s);}var c=a.slice(0,r-1),l=a.slice(r-1,r),f=a.slice(r);console.log(c.join("\n")),console.log(e.split("\n")[0]),console.log("%c "+j(l[0],s),"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(f.join("\n"));}(n,t.getShaderInfoLog(r)),new Error("Failed to compile fragment shader.");return r;}var le,fe,he=/ERROR: [0-9]+:([0-9]+):/g;function de(t,e){return Fe(t,e,function(){return t.createProgram();},"Unable to create WebGLProgram.");}function pe(t,e,n){if(ne(t,e,function(){return t.linkProgram(n);}),!1===t.getProgramParameter(n,t.LINK_STATUS))throw console.log(t.getProgramInfoLog(n)),new Error("Failed to link vertex and fragment shaders.");}function me(t,e,n){if(ne(t,e,function(){return t.validateProgram(n);}),!1===t.getProgramParameter(n,t.VALIDATE_STATUS))throw console.log(t.getProgramInfoLog(n)),new Error("Shader program validation failed.");}function ge(t,e,n){var r=Fe(t,e,function(){return t.createBuffer();},"Unable to create WebGLBuffer");return ne(t,e,function(){return t.bindBuffer(t.ARRAY_BUFFER,r);}),ne(t,e,function(){return t.bufferData(t.ARRAY_BUFFER,n,t.STATIC_DRAW);}),r;}function ve(t,e,n){var r=Fe(t,e,function(){return t.createBuffer();},"Unable to create WebGLBuffer");return ne(t,e,function(){return t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,r);}),ne(t,e,function(){return t.bufferData(t.ELEMENT_ARRAY_BUFFER,n,t.STATIC_DRAW);}),r;}function ye(t,e){return Fe(t,e,function(){return t.createTexture();},"Unable to create WebGLTexture.");}function be(t,e){var n=f().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t<=0||e<=0){var r="["+t+"x"+e+"]";throw new Error("Requested texture size "+r+" is invalid.");}if(t>n||e>n)throw r="["+t+"x"+e+"]",new Error("Requested texture size "+r+" greater than WebGL maximum on this browser / GPU ["+n+"x"+n+"].");}function xe(t,e){return Fe(t,e,function(){return t.createFramebuffer();},"Unable to create WebGLFramebuffer.");}function we(t,e,n,r,i,o,a,s){var u=t.getAttribLocation(n,r);return -1!==u&&(ne(t,e,function(){return t.bindBuffer(t.ARRAY_BUFFER,i);}),ne(t,e,function(){return t.vertexAttribPointer(u,o,t.FLOAT,!1,a,s);}),ne(t,e,function(){return t.enableVertexAttribArray(u);}),!0);}function ke(t,e,n,r){Te(t,r),ne(t,e,function(){return t.activeTexture(t.TEXTURE0+r);}),ne(t,e,function(){return t.bindTexture(t.TEXTURE_2D,n);});}function Ee(t,e,n,r){return Fe(t,e,function(){return t.getUniformLocation(n,r);},'uniform "'+r+'" not present in program.');}function Ce(t,e,n){return t.getUniformLocation(e,n);}function Ae(t,e,n,r,i,o){ne(t,e,function(){return ke(t,e,r,o);}),ne(t,e,function(){return t.uniform1i(i,o);});}function Oe(t,e,n,r){ne(t,e,function(){return t.bindFramebuffer(t.FRAMEBUFFER,r);}),ne(t,e,function(){return t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0);});}function _e(t,e,n){ne(t,e,function(){return t.bindFramebuffer(t.FRAMEBUFFER,n);}),ne(t,e,function(){return t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,null,0);});}function Se(t){var e=t.checkFramebufferStatus(t.FRAMEBUFFER);if(e!==t.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+De(t,e));}function De(t,e){switch(e){case t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return "FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return "FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case t.FRAMEBUFFER_UNSUPPORTED:return "FRAMEBUFFER_UNSUPPORTED";default:return "unknown error "+e;}}function Fe(t,e,n,r){var i=ne(t,e,function(){return n();});if(null==i)throw new Error(r);return i;}function Te(t,e){var n=t.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=e+t.TEXTURE0;if(r<t.TEXTURE0||r>n)throw new Error("textureUnit must be in [gl.TEXTURE0, gl.TEXTURE"+n+"].");}function Ne(t,e){return void 0===e&&(e=2),T(t.slice(0,t.length-e));}function Ie(t){if(0===t.length)throw Error("Cannot get rows and columns of an empty shape array.");return [t.length>1?t[t.length-2]:1,t[t.length-1]];}function Re(t){var e=[1,1,1];return 0===t.length||1===t.length&&1===t[0]||(e=[Ne(t)].concat(Ie(t))),e;}function Me(t,e){var n;void 0===e&&(e=!1);var r=f().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e&&(r*=2,1===(t=t.map(function(e,n){return n>=t.length-2?A(t[n]):t[n];})).length&&(t=[2,t[0]])),2!==t.length){var i=z(t);t=i.newShape;}var o=T(t);if(t.length<=1&&o<=r)return [1,o];if(2===t.length&&t[0]<=r&&t[1]<=r)return t;if(3===t.length&&t[0]*t[1]<=r&&t[2]<=r)return [t[0]*t[1],t[2]];if(3===t.length&&t[0]<=r&&t[1]*t[2]<=r)return [t[0],t[1]*t[2]];if(4===t.length&&t[0]*t[1]*t[2]<=r&&t[3]<=r)return [t[0]*t[1]*t[2],t[3]];if(4===t.length&&t[0]<=r&&t[1]*t[2]*t[3]<=r)return [t[0],t[1]*t[2]*t[3]];if(e){var a=Ne(t),s=2,u=2;return t.length&&(s=(n=Ie(t))[0],u=n[1]),M(o=a*(s/2)*(u/2)).map(function(t){return 2*t;});}return M(o);}function je(t){return t%2==0;}function Be(t,e){if(N(t=t.slice(-2),e=e.slice(-2)))return !0;if(!t.length||!e.length)return !0;if(0===t[0]||0===t[1]||0===e[0]||0===e[1])return !0;if(t.length!==e.length){var n=t.slice(-1)[0],r=e.slice(-1)[0];if(n===r)return !0;if(je(n)&&je(r)&&(1===t[0]||1===e[0]))return !0;}return t[1]===e[1]&&je(t[0])&&je(e[0]);}function Pe(t){if(null==le){var e=Jt(t);le=e.getParameter(e.MAX_TEXTURE_SIZE);}return le;}function Le(t){if(null==fe){var e=Jt(t);fe=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);}return Math.min(16,fe);}function ze(t){if(0===t)return 0;var e=Jt(t);return Ue(e,"EXT_disjoint_timer_query_webgl2")&&2===t?2:Ue(e,"EXT_disjoint_timer_query")?1:0;}function Ue(t,e){return null!=t.getExtension(e);}function We(t){try{if(null!=Jt(t))return !0;}catch(t){return !1;}return !1;}function Ve(t){if(0===t)return !1;var e=Jt(t);if(1===t){if(!Ue(e,"OES_texture_float"))return !1;}else if(!Ue(e,"EXT_color_buffer_float"))return !1;return $e(e);}function qe(t){if(0===t)return !1;var e=Jt(t);return 1!==t?Ue(e,"EXT_color_buffer_float")?$e(e):!!Ue(e,"EXT_color_buffer_half_float")&&function(t,e){var n=ee(t,e),r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r),t.texImage2D(t.TEXTURE_2D,0,n.internalFormatHalfFloat,1,1,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);var i=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,i),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0);var o=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(r),t.deleteFramebuffer(i),o;}(e,e.getExtension("EXT_color_buffer_half_float")):!!Ue(e,"OES_texture_float")&&!!Ue(e,"WEBGL_color_buffer_float")&&$e(e);}function $e(t){var e=ee(t),n=t.createTexture();t.bindTexture(t.TEXTURE_2D,n),t.texImage2D(t.TEXTURE_2D,0,e.internalFormatFloat,1,1,0,e.textureFormatFloat,e.textureTypeFloat,null);var r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0);var i=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(n),t.deleteFramebuffer(r),i;}function He(t){return 2===t&&null!=Jt(t).fenceSync;}var Ge=Object.freeze({callAndCheck:ne,canBeRepresented:oe,getWebGLErrorMessage:ae,getExtensionOrThrow:se,createVertexShader:ue,createFragmentShader:ce,createProgram:de,linkProgram:pe,validateProgram:me,createStaticVertexBuffer:ge,createStaticIndexBuffer:ve,getNumChannels:function getNumChannels(){return 2===f().getNumber("WEBGL_VERSION")?1:4;},createTexture:ye,validateTextureSize:be,createFramebuffer:xe,bindVertexBufferToProgramAttribute:we,bindTextureUnit:ke,unbindTextureUnit:function unbindTextureUnit(t,e,n){Te(t,n),ne(t,e,function(){return t.activeTexture(t.TEXTURE0+n);}),ne(t,e,function(){return t.bindTexture(t.TEXTURE_2D,null);});},getProgramUniformLocationOrThrow:Ee,getProgramUniformLocation:Ce,bindTextureToProgramUniformSampler:Ae,bindCanvasToFramebuffer:function bindCanvasToFramebuffer(t,e){ne(t,e,function(){return t.bindFramebuffer(t.FRAMEBUFFER,null);}),ne(t,e,function(){return t.viewport(0,0,t.canvas.width,t.canvas.height);}),ne(t,e,function(){return t.scissor(0,0,t.canvas.width,t.canvas.height);});},bindColorTextureToFramebuffer:Oe,unbindColorTextureFromFramebuffer:_e,validateFramebuffer:Se,getFramebufferErrorMessage:De,getBatchDim:Ne,getRowsCols:Ie,getShapeAs3D:Re,getTextureShapeFromLogicalShape:Me,isReshapeFree:Be,getWebGLMaxTextureSize:Pe,resetMaxTextureSize:function resetMaxTextureSize(){le=null;},resetMaxTexturesInShader:function resetMaxTexturesInShader(){fe=null;},getMaxTexturesInShader:Le,getWebGLDisjointQueryTimerVersion:ze,hasExtension:Ue,isWebGLVersionEnabled:We,isCapableOfRenderingToFloatTexture:Ve,isDownloadFloatTextureEnabled:qe,isWebGLFenceEnabled:He}),Ke=f();function Xe(){f().set("PROD",!0);}function Ye(){f().set("DEBUG",!0);}function Je(){f().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.");}function Qe(t){f().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(t+" You can disable deprecation warnings with tf.disableDeprecationWarnings().");}function Ze(){Wt.disposeVariables();}function tn(){return Wt;}function en(){return Wt.memory();}function nn(t){return Wt.profile(t);}function rn(t,e){return Wt.tidy(t,e);}function on(t){Bt(t).forEach(function(t){return t.dispose();});}function an(t){return Wt.keep(t);}function sn(t){return Wt.time(t);}function un(t){return Wt.setBackend(t);}function cn(){return Wt.ready();}function ln(){return Wt.backendName;}function fn(t){Wt.removeBackend(t);}function hn(t){return Wt.findBackend(t);}function dn(t){return Wt.findBackendFactory(t);}function pn(t,e,n){return void 0===n&&(n=1),Wt.registerBackend(t,e,n);}function mn(){return Wt.backend;}function gn(t,e){f().setPlatform(t,e);}function vn(){for(var t=[],e=0;e<arguments.length;e++){t[e]=arguments[e];}f().getBool("IS_TEST")||console.warn.apply(console,t);}function yn(t,e){var n=t;if(H(t))return "string"===e?[]:[t.length];if(!Array.isArray(t))return [];for(var r=[];Array.isArray(n)||H(n)&&"string"!==e;){r.push(n.length),n=n[0];}return Array.isArray(t)&&f().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&function t(e,n,r){if(r=r||[],Array.isArray(e)||H(e)){_(n.length>0,function(){return "Element arr["+r.join("][")+"] should be a primitive, but is an array of "+e.length+" elements";}),_(e.length===n[0],function(){return "Element arr["+r.join("][")+"] should have "+n[0]+" elements, but has "+e.length+" elements";});for(var i=n.slice(1),o=0;o<e.length;++o){t(e[o],i,r.concat(o));}}else _(0===n.length,function(){return "Element arr["+r.join("][")+"] is a primitive, but should be an array/TypedArray of "+n[0]+" elements";});}(t,r,[]),r;}function bn(t,e,n,r){if(null!=t&&("numeric"!==t&&t!==e||"numeric"===t&&"string"===e))throw new Error("Argument '"+n+"' passed to '"+r+"' must be "+t+" tensor, but got "+e+" tensor");}function xn(t,e,n,r){if(void 0===r&&(r="numeric"),t instanceof At)return bn(r,t.dtype,e,n),t;var i=Q(t);if("string"!==i&&["bool","int32","float32"].indexOf(r)>=0&&(i=r),bn(r,i,e,n),null==t||!H(t)&&!Array.isArray(t)&&"number"!=typeof t&&"boolean"!=typeof t&&"string"!=typeof t){var o=null==t?"null":t.constructor.name;throw new Error("Argument '"+e+"' passed to '"+n+"' must be a Tensor or TensorLike, but got '"+o+"'");}var a=yn(t,i);H(t)||Array.isArray(t)||(t=[t]);var s="string"!==i?nt(t,i,f().getBool("DEBUG")):F(t,[],!0);return Wt.makeTensor(s,a,i);}function wn(t,e,n,r){if(void 0===r&&(r="numeric"),!Array.isArray(t))throw new Error("Argument "+e+" passed to "+n+" must be a `Tensor[]` or `TensorLike[]`");return t.map(function(t,r){return xn(t,e+"["+r+"]",n);},r);}function kn(t,e){for(var n=0;n<t.length;++n){if(t[t.length-n-1]!==e-1-n)return !1;}return !0;}function En(t,e,n){for(var r=t.length+e.length,i=[],o=0,a=0,s=0;s<r;s++){-1===n.indexOf(s)?i.push(t[o++]):i.push(e[a++]);}return i;}function Cn(t,e){for(var n=[],r=t.length,i=0;i<r;i++){-1===e.indexOf(i)&&n.push(t[i]);}return [n,e.map(function(e){return t[e];})];}function An(t,e){return En(t,e.map(function(t){return 1;}),e);}function On(t,e,n){_(kn(e,n),function(){return t+" supports only inner-most axes for now. Got axes "+e+" and rank-"+n+" input.";});}function _n(t,e){if(kn(t,e))return null;for(var n=[],r=0;r<e;++r){-1===t.indexOf(r)&&n.push(r);}return t.forEach(function(t){return n.push(t);}),n;}function Sn(t){return t.map(function(t,e){return [e,t];}).sort(function(t,e){return t[1]-e[1];}).map(function(t){return t[0];});}function Dn(t,e){for(var n=[],r=e-t;r<e;++r){n.push(r);}return n;}function Fn(t,e){var n=t[0].length;t.forEach(function(t,e){_(t.length===n,function(){return "Error in concat"+n+"D: rank of tensors["+e+"] must be the same as the rank of the rest ("+n+")";});}),_(e>=0&&e<n,function(){return "Error in concat"+n+"D: axis must be between 0 and "+(n-1)+".";});var r=t[0];t.forEach(function(t,i){for(var o=0;o<n;o++){_(o===e||t[o]===r[o],function(){return "Error in concat"+n+"D: Shape of tensors["+i+"] ("+t+") does not match the shape of the rest ("+r+") along the non-concatenated axis "+i+".";});}});}function Tn(t,e){for(var n=t[0].slice(),r=1;r<t.length;r++){n[e]+=t[r][e];}return n;}function Nn(t){var e=Object.keys(t);if(1!==e.length)throw new Error("Please provide an object with a single key (operation name) mapping to a function. Got an object with "+e.length+" keys.");var n=e[0],r=t[n];n.endsWith("_")&&(n=n.substring(0,n.length-1));var i=function i(){for(var t=[],e=0;e<arguments.length;e++){t[e]=arguments[e];}Wt.startScope(n);try{var i=r.apply(void 0,t);return i instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),Wt.endScope(i),i;}catch(t){throw Wt.endScope(null),t;}};return Object.defineProperty(i,"name",{value:n,configurable:!0}),i;}Ke.registerFlag("HAS_WEBGL",function(){return Ke.getNumber("WEBGL_VERSION")>0;}),Ke.registerFlag("WEBGL_VERSION",function(){return We(2)?2:We(1)?1:0;}),Ke.registerFlag("WEBGL_BUFFER_SUPPORTED",function(){return 2===Ke.get("WEBGL_VERSION");}),Ke.registerFlag("WEBGL_CPU_FORWARD",function(){return !0;}),Ke.registerFlag("WEBGL_FORCE_F16_TEXTURES",function(){return !1;}),Ke.registerFlag("WEBGL_PACK",function(){return Ke.getBool("HAS_WEBGL");}),Ke.registerFlag("WEBGL_PACK_NORMALIZATION",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_PACK_CLIP",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_PACK_DEPTHWISECONV",function(){return !1;}),Ke.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_PACK_REDUCE",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_LAZILY_UNPACK",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_CONV_IM2COL",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_MAX_TEXTURE_SIZE",function(){return Pe(Ke.getNumber("WEBGL_VERSION"));}),Ke.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",function(){return Le(Ke.getNumber("WEBGL_VERSION"));}),Ke.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",function(){var t=Ke.getNumber("WEBGL_VERSION");return 0===t?0:ze(t);}),Ke.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",function(){return Ke.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&(t=navigator.userAgent||navigator.vendor||window.opera,!(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4))));var t;}),Ke.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",function(){return Ve(Ke.getNumber("WEBGL_VERSION"));}),Ke.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",function(){return !Ke.getBool("WEBGL_FORCE_F16_TEXTURES")&&Ke.getBool("WEBGL_RENDER_FLOAT32_CAPABLE");}),Ke.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",function(){return qe(Ke.getNumber("WEBGL_VERSION"));}),Ke.registerFlag("WEBGL_FENCE_API_ENABLED",function(){return He(Ke.getNumber("WEBGL_VERSION"));}),Ke.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",function(){return Ke.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0;}),Ct=Qe;var In=Nn({complex_:function complex_(t,e){var n=xn(t,"real","complex"),r=xn(e,"imag","complex");return S(n.shape,r.shape,"real and imag shapes, "+n.shape+" and "+r.shape+", must match in call to tf.complex()."),Wt.runKernelFunc(function(t){return t.complex(n,r);},{$real:n,$imag:r});}}),Rn=Nn({real_:function real_(t){var e=xn(t,"input","real");return Wt.runKernelFunc(function(t){return t.real(e);},{$input:e});}}),Mn=Nn({imag_:function imag_(t){var e=xn(t,"input","imag");return Wt.runKernelFunc(function(t){return t.imag(e);},{$input:e});}});function jn(t,e,n){return Bn(t,e,yn(t,n),n);}function Bn(t,e,n,r){if(null==r&&(r=Q(t)),"complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!H(t)&&!Array.isArray(t)&&"number"!=typeof t&&"boolean"!=typeof t&&"string"!=typeof t)throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(null!=e){st(e);var i=T(e),o=T(n);_(i===o,function(){return "Based on the provided shape, ["+e+"], the tensor should have "+i+" values but has "+o;});for(var a=0;a<n.length;++a){var s=n[a],u=a!==n.length-1||s!==T(e.slice(a));_(n[a]===e[a]||!u,function(){return "Error creating a new Tensor. Inferred shape ("+n+") does not match the provided shape ("+e+"). ";});}}return H(t)||Array.isArray(t)||(t=[t]),e=e||n,t="string"!==r?nt(t,r,f().getBool("DEBUG")):F(t,[],!0),Wt.makeTensor(t,e,r);}function Pn(t,e){if((H(t)&&"string"!==e||Array.isArray(t))&&"complex64"!==e)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===e&&H(t)&&!(t instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return Bn(t,[],[],e);}function Ln(t,e){D(t);var n=yn(t,e);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return Bn(t,null,n,e);}function zn(t,e,n){if(D(t),null!=e&&2!==e.length)throw new Error("tensor2d() requires shape to have two numbers");var r=yn(t,n);if(2!==r.length&&1!==r.length)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return Bn(t,e,r,n);}function Un(t,e,n){if(D(t),null!=e&&3!==e.length)throw new Error("tensor3d() requires shape to have three numbers");var r=yn(t,n);if(3!==r.length&&1!==r.length)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return Bn(t,e,r,n);}function Wn(t,e,n){if(D(t),null!=e&&4!==e.length)throw new Error("tensor4d() requires shape to have four numbers");var r=yn(t,n);if(4!==r.length&&1!==r.length)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return Bn(t,e,r,n);}function Vn(t,e,n){if(D(t),null!=e&&5!==e.length)throw new Error("tensor5d() requires shape to have five numbers");var r=yn(t,n);if(5!==r.length&&1!==r.length)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return Bn(t,e,r,n);}function qn(t,e,n){if(D(t),null!=e&&6!==e.length)throw new Error("tensor6d() requires shape to have six numbers");var r=yn(t,n);if(6!==r.length&&1!==r.length)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return Bn(t,e=e||r,r,n);}function $n(t,e,n,r){return void 0===e&&(e=!0),Wt.makeVariable(t,e,n,r);}function Hn(t,e){if(void 0===e&&(e="float32"),"complex64"===e){var n=Hn(t,"float32"),r=Gn(t,"float32");return In(n,r);}var i=it(T(t),e);return Wt.makeTensor(i,t,e);}function Gn(t,e){if(void 0===e&&(e="float32"),"complex64"===e){var n=Gn(t,"float32"),r=Gn(t,"float32");return In(n,r);}var i=ot(T(t),e);return Wt.makeTensor(i,t,e);}function Kn(t,e,n){return Wt.runKernelFunc(function(r){return r.fill(t,e,n);},{});}function Xn(t,e,n){if(n<=0)throw new Error("The number of values should be positive.");return Wt.runKernelFunc(function(r){return r.linspace(t,e,n);},{});}function Yn(t,e,n,r){if(void 0===n&&(n=1),void 0===r&&(r="float32"),0===n)throw new Error("Cannot have a step of zero");if(t===e||t<e&&n<0||e<t&&n>1)return Gn([0],r);var i=ot(Math.abs(Math.ceil((e-t)/n)),r);e<t&&1===n&&(n=-1),i[0]=t;for(var o=1;o<i.length;o++){i[o]=i[o-1]+n;}return Ln(i,r);}var Jn=Nn({onesLike_:function onesLike_(t){var e=xn(t,"x","onesLike");if("complex64"===e.dtype){var n=Jn(Rn(e)),r=Qn(Mn(e));return In(n,r);}return Wt.runKernelFunc(function(t){return t.onesLike(e);},{x:e},function(t,e){return {x:function x(){return Qn(t);}};},"OnesLike");}}),Qn=Nn({zerosLike_:function zerosLike_(t){var e=xn(t,"x","zerosLike");return Wt.runKernelFunc(function(t){return t.zerosLike(e);},{x:e},function(t,e){return {x:function x(){return Qn(t);}};},"ZerosLike");}}),Zn=Nn({concat_:function concat_(t,e){void 0===e&&(e=0),_(t.length>=1,function(){return "Pass at least one tensor to concat";});var n=wn(t,"tensors","concat");"complex64"===n[0].dtype&&n.forEach(function(t){if("complex64"!==t.dtype)throw new Error("Cannot concatenate complex64 tensors with a tensor\n          with dtype "+t.dtype+". ");}),e=L(e,n[0].shape)[0];var r=Tn(n.map(function(t){return t.shape;}),e);if(0===T(r))return jn([],r);if(1===(n=n.filter(function(t){return t.size>0;})).length)return n[0];var i=n.map(function(t){return t.shape;});Fn(i,e);var o=n,a={axis:e};return Wt.runKernelFunc(function(t){return t.concat(n,e);},o,function(t){var n=i.map(function(t){return t[e];});return ir(t,n,e).map(function(t){return function(){return t;};});},"Concat",a);}}),tr=Nn({concat1d_:function concat1d_(t){return Zn(t,0);}}),er=Nn({concat2d_:function concat2d_(t,e){return Zn(t,e);}}),nr=Nn({concat3d_:function concat3d_(t,e){return Zn(t,e);}}),rr=Nn({concat4d_:function concat4d_(t,e){return Zn(t,e);}}),ir=Nn({split_:function split_(t,e,n){void 0===n&&(n=0);var r,i=xn(t,"x","split");return n=L(n,i.shape)[0],"number"==typeof e?(_(i.shape[n]%e==0,function(){return "Number of splits must evenly divide the axis.";}),r=new Array(e).fill(i.shape[n]/e)):(_(i.shape[n]===e.reduce(function(t,e){return t+e;}),function(){return "The sum of sizes must match the size of the axis dimension.";}),r=e),Wt.runKernelFunc(function(t){return t.split(i,r,n);},{$x:i},function(t){return {$x:function $x(){return Zn(t,n);}};});}});function or(t,e,n){return void 0===e&&(e="float32"),e=e||"float32",st(t),new wt(t,e,n);}function ar(t,e){void 0===e&&(e=!1),console.log(t.toString(e));}var sr=Nn({batchToSpaceND_:function batchToSpaceND_(t,e,n){var r=xn(t,"x","batchToSpaceND"),i=e.reduce(function(t,e){return t*e;});return _(r.rank>=1+e.length,function(){return "input rank is "+r.rank+" but should be > than blockShape.length "+e.length;}),_(n.length===e.length,function(){return "crops.length is "+n.length+" but should be equal to blockShape.length  "+e.length;}),_(r.shape[0]%i==0,function(){return "input tensor batch is "+r.shape[0]+" but is not divisible by the product of the elements of blockShape "+e.join(" * ")+" === "+i;}),Wt.runKernelFunc(function(t){return t.batchToSpaceND(r,e,n);},{$x:r},function(t){return {$x:function $x(){return t.spaceToBatchND(e,n);}};});}}),ur=Nn({cast_:function cast_(t,e){var n=xn(t,"x","cast");if(!q(e))throw new Error("Failed to cast to unknown dtype "+e);if("string"===e&&"string"!==n.dtype||"string"!==e&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");var r={dtype:e};return Wt.runKernelFunc(function(t){return t.cast(n,e);},{x:n},function(t){return {x:function x(){return t.clone();}};},"Cast",r);}}),cr=Nn({cumsum_:function cumsum_(t,e,n,r){void 0===e&&(e=0),void 0===n&&(n=!1),void 0===r&&(r=!1);var i=xn(t,"x","cumsum"),o=_n([e|=0],i.rank),a=i;null!=o&&(a=i.transpose(o));var s=Dn(1,i.rank)[0],u=Wt.runKernelFunc(function(t){return t.cumsum(a,s,n,r);},{permutedX:a},function(t){return {permutedX:function permutedX(){return t.cumsum(e,n,!r);}};});return null!=o&&(u=u.transpose(o)),u;}}),lr=Nn({depthToSpace_:function depthToSpace_(t,e,n){void 0===n&&(n="NHWC");var r=xn(t,"x","depthToSpace"),i="NHWC"===n?r.shape[1]:r.shape[2],o="NHWC"===n?r.shape[2]:r.shape[3],a="NHWC"===n?r.shape[3]:r.shape[1];return _(i*e>=0,function(){return "Negative dimension size caused by overflow when multiplying\n      "+i+" and "+e+"  for depthToSpace with input shape\n      "+r.shape;}),_(o*e>=0,function(){return "Negative dimension size caused by overflow when multiplying\n      "+o+" and "+e+" for depthToSpace with input shape\n          "+r.shape;}),_(a%(e*e)==0,function(){return "Dimension size must be evenly divisible by "+e*e+" but is "+a+" for depthToSpace with input shape "+r.shape;}),Wt.runKernelFunc(function(t){return t.depthToSpace(r,e,n);},{$x:r});}}),fr=Nn({expandDims_:function expandDims_(t,e){void 0===e&&(e=0);var n=xn(t,"x","expandDims",null);_(e<=n.rank,function(){return "Axis must be <= rank of the tensor";});var r=n.shape.slice();return e<0&&(_(-(n.rank+1)<=e,function(){return "Axis must be in the interval ["+-(n.rank+1)+", "+n.rank+"]";}),e=n.rank+e+1),r.splice(e,0,1),hr(n,r);}}),hr=Nn({reshape_:function reshape_(t,e){var n=xn(t,"x","reshape",null);e=P(e,n.size),_(n.size===T(e),function(){return "new shape and old shape must have the same number of elements.";});var r={shape:e};return Wt.runKernelFunc(function(t){return t.reshape(n,e);},{x:n},function(t){return {x:function x(){return t.reshape(n.shape);}};},"Reshape",r);}}),dr=Nn({spaceToBatchND_:function spaceToBatchND_(t,e,n){var r=xn(t,"x","spaceToBatchND");return _(r.rank>=1+e.length,function(){return "input rank "+r.rank+" should be > than [blockShape] "+e.length;}),_(n.length===e.length,function(){return "paddings.shape[0] "+n.length+" must be equal to [blockShape] "+e.length;}),_(r.shape.reduce(function(t,r,i){return i>0&&i<=e.length?t&&(r+n[i-1][0]+n[i-1][1])%e[i-1]==0:t;},!0),function(){return "input spatial dimensions "+r.shape.slice(1)+" with paddings "+n.toString()+" must be divisible by blockShapes "+e.toString();}),Wt.runKernelFunc(function(t){return t.spaceToBatchND(r,e,n);},{$x:r},function(t){return {$x:function $x(){return t.batchToSpaceND(e,n);}};});}}),pr=Nn({squeeze_:function squeeze_(t,e){var n=xn(t,"x","squeeze");return hr(n,z(n.shape,e).newShape);}}),mr=Nn({stack_:function stack_(t,e){void 0===e&&(e=0);var n=wn(t,"tensors","stack");if(_(n.length>=1,function(){return "Pass at least one tensor to tf.stack";}),1===n.length)return n[0].expandDims(e);var r=n[0].rank,i=n[0].shape,o=n[0].dtype;_(e<=r,function(){return "Axis must be <= rank of the tensor";}),n.forEach(function(t){S(i,t.shape,"All tensors passed to stack must have matching shapes");}),n.forEach(function(t){_(o===t.dtype,function(){return "All tensors passed to stack must have matching dtypes";});});var a=n.map(function(t){return t.expandDims(e);});return Zn(a,e);}}),gr=Nn({unstack_:function unstack_(t,e){void 0===e&&(e=0),e=e||0;var n=xn(t,"x","unstack");_(e>=-n.shape.length&&e<n.shape.length,function(){return "Axis = "+e+" is not in [-"+n.shape.length+", "+n.shape.length+")";}),e<0&&(e+=n.shape.length);var r={axis:e};return Wt.runKernelFunc(function(t){return t.unstack(n,e);},{x:n},function(t){return {x:function x(){return mr(t,e);}};},"Unpack",r);}}),vr=function vr(t,e){return u(this,void 0,void 0,function(){var n,r,i,o,a,s,u,l,f,h;return c(this,function(c){switch(c.label){case 0:return n=xn(t,"x","setdiff1d"),r=xn(e,"y","setdiff1d"),_(n.dtype===r.dtype,function(){return "x and y should have the same dtype, but got x ("+n.dtype+") and y ("+r.dtype+").";}),_(1===n.rank,function(){return "x should be 1D tensor, but got x ("+n.shape+").";}),_(1===r.rank,function(){return "y should be 1D tensor, but got y ("+r.shape+").";}),[4,n.data()];case 1:return i=c.sent(),[4,r.data()];case 2:for(o=c.sent(),a=new Set(o),s=0,f=0;f<i.length;f++){a.has(i[f])||s++;}for(u=new wt([s],n.dtype),l=new wt([s],"int32"),f=0,h=0;f<i.length;f++){a.has(i[f])||(u.values[h]=i[f],l.values[h]=f,h++);}return [2,[u.toTensor(),l.toTensor()]];}});});};function yr(t,e,n,r){void 0===r&&(r=!0);var i=[];if(r)(i=i.concat(e.slice(0))).push(t[0]/n),i=i.concat(t.slice(1));else {i=i.concat(t[0]);for(var o=e.length,a=0;a<o;++a){i=i.concat([t[a+1]/e[a],e[a]]);}i=i.concat(t.slice(o+1));}return i;}function br(t,e,n){void 0===n&&(n=!0);var r=[];if(n){r.push(e);for(var i=e+1;i<t;++i){i<=2*e?(r.push(i),r.push(i-(e+1))):r.push(i);}}else {var o=[],a=[];for(i=1;i<t;++i){i>=2*e+1||i%2==1?a.push(i):o.push(i);}r.push.apply(r,o),r.push(0),r.push.apply(r,a);}return r;}function xr(t,e,n,r){void 0===r&&(r=!0);var i=[];r?i.push(t[0]/n):i.push(t[0]*n);for(var o=1;o<t.length;++o){o<=e.length?r?i.push(e[o-1]*t[o]):i.push(t[o]/e[o-1]):i.push(t[o]);}return i;}function wr(t,e){for(var n=[0],r=0;r<e;++r){n.push(t[r][0]);}return n;}function kr(t,e,n){for(var r=t.slice(0,1),i=0;i<n;++i){r.push(t[i+1]-e[i][0]-e[i][1]);}return r;}var Er="Add",Cr="AddN",Ar="Div",Or="FusedBatchNorm",_r="SquaredDifference",Sr="Square",Dr="Transpose",Fr="NonMaxSuppressionV5",Tr="BroadcastTo",Nr="OneHot",Ir="Identity",Rr="Tile",Mr="PadV2",jr="FromPixels",Br="MaxPoolWithArgmax",Pr=Nn({add_:function add_(t,e){var n,r=xn(t,"a","add"),i=xn(e,"b","add");n=Mt(r,i),r=n[0],i=n[1];var o={a:r,b:i};return Wt.runKernelFunc(function(t,e){var n=t.add(r,i);return e([r,i]),n;},o,null,Er);}});function Lr(t,e){for(var n=t.length,r=[],i=0;i<n;i++){var o=n-1-i,a=t[o]||1;(e[e.length-1-i]||1)>1&&1===a&&r.unshift(o);}return r;}function zr(t,e){for(var n=[],r=0;r<e.length;r++){var i=t[t.length-r-1],o=e.length-r-1,a=e[o];(null==i||1===i&&a>1)&&n.unshift(o);}return n;}function Ur(t,e){for(var n=[],r=Math.max(t.length,e.length),i=0;i<r;i++){var o=t[t.length-i-1];null==o&&(o=1);var a=e[e.length-i-1];if(null==a&&(a=1),1===o)n.unshift(a);else if(1===a)n.unshift(o);else {if(o!==a)throw Error("Operands could not be broadcast together with shapes "+t+" and "+e+".");n.unshift(o);}}return n;}var Wr=Nn({abs_:function abs_(t){var e=xn(t,"x","abs");return "complex64"===e.dtype?Wt.runKernelFunc(function(t){return t.complexAbs(e);},{$x:e}):Wt.runKernelFunc(function(t,n){var r=t.abs(e);return n([e]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return t.mul(n.toFloat().step(-1));}};},"Abs");}}),Vr=Nn({acos_:function acos_(t){var e=xn(t,"x","acos");return Wt.runKernelFunc(function(t,n){var r=t.acos(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.divStrict(Pn(1).sub(n.toFloat().square()).sqrt()).neg();}};});}}),qr=Nn({acosh_:function acosh_(t){var e=xn(t,"x","acosh");return Wt.runKernelFunc(function(t,n){var r=t.acosh(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.divStrict(n.toFloat().square().sub(1).sqrt());}};});}}),$r=Nn({asin_:function asin_(t){var e=xn(t,"x","asin");return Wt.runKernelFunc(function(t,n){var r=t.asin(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.divStrict(Pn(1).sub(n.toFloat().square()).sqrt());}};});}}),Hr=Nn({asinh_:function asinh_(t){var e=xn(t,"x","asinh");return Wt.runKernelFunc(function(t,n){var r=t.asinh(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.divStrict(Pn(1).add(n.toFloat().square()).sqrt());}};});}}),Gr=Nn({atan_:function atan_(t){var e=xn(t,"x","atan");return Wt.runKernelFunc(function(t,n){var r=t.atan(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(n.toFloat().square().add(1));}};});}}),Kr=Nn({atanh_:function atanh_(t){var e=xn(t,"x","atanh");return Wt.runKernelFunc(function(t,n){var r=t.atanh(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(Pn(1).sub(n.toFloat().square()));}};});}}),Xr=Nn({ceil_:function ceil_(t){var e=xn(t,"x","ceil");return Wt.runKernelFunc(function(t){return t.ceil(e);},{$x:e},function(t){return {$x:function $x(){return Qn(t);}};});}}),Yr=Nn({clipByValue_:function clipByValue_(t,e,n){var r=xn(t,"x","clipByValue");_(e<=n,function(){return "Error in clip: min ("+e+") must be less than or equal to max ("+n+").";});var i=[r],o={min:e,max:n};return Wt.runKernelFunc(function(t,i){var o=t.clip(r,e,n);return i([r]),o;},{x:r},function(t,r){var i=r[0];return {x:function x(){return t.where(i.greaterEqual(e).logicalAnd(i.lessEqual(n)),Qn(t));}};},"ClipByValue",o,i);}}),Jr=Nn({cos_:function cos_(t){var e=xn(t,"x","cos"),n=[e];return Wt.runKernelFunc(function(t,n){var r=t.cos(e);return n([e]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return n.toFloat().sin().neg().mul(t);}};},"Cos",{},n);}}),Qr=Nn({cosh_:function cosh_(t){var e=xn(t,"x","cosh");return Wt.runKernelFunc(function(t,n){var r=t.cosh(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return n.toFloat().sinh().mulStrict(t);}};});}}),Zr=Nn({erf_:function erf_(t){var e=xn(t,"x","erf");return _("int32"===e.dtype||"float32"===e.dtype,function(){return "Input dtype must be `int32` or `float32`.";}),"int32"===e.dtype&&(e=e.toFloat()),Wt.runKernelFunc(function(t,n){var r=t.erf(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.mul(n.square().neg().exp().mul(2/Math.sqrt(Math.PI)));}};});}}),ti=Nn({exp_:function exp_(t){var e=xn(t,"x","exp");return Wt.runKernelFunc(function(t,n){var r=t.exp(e);return n([r]),r;},{x:e},function(t,e){return {x:function x(){return t.mulStrict(e[0]);}};},"Exp",{},[],[!0]);}}),ei=Nn({expm1_:function expm1_(t){var e=xn(t,"x","expm1");return Wt.runKernelFunc(function(t,n){var r=t.expm1(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.mul(n.exp());}};});}}),ni=Nn({floor_:function floor_(t){var e=xn(t,"x","floor");return Wt.runKernelFunc(function(t){return t.floor(e);},{$x:e},function(t){return {$x:function $x(){return Qn(t);}};});}}),ri=Nn({log_:function log_(t){var e=xn(t,"x","log"),n=[e];return Wt.runKernelFunc(function(t,n){var r=t.log(e);return n([e]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return t.div(n.toFloat());}};},"Log",{},n);}}),ii=Nn({log1p_:function log1p_(t){var e=xn(t,"x","log1p");return Wt.runKernelFunc(function(t,n){var r=t.log1p(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(n.add(1));}};});}}),oi=Nn({logSigmoid_:function logSigmoid_(t){var e=xn(t,"x","logSigmoid");return Wt.runKernelFunc(function(t,n){var r=t.softplus(e.neg()).neg();return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.mul(n.neg().sigmoid());}};});}}),ai=Nn({neg_:function neg_(t){var e=xn(t,"x","neg"),n=[e];return Wt.runKernelFunc(function(t){return t.neg(e);},{x:e},function(t){return {x:function x(){return t.neg();}};},"Neg",{},n);}}),si=Nn({reciprocal_:function reciprocal_(t){var e=xn(t,"x","reciprocal");return Wt.runKernelFunc(function(t,n){var r=t.reciprocal(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(n.square().neg());}};});}}),ui=Nn({round_:function round_(t){var e=xn(t,"x","round");return Wt.runKernelFunc(function(t){return t.round(e);},{$x:e},function(t){return {$x:function $x(){return Qn(t);}};});}}),ci=Nn({rsqrt_:function rsqrt_(t){var e=xn(t,"x","rsqrt"),n=[e];return Wt.runKernelFunc(function(t,n){var r=t.rsqrt(e);return n([e]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return t.div(n.pow(1.5).mul(2)).neg();}};},"Rsqrt",{},n);}}),li=Nn({sigmoid_:function sigmoid_(t){var e=xn(t,"x","sigmoid");return Wt.runKernelFunc(function(t,n){var r=t.sigmoid(e);return n([r]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return t.mul(n.mul(Pn(1).sub(n)));}};},"Sigmoid");}}),fi=Nn({sign_:function sign_(t){var e=xn(t,"x","sign");return Wt.runKernelFunc(function(t){return t.sign(e);},{$x:e},function(t){return {$x:function $x(){return Qn(t);}};});}}),hi=Nn({isNaN_:function isNaN_(t){var e=xn(t,"x","isNaN");return Wt.runKernelFunc(function(t){return t.isNaN(e);},{$x:e},function(t){return {$x:function $x(){return Qn(t);}};});}}),di=Nn({isInf_:function isInf_(t){var e=xn(t,"x","isInf");return Wt.runKernelFunc(function(t){return t.isInf(e);},{$x:e},function(t){return {$x:function $x(){return Qn(t);}};});}}),pi=Nn({isFinite_:function isFinite_(t){var e=xn(t,"x","isFinite");return Wt.runKernelFunc(function(t){return t.isFinite(e);},{$x:e},function(t){return {$x:function $x(){return Qn(t);}};});}}),mi=Nn({sin_:function sin_(t){var e=xn(t,"x","sin"),n=[e];return Wt.runKernelFunc(function(t,n){var r=t.sin(e);return n([e]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return n.toFloat().cos().mul(t);}};},"Sin",{},n);}}),gi=Nn({sinh_:function sinh_(t){var e=xn(t,"x","sinh");return Wt.runKernelFunc(function(t,n){var r=t.sinh(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return n.toFloat().cosh().mulStrict(t);}};});}}),vi=Nn({softplus_:function softplus_(t){var e=xn(t,"x","softplus");return Wt.runKernelFunc(function(t,n){var r=t.softplus(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.mul(n.sigmoid());}};});}}),yi=Nn({sqrt_:function sqrt_(t){var e=xn(t,"x","sqrt");return Wt.runKernelFunc(function(t,n){var r=t.sqrt(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(n.toFloat().sqrt().mul(2));}};});}}),bi=Nn({step_:function step_(t,e){void 0===e&&(e=0);var n=xn(t,"x","step");return Wt.runKernelFunc(function(t){return t.step(n,e);},{$x:n},function(t){return {$x:function $x(){return Qn(t);}};});}}),xi=Nn({tan_:function tan_(t){var e=xn(t,"x","tan");return Wt.runKernelFunc(function(t,n){var r=t.tan(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(n.cos().square());}};});}}),wi=Nn({tanh_:function tanh_(t){var e=xn(t,"x","tanh");return Wt.runKernelFunc(function(t,n){var r=t.tanh(e);return n([r]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return Pn(1).sub(n.square()).mulStrict(t);}};},"Tanh",{},null,[!0]);}}),ki=Nn({addStrict_:function addStrict_(t,e){var n=xn(t,"a","addStrict"),r=xn(e,"b","addStrict");return S(n.shape,r.shape,"Error in addStrict: "),n.add(r);}}),Ei=Nn({atan2_:function atan2_(t,e){var n,r=xn(t,"a","atan2"),i=xn(e,"b","atan2");n=Mt(r,i),r=n[0],i=n[1];var o=Ur(r.shape,i.shape);return Wt.runKernelFunc(function(t,e){var n=t.atan2(r,i);return e([r,i]),n;},{$a:r,$b:i},function(t,e){var n=e[0],r=e[1];return {$a:function $a(){var e=Pr(n.square(),r.square()),i=t.mul(r.div(e)),a=zr(n.shape,o);return a.length>0&&(i=i.sum(a)),i.reshape(n.shape);},$b:function $b(){var e=Pr(n.square(),r.square()),i=ai(t.mul(n.div(e))),a=zr(r.shape,o);return a.length>0&&(i=i.sum(a)),i.reshape(r.shape);}};});}}),Ci=Nn({divStrict_:function divStrict_(t,e){var n=xn(t,"a","div"),r=xn(e,"b","div");return S(n.shape,r.shape,"Error in divideStrict: "),n.div(r);}}),Ai=Nn({floorDiv_:function floorDiv_(t,e){var n,r=xn(t,"a","floorDiv"),i=xn(e,"b","floorDiv");n=Mt(r,i),r=n[0],i=n[1];var o=Ur(r.shape,i.shape);return Wt.runKernelFunc(function(t,e){var n=t.floorDiv(r,i);return e([r,i]),n;},{a:r,b:i},function(t,e){var n=e[0],r=e[1];return {a:function a(){var e=t.div(r.toFloat()),i=zr(n.shape,o);return i.length>0?e.sum(i).reshape(n.shape):e;},b:function b(){var e=t.mul(n.toFloat()),i=zr(r.shape,o);i.length>0&&(e=e.sum(i).reshape(r.shape));var a=r.square();return e.div(a.toFloat()).neg();}};},"FloorDiv");}}),Oi=Nn({maximum_:function maximum_(t,e){var n,r=xn(t,"a","maximum"),i=xn(e,"b","maximum");return n=Mt(r,i),r=n[0],i=n[1],"bool"===r.dtype&&(r=r.toInt(),i=i.toInt()),Ur(r.shape,i.shape),Wt.runKernelFunc(function(t,e){var n=t.maximum(r,i);return e([r,i]),n;},{a:r,b:i},function(t,e){var n=e[0],r=e[1];return {a:function a(){return t.mul(n.greaterEqual(r).toFloat());},b:function b(){return t.mul(n.less(r).toFloat());}};},"Maximum");}}),_i=Nn({maximumStrict_:function maximumStrict_(t,e){var n=xn(t,"a","maximumStrict"),r=xn(e,"b","maximumStrict");return S(n.shape,r.shape,"Error in maximumStrict: "),n.maximum(r);}}),Si=Nn({minimum_:function minimum_(t,e){var n,r=xn(t,"a","minimum"),i=xn(e,"b","minimum");return n=Mt(r,i),r=n[0],i=n[1],"bool"===r.dtype&&(r=r.toInt(),i=i.toInt()),Ur(r.shape,i.shape),Wt.runKernelFunc(function(t,e){var n=t.minimum(r,i);return e([r,i]),n;},{a:r,b:i},function(t,e){var n=e[0],r=e[1];return {a:function a(){return t.mul(n.lessEqual(r).toFloat());},b:function b(){return t.mul(n.greater(r).toFloat());}};},"Minimum");}}),Di=Nn({minimumStrict_:function minimumStrict_(t,e){var n=xn(t,"a","minimumStrict"),r=xn(e,"b","minimumStrict");return S(n.shape,r.shape,"Error in minimumStrict: "),n.minimum(r);}}),Fi=Nn({mod_:function mod_(t,e){var n,r=xn(t,"a","mod"),i=xn(e,"b","mod");n=Mt(r,i),r=n[0],i=n[1];var o=Ur(r.shape,i.shape);return Wt.runKernelFunc(function(t,e){var n=t.mod(r,i);return e([r,i]),n;},{$a:r,$b:i},function(t,e){var n=e[0],r=e[1];return {$a:function $a(){var e=zr(n.shape,o);return e.length>0?t.sum(e).reshape(n.shape):t;},$b:function $b(){var e=t.mul(n.div(r).floor().neg()),i=zr(r.shape,o);return i.length>0?e.sum(i).reshape(r.shape):e;}};});}}),Ti=Nn({modStrict_:function modStrict_(t,e){var n=xn(t,"a","modStrict"),r=xn(e,"b","modStrict");return S(n.shape,r.shape,"Error in modStrict: "),n.mod(r);}}),Ni=Nn({mul_:function mul_(t,e){var n,r=xn(t,"a","mul"),i=xn(e,"b","mul");n=Mt(r,i),r=n[0],i=n[1];var o=Ur(r.shape,i.shape);return Wt.runKernelFunc(function(t,e){var n=t.multiply(r,i);return e([r,i]),n;},{a:r,b:i},function(t,e){var n=e[0],r=e[1];return {a:function a(){var e=t.mul(r.toFloat()),i=zr(n.shape,o);return i.length>0?e.sum(i).reshape(n.shape):e;},b:function b(){var e=t.mul(n.toFloat()),i=zr(r.shape,o);return i.length>0?e.sum(i).reshape(r.shape):e;}};},"Mul");}}),Ii=Nn({mulStrict_:function mulStrict_(t,e){var n=xn(t,"a","mul"),r=xn(e,"b","mul");return S(n.shape,r.shape,"Error in multiplyStrict: "),n.mul(r);}}),Ri=Nn({pow_:function pow_(t,e){var n,r=xn(t,"base","pow"),i=xn(e,"exp","pow");n=Mt(r,i),r=n[0],i=n[1];var o=Ur(r.shape,i.shape),a=[r,i];return Wt.runKernelFunc(function(t,e){var n=t.pow(r,i);return e([r,i,n]),n;},{a:r,b:i},function(t,e){var n=e[0],r=e[1],i=e[2];return {a:function a(){var e=r.toFloat(),i=t.mul(e.mul(n.pow(e.sub(Pn(1))))),a=zr(n.shape,o);return a.length>0&&(i=i.sum(a)),i.reshape(n.shape);},b:function b(){var e=n.greater(0),a=n.log().where(e,Qn(n)),s=t.mul(i.mul(a)),u=zr(r.shape,o);return u.length>0&&(s=s.sum(u)),s.reshape(r.shape);}};},"Pow",{},a,[!0]);}}),Mi=Nn({powStrict_:function powStrict_(t,e){return S(t.shape,e.shape,"Error in powStrict: "),t.pow(e);}}),ji=Nn({squaredDifferenceStrict_:function squaredDifferenceStrict_(t,e){var n=xn(t,"a","squaredDifferenceStrict"),r=xn(e,"b","squaredDifferenceStrict");return S(n.shape,r.shape,"Error in squaredDifferenceStrict: "),n.squaredDifference(r);}}),Bi=Nn({sub_:function sub_(t,e){var n,r=xn(t,"a","sub"),i=xn(e,"b","sub");n=Mt(r,i),r=n[0],i=n[1];var o=Ur(r.shape,i.shape);return Wt.runKernelFunc(function(t){return t.subtract(r,i);},{a:r,b:i},function(t){return {a:function a(){var e=t,n=zr(r.shape,o);return n.length>0&&(e=e.sum(n)),e.reshape(r.shape);},b:function b(){var e=t,n=zr(i.shape,o);return n.length>0&&(e=e.sum(n)),e.neg().reshape(i.shape);}};},"Sub");}}),Pi=Nn({subStrict_:function subStrict_(t,e){var n=xn(t,"a","subStrict"),r=xn(e,"b","subStrict");return S(n.shape,r.shape,"Error in subStrict: "),n.sub(r);}}),Li=Nn({div_:function div_(t,e){var n,r=xn(t,"a","div"),i=xn(e,"b","div");if(n=Mt(r,i),r=n[0],i=n[1],"int32"===r.dtype&&"int32"===i.dtype)return Ai(r,i);var o={a:r,b:i};return Wt.runKernelFunc(function(t,e){var n=t.realDivide(r,i);return e([r,i]),n;},o,null,Ar,{});}});function zi(t,e){if(t.rank<1)throw new Error("tf.gatherND() expects the input to be rank 1 or higher, but the rank was "+t.rank+".");if(e.rank<1)throw new Error("tf.gatherND() expects the indices to be rank 1 or higher, but the rank was "+e.rank+".");if("int32"!==e.dtype)throw new Error("tf.gatherND() expects the indices to be int32 type, but the dtype was "+e.dtype+".");if(e.shape[e.rank-1]>t.rank)throw new Error("index innermost dimension length must be <= tensor rank; saw: "+e.shape[e.rank-1]+" vs. "+t.rank);if(0===t.size)throw new Error("Requested more than 0 entries, but input is empty. Input shape: "+t.shape+".");for(var n=e.shape,r=n[n.length-1],i=1,o=0;o<n.length-1;++o){i*=n[o];}var a=t.shape,s=n.slice();s.pop();var u=1;for(o=r;o<t.rank;++o){u*=a[o],s.push(a[o]);}var c=et(t.shape).map(function(t){return t/u;}).concat([1]).slice(0,r);return [s,i,u,c];}var Ui=Object.freeze({prepareAndValidate:zi}),Wi=30;function Vi(t){return t<=Wi?t:tt(t,Math.floor(Math.sqrt(t)));}function qi(t,e,n){var r=e.rank>1?e.shape[e.rank-1]:1,i=e.rank>1?e.rank-1:1,o="Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: "+n.shape+", indices.shape: "+e.shape+", shape: "+t+", sliceDim: "+r+", and batchDim: "+i+".";if(n.rank<i)throw new Error(o+" update.rank < "+i+". ");if(t.length<r+(n.rank-i))throw new Error(o+" Output shape length < "+(r+(n.rank-i)));if(n.rank!==i+t.length-r)throw new Error(o+" update.rank != "+(i+t.length-r));for(var a=0;a<i;++a){if(n.shape[a]!==e.shape[a])throw new Error(o+" updates.shape["+a+"] ("+n.shape[a]+") != indices.shape["+a+"] ("+e.shape[a]+").");}for(a=0;a<n.rank-i;++a){if(n.shape[a+i]!==t[a+r])throw new Error(o+" updates.shape["+(a+i)+"] ("+n.shape[a+i]+") != shape["+(a+i)+"] ("+t[a+i]+")");}}function $i(t,e,n){if(e.rank<1)throw new Error("tf.scatterND() expects the indices to be rank 1 or higher, but the rank was "+e.rank+".");if(t.rank<1)throw new Error("tf.scatterND() expects the updates to be rank 1 or higher, but the rank was "+t.rank+".");if("int32"!==e.dtype)throw new Error("The dtype of 'indices' should be int32, but got dtype: "+e.dtype);if(n.length<1)throw new Error("Output rank must be greater or equal to 1, but got shape: "+n);if(0===n.length){if(0===e.size)throw new Error("Indices specified for empty output. indices shape: "+e.shape);if(0===t.size)throw new Error("Updates specified for empty output. updates shape: "+t.shape);}qi(n,e,t);}function Hi(t,e,n){for(var r=e.shape.length,i=r>1?e.shape[r-1]:1,o=n.length,a=1,s=i;s<o;++s){a*=n[s];}var u=i<1?1:i;return {sliceRank:i,numUpdates:T(e.shape)/u,sliceSize:a,strides:et(n.slice(0,i)).concat([1]),outputSize:T(n)};}var Gi=Object.freeze({validateUpdateShape:qi,validateInput:$i,calculateShapes:Hi});function Ki(t,e,n){_(t.rank===e.length,function(){return "Error in slice"+t.rank+"D: Length of begin "+e+" must match the rank of the array ("+t.rank+").";}),_(t.rank===n.length,function(){return "Error in slice"+t.rank+"D: Length of size "+n+" must match the rank of the array ("+t.rank+").";});for(var r=function r(_r3){_(e[_r3]+n[_r3]<=t.shape[_r3],function(){return "Error in slice"+t.rank+"D: begin["+_r3+"] + size["+_r3+"] ("+(e[_r3]+n[_r3])+") would overflow input.shape["+_r3+"] ("+t.shape[_r3]+")";});},i=0;i<t.rank;++i){r(i);}}function Xi(t){for(var e=[],n=0;t>0;){1&t&&e.push(n),t/=2,n++;}return e;}function Yi(t,e,n){for(var r=[],i=0;i<t.length;i++){r[i]=Math.ceil((e[i]-t[i])/n[i]);}return r;}function Ji(t,e,n,r,i){var o=e[i],a=n[i]||1;(t&1<<i||null==o)&&(o=a>0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);var s=r[i];return o<0&&(o+=s),C(0,o,s-1);}function Qi(t,e,n,r,i){var o=e[i],a=n[i]||1;(t&1<<i||null==o)&&(o=a>0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);var s=r[i];return o<0&&(o+=s),a>0?C(0,o,s):C(-1,o,s-1);}function Zi(t,e,n){for(var r=n.length,i=0;i<n.length;i++){if(n[i]>1){r=i;break;}}for(i=r+1;i<n.length;i++){if(e[i]>0||n[i]!==t[i])return !1;}return !0;}function to(t,e){for(var n=t.length>0?t[t.length-1]:1,r=0;r<t.length-1;r++){n+=t[r]*e[r];}return n;}var eo=Object.freeze({assertParamsValid:Ki,maskToAxes:Xi,computeOutShape:Yi,startForAxis:Ji,stopForAxis:Qi,isSliceContinous:Zi,computeFlatOffset:to});function no(t){return _(Z(t),function(){return "The f passed in grad(f) must be a function";}),function(e,n){var r=xn(e,"x","tf.grad",null),i=null!=n?xn(n,"dy","tf.grad"):null;return Wt.tidy(function(){var e=Wt.gradients(function(){return t(r);},[r],i),n=e.value,o=e.grads;return null!=i&&S(n.shape,i.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),uo(o),o[0];});};}function ro(t){return _(Z(t),function(){return "The f passed in grads(f) must be a function";}),function(e,n){_(Array.isArray(e),function(){return "The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s";});var r=wn(e,"args","tf.grads",null),i=null!=n?xn(n,"dy","tf.grads"):null;return Wt.tidy(function(){var e=Wt.gradients(function(){return t.apply(void 0,r);},r,i),n=e.value,o=e.grads;return null!=i&&S(n.shape,i.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),uo(o),o;});};}function io(t){return _(Z(t),function(){return "The f passed in valueAndGrad(f) must be a function";}),function(e,n){_(e instanceof At,function(){return "The x passed in valueAndGrad(f)(x) must be a tensor";}),_(null==n||n instanceof At,function(){return "The dy passed in valueAndGrad(f)(x, dy) must be a tensor";});var r=Wt.gradients(function(){return t(e);},[e],n),i=r.grads,o=r.value;return uo(i),{grad:i[0],value:o};};}function oo(t){return _(Z(t),function(){return "The f passed in valueAndGrads(f) must be a function";}),function(e,n){_(Array.isArray(e)&&e.every(function(t){return t instanceof At;}),function(){return "The args passed in valueAndGrads(f)(args) must be array of tensors";}),_(null==n||n instanceof At,function(){return "The dy passed in valueAndGrads(f)(args, dy) must be a tensor";});var r=Wt.gradients(function(){return t.apply(void 0,e);},e,n);return null!=n&&S(r.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),uo(r.grads),r;};}function ao(t,e){_(Z(t),function(){return "The f passed in variableGrads(f) must be a function";}),_(null==e||Array.isArray(e)&&e.every(function(t){return t instanceof Tt;}),function(){return "The varList passed in variableGrads(f, varList) must be an array of variables";});var n=null!=e;if(!n)for(var r in e=[],Wt.registeredVariables){e.push(Wt.registeredVariables[r]);}var i=n?e.filter(function(t){return !t.trainable;}):null,o=e.length;_((e=e.filter(function(t){return t.trainable;})).length>0,function(){return "variableGrads() expects at least one of the input variables to be trainable, but none of the "+o+" variables is trainable.";});var a=Wt.gradients(t,e,null,!0),s=a.value,u=a.grads;_(u.some(function(t){return null!=t;}),function(){return "Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize().";}),_(0===s.rank,function(){return "The f passed in variableGrads(f) must return a scalar, but it returned a rank-"+s.rank+" tensor";});var c={};return e.forEach(function(t,e){null!=u[e]&&(c[t.name]=u[e]);}),null!=i&&i.forEach(function(t){return c[t.name]=null;}),{value:s,grads:c};}function so(t){return Wt.customGrad(t);}function uo(t){if(t.filter(function(t){return null==t;}).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.");}var co=Nn({softmax_:function softmax_(t,e){void 0===e&&(e=-1);var n=xn(t,"logits","softmax","float32");if(-1===e&&(e=n.rank-1),e!==n.rank-1)throw Error("Softmax along a non-last dimension is not yet supported. Logits was rank "+n.rank+" and dim was "+e);return Wt.runKernelFunc(function(t,r){var i=t.softmax(n,e);return r([i]),i;},{logits:n},function(t,n){var r=n[0],i=t.mul(r);return {logits:function logits(){return i.sub(i.sum([e],!0).mul(r));}};},"Softmax",{dim:e},[],[!0]);}}),lo=Nn({logSoftmax_:function logSoftmax_(t,e){void 0===e&&(e=-1);var n=xn(t,"logits","logSoftmax");if(-1===e&&(e=n.rank-1),e!==n.rank-1)throw Error("Log Softmax along a non-last dimension is not yet supported. Logits was rank "+n.rank+" and axis was "+e);return so(function(t,n){var r=t.max(e,!0),i=t.sub(r),o=i.toFloat().sub(i.exp().sum(e,!0).log());return n([o]),{value:o,gradFunc:function gradFunc(t,n){var r=n[0].exp();return t.sub(t.sum(e,!0).mul(r));}};})(n);}}),fo=Nn({transpose_:function transpose_(t,e){var n=xn(t,"x","transpose");if(null==e&&(e=n.shape.map(function(t,e){return e;}).reverse()),_(n.rank===e.length,function(){return "Error in transpose: rank of input "+n.rank+" must match length of perm "+e+".";}),e.forEach(function(t){_(t>=0&&t<n.rank,function(){return "All entries in 'perm' must be between 0 and "+(n.rank-1)+" but got "+e;});}),n.rank<=1)return n.clone();var r={perm:e};return Wt.runKernelFunc(function(t){return t.transpose(n,e);},{x:n},null,"Transpose",r);}}),ho=function(){function t(t,e){this.backend=t,this.dataMover=e,this.data=new WeakMap(),this.dataIdsCount=0;}return t.prototype.get=function(t){return this.data.has(t)||this.dataMover.moveData(this.backend,t),this.data.get(t);},t.prototype.set=function(t,e){this.dataIdsCount++,this.data.set(t,e);},t.prototype.has=function(t){return this.data.has(t);},t.prototype.delete=function(t){return this.dataIdsCount--,this.data.delete(t);},t.prototype.numDataIds=function(){return this.dataIdsCount;},t;}(),po=function(){function t(){}return t.prototype.time=function(t){return mo("time");},t.prototype.read=function(t){return mo("read");},t.prototype.readSync=function(t){return mo("readSync");},t.prototype.numDataIds=function(){return mo("numDataIds");},t.prototype.disposeData=function(t){return mo("disposeData");},t.prototype.write=function(t,e,n){return mo("write");},t.prototype.move=function(t,e,n,r){return mo("move");},t.prototype.memory=function(){return mo("memory");},t.prototype.floatPrecision=function(){return mo("floatPrecision");},t.prototype.epsilon=function(){return 32===this.floatPrecision()?1e-7:1e-4;},t.prototype.batchMatMul=function(t,e,n,r){return mo("batchMatMul");},t.prototype.fusedBatchMatMul=function(t){return t.a,t.b,t.transposeA,t.transposeB,t.bias,t.activation,t.preluActivationWeights,mo("fusedBatchMatMul");},t.prototype.slice=function(t,e,n){return mo("slice");},t.prototype.stridedSlice=function(t,e,n,r){return mo("stridedSlice");},t.prototype.unstack=function(t,e){return mo("unstack");},t.prototype.reverse=function(t,e){return mo("reverse");},t.prototype.concat=function(t,e){return mo("concat");},t.prototype.neg=function(t){return mo("neg");},t.prototype.add=function(t,e){return mo("add");},t.prototype.addN=function(t){return mo("addN");},t.prototype.subtract=function(t,e){return mo("subtract");},t.prototype.multiply=function(t,e){return mo("multiply");},t.prototype.realDivide=function(t,e){return mo("realDivide");},t.prototype.floorDiv=function(t,e){return mo("floorDiv");},t.prototype.sum=function(t,e){return mo("sum");},t.prototype.prod=function(t,e){return mo("prod");},t.prototype.unsortedSegmentSum=function(t,e,n){return mo("unsortedSegmentSum");},t.prototype.argMin=function(t,e){return mo("argMin");},t.prototype.argMax=function(t,e){return mo("argMax");},t.prototype.equal=function(t,e){return mo("equal");},t.prototype.notEqual=function(t,e){return mo("notEqual");},t.prototype.less=function(t,e){return mo("less");},t.prototype.lessEqual=function(t,e){return mo("lessEqual");},t.prototype.greater=function(t,e){return mo("greater");},t.prototype.greaterEqual=function(t,e){return mo("greaterEqual");},t.prototype.logicalNot=function(t){return mo("logicalNot");},t.prototype.logicalAnd=function(t,e){return mo("logicalAnd");},t.prototype.logicalOr=function(t,e){return mo("logicalOr");},t.prototype.where=function(t){return mo("where");},t.prototype.select=function(t,e,n){return mo("select");},t.prototype.topk=function(t,e,n){return mo("topk");},t.prototype.min=function(t,e){return mo("min");},t.prototype.minimum=function(t,e){return mo("minimum");},t.prototype.mod=function(t,e){return mo("mod");},t.prototype.max=function(t,e){return mo("max");},t.prototype.maximum=function(t,e){return mo("maximum");},t.prototype.all=function(t,e){return mo("all");},t.prototype.any=function(t,e){return mo("any");},t.prototype.squaredDifference=function(t,e){return mo("squaredDifference");},t.prototype.ceil=function(t){return mo("ceil");},t.prototype.floor=function(t){return mo("floor");},t.prototype.round=function(t){return mo("round");},t.prototype.sign=function(t){return mo("sign");},t.prototype.isNaN=function(t){return mo("isNaN");},t.prototype.isInf=function(t){return mo("isInf");},t.prototype.isFinite=function(t){return mo("isFinite");},t.prototype.pow=function(t,e){return mo("pow");},t.prototype.exp=function(t){return mo("exp");},t.prototype.expm1=function(t){return mo("expm1");},t.prototype.softmax=function(t,e){return mo("softmax");},t.prototype.log=function(t){return mo("log");},t.prototype.log1p=function(t){return mo("log1p");},t.prototype.sqrt=function(t){return mo("sqrt");},t.prototype.rsqrt=function(t){return mo("rsqrt");},t.prototype.square=function(t){return mo("square");},t.prototype.reciprocal=function(t){return mo("reciprocal");},t.prototype.relu=function(t){return mo("relu");},t.prototype.relu6=function(t){return mo("relu6");},t.prototype.prelu=function(t,e){return mo("prelu");},t.prototype.elu=function(t){return mo("elu");},t.prototype.eluDer=function(t,e){return mo("eluDer");},t.prototype.selu=function(t){return mo("selu");},t.prototype.int=function(t){return mo("int");},t.prototype.clip=function(t,e,n){return mo("clip");},t.prototype.abs=function(t){return mo("abs");},t.prototype.complexAbs=function(t){return mo("complexAbs");},t.prototype.sigmoid=function(t){return mo("sigmoid");},t.prototype.softplus=function(t){return mo("softplus");},t.prototype.sin=function(t){return mo("sin");},t.prototype.cos=function(t){return mo("cos");},t.prototype.tan=function(t){return mo("tan");},t.prototype.asin=function(t){return mo("asin");},t.prototype.acos=function(t){return mo("acos");},t.prototype.atan=function(t){return mo("atan");},t.prototype.atan2=function(t,e){return mo("atan2");},t.prototype.sinh=function(t){return mo("sinh");},t.prototype.cosh=function(t){return mo("cosh");},t.prototype.tanh=function(t){return mo("tanh");},t.prototype.asinh=function(t){return mo("asinh");},t.prototype.acosh=function(t){return mo("acosh");},t.prototype.atanh=function(t){return mo("atanh");},t.prototype.erf=function(t){return mo("erf");},t.prototype.step=function(t,e){return mo("step");},t.prototype.fusedConv2d=function(t){return t.input,t.filter,t.convInfo,t.bias,t.activation,t.preluActivationWeights,mo("fusedConv2d");},t.prototype.conv2d=function(t,e,n){return mo("conv2d");},t.prototype.conv2dDerInput=function(t,e,n){return mo("conv2dDerInput");},t.prototype.conv2dDerFilter=function(t,e,n){return mo("conv2dDerFilter");},t.prototype.fusedDepthwiseConv2D=function(t){return t.input,t.filter,t.convInfo,t.bias,t.activation,t.preluActivationWeights,mo("fusedDepthwiseConv2D");},t.prototype.depthwiseConv2D=function(t,e,n){return mo("depthwiseConv2D");},t.prototype.depthwiseConv2DDerInput=function(t,e,n){return mo("depthwiseConv2DDerInput");},t.prototype.depthwiseConv2DDerFilter=function(t,e,n){return mo("depthwiseConv2DDerFilter");},t.prototype.conv3d=function(t,e,n){return mo("conv3d");},t.prototype.conv3dDerInput=function(t,e,n){return mo("conv3dDerInput");},t.prototype.conv3dDerFilter=function(t,e,n){return mo("conv3dDerFilter");},t.prototype.maxPool=function(t,e){return mo("maxPool");},t.prototype.maxPoolBackprop=function(t,e,n,r){return mo("maxPoolBackprop");},t.prototype.avgPool=function(t,e){return mo("avgPool");},t.prototype.avgPoolBackprop=function(t,e,n){return mo("avgPoolBackprop");},t.prototype.avgPool3d=function(t,e){return mo("avgPool3d");},t.prototype.avgPool3dBackprop=function(t,e,n){return mo("avgPool3dBackprop");},t.prototype.maxPool3d=function(t,e){return mo("maxPool3d");},t.prototype.maxPool3dBackprop=function(t,e,n,r){return mo("maxPool3dBackprop");},t.prototype.reshape=function(t,e){return mo("reshape");},t.prototype.cast=function(t,e){return mo("cast");},t.prototype.tile=function(t,e){return mo("tile");},t.prototype.pad=function(t,e,n){return mo("pad");},t.prototype.transpose=function(t,e){return mo("transpose");},t.prototype.gather=function(t,e,n){return mo("gather");},t.prototype.gatherND=function(t,e){return mo("gatherND");},t.prototype.scatterND=function(t,e,n){return mo("scatterND");},t.prototype.batchToSpaceND=function(t,e,n){return mo("batchToSpaceND");},t.prototype.spaceToBatchND=function(t,e,n){return mo("spaceToBatchND");},t.prototype.resizeBilinear=function(t,e,n,r){return mo("resizeBilinear");},t.prototype.resizeBilinearBackprop=function(t,e,n){return mo("resizeBilinearBackprop");},t.prototype.resizeNearestNeighbor=function(t,e,n,r){return mo("resizeNearestNeighbor");},t.prototype.resizeNearestNeighborBackprop=function(t,e,n){return mo("resizeNearestNeighborBackprop");},t.prototype.batchNormalization=function(t,e,n,r,i,o){return mo("batchNormalization");},t.prototype.localResponseNormalization4D=function(t,e,n,r,i){return mo("localResponseNormalization4D");},t.prototype.LRNGrad=function(t,e,n,r,i,o,a){return mo("LRNGrad");},t.prototype.multinomial=function(t,e,n,r){return mo("multinomial");},t.prototype.oneHot=function(t,e,n,r){return mo("oneHot");},t.prototype.cumsum=function(t,e,n,r){return mo("cumsum");},t.prototype.nonMaxSuppression=function(t,e,n,r,i){return mo("nonMaxSuppression");},t.prototype.fft=function(t){return mo("fft");},t.prototype.ifft=function(t){return mo("ifft");},t.prototype.complex=function(t,e){return mo("complex");},t.prototype.real=function(t){return mo("real");},t.prototype.imag=function(t){return mo("imag");},t.prototype.cropAndResize=function(t,e,n,r,i,o){return mo("cropAndResize");},t.prototype.depthToSpace=function(t,e,n){return mo("depthToSpace");},t.prototype.split=function(t,e,n){return mo("split");},t.prototype.sparseToDense=function(t,e,n,r){return mo("sparseToDense");},t.prototype.diag=function(t){return mo("diag");},t.prototype.fill=function(t,e,n){return mo("fill");},t.prototype.onesLike=function(t){return mo("onesLike");},t.prototype.zerosLike=function(t){return mo("zerosLike");},t.prototype.linspace=function(t,e,n){return mo("linspace");},t.prototype.dispose=function(){return mo("dispose");},t;}();function mo(t){throw new Error("'"+t+"' not yet implemented or not found in the registry. Did you forget to import the kernel?");}function go(t,e,n,r,i,o,a){void 0===a&&(a="channelsLast");var s,u=wo(e),c=u[0],l=u[1];if("channelsLast"===a)s=[c,l,t[3],t[3]];else {if("channelsFirst"!==a)throw new Error("Unknown dataFormat "+a);s=[c,l,t[1],t[1]];}return yo(t,s,n,r,i,o,!1,a);}function vo(t,e,n,r,i,o,a){void 0===a&&(a="NDHWC");var s,u,c=ko(e),l=c[0],f=c[1],h=c[2];if("NDHWC"===a)u="channelsLast",s=[l,f,h,t[4],t[4]];else {if("NCDHW"!==a)throw new Error("Unknown dataFormat "+a);u="channelsFirst",s=[l,f,h,t[1],t[1]];}return bo(t,s,n,r,i,!1,u,o);}function yo(t,e,n,r,i,o,a,s){void 0===a&&(a=!1),void 0===s&&(s="channelsLast");var u=[-1,-1,-1,-1],c=u[0],l=u[1],f=u[2],h=u[3];if("channelsLast"===s)c=t[0],l=t[1],f=t[2],h=t[3];else {if("channelsFirst"!==s)throw new Error("Unknown dataFormat "+s);c=t[0],h=t[1],l=t[2],f=t[3];}var d,p=e[0],m=e[1],g=e[3],v=wo(n),y=v[0],b=v[1],x=wo(r),w=x[0],k=x[1],E=Eo(p,w),C=Eo(m,k),A=function(t,e,n,r,i,o,a,s){var u,c,l;if("number"==typeof t){u={top:t,bottom:t,left:t,right:t,type:0===t?"VALID":"NUMBER"};var f=function(t,e,n,r,i){null==r&&(r=xo(t,e,n));var o=t[1],a=Co((t[0]-e+2*r)/n+1,i);_(I(a),function(){return "The output # of rows ("+a+") must be an integer. Change the stride and/or zero pad parameters";});var s=Co((o-e+2*r)/n+1,i);return _(I(s),function(){return "The output # of columns ("+s+") must be an integer. Change the stride and/or zero pad parameters";}),[a,s];}([e,n],o,r,t,s);c=f[0],l=f[1];}else if("same"===t){c=Math.ceil(e/r),l=Math.ceil(n/i);var h=Math.max(0,(c-1)*r+o-e),d=Math.max(0,(l-1)*i+a-n),p=Math.floor(h/2),m=h-p,g=Math.floor(d/2);u={top:p,bottom:m,left:g,right:d-g,type:"SAME"};}else {if("valid"!==t)throw Error("Unknown padding parameter: "+t);u={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((e-o+1)/r),l=Math.ceil((n-a+1)/i);}return {padInfo:u,outHeight:c,outWidth:l};}(i,l,f,y,b,E,C,o),O=A.padInfo,S=A.outHeight,D=A.outWidth,F=a?g*h:g;return "channelsFirst"===s?d=[c,F,S,D]:"channelsLast"===s&&(d=[c,S,D,F]),{batchSize:c,dataFormat:s,inHeight:l,inWidth:f,inChannels:h,outHeight:S,outWidth:D,outChannels:F,padInfo:O,strideHeight:y,strideWidth:b,filterHeight:p,filterWidth:m,effectiveFilterHeight:E,effectiveFilterWidth:C,dilationHeight:w,dilationWidth:k,inShape:t,outShape:d,filterShape:e};}function bo(t,e,n,r,i,o,a,s){void 0===o&&(o=!1),void 0===a&&(a="channelsLast");var u=[-1,-1,-1,-1,-1],c=u[0],l=u[1],f=u[2],h=u[3],d=u[4];if("channelsLast"===a)c=t[0],l=t[1],f=t[2],h=t[3],d=t[4];else {if("channelsFirst"!==a)throw new Error("Unknown dataFormat "+a);c=t[0],d=t[1],l=t[2],f=t[3],h=t[4];}var p,m=e[0],g=e[1],v=e[2],y=e[4],b=ko(n),x=b[0],w=b[1],k=b[2],E=ko(r),C=E[0],A=E[1],O=E[2],S=Eo(m,C),D=Eo(g,A),F=Eo(v,O),T=function(t,e,n,r,i,o,a,s,u,c,l){var f,h,d,p;if("number"==typeof t){f={top:t,bottom:t,left:t,right:t,front:t,back:t,type:0===t?"VALID":"NUMBER"};var m=function(t,e,n,r,i,o){null==i&&(i=xo(t,e,r));var a=t[1],s=t[2],u=Co((t[0]-e+2*i)/r+1,o);_(I(u),function(){return "The output # of depths ("+u+") must be an integer. Change the stride and/or zero pad parameters";});var c=Co((a-e+2*i)/r+1,o);_(I(c),function(){return "The output # of rows ("+c+") must be an integer. Change the stride and/or zero pad parameters";});var l=Co((s-e+2*i)/r+1,o);return _(I(l),function(){return "The output # of columns ("+l+") must be an integer. Change the stride and/or zero pad parameters";}),[u,c,l,1];}([e,n,r,1],s,0,i,t,l);h=m[0],d=m[1],p=m[2];}else if("same"===t){var g=((h=Math.ceil(e/i))-1)*i+s-e,v=((d=Math.ceil(n/o))-1)*o+u-n,y=((p=Math.ceil(r/a))-1)*a+c-r,b=Math.floor(g/2),x=g-b,w=Math.floor(v/2),k=v-w,E=Math.floor(y/2);f={top:w,bottom:k,left:E,right:y-E,front:b,back:x,type:"SAME"};}else {if("valid"!==t)throw Error("Unknown padding parameter: "+t);f={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},h=Math.ceil((e-s+1)/i),d=Math.ceil((n-u+1)/o),p=Math.ceil((r-c+1)/a);}return {padInfo:f,outDepth:h,outHeight:d,outWidth:p};}(i,l,f,h,x,w,k,S,D,F,s),N=T.padInfo,R=T.outDepth,M=T.outHeight,j=T.outWidth,B=o?y*d:y;return "channelsFirst"===a?p=[c,B,R,M,j]:"channelsLast"===a&&(p=[c,R,M,j,B]),{batchSize:c,dataFormat:a,inDepth:l,inHeight:f,inWidth:h,inChannels:d,outDepth:R,outHeight:M,outWidth:j,outChannels:B,padInfo:N,strideDepth:x,strideHeight:w,strideWidth:k,filterDepth:m,filterHeight:g,filterWidth:v,effectiveFilterDepth:S,effectiveFilterHeight:D,effectiveFilterWidth:F,dilationDepth:C,dilationHeight:A,dilationWidth:O,inShape:t,outShape:p,filterShape:e};}function xo(t,e,n,r){void 0===r&&(r=1);var i=Eo(e,r);return Math.floor((t[0]*(n-1)-n+i)/2);}function wo(t){return "number"==typeof t?[t,t,t]:2===t.length?[t[0],t[1],1]:t;}function ko(t){return "number"==typeof t?[t,t,t]:t;}function Eo(t,e){return e<=1?t:t+(t-1)*(e-1);}function Co(t,e){if(!e)return t;switch(e){case"round":return Math.round(t);case"ceil":return Math.ceil(t);case"floor":return Math.floor(t);default:throw new Error("Unknown roundingMode "+e);}}function Ao(t){var e=wo(t),n=e[0],r=e[1],i=e[2];return 1===n&&1===r&&1===i;}function Oo(t,e){return Ao(t)||Ao(e);}function _o(t){if("NHWC"===t)return "channelsLast";if("NCHW"===t)return "channelsFirst";throw new Error("Unknown dataFormat "+t);}function So(t,e,n){if("complex64"===e){if("complex64"===t.dtype)return t.clone();var r=Gn(t.shape),i=t.toFloat(),o=n.complex(i,r);return r.dispose(),i.dispose(),o;}if(!$(t.dtype,e))return Wt.makeTensorFromDataId(t.dataId,t.shape,e);if("complex64"===t.dtype){var a=n.real(t);return o=a.cast(e),a.dispose(),o;}if("int32"===e)return n.int(t);if("bool"===e){var s=Pn(0,t.dtype);return o=n.notEqual(t,s),s.dispose(),o;}throw new Error("Error in Cast: failed to cast "+t.dtype+" to "+e);}function Do(t,e){return Wt.makeTensorFromDataId(t.dataId,e,t.dtype);}function Fo(t,e,n){var r=(e-t)/(n-1),i=ot(n,"float32");i[0]=t;for(var o=1;o<i.length;o++){i[o]=i[o-1]+r;}return Ln(i,"float32");}var To=Object.freeze({castTensor:So,reshapeTensor:Do,linspaceImpl:Fo,upcastType:It,axesAreInnerMostDims:kn,combineLocations:En,computeOutAndReduceShapes:Cn,expandShapeToKeepDim:An,assertAxesAreInnerMostDims:On,getAxesPermutation:_n,getUndoAxesPermutation:Sn,getInnerMostAxes:Dn,getBroadcastDims:Lr,getReductionAxes:zr,assertAndGetBroadcastShape:Ur,assertParamsConsistent:Fn,computeOutShape:Tn,computePool2DInfo:go,computePool3DInfo:vo,computeConv2DInfo:yo,computeConv3DInfo:bo,computeDefaultPad:xo,tupleValuesAreOne:Ao,eitherStridesOrDilationsAreOne:Oo,convertConv2DDataFormat:_o,PARALLELIZE_THRESHOLD:Wi,computeOptimalWindowSize:Vi});function No(t,e){if(t.length!==e.length)throw new Error("Cannot merge real and imag arrays of different lengths. real:"+t.length+", imag: "+e.length+".");for(var n=new Float32Array(2*t.length),r=0;r<n.length;r+=2){n[r]=t[r/2],n[r+1]=e[r/2];}return n;}function Io(t,e){return {real:t[2*e],imag:t[2*e+1]};}function Ro(t,e,n,r){t[2*r]=e,t[2*r+1]=n;}function Mo(t,e,n){var r=(n?2:-2)*Math.PI*(t/e);return {real:Math.cos(r),imag:Math.sin(r)};}function jo(t,e,n){var r=function(t,e,n){return function(t,e,n){for(var r=0,i=t.length,o=0,a=!1;r<i;){var s=n(e,t[o=r+(i-r>>>1)]);s>0?r=o+1:(i=o,a=!s);}return a?r:-r-1;}(t,e,n||Bo);}(t,e,n),i=r<0?-(r+1):r;t.splice(i,0,e);}function Bo(t,e){return t>e?1:t<e?-1:0;}function Po(t,e,n,r,i){return zo(t,e,n,r,i,0).selectedIndices;}function Lo(t,e,n,r,i,o){var a=zo(t,e,n,r,i,o);return a.numValidOutputs.dispose(),{selectedIndices:a.selectedIndices,selectedScores:a.selectedScores};}function zo(t,e,n,r,i,o,a,s){void 0===s&&(s=!1);for(var u=Array.from(e).map(function(t,e){return {score:t,boxIndex:e,suppressBeginIndex:0};}).filter(function(t){return t.score>i;}).sort(Vo),c=o>0?-.5/o:0,l=[],f=[];l.length<n&&u.length>0;){var h=u.pop(),d=h.score,p=h.boxIndex,m=h.suppressBeginIndex;if(d<i)break;for(var g=!1,v=l.length-1;v>=m;--v){var y=Uo(t,p,l[v]);if(y>=r){g=!0;break;}if(h.score=h.score*Wo(r,c,y),h.score<=i)break;}h.suppressBeginIndex=l.length,g||(h.score===d?(l.push(p),f.push(h.score)):h.score>i&&jo(u,h,Vo));}var b=l.length;return s&&(l.fill(0,b),f.fill(0,b)),{selectedIndices:Ln(l,"int32"),selectedScores:Ln(f,"float32"),numValidOutputs:Pn(b,"int32")};}function Uo(t,e,n){var r=t.subarray(4*e,4*e+4),i=t.subarray(4*n,4*n+4),o=Math.min(r[0],r[2]),a=Math.min(r[1],r[3]),s=Math.max(r[0],r[2]),u=Math.max(r[1],r[3]),c=Math.min(i[0],i[2]),l=Math.min(i[1],i[3]),f=Math.max(i[0],i[2]),h=Math.max(i[1],i[3]),d=(s-o)*(u-a),p=(f-c)*(h-l);if(d<=0||p<=0)return 0;var m=Math.max(o,c),g=Math.max(a,l),v=Math.min(s,f),y=Math.min(u,h),b=Math.max(v-m,0)*Math.max(y-g,0);return b/(d+p-b);}function Wo(t,e,n){var r=Math.exp(e*n*n);return n<=t?r:0;}function Vo(t,e){return t.score-e.score||t.score===e.score&&e.boxIndex-t.boxIndex;}function qo(t,e,n){var r=new Array(t.rank).fill(0),i=t.shape.slice();return e.map(function(e){i[n]=e;var o=t.slice(r,i);return r[n]+=e,o;});}function $o(t,e){for(var n=new Array(t.rank),r=0;r<n.length;r++){n[r]=t.shape[r]*e[r];}var i=or(n,t.dtype);for(r=0;r<i.values.length;++r){for(var o=i.indexToLoc(r),a=new Array(t.rank),s=0;s<a.length;s++){a[s]=o[s]%t.shape[s];}var u=t.locToIndex(a);i.values[r]=t.values[u];}return i.toTensor();}function Ho(t,e,n,r,i){for(var o=e[e.length-1],a=[t.length/o,o],s=a[0],u=a[1],c=U(n,s*r),l=U("int32",s*r),f=0;f<s;f++){for(var h=f*u,d=t.subarray(h,h+u),p=[],m=0;m<d.length;m++){p.push({value:d[m],index:m});}p.sort(function(t,e){return e.value-t.value;});var g=f*r,v=c.subarray(g,g+r),y=l.subarray(g,g+r);for(m=0;m<r;m++){v[m]=p[m].value,y[m]=p[m].index;}}var b=e.slice();return b[b.length-1]=r,[jn(c,b,n),jn(l,b,"int32")];}function Go(t,e){for(var n=[],r=0;r<e.length;r++){e[r]&&n.push(r);}var i=or(t,"int32"),o=or([n.length,t.length],"int32");for(r=0;r<n.length;r++){var a=i.indexToLoc(n[r]),s=r*t.length;o.values.set(a,s);}return o.toTensor();}function Ko(t,e){return ["x","y","z","w","u","v"].slice(0,e).map(function(e){return t+"."+e;});}function Xo(t,e){return 1===e?[t]:Ko(t,e);}function Yo(){var t,e,n,r,i,o,a,s,u,c;return 2===f().getNumber("WEBGL_VERSION")?(t="#version 300 es",e="in",n="out",r="in",i="texture",o="outputColor",a="out vec4 outputColor;",s="\n      bool isnan_custom(float val) {\n        return (val > 0.0 || val < 0.0) ? false : val != 0.0;\n      }\n\n      bvec4 isnan_custom(vec4 val) {\n        return bvec4(isnan_custom(val.x),\n          isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n      }\n\n      #define isnan(value) isnan_custom(value)\n    ",u="",c="\n      #define round(value) newRound(value)\n      int newRound(float value) {\n        return int(floor(value + 0.5));\n      }\n\n      ivec4 newRound(vec4 value) {\n        return ivec4(floor(value + vec4(0.5)));\n      }\n    "):(t="",e="attribute",n="varying",r="varying",i="texture2D",o="gl_FragColor",a="",s="\n      #define isnan(value) isnan_custom(value)\n      bool isnan_custom(float val) {\n        return (val > 0. || val < 1. || val == 0.) ? false : true;\n      }\n      bvec4 isnan_custom(vec4 val) {\n        return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n      }\n    ",u="\n      uniform float INFINITY;\n\n      bool isinf(float val) {\n        return abs(val) == INFINITY;\n      }\n      bvec4 isinf(vec4 val) {\n        return equal(abs(val), vec4(INFINITY));\n      }\n    ",c="\n      int round(float value) {\n        return int(floor(value + 0.5));\n      }\n\n      ivec4 round(vec4 value) {\n        return ivec4(floor(value + vec4(0.5)));\n      }\n    "),{version:t,attribute:e,varyingVs:n,varyingFs:r,texture2D:i,output:o,defineOutput:a,defineSpecialNaN:s,defineSpecialInf:u,defineRound:c};}function Jo(t,e,n){void 0===n&&(n="index");var r=et(e);return r.map(function(e,i){return "int "+t[i]+" = "+n+" / "+e+"; "+(i===r.length-1?"int "+t[i+1]+" = "+n+" - "+t[i]+" * "+e:"index -= "+t[i]+" * "+e)+";";}).join("");}function Qo(t){var e=et(t).map(function(t){return t.toString();});return "\n  int getFlatIndex(ivec3 coords) {\n    return coords.x * "+e[0]+" + coords.y * "+e[1]+" + coords.z;\n  }\n";}var Zo="\n  const float FLOAT_MAX = 1.70141184e38;\n  const float FLOAT_MIN = 1.17549435e-38;\n\n  lowp vec4 encode_float(highp float v) {\n    if (isnan(v)) {\n      return vec4(255, 255, 255, 255);\n    }\n\n    highp float av = abs(v);\n\n    if(av < FLOAT_MIN) {\n      return vec4(0.0, 0.0, 0.0, 0.0);\n    } else if(v > FLOAT_MAX) {\n      return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n    } else if(v < -FLOAT_MAX) {\n      return vec4(0.0, 0.0,  128.0, 255.0) / 255.0;\n    }\n\n    highp vec4 c = vec4(0,0,0,0);\n\n    highp float e = floor(log2(av));\n    highp float m = exp2(fract(log2(av))) - 1.0;\n\n    c[2] = floor(128.0 * m);\n    m -= c[2] / 128.0;\n    c[1] = floor(32768.0 * m);\n    m -= c[1] / 32768.0;\n    c[0] = floor(8388608.0 * m);\n\n    highp float ebias = e + 127.0;\n    c[3] = floor(ebias / 2.0);\n    ebias -= c[3] * 2.0;\n    c[2] += floor(ebias) * 128.0;\n\n    c[3] += 128.0 * step(0.0, -v);\n\n    return c / 255.0;\n  }\n";function ta(t,e,n,r){var i=[];t.forEach(function(t){var e=T(t.shapeInfo.logicalShape);t.shapeInfo.isUniform?i.push("uniform float "+t.name+(e>1?"["+e+"]":"")+";"):(i.push("uniform sampler2D "+t.name+";"),i.push("uniform int offset"+t.name+";"));});var o,a,s=i.join("\n"),u=t.map(function(t){return function(t,e,n){void 0===n&&(n=!1);var r="";r+=n?function t(e){var n,r,i;switch(e.shapeInfo.logicalShape.length){case 0:return n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),i=Yo(),"\n    vec4 "+r+"() {\n      return "+i.texture2D+"("+n+", halfCR);\n    }\n  ";case 1:return function(t){var e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1),r=t.shapeInfo.texShape,i=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)],o=Yo();return "\n    vec4 "+n+"(int index) {\n      vec2 uv = packedUVfrom1D(\n        "+i[0]+", "+i[1]+", index);\n      return "+o.texture2D+"("+e+", uv);\n    }\n  ";}(e);case 2:return function(t){var e=t.shapeInfo.logicalShape,n=t.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),i=t.shapeInfo.texShape,o=i[0],a=i[1],s=Yo();if(null!=i&&N(e,i))return "\n      vec4 "+r+"(int row, int col) {\n        vec2 uv = (vec2(col, row) + halfCR) / vec2("+a+".0, "+o+".0);\n\n        return "+s.texture2D+"("+n+", uv);\n      }\n    ";var u=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)],c=Math.ceil(e[1]/2);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  ";}(e);case 3:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,i="get"+r.charAt(0).toUpperCase()+r.slice(1),o=e.shapeInfo.texShape,a=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)];if(1===n[0]){var s=n.slice(1),u=ua(e,s);return "\n        "+t(u)+"\n        vec4 "+i+"(int b, int row, int col) {\n          return "+i+"("+ca(["b","row","col"],[1,2])+");\n        }\n      ";}var c=a[0],l=a[1],f=Math.ceil(n[2]/2),h=f*Math.ceil(n[1]/2),d=Yo();return "\n    vec4 "+i+"(int b, int row, int col) {\n      vec2 uv = packedUVfrom3D(\n        "+c+", "+l+", "+h+", "+f+", b, row, col);\n      return "+d.texture2D+"("+r+", uv);\n    }\n  ";}(e);default:return function(t){for(var e=t.shapeInfo.logicalShape,n=e.length,r=t.name,i="get"+r.charAt(0).toUpperCase()+r.slice(1),o=t.shapeInfo.texShape,a=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)],s=a[0],u=a[1],c=Math.ceil(e[n-1]/2),l=c*Math.ceil(e[n-2]/2),f="int b, int row, int col",h="b * "+l+" + (row / 2) * "+c+" + (col / 2)",d=2;d<n-1;d++){f="int b"+d+", "+f,l*=e[n-d-1],h="b"+d+" * "+l+" + "+h;}var p=Yo();return "\n    vec4 "+i+"("+f+") {\n      int index = "+h+";\n      int texR = index / "+u+";\n      int texC = index - texR * "+u+";\n      vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+u+", "+s+");\n      return "+p.texture2D+"("+r+", uv);\n    }\n  ";}(e);}}(t):function t(e){var n=e.shapeInfo.logicalShape;switch(n.length){case 0:return function(t){var e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1);if(t.shapeInfo.isUniform)return "float "+n+"() {return "+e+";}";var r=t.shapeInfo.texShape,i=r[0],o=r[1];if(1===i&&1===o)return "\n      float "+n+"() {\n        return sampleTexture("+e+", halfCR);\n      }\n    ";var a=t.shapeInfo.texShape,s=a[0],u=a[1],c=oa(e);return "\n    float "+n+"() {\n      vec2 uv = uvFromFlat("+s+", "+u+", "+c+");\n      return sampleTexture("+e+", uv);\n    }\n  ";}(e);case 1:return function(t){var e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1);if(t.shapeInfo.isUniform)return "\n      float "+n+"(int index) {\n        "+aa(t)+"\n      }\n    ";var r=t.shapeInfo.texShape,i=r[0],o=r[1];if(1===o&&1===i)return "\n      float "+n+"(int index) {\n        return sampleTexture("+e+", halfCR);\n      }\n    ";var a=oa(e);return 1===o?"\n      float "+n+"(int index) {\n        vec2 uv = vec2(0.5, (float(index + "+a+") + 0.5) / "+i+".0);\n        return sampleTexture("+e+", uv);\n      }\n    ":1===i?"\n      float "+n+"(int index) {\n        vec2 uv = vec2((float(index + "+a+") + 0.5) / "+o+".0, 0.5);\n        return sampleTexture("+e+", uv);\n      }\n    ":"\n    float "+n+"(int index) {\n      vec2 uv = uvFromFlat("+i+", "+o+", index + "+a+");\n      return sampleTexture("+e+", uv);\n    }\n  ";}(e);case 2:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,i="get"+r.charAt(0).toUpperCase()+r.slice(1),o=e.shapeInfo.texShape;if(null!=o&&N(n,o)){var a=o[0],s=o[1];return "\n    float "+i+"(int row, int col) {\n      vec2 uv = (vec2(col, row) + halfCR) / vec2("+s+".0, "+a+".0);\n      return sampleTexture("+r+", uv);\n    }\n  ";}var u=z(n),c=u.newShape,l=u.keptDims,f=c;if(f.length<n.length){var h=ua(e,f);return "\n      "+t(h)+"\n      float "+i+"(int row, int col) {\n        return "+i+"("+ca(["row","col"],l)+");\n      }\n    ";}if(e.shapeInfo.isUniform)return "\n      float "+i+"(int row, int col) {\n        int index = round(dot(vec2(row, col), vec2("+n[1]+", 1)));\n        "+aa(e)+"\n      }\n    ";var d=o[0],p=o[1],m=oa(r);return 1===p?"\n    float "+i+"(int row, int col) {\n      float index = dot(vec3(row, col, "+m+"), vec3("+n[1]+", 1, 1));\n      vec2 uv = vec2(0.5, (index + 0.5) / "+d+".0);\n      return sampleTexture("+r+", uv);\n    }\n  ":1===d?"\n    float "+i+"(int row, int col) {\n      float index = dot(vec3(row, col, "+m+"), vec3("+n[1]+", 1, 1));\n      vec2 uv = vec2((index + 0.5) / "+p+".0, 0.5);\n      return sampleTexture("+r+", uv);\n    }\n  ":"\n  float "+i+"(int row, int col) {\n    // Explicitly use integer operations as dot() only works on floats.\n    int index = row * "+n[1]+" + col + "+m+";\n    vec2 uv = uvFromFlat("+d+", "+p+", index);\n    return sampleTexture("+r+", uv);\n  }\n";}(e);case 3:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,i="get"+r.charAt(0).toUpperCase()+r.slice(1),o=n[1]*n[2],a=n[2],s=z(n),u=s.newShape,c=s.keptDims,l=u;if(l.length<n.length){var f=ua(e,l);return "\n        "+t(f)+"\n        float "+i+"(int row, int col, int depth) {\n          return "+i+"("+ca(["row","col","depth"],c)+");\n        }\n      ";}if(e.shapeInfo.isUniform)return "\n      float "+i+"(int row, int col, int depth) {\n        int index = round(dot(vec3(row, col, depth),\n                          vec3("+o+", "+a+", 1)));\n        "+aa(e)+"\n      }\n    ";var h=e.shapeInfo.texShape,d=h[0],p=h[1],m=e.shapeInfo.flatOffset;if(p===o&&null==m)return "\n        float "+i+"(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("+p+".0, "+d+".0);\n          return sampleTexture("+r+", uv);\n        }\n      ";if(p===a&&null==m)return "\n    float "+i+"(int row, int col, int depth) {\n      float texR = dot(vec2(row, col), vec2("+n[1]+", 1));\n      float texC = float(depth);\n      vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+p+".0, "+d+".0);\n      return sampleTexture("+r+", uv);\n    }\n  ";var g=oa(r);return "\n      float "+i+"(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 + "+g+";\n        vec2 uv = uvFromFlat("+d+", "+p+", index);\n        return sampleTexture("+r+", uv);\n      }\n  ";}(e);case 4:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,i="get"+r.charAt(0).toUpperCase()+r.slice(1),o=n[3],a=n[2]*o,s=n[1]*a,u=z(n),c=u.newShape,l=u.keptDims;if(c.length<n.length){var f=ua(e,c);return "\n      "+t(f)+"\n      float "+i+"(int row, int col, int depth, int depth2) {\n        return "+i+"("+ca(["row","col","depth","depth2"],l)+");\n      }\n    ";}if(e.shapeInfo.isUniform)return "\n      float "+i+"(int row, int col, int depth, int depth2) {\n        int index = round(dot(vec4(row, col, depth, depth2),\n                          vec4("+s+", "+a+", "+o+", 1)));\n        "+aa(e)+"\n      }\n    ";var h=e.shapeInfo.flatOffset,d=e.shapeInfo.texShape,p=d[0],m=d[1];if(m===s&&null==h)return "\n      float "+i+"(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("+m+".0, "+p+".0);\n        return sampleTexture("+r+", uv);\n      }\n    ";if(m===o&&null==h)return "\n      float "+i+"(int row, int col, int depth, int depth2) {\n        float texR = dot(vec3(row, col, depth),\n                         vec3("+n[1]*n[2]+", "+n[2]+", 1));\n        float texC = float(depth2);\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2("+m+".0, "+p+".0);\n        return sampleTexture("+r+", uv);\n      }\n    ";var g=oa(r);return "\n    float "+i+"(int row, int col, int depth, int depth2) {\n      // Explicitly use integer operations as dot() only works on floats.\n      int index = row * "+s+" + col * "+a+" +\n          depth * "+o+" + depth2;\n      vec2 uv = uvFromFlat("+p+", "+m+", index + "+g+");\n      return sampleTexture("+r+", uv);\n    }\n  ";}(e);case 5:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,i="get"+r.charAt(0).toUpperCase()+r.slice(1),o=n[4],a=n[3]*o,s=n[2]*a,u=n[1]*s,c=z(n),l=c.newShape,f=c.keptDims;if(l.length<n.length){var h=ua(e,l);return "\n      "+t(h)+"\n      float "+i+"(int row, int col, int depth, int depth2, int depth3) {\n        return "+i+"("+ca(["row","col","depth","depth2","depth3"],f)+");\n      }\n    ";}if(e.shapeInfo.isUniform)return "\n      float "+i+"(int row, int col, int depth, int depth2, int depth3) {\n        float index = dot(\n          vec4(row, col, depth, depth2),\n          vec4("+u+", "+s+", "+a+", "+o+")) +\n          depth3;\n        "+aa(e)+"\n      }\n    ";var d=e.shapeInfo.flatOffset,p=e.shapeInfo.texShape,m=p[0],g=p[1];if(g===u&&null==d)return "\n      float "+i+"(int row, int col, int depth, int depth2, int depth3) {\n        int texR = row;\n        float texC = dot(vec4(col, depth, depth2, depth3),\n                         vec4("+s+", "+a+", "+o+", 1));\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                   vec2("+g+".0, "+m+".0);\n        return sampleTexture("+r+", uv);\n      }\n    ";if(g===o&&null==d)return "\n      float "+i+"(int row, int col, int depth, int depth2, int depth3) {\n        float texR = dot(\n          vec4(row, col, depth, depth2),\n          vec4("+n[1]*n[2]*n[3]+",\n               "+n[2]*n[3]+", "+n[3]+", 1));\n        int texC = depth3;\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2("+g+".0, "+m+".0);\n        return sampleTexture("+r+", uv);\n      }\n    ";var v=oa(r);return "\n    float "+i+"(int row, int col, int depth, int depth2, int depth3) {\n      // Explicitly use integer operations as dot() only works on floats.\n      int index = row * "+u+" + col * "+s+" + depth * "+a+" +\n          depth2 * "+o+" + depth3 + "+v+";\n      vec2 uv = uvFromFlat("+m+", "+g+", index);\n      return sampleTexture("+r+", uv);\n    }\n  ";}(e);case 6:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,i="get"+r.charAt(0).toUpperCase()+r.slice(1),o=z(n),a=o.newShape,s=o.keptDims;if(a.length<n.length){var u=ua(e,a);return "\n      "+t(u)+"\n      float "+i+"(int row, int col, int depth,\n                    int depth2, int depth3, int depth4) {\n        return "+i+"("+ca(["row","col","depth","depth2","depth3","depth4"],s)+");\n      }\n    ";}var c=n[5],l=n[4]*c,f=n[3]*l,h=n[2]*f,d=n[1]*h;if(e.shapeInfo.isUniform)return "\n      float "+i+"(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("+d+", "+h+", "+f+", "+l+")) +\n          dot(\n            vec2(depth3, depth4),\n            vec2("+c+", 1)));\n        "+aa(e)+"\n      }\n    ";var p=e.shapeInfo.flatOffset,m=e.shapeInfo.texShape,g=m[0],v=m[1];if(v===d&&null==p)return "\n      float "+i+"(int row, int col, int depth,\n                    int depth2, int depth3, int depth4) {\n        int texR = row;\n        float texC = dot(vec4(col, depth, depth2, depth3),\n          vec4("+h+", "+f+", "+l+", "+c+")) +\n               float(depth4);\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                   vec2("+v+".0, "+g+".0);\n        return sampleTexture("+r+", uv);\n      }\n    ";if(v===c&&null==p)return "\n      float "+i+"(int row, int col, int depth,\n                    int depth2, int depth3, int depth4) {\n        float texR = dot(vec4(row, col, depth, depth2),\n          vec4("+n[1]*n[2]*n[3]*n[4]+",\n               "+n[2]*n[3]*n[4]+",\n               "+n[3]*n[4]+",\n               "+n[4]+")) + float(depth3);\n        int texC = depth4;\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2("+v+".0, "+g+".0);\n        return sampleTexture("+r+", uv);\n      }\n    ";var y=oa(r);return "\n    float "+i+"(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 * "+d+" + col * "+h+" + depth * "+f+" +\n          depth2 * "+l+" + depth3 * "+c+" + depth4 + "+y+";\n      vec2 uv = uvFromFlat("+g+", "+v+", index);\n      return sampleTexture("+r+", uv);\n    }\n  ";}(e);default:throw new Error(n.length+"-D input sampling is not yet supported");}}(t);var i=t.shapeInfo.logicalShape,o=e.logicalShape;return i.length<=o.length&&(r+=n?function(t,e){var n,r=t.name,i=r.charAt(0).toUpperCase()+r.slice(1),o="get"+i+"AtOutCoords",a=t.shapeInfo.logicalShape.length,s=e.logicalShape.length,u=Lr(t.shapeInfo.logicalShape,e.logicalShape),c=sa(s),l=s-a,f=["x","y","z","w","u","v"];n=0===a?"":s<2&&u.length>=1?"coords = 0;":u.map(function(t){return "coords."+f[t+l]+" = 0;";}).join("\n");var h;h=s<2&&a>0?"coords":t.shapeInfo.logicalShape.map(function(t,e){return "coords."+f[e+l];}).join(", ");var d="return outputValue;",p=1===T(t.shapeInfo.logicalShape),m=1===T(e.logicalShape);if(1!==a||p||m){if(p&&!m)d=1===s?"\n        return vec4(outputValue.x, outputValue.x, 0., 0.);\n      ":"\n        return vec4(outputValue.x);\n      ";else if(u.length){var g=a-2,v=a-1;u.indexOf(g)>-1&&u.indexOf(v)>-1?d="return vec4(outputValue.x);":u.indexOf(g)>-1?d="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":u.indexOf(v)>-1&&(d="return vec4(outputValue.xx, outputValue.zz);");}}else d="\n      return vec4(outputValue.xy, outputValue.xy);\n    ";return "\n    vec4 "+o+"() {\n      "+c+" coords = getOutputCoords();\n      "+n+"\n      vec4 outputValue = get"+i+"("+h+");\n      "+d+"\n    }\n  ";}(t,e):function(t,e){var n=t.name,r=n.charAt(0).toUpperCase()+n.slice(1),i="get"+r+"AtOutCoords",o=e.texShape,a=t.shapeInfo.texShape,s=t.shapeInfo.logicalShape.length,u=e.logicalShape.length;if(!t.shapeInfo.isUniform&&s===u&&null==t.shapeInfo.flatOffset&&N(a,o))return "\n      float "+i+"() {\n        return sampleTexture("+n+", resultUV);\n      }\n    ";var c=sa(u),l=Lr(t.shapeInfo.logicalShape,e.logicalShape),f=u-s,h=["x","y","z","w","u","v"];return "\n    float "+i+"() {\n      "+c+" coords = getOutputCoords();\n      "+(0===s?"":u<2&&l.length>=1?"coords = 0;":l.map(function(t){return "coords."+h[t+f]+" = 0;";}).join("\n"))+"\n      return get"+r+"("+(u<2&&s>0?"coords":t.shapeInfo.logicalShape.map(function(t,e){return "coords."+h[e+f];}).join(", "))+");\n    }\n  ";}(t,e)),r;}(t,e,r);}).join("\n"),c=e.texShape,l=Yo(),f="\n    float sampleTexture(sampler2D textureSampler, vec2 uv) {\n      return "+l.texture2D+"(textureSampler, uv).r;\n    }\n  ",h=function(t){return t.version+"\n    precision highp float;\n    precision highp int;\n    precision highp sampler2D;\n    "+t.varyingFs+" vec2 resultUV;\n    "+t.defineOutput+"\n    const vec2 halfCR = vec2(0.5, 0.5);\n\n    struct ivec5\n    {\n      int x;\n      int y;\n      int z;\n      int w;\n      int u;\n    };\n\n    struct ivec6\n    {\n      int x;\n      int y;\n      int z;\n      int w;\n      int u;\n      int v;\n    };\n\n    uniform float NAN;\n    "+t.defineSpecialNaN+"\n    "+t.defineSpecialInf+"\n    "+t.defineRound+"\n\n    int imod(int x, int y) {\n      return x - y * (x / y);\n    }\n\n    int idiv(int a, int b, float sign) {\n      int res = a / b;\n      int mod = imod(a, b);\n      if (sign < 0. && mod != 0) {\n        res -= 1;\n      }\n      return res;\n    }\n\n    //Based on the work of Dave Hoskins\n    //https://www.shadertoy.com/view/4djSRW\n    #define HASHSCALE1 443.8975\n    float random(float seed){\n      vec2 p = resultUV * seed;\n      vec3 p3  = fract(vec3(p.xyx) * HASHSCALE1);\n      p3 += dot(p3, p3.yzx + 19.19);\n      return fract((p3.x + p3.y) * p3.z);\n    }\n\n    "+ea+"\n    "+na+"\n    "+ra+"\n  ";}(l);return e.isPacked?(o=function(t,e){switch(t.length){case 0:return "\n    int getOutputCoords() {\n      return 0;\n    }\n  ";case 1:return function(t,e){var n=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];return 1===n[0]?"\n      int getOutputCoords() {\n        return 2 * int(resultUV.x * "+n[1]+".0);\n      }\n    ":1===n[1]?"\n      int getOutputCoords() {\n        return 2 * int(resultUV.y * "+n[0]+".0);\n      }\n    ":"\n    int getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+n[0]+", "+n[1]+"));\n      return 2 * (resTexRC.x * "+n[1]+" + resTexRC.y);\n    }\n  ";}(0,e);case 2:return function(t,e){var n=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(N(t,e))return "\n      ivec2 getOutputCoords() {\n        return 2 * ivec2(resultUV.yx * vec2("+n[0]+", "+n[1]+"));\n      }\n    ";var r=Math.ceil(t[1]/2);return "\n    ivec2 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+n[0]+", "+n[1]+"));\n\n      int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n      int r = 2 * (index / "+r+");\n      int c = imod(index, "+r+") * 2;\n\n      return ivec2(r, c);\n    }\n  ";}(t,e);case 3:return n=t,r=e,i=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)],a=(o=Math.ceil(n[2]/2))*Math.ceil(n[1]/2),"\n    ivec3 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+i[0]+", "+i[1]+"));\n      int index = resTexRC.x * "+i[1]+" + resTexRC.y;\n\n      int b = index / "+a+";\n      index -= b * "+a+";\n\n      int r = 2 * (index / "+o+");\n      int c = imod(index, "+o+") * 2;\n\n      return ivec3(b, r, c);\n    }\n  ";default:return function(t,e){for(var n=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],r=Math.ceil(t[t.length-1]/2),i=r*Math.ceil(t[t.length-2]/2),o=i,a="",s="b, r, c",u=2;u<t.length-1;u++){a="\n      int b"+u+" = index / "+(o*=t[t.length-u-1])+";\n      index -= b"+u+" * "+o+";\n    "+a,s="b"+u+", "+s;}return "\n    ivec"+t.length+" getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+n[0]+", "+n[1]+"));\n      int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n\n      "+a+"\n\n      int b = index / "+i+";\n      index -= b * "+i+";\n\n      int r = 2 * (index / "+r+");\n      int c = imod(index, "+r+") * 2;\n\n      return ivec"+t.length+"("+s+");\n    }\n  ";}(t,e);}var n,r,i,o,a;}(e.logicalShape,c),a="\n    void setOutput(vec4 val) {\n      "+l.output+" = val;\n    }\n  "):(o=function(t,e){switch(t.length){case 0:return "\n    int getOutputCoords() {\n      return 0;\n    }\n  ";case 1:return function(t,e){return 1===e[0]?"\n      int getOutputCoords() {\n        return int(resultUV.x * "+e[1]+".0);\n      }\n    ":1===e[1]?"\n      int getOutputCoords() {\n        return int(resultUV.y * "+e[0]+".0);\n      }\n    ":"\n    int getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+e[0]+", "+e[1]+"));\n      return resTexRC.x * "+e[1]+" + resTexRC.y;\n    }\n  ";}(0,e);case 2:return function(t,e){return N(t,e)?"\n      ivec2 getOutputCoords() {\n        return ivec2(resultUV.yx * vec2("+e[0]+", "+e[1]+"));\n      }\n    ":1===t[1]?"\n      ivec2 getOutputCoords() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n                               vec2("+e[0]+", "+e[1]+"));\n        int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n        return ivec2(index, 0);\n      }\n    ":1===t[0]?"\n      ivec2 getOutputCoords() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n                               vec2("+e[0]+", "+e[1]+"));\n        int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n        return ivec2(0, index);\n      }\n    ":"\n    ivec2 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+e[0]+", "+e[1]+"));\n      int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n      int r = index / "+t[1]+";\n      int c = index - r * "+t[1]+";\n      return ivec2(r, c);\n    }\n  ";}(t,e);case 3:return n=e,r=Jo(["r","c","d"],t),"\n    ivec3 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+n[0]+", "+n[1]+"));\n      int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n      "+r+"\n      return ivec3(r, c, d);\n    }\n  ";case 4:return function(t,e){var n=Jo(["r","c","d","d2"],t);return "\n    ivec4 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n        vec2("+e[0]+", "+e[1]+"));\n      int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n      "+n+"\n      return ivec4(r, c, d, d2);\n    }\n  ";}(t,e);case 5:return function(t,e){var n=Jo(["r","c","d","d2","d3"],t);return "\n    ivec5 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx * vec2("+e[0]+",\n                             "+e[1]+"));\n\n      int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n\n      "+n+"\n\n      ivec5 outShape = ivec5(r, c, d, d2, d3);\n      return outShape;\n    }\n  ";}(t,e);case 6:return function(t,e){var n=Jo(["r","c","d","d2","d3","d4"],t);return "\n    ivec6 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n        vec2("+e[0]+", "+e[1]+"));\n      int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n\n      "+n+"\n\n      ivec6 result = ivec6(r, c, d, d2, d3, d4);\n      return result;\n    }\n  ";}(t,e);default:throw new Error(t.length+"-D output sampling is not yet supported");}var n,r;}(e.logicalShape,c),a="\n    void setOutput(float val) {\n      "+l.output+" = vec4(val, 0, 0, 0);\n    }\n  "),r&&(h+=ia),[h,f,a,s,o,u,n].join("\n");}var ea="\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",na="\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",ra="\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",ia="\n  float getChannel(vec4 frag, vec2 innerDims) {\n    vec2 modCoord = mod(innerDims, 2.);\n    return modCoord.x == 0. ?\n      (modCoord.y == 0. ? frag.r : frag.g) :\n      (modCoord.y == 0. ? frag.b : frag.a);\n  }\n  float getChannel(vec4 frag, int dim) {\n    float modCoord = mod(float(dim), 2.);\n    return modCoord == 0. ? frag.r : frag.g;\n  }\n";function oa(t){return "offset"+t;}function aa(t){var e=t.name,n=T(t.shapeInfo.logicalShape);return n<2?"return "+e+";":"\n    for (int i = 0; i < "+n+"; i++) {\n      if (i == index) {\n        return "+e+"[i];\n      }\n    }\n  ";}function sa(t){if(t<=1)return "int";if(2===t)return "ivec2";if(3===t)return "ivec3";if(4===t)return "ivec4";if(5===t)return "ivec5";if(6===t)return "ivec6";throw Error("GPU for rank "+t+" is not yet supported");}function ua(t,e){var n=JSON.parse(JSON.stringify(t));return n.shapeInfo.logicalShape=e,n;}function ca(t,e){return e.map(function(e){return t[e];}).join(", ");}var la=function la(t,e,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=Ur(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    ";},fa="return a + b;",ha="return a - b;",da="return a * b;",pa="return (a < 0.) ? b * a : a;",ma=function ma(t,e,n){this.variableNames=["A","B"],this.outputShape=Ur(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    ";},ga="\n  vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n  return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n",va=function va(t,e,n,r){void 0===r&&(r=!1),this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=Ur(e,n);var i=this.outputShape.length,o="";if(r)if(0===i||1===T(this.outputShape))o="\n          result.y = 0.;\n          result.z = 0.;\n          result.w = 0.;\n        ";else if(o="\n          "+sa(i)+" coords = getOutputCoords();\n        ",1===i)o+="\n            result.y = (coords + 1) >= "+this.outputShape[0]+" ? 0. : result.y;\n            result.z = 0.;\n            result.w = 0.;\n          ";else {var a=Xo("coords",i);o+="\n            bool nextRowOutOfBounds =\n              ("+a[i-2]+" + 1) >= "+this.outputShape[i-2]+";\n            bool nextColOutOfBounds =\n              ("+a[i-1]+" + 1) >= "+this.outputShape[i-1]+";\n            result.y = nextColOutOfBounds ? 0. : result.y;\n            result.z = nextRowOutOfBounds ? 0. : result.z;\n            result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n          ";}this.userCode="\n      vec4 binaryOperation(vec4 a, vec4 b) {\n        "+t+"\n      }\n\n      void main() {\n        vec4 a = getAAtOutCoords();\n        vec4 b = getBAtOutCoords();\n\n        vec4 result = binaryOperation(a, b);\n        "+o+"\n\n        setOutput(result);\n      }\n    ";},ya=function(){function t(t){this.variableNames=["A"],this.outputShape=t,this.userCode="\n      uniform float minVal;\n      uniform float maxVal;\n\n      void main() {\n        float value = getAAtOutCoords();\n        if (isnan(value)) {\n          setOutput(value);\n          return;\n        }\n\n        setOutput(clamp(value, minVal, maxVal));\n      }\n    ";}return t.prototype.getCustomSetupFunc=function(t,e){var n=this;return function(r,i){null==n.minLoc&&(n.minLoc=r.getUniformLocationNoThrow(i,"minVal"),n.maxLoc=r.getUniformLocationNoThrow(i,"maxVal")),r.gl.uniform1f(n.minLoc,t),r.gl.uniform1f(n.maxLoc,e);};},t;}(),ba=function(){function t(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.userCode="\n      uniform float minVal;\n      uniform float maxVal;\n\n      void main() {\n        vec4 value = getAAtOutCoords();\n\n        if (any(isnan(value))) {\n          setOutput(value);\n          return;\n        }\n\n        setOutput(clamp(value, vec4(minVal), vec4(maxVal)));\n      }\n    ";}return t.prototype.getCustomSetupFunc=function(t,e){var n=this;return function(r,i){null==n.minLoc&&(n.minLoc=r.getUniformLocationNoThrow(i,"minVal"),n.maxLoc=r.getUniformLocationNoThrow(i,"maxVal")),r.gl.uniform1f(n.minLoc,t),r.gl.uniform1f(n.maxLoc,e);};},t;}();function xa(t,e,n){var r=t.indexOf(e);return t.map(function(t,e){return e===r?t+" - "+n:t;}).join();}var wa=function wa(t,e,n,r){void 0===e&&(e=!1),void 0===n&&(n=null),void 0===r&&(r=!1),this.variableNames=["x","W"],this.outputShape=t.outShape;var i=t.padInfo.top,o=t.padInfo.left,a=t.strideHeight,s=t.strideWidth,u=t.dilationHeight,c=t.dilationWidth,l=t.filterHeight,f=t.filterWidth,h=4*Math.floor(t.inChannels/4),d=t.inChannels%4,p="channelsLast"===t.dataFormat,m=p?1:2,g=p?2:3,v=p?3:1,y="",b="";n&&(y=r?"float activation(float a) {\n          float b = getPreluActivationWeightsAtOutCoords();\n          "+n+"\n        }":"\n          float activation(float x) {\n            "+n+"\n          }\n        ",b="result = activation(result);");var x=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode="\n      "+y+"\n\n      const ivec2 strides = ivec2("+a+", "+s+");\n      const ivec2 pads = ivec2("+i+", "+o+");\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords[0];\n        int d2 = coords["+v+"];\n\n        ivec2 xRCCorner =\n            ivec2(coords["+m+"], coords["+g+"]) * strides - pads;\n        int xRCorner = xRCCorner.x;\n        int xCCorner = xRCCorner.y;\n\n        // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < "+l+"; wR++) {\n          int xR = xRCorner + wR * "+u+";\n\n          if (xR < 0 || xR >= "+t.inHeight+") {\n            continue;\n          }\n\n          for (int wC = 0; wC < "+f+"; wC++) {\n            int xC = xCCorner + wC * "+c+";\n\n            if (xC < 0 || xC >= "+t.inWidth+") {\n              continue;\n            }\n\n            for (int d1 = 0; d1 < "+h+"; d1 += 4) {\n              vec4 wValues = vec4(\n                getW(wR, wC, d1, d2),\n                getW(wR, wC, d1 + 1, d2),\n                getW(wR, wC, d1 + 2, d2),\n                getW(wR, wC, d1 + 3, d2)\n              );\n\n              if ("+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, "+h+") *\n                    getW(wR, wC, "+h+", d2);\n              } else {\n                dotProd +=\n                    getX(batch, "+h+", xR, xC) *\n                    getW(wR, wC, "+h+", d2);\n              }\n\n            } else if ("+(2===d)+") {\n              vec2 wValues = vec2(\n                getW(wR, wC, "+h+", d2),\n                getW(wR, wC, "+h+" + 1, d2)\n              );\n\n              if ("+p+") {\n                vec2 xValues = vec2(\n                  getX(batch, xR, xC, "+h+"),\n                  getX(batch, xR, xC, "+h+" + 1)\n                );\n                dotProd += dot(xValues, wValues);\n              } else {\n                vec2 xValues = vec2(\n                  getX(batch, "+h+", xR, xC),\n                  getX(batch, "+h+" + 1, xR, xC)\n                );\n                dotProd += dot(xValues, wValues);\n              }\n\n            } else if ("+(3===d)+") {\n              vec3 wValues = vec3(\n                getW(wR, wC, "+h+", d2),\n                getW(wR, wC, "+h+" + 1, d2),\n                getW(wR, wC, "+h+" + 2, d2)\n              );\n\n              if ("+p+") {\n                vec3 xValues = vec3(\n                  getX(batch, xR, xC, "+h+"),\n                  getX(batch, xR, xC, "+h+" + 1),\n                  getX(batch, xR, xC, "+h+" + 2)\n                );\n                dotProd += dot(xValues, wValues);\n              } else {\n                vec3 xValues = vec3(\n                  getX(batch, "+h+", xR, xC),\n                  getX(batch, "+h+" + 1, xR, xC),\n                  getX(batch, "+h+" + 2, xR, xC)\n                );\n                dotProd += dot(xValues, wValues);\n              }\n\n            }\n          }\n        }\n\n        float result = dotProd;\n        "+x+"\n        "+b+"\n        setOutput(result);\n      }\n    ";},ka=function ka(t,e,n,r){void 0===e&&(e=!1),void 0===n&&(n=null),void 0===r&&(r=!1),this.variableNames=["x","W"],this.outputShape=t.outShape;var i=t.inHeight,o=t.inWidth,a=t.padInfo.top,s=t.padInfo.left,u=t.strideHeight,c=t.strideWidth,l=t.dilationHeight,f=t.dilationWidth,h=t.filterHeight,d=t.filterWidth,p=t.outChannels/t.inChannels,m="",g="";n&&(m=r?"float activation(float a) {\n          float b = getPreluActivationWeightsAtOutCoords();\n          "+n+"\n        }":"\n          float activation(float x) {\n            "+n+"\n          }\n        ",g="result = activation(result);");var v=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode="\n      "+m+"\n\n      const ivec2 strides = ivec2("+u+", "+c+");\n      const ivec2 pads = ivec2("+a+", "+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 < "+h+"; wR++) {\n          int xR = xRCorner + wR * "+l+";\n\n          if (xR < 0 || xR >= "+i+") {\n            continue;\n          }\n\n          for (int wC = 0; wC < "+d+"; wC++) {\n            int xC = xCCorner + wC * "+f+";\n\n            if (xC < 0 || xC >= "+o+") {\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        "+v+"\n        "+g+"\n        setOutput(result);\n      }\n    ";},Ea=function Ea(t,e,n,r){void 0===e&&(e=!1),void 0===n&&(n=null),void 0===r&&(r=!1),this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.outShape;for(var i=t.inHeight,o=t.inWidth,a=t.padInfo.top,s=t.padInfo.left,u=t.strideHeight,c=t.strideWidth,l=t.dilationHeight,f=t.dilationWidth,h=t.filterHeight,d=t.filterWidth,p=d,m="int xR; int xC; int xCOffset;",g=0;g<h;g++){for(var v=0;v<d;v++){m+="\n          vec4 xTexelR"+g+"C"+2*v+" = vec4(0.);\n          vec4 wR"+g+"C"+v+" = vec4(0.);\n          vec4 xR"+g+"C"+v+" = vec4(0.);";}}for(g=0;g<h;g++){for(var y=0;y<p;y++){if(m+="\n          xR = xRCorner + "+g*l+";\n          xC = xCCorner + "+(v=2*y)*f+";\n        ",1===c){if(v<d&&(m+=s%2==1?"\n                xCOffset = xC + 1;\n                if(xR >= 0 && xR < "+i+" && xCOffset >= 0 && xCOffset < "+o+") {\n                  xTexelR"+g+"C"+v+" = 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 >= "+o+") {\n                    xTexelR"+g+"C"+v+".zw = vec2(0.);\n                  }\n                } else {\n                  xTexelR"+g+"C"+v+" = vec4(0.);\n                }\n\n                xCOffset = xC + 1 - 2;\n                if(xR >= 0 && xR < "+i+" && xCOffset >= 0 && xCOffset < "+o+") {\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 >= "+o+") {\n                    previous.zw = vec2(0.);\n                  }\n\n                  xR"+g+"C"+v+" = vec4(previous.zw, xTexelR"+g+"C"+v+".xy);\n                } else {\n                  xR"+g+"C"+v+" = vec4(0, 0, xTexelR"+g+"C"+v+".xy);\n                }\n              ":"\n                if(xR >= 0 && xR < "+i+" && xC >= 0 && xC < "+o+") {\n                  xTexelR"+g+"C"+v+" = getX(batch, xR, xC, d1);\n                } else {\n                  xTexelR"+g+"C"+v+" = vec4(0.);\n                }\n\n                xR"+g+"C"+v+" = xTexelR"+g+"C"+v+";\n              ",v+1<d)){var b=s%2==0?A(f):f;f%2==0&&s%2==1||f%2!=0&&s%2!=1?(m+="\n                  xCOffset = xC + "+s%2+" + "+b+";\n\n                  if(xR >= 0 && xR < "+i+" &&\n                    xCOffset >= 0 && xCOffset < "+o+") {\n                    xTexelR"+g+"C"+(v+2)+" = getX(batch, xR, xCOffset, d1);\n                  }\n                ",f>1&&(m+="\n                    xCOffset -= 2;\n                    if(xR >= 0 && xR < "+i+" &&\n                      xCOffset >= 0 && xCOffset < "+o+") {\n                      xTexelR"+g+"C"+v+" = getX(batch, xR, xCOffset, d1);\n                    } else {\n                      xTexelR"+g+"C"+v+" = vec4(0.);\n                    }\n                  "),m+="\n                  xR"+g+"C"+(v+1)+" = vec4(\n                    xTexelR"+g+"C"+v+".zw, xTexelR"+g+"C"+(v+2)+".xy);\n                "):m+="\n                  xCOffset = xC + "+b+";\n\n                  if(xR >= 0 && xR < "+i+" &&\n                    xCOffset >= 0 && xCOffset < "+o+") {\n                    xTexelR"+g+"C"+(v+2)+" = getX(batch, xR, xCOffset, d1);\n                  }\n\n                  xR"+g+"C"+(v+1)+" = xTexelR"+g+"C"+(v+2)+";\n                ";}}else v<d&&(m+="\n              if(xR >= 0 && xR < "+i+") {\n            ",s%2==1?(m+="\n                xCOffset = xC + 1 - "+c+";\n                if(xCOffset >= 0 && xCOffset < "+o+") {\n                  xTexelR"+g+"C"+v+" = getX(batch, xR, xCOffset, d1);\n                } else {\n                  xTexelR"+g+"C"+v+" = vec4(0.);\n                }\n\n                if(xC + 1 >= 0 && xC + 1 < "+o+") {\n                  xTexelR"+g+"C"+(v+2)+" = getX(batch, xR, xC + 1, d1);\n                } else {\n                  xTexelR"+g+"C"+(v+2)+" = vec4(0.);\n                }\n\n                xR"+g+"C"+v+" = vec4(\n                  xTexelR"+g+"C"+v+".zw, xTexelR"+g+"C"+(v+2)+".zw);\n              ",v+1<d&&(m+="\n                  vec4 final = vec4(0.);\n                  xCOffset = xC + 1 + "+c+";\n                  if(xCOffset >= 0 && xCOffset < "+o+") {\n                    final = getX(batch, xR, xCOffset, d1);\n                  }\n                  xR"+g+"C"+(v+1)+" = vec4(xTexelR"+g+"C"+(v+2)+".xy, final.xy);\n                ")):(m+="\n                if(xC >= 0 && xC < "+o+") {\n                  xTexelR"+g+"C"+v+" = getX(batch, xR, xC, d1);\n                } else {\n                  xTexelR"+g+"C"+v+" = vec4(0.);\n                }\n\n                xCOffset = xC + "+c+";\n                if(xCOffset >= 0 && xCOffset < "+o+") {\n                  xTexelR"+g+"C"+(v+2)+" = getX(batch, xR, xCOffset, d1);\n                } else {\n                  xTexelR"+g+"C"+(v+2)+" = vec4(0.);\n                }\n\n                xR"+g+"C"+v+" = vec4(\n                  xTexelR"+g+"C"+v+".xy, xTexelR"+g+"C"+(v+2)+".xy);\n              ",v+1<d&&(m+="\n                  xR"+g+"C"+(v+1)+" = vec4(\n                    xTexelR"+g+"C"+v+".zw, xTexelR"+g+"C"+(v+2)+".zw);\n                ")),m+="}");v<d&&(m+="\n            vec4 wTexelR"+g+"C"+v+" = getW("+g+", "+v+", d1, q);\n            wR"+g+"C"+v+" = vec4(wTexelR"+g+"C"+v+".xz, wTexelR"+g+"C"+v+".xz);\n          ",v+1<d&&(m+="\n              vec4 wTexelR"+g+"C"+(v+1)+" = getW("+g+", "+(v+1)+", d1, q);\n              wR"+g+"C"+(v+1)+" =\n                vec4(wTexelR"+g+"C"+(v+1)+".xz, wTexelR"+g+"C"+(v+1)+".xz);"));}}for(g=0;g<h;g++){for(v=0;v<d;v++){m+="dotProd += xR"+g+"C"+v+" * wR"+g+"C"+v+";";}}var x="",w="";n&&(x=r?"vec4 activation(vec4 a) {\n          vec4 b = getPreluActivationWeightsAtOutCoords();\n          "+n+"\n        }":"vec4 activation(vec4 x) {\n          "+n+"\n        }",w="result = activation(result);");var k=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode="\n      "+x+"\n\n      const ivec2 strides = ivec2("+u+", "+c+");\n      const ivec2 pads = ivec2("+a+", "+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        "+m+"\n\n        vec4 result = dotProd;\n        "+k+"\n        "+w+"\n        setOutput(result);\n      }\n    ";};function Ca(t,e){if(1===t)return ""+e;if(2===t)return e+".y";if(3===t)return e+".z";if(4===t)return e+".w";throw Error("Cumulative sum for rank "+t+" is not yet supported");}var Aa=function(){function t(t,e,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=t,this.blockSize=e,this.dataFormat=n,this.userCode="\n    void main() {\n      ivec4 coords = getOutputCoords();\n      int b = coords[0];\n      int h = "+this.getHeightCoordString()+";\n      int w = "+this.getWidthCoordString()+";\n      int d = "+this.getDepthCoordString()+";\n\n      int in_h = h / "+e+";\n      int offset_h = imod(h, "+e+");\n      int in_w = w / "+e+";\n      int offset_w = imod(w, "+e+");\n      int offset_d = (offset_h * "+e+" + offset_w) *\n        "+this.getOutputDepthSize()+";\n      int in_d = d + offset_d;\n\n      float result = "+this.getInputSamplingString()+";\n      setOutput(result);\n    }\n  ";}return t.prototype.getHeightCoordString=function(){return "NHWC"===this.dataFormat?"coords[1]":"coords[2]";},t.prototype.getWidthCoordString=function(){return "NHWC"===this.dataFormat?"coords[2]":"coords[3]";},t.prototype.getDepthCoordString=function(){return "NHWC"===this.dataFormat?"coords[3]":"coords[1]";},t.prototype.getOutputDepthSize=function(){return "NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1];},t.prototype.getInputSamplingString=function(){return "NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)";},t;}(),Oa=function Oa(t,e,n){this.variableNames=["real","imag"];var r=e[1];this.outputShape=e;var i=n?"2.0 * "+Math.PI:"-2.0 * "+Math.PI,o=n?r+".0":"1.0";this.userCode="\n      const float exponentMultiplier = "+i+";\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) / "+o+";\n        }\n\n        return result;\n      }\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        setOutput(mulMatDFT(coords[0], coords[1]));\n      }\n    ";},_a=function(){function t(t,e){this.outputShape=[],this.variableNames=["x"],this.outputShape=t,this.userCode="\n      uniform float value;\n      void main() {\n        // Input can be obtained from uniform value.\n        setOutput(value);\n      }\n    ";}return t.prototype.getCustomSetupFunc=function(t){var e=this;return function(n,r){null==e.valueLoc&&(e.valueLoc=n.getUniformLocationNoThrow(r,"value")),n.gl.uniform1f(e.valueLoc,t);};},t;}();function Sa(t,e){var n=Yo();return ue(t,e,n.version+"\n    precision highp float;\n    "+n.attribute+" vec3 clipSpacePos;\n    "+n.attribute+" vec2 uv;\n    "+n.varyingVs+" vec2 resultUV;\n\n    void main() {\n      gl_Position = vec4(clipSpacePos, 1);\n      resultUV = uv;\n    }");}function Da(t,e){return ge(t,e,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]));}function Fa(t,e){return ve(t,e,new Uint16Array([0,1,2,2,1,3]));}function Ta(t,e,n,r,i,o,a){be(n,r);var s=ye(t,e),u=t.TEXTURE_2D;return ne(t,e,function(){return t.bindTexture(u,s);}),ne(t,e,function(){return t.texParameteri(u,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE);}),ne(t,e,function(){return t.texParameteri(u,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE);}),ne(t,e,function(){return t.texParameteri(u,t.TEXTURE_MIN_FILTER,t.NEAREST);}),ne(t,e,function(){return t.texParameteri(u,t.TEXTURE_MAG_FILTER,t.NEAREST);}),ne(t,e,function(){return t.texImage2D(u,0,i,n,r,0,o,a,null);}),ne(t,e,function(){return t.bindTexture(t.TEXTURE_2D,null);}),s;}function Na(t,e,n,r,i){var o=Qt(n,r);return Ta(t,e,o[0],o[1],i.internalFormatFloat,i.textureFormatFloat,t.FLOAT);}function Ia(t,e,n,r,i){var o=Qt(n,r);return Ta(t,e,o[0],o[1],i.internalFormatHalfFloat,i.textureFormatFloat,i.textureTypeHalfFloat);}function Ra(t,e,n,r,i){var o=Qt(n,r);return Ta(t,e,o[0],o[1],t.RGBA,t.RGBA,t.UNSIGNED_BYTE);}function Ma(t,e,n,r,i){var o=te(n,r);return Ta(t,e,o[0],o[1],i.internalFormatPackedFloat,t.RGBA,t.FLOAT);}function ja(t,e,n,r,i){var o=te(n,r);return Ta(t,e,o[0],o[1],i.internalFormatPackedHalfFloat,t.RGBA,i.textureTypeHalfFloat);}function Ba(t,e,n,r){return ne(t,e,function(){return t.bindBuffer(t.ARRAY_BUFFER,r);}),we(t,e,n,"clipSpacePos",r,3,20,0)&&we(t,e,n,"uv",r,2,20,12);}function Pa(t,e,n,r,i,o,a){var s,u,c;ne(t,e,function(){return t.bindTexture(t.TEXTURE_2D,n);}),o instanceof Uint8Array?(s=new Uint8Array(r*i*4),u=t.UNSIGNED_BYTE,c=t.RGBA):(s=new Float32Array(r*i*4),u=t.FLOAT,c=a.internalFormatPackedFloat),s.set(o),ne(t,e,function(){return t.texImage2D(t.TEXTURE_2D,0,c,r,i,0,t.RGBA,u,s);}),ne(t,e,function(){return t.bindTexture(t.TEXTURE_2D,null);});}function La(t,e,n,r){ne(t,e,function(){return t.bindTexture(t.TEXTURE_2D,n);}),r.data instanceof Uint8Array?ne(t,e,function(){return t.texImage2D(t.TEXTURE_2D,0,t.RGBA,r.width,r.height,0,t.RGBA,t.UNSIGNED_BYTE,r.data);}):ne(t,e,function(){return t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,r);}),ne(t,e,function(){return t.bindTexture(t.TEXTURE_2D,null);});}function za(t,e,n,r,i){var o=t.createBuffer();ne(t,e,function(){return t.bindBuffer(t.PIXEL_PACK_BUFFER,o);});var a=16*n*r;return ne(t,e,function(){return t.bufferData(t.PIXEL_PACK_BUFFER,a,t.STREAM_READ);}),ne(t,e,function(){return t.readPixels(0,0,r,n,t.RGBA,t.FLOAT,0);}),ne(t,e,function(){return t.bindBuffer(t.PIXEL_PACK_BUFFER,null);}),o;}function Ua(t,e,n){var r=t,i=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,e),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,i),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),i;}function Wa(t,e,n,r,i){var o=Qt(n,r),a=o[0],s=o[1],u=new Uint8Array(n*r*4);return ne(t,e,function(){return t.readPixels(0,0,a,s,i.downloadTextureFormat,t.UNSIGNED_BYTE,u);}),new Float32Array(u.buffer);}function Va(t,e,n,r,i,o,a,s){var u=t,c=new Float32Array(function(t,e){var n=te(o,a);return n[0]*n[1]*4;}());return u.bindBuffer(u.PIXEL_PACK_BUFFER,e),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,c),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),c;}function qa(t,e,n,r){var i=new Float32Array(n*r*4);return ne(t,e,function(){return t.readPixels(0,0,r,n,t.RGBA,t.FLOAT,i);}),i;}var $a=Object.freeze({createVertexShader:Sa,createVertexBuffer:Da,createIndexBuffer:Fa,createFloat32MatrixTexture:Na,createFloat16MatrixTexture:Ia,createUnsignedBytesMatrixTexture:Ra,createPackedMatrixTexture:Ma,createFloat16PackedMatrixTexture:ja,bindVertexProgramAttributeStreams:Ba,uploadDenseMatrixToTexture:Pa,uploadPixelDataToTexture:La,createBufferFromOutputTexture:za,downloadFloat32MatrixFromBuffer:Ua,downloadByteEncodedFloatMatrixFromOutputTexture:Wa,downloadPackedMatrixFromBuffer:Va,downloadMatrixFromPackedOutputTexture:qa}),Ha=function(){function t(t){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];var e=f().getNumber("WEBGL_VERSION");null!=t?(this.gl=t,Yt(e,t)):this.gl=Jt(e);var n="WEBGL_color_buffer_float";if(1===f().getNumber("WEBGL_VERSION")){if(this.textureFloatExtension=se(this.gl,this.debug,"OES_texture_float"),Ue(this.gl,"OES_texture_half_float"))this.textureHalfFloatExtension=se(this.gl,this.debug,"OES_texture_half_float");else if(f().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(n),Ue(this.gl,"EXT_color_buffer_half_float"))this.colorBufferHalfFloatExtension=se(this.gl,this.debug,"EXT_color_buffer_half_float");else if(f().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");}else if(n="EXT_color_buffer_float",Ue(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else {if(!Ue(this.gl,"EXT_color_buffer_half_float"))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension("EXT_color_buffer_half_float");}this.vertexBuffer=Da(this.gl,this.debug),this.indexBuffer=Fa(this.gl,this.debug),this.framebuffer=xe(this.gl,this.debug),this.textureConfig=ee(this.gl,this.textureHalfFloatExtension);}return Object.defineProperty(t.prototype,"debug",{get:function get(){return f().getBool("DEBUG");},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){var t=this;if(!this.disposed){null!=this.program&&console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."),null!=this.outputTexture&&console.warn("Disposing a GPGPUContext that still has a bound output matrix texture.  This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");var e=this.gl;ne(e,this.debug,function(){return e.finish();}),ne(e,this.debug,function(){return e.bindFramebuffer(e.FRAMEBUFFER,null);}),ne(e,this.debug,function(){return e.deleteFramebuffer(t.framebuffer);}),ne(e,this.debug,function(){return e.bindBuffer(e.ARRAY_BUFFER,null);}),ne(e,this.debug,function(){return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null);}),ne(e,this.debug,function(){return e.deleteBuffer(t.indexBuffer);}),this.disposed=!0;}},t.prototype.createFloat32MatrixTexture=function(t,e){return this.throwIfDisposed(),Na(this.gl,this.debug,t,e,this.textureConfig);},t.prototype.createFloat16MatrixTexture=function(t,e){return this.throwIfDisposed(),Ia(this.gl,this.debug,t,e,this.textureConfig);},t.prototype.createUnsignedBytesMatrixTexture=function(t,e){return this.throwIfDisposed(),Ra(this.gl,this.debug,t,e,this.textureConfig);},t.prototype.uploadPixelDataToTexture=function(t,e){this.throwIfDisposed(),La(this.gl,this.debug,t,e);},t.prototype.uploadDenseMatrixToTexture=function(t,e,n,r){this.throwIfDisposed(),Pa(this.gl,this.debug,t,e,n,r,this.textureConfig);},t.prototype.createFloat16PackedMatrixTexture=function(t,e){return this.throwIfDisposed(),ja(this.gl,this.debug,t,e,this.textureConfig);},t.prototype.createPackedMatrixTexture=function(t,e){return this.throwIfDisposed(),Ma(this.gl,this.debug,t,e,this.textureConfig);},t.prototype.deleteMatrixTexture=function(t){var e=this;this.throwIfDisposed(),this.outputTexture===t&&(_e(this.gl,this.debug,this.framebuffer),this.outputTexture=null),ne(this.gl,this.debug,function(){return e.gl.deleteTexture(t);});},t.prototype.downloadByteEncodedFloatMatrixFromOutputTexture=function(t,e,n){var r=this;return this.downloadMatrixDriver(t,function(){return Wa(r.gl,r.debug,e,n,r.textureConfig);});},t.prototype.downloadPackedMatrixFromBuffer=function(t,e,n,r,i,o){return Va(this.gl,t,0,0,0,i,o,this.textureConfig);},t.prototype.downloadFloat32MatrixFromBuffer=function(t,e){return Ua(this.gl,t,e);},t.prototype.createBufferFromTexture=function(t,e,n){this.bindTextureToFrameBuffer(t);var r=za(this.gl,this.debug,e,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r;},t.prototype.createAndWaitForFence=function(){var t=this.createFence(this.gl);return this.pollFence(t);},t.prototype.createFence=function(t){var e,n,r=this;if(f().getBool("WEBGL_FENCE_API_ENABLED")){var i=t,o=i.fenceSync(i.SYNC_GPU_COMMANDS_COMPLETE,0);t.flush(),n=function n(){var t=i.clientWaitSync(o,0,0);return t===i.ALREADY_SIGNALED||t===i.CONDITION_SATISFIED;},e=o;}else f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(e=this.beginQuery(),this.endQuery(),n=function n(){return r.isQueryAvailable(e,f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"));}):n=function n(){return !0;};return {query:e,isFencePassed:n};},t.prototype.downloadMatrixFromPackedTexture=function(t,e,n){var r=this;return this.downloadMatrixDriver(t,function(){return qa(r.gl,r.debug,e,n);});},t.prototype.createProgram=function(t){this.throwIfDisposed();var e=this.gl,n=ce(e,this.debug,t),r=Sa(e,this.debug),i=de(e,this.debug);return ne(e,this.debug,function(){return e.attachShader(i,r);}),ne(e,this.debug,function(){return e.attachShader(i,n);}),pe(e,this.debug,i),this.debug&&me(e,this.debug,i),this.vertexAttrsAreBound||(this.setProgram(i),this.vertexAttrsAreBound=Ba(e,this.debug,this.program,this.vertexBuffer)),i;},t.prototype.deleteProgram=function(t){var e=this;this.throwIfDisposed(),t===this.program&&(this.program=null),null!=t&&ne(this.gl,this.debug,function(){return e.gl.deleteProgram(t);});},t.prototype.setProgram=function(t){var e=this;this.throwIfDisposed(),this.program=t,null!=this.program&&this.debug&&me(this.gl,this.debug,this.program),ne(this.gl,this.debug,function(){return e.gl.useProgram(t);});},t.prototype.getUniformLocation=function(t,e,n){return void 0===n&&(n=!0),this.throwIfDisposed(),n?Ee(this.gl,this.debug,t,e):Ce(this.gl,t,e);},t.prototype.getAttributeLocation=function(t,e){var n=this;return this.throwIfDisposed(),ne(this.gl,this.debug,function(){return n.gl.getAttribLocation(t,e);});},t.prototype.getUniformLocationNoThrow=function(t,e){return this.throwIfDisposed(),this.gl.getUniformLocation(t,e);},t.prototype.setInputMatrixTexture=function(t,e,n){this.throwIfDisposed(),this.throwIfNoProgram(),Ae(this.gl,this.debug,this.program,t,e,n);},t.prototype.setOutputMatrixTexture=function(t,e,n){this.setOutputMatrixTextureDriver(t,n,e);},t.prototype.setOutputPackedMatrixTexture=function(t,e,n){this.throwIfDisposed();var r=te(e,n),i=r[0],o=r[1];this.setOutputMatrixTextureDriver(t,i,o);},t.prototype.setOutputMatrixWriteRegion=function(t,e,n,r){this.setOutputMatrixWriteRegionDriver(n,t,r,e);},t.prototype.setOutputPackedMatrixWriteRegion=function(t,e,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.");},t.prototype.debugValidate=function(){null!=this.program&&me(this.gl,this.debug,this.program),Se(this.gl);},t.prototype.executeProgram=function(){this.throwIfDisposed(),this.throwIfNoProgram();var t=this.gl;this.debug&&this.debugValidate(),ne(t,this.debug,function(){return t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0);});},t.prototype.blockUntilAllProgramsCompleted=function(){var t=this;this.throwIfDisposed(),ne(this.gl,this.debug,function(){return t.gl.finish();});},t.prototype.getQueryTimerExtension=function(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=se(this.gl,this.debug,2===f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension;},t.prototype.getQueryTimerExtensionWebGL2=function(){return this.getQueryTimerExtension();},t.prototype.getQueryTimerExtensionWebGL1=function(){return this.getQueryTimerExtension();},t.prototype.beginQuery=function(){if(2===f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){var t=this.gl,e=this.getQueryTimerExtensionWebGL2(),n=t.createQuery();return t.beginQuery(e.TIME_ELAPSED_EXT,n),n;}var r=this.getQueryTimerExtensionWebGL1(),i=r.createQueryEXT();return r.beginQueryEXT(r.TIME_ELAPSED_EXT,i),i;},t.prototype.endQuery=function(){if(2!==f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){var t=this.getQueryTimerExtensionWebGL1();t.endQueryEXT(t.TIME_ELAPSED_EXT);}else {var e=this.gl,n=this.getQueryTimerExtensionWebGL2();e.endQuery(n.TIME_ELAPSED_EXT);}},t.prototype.waitForQueryAndGetTime=function(t){return u(this,void 0,void 0,function(){var e=this;return c(this,function(n){switch(n.label){case 0:return [4,B(function(){return e.disposed||e.isQueryAvailable(t,f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"));})];case 1:return n.sent(),[2,this.getQueryTime(t,f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))];}});});},t.prototype.getQueryTime=function(t,e){if(0===e)return null;if(2===e){var n=this.gl;return n.getQueryParameter(t,n.QUERY_RESULT)/1e6;}var r=this.getQueryTimerExtensionWebGL1();return r.getQueryObjectEXT(t,r.QUERY_RESULT_EXT)/1e6;},t.prototype.isQueryAvailable=function(t,e){if(0===e)return !0;if(2===e){var n=this.gl,r=this.getQueryTimerExtensionWebGL2(),i=n.getQueryParameter(t,n.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),i&&!this.disjoint;}return i=(r=this.getQueryTimerExtensionWebGL1()).getQueryObjectEXT(t,r.QUERY_RESULT_AVAILABLE_EXT),null==this.disjoint&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),i&&!this.disjoint;},t.prototype.pollFence=function(t){var e=this;return new Promise(function(n){e.addItemToPoll(function(){return t.isFencePassed();},function(){return n();});});},t.prototype.pollItems=function(){for(var t=function(t){for(var e=0;e<t.length&&t[e]();++e){}return e-1;}(this.itemsToPoll.map(function(t){return t.isDoneFn;})),e=0;e<=t;++e){(0, this.itemsToPoll[e].resolveFn)();}this.itemsToPoll=this.itemsToPoll.slice(t+1);},t.prototype.addItemToPoll=function(t,e){var n=this;this.itemsToPoll.push({isDoneFn:t,resolveFn:e}),this.itemsToPoll.length>1||B(function(){return n.pollItems(),0===n.itemsToPoll.length;});},t.prototype.bindTextureToFrameBuffer=function(t){this.throwIfDisposed(),Oe(this.gl,this.debug,t,this.framebuffer),this.debug&&Se(this.gl);},t.prototype.unbindTextureToFrameBuffer=function(){null!=this.outputTexture?(Oe(this.gl,this.debug,this.outputTexture,this.framebuffer),this.debug&&Se(this.gl)):_e(this.gl,this.debug,this.framebuffer);},t.prototype.downloadMatrixDriver=function(t,e){this.bindTextureToFrameBuffer(t);var n=e();return this.unbindTextureToFrameBuffer(),n;},t.prototype.setOutputMatrixTextureDriver=function(t,e,n){this.throwIfDisposed();var r=this.gl;Oe(r,this.debug,t,this.framebuffer),this.debug&&Se(r),this.outputTexture=t,ne(r,this.debug,function(){return r.viewport(0,0,e,n);}),ne(r,this.debug,function(){return r.scissor(0,0,e,n);});},t.prototype.setOutputMatrixWriteRegionDriver=function(t,e,n,r){var i=this;this.throwIfDisposed(),ne(this.gl,this.debug,function(){return i.gl.scissor(t,e,n,r);});},t.prototype.throwIfDisposed=function(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.");},t.prototype.throwIfNoProgram=function(){if(null==this.program)throw new Error("No GPU program is currently set.");},t;}();function Ga(t,e){if(t.length!==e.length)throw Error("Binary was compiled with "+t.length+" inputs, but was executed with "+e.length+" inputs");t.forEach(function(t,n){var r=t.logicalShape,i=e[n],o=i.shape;if(!N(r,o))throw Error("Binary was compiled with different shapes than the current args. Shapes "+r+" and "+o+" must match");if(!t.isUniform||!i.isUniform){var a=t.texShape,s=i.isUniform?null:i.texData.texShape;if(!N(a,s))throw Error("Binary was compiled with different texture shapes than the current args. Shape "+a+" and "+s+" must match");}});}var Ka=function Ka(t,e,n,r,i,o,a){void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===i&&(i=!1),void 0===o&&(o=null),void 0===a&&(a=!1),this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e;var s=n?t[1]:t[2],u=Math.ceil(s/2),c=n?"i * 2, rc.y":"rc.y, i * 2",l=r?"rc.z, i * 2":"i * 2, rc.z",f=n?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],h=r?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],d="",p="";o&&(d=a?"vec4 activation(vec4 a) {\n          vec4 b = getPreluActivationWeightsAtOutCoords();\n          "+o+"\n        }":"vec4 activation(vec4 x) {\n          "+o+"\n        }",p="result = activation(result);");var m=i?"result += getBiasAtOutCoords();":"";i&&this.variableNames.push("bias"),a&&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 += ("+f[0]+" * "+h[0]+");\n          result += ("+f[1]+" * "+h[1]+");\n        }\n        return result;\n      }\n\n      void main() {\n        ivec3 rc = getOutputCoords();\n        vec4 result = dot2x2ARowBCol(rc);\n\n        "+m+"\n\n        "+p+"\n\n        setOutput(result);\n      }\n    ";},Xa=function(){function t(t,e,n){this.variableNames=["probs"],this.outputShape=[t,n],this.userCode="\n      uniform float seed;\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n\n        float r = random(seed);\n        float cdf = 0.0;\n\n        for (int i = 0; i < "+(e-1)+"; i++) {\n          cdf += getProbs(batch, i);\n\n          if (r < cdf) {\n            setOutput(float(i));\n            return;\n          }\n        }\n\n        // If no other event happened, last event happened.\n        setOutput(float("+(e-1)+"));\n      }\n    ";}return t.prototype.getCustomSetupFunc=function(t){var e=this;return function(n,r){null==e.seedLoc&&(e.seedLoc=n.getUniformLocation(r,"seed")),n.gl.uniform1f(e.seedLoc,t);};},t;}(),Ya=function Ya(t,e,n,r,i){if(void 0===r&&(r=!1),void 0===i&&(i=!1),this.variableNames=["x"],"avg"===e&&n)throw new Error("Cannot compute positions for average pool.");var o=t.filterWidth,a=t.strideHeight,s=t.strideWidth,u=t.dilationHeight,c=t.dilationWidth,l=t.effectiveFilterHeight,f=t.effectiveFilterWidth,h=t.padInfo.top,d=t.padInfo.left;this.outputShape=t.outShape;var p="avg"===e,m="((batch  * "+t.inHeight+" + xR) * "+t.inWidth+" + xC) * "+t.inChannels+" + d",g="(xR * "+t.inWidth+" + xC) * "+t.inChannels+" + d",v="0.0";if(p||(v="-1.0 / 1e-20"),n)this.userCode="\n        const ivec2 strides = ivec2("+a+", "+s+");\n        const ivec2 pads = ivec2("+h+", "+d+");\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 < "+l+";\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, 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 = "+(r?i?m:g:"wR * "+f+" + wC")+";\n              }\n            }\n          }\n          setOutput(float(minMaxPosition));\n        }\n      ";else {var y=e+"("+e+"("+e+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"avg"===e&&(y="avgValue / count");var b=4*Math.floor(o/4),x=o%4,w="\n      if ("+p+") {\n        avgValue += dot(values, ones);\n      } else {\n        minMaxValue = max(values, minMaxValue);\n      }\n    ";this.userCode="\n      const ivec2 strides = ivec2("+a+", "+s+");\n      const ivec2 pads = ivec2("+h+", "+d+");\n      const float initializationValue = "+v+";\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("+v+");\n        float avgValue = 0.0;\n        count = 0.0;\n\n        for (int wR = 0; wR < "+l+";\n            wR += "+u+") {\n          int xR = xRCorner + wR;\n\n          if (xR < 0 || xR >= "+t.inHeight+") {\n            continue;\n          }\n\n          for (int wC = 0; wC < "+b+"; wC += 4) {\n            int xC = xCCorner + wC * "+c+";\n\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              getValue(batch, xR, xC + "+c+", d),\n              getValue(batch, xR, xC + 2 * "+c+", d),\n              getValue(batch, xR, xC + 3 * "+c+", d)\n            );\n\n            "+w+"\n          }\n\n          int xC = xCCorner + "+b+";\n          if ("+(1===x)+") {\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              initializationValue,\n              initializationValue,\n              initializationValue\n            );\n\n            "+w+"\n          } else if ("+(2===x)+") {\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              getValue(batch, xR, xC + "+c+", d),\n              initializationValue,\n              initializationValue\n            );\n\n            "+w+"\n          } else if ("+(3===x)+") {\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              getValue(batch, xR, xC + "+c+", d),\n              getValue(batch, xR, xC + 2 * "+c+", d),\n              initializationValue\n            );\n\n            "+w+"\n          }\n        }\n        setOutput("+y+");\n      }\n    ";}},Ja=function Ja(t,e,n,r,i){if(void 0===r&&(r=!1),void 0===i&&(i=!1),this.variableNames=["x"],"avg"===e&&n)throw new Error("Cannot compute positions for average pool.");var o=t.filterWidth,a=t.strideDepth,s=t.strideHeight,u=t.strideWidth,c=t.dilationDepth,l=t.dilationHeight,f=t.dilationWidth,h=t.effectiveFilterDepth,d=t.effectiveFilterHeight,p=t.effectiveFilterWidth,m=t.padInfo.front,g=t.padInfo.top,v=t.padInfo.left;this.outputShape=t.outShape;var y="avg"===e,b="0.0";if(y||(b="-1.0 / 1e-20"),n)this.userCode="\n        const ivec3 strides =\n            ivec3("+a+", "+s+", "+u+");\n        const ivec3 pads = ivec3("+m+", "+g+", "+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 < "+h+";\n              wD += "+c+") {\n            int xD = xDCorner + wD;\n\n            if (xD < 0 || xD >= "+t.inDepth+") {\n              continue;\n            }\n\n            for (int wR = 0; wR < "+d+";\n                wR += "+l+") {\n              int xR = xRCorner + wR;\n\n              if (xR < 0 || xR >= "+t.inHeight+") {\n                continue;\n              }\n\n              for (int wC = 0; wC < "+p+";\n                  wC += "+f+") {\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 = "+(r?i?"(((batch * "+t.inDepth+" + xD) * "+t.inHeight+" + xR) * "+t.inWidth+" + xC) * "+t.inChannels+" + ch":"((xD * "+t.inHeight+" + xR) * "+t.inWidth+" + xC) * "+t.inChannels+" + ch":"wD * "+d+" * "+p+" +\n                      wR * "+p+" + wC")+";\n                }\n              }\n            }\n          }\n          setOutput(float(minMaxPosition));\n        }\n      ";else {var x=e+"("+e+"("+e+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"avg"===e&&(x="avgValue / count");var w=4*Math.floor(o/4),k=o%4,E="\n      if ("+y+") {\n        avgValue += dot(values, ones);\n      } else {\n        minMaxValue = max(values, minMaxValue);\n      }\n    ";this.userCode="\n      const ivec3 strides =\n        ivec3("+a+", "+s+", "+u+");\n      const ivec3 pads = ivec3("+m+", "+g+", "+v+");\n      const float initializationValue = "+b+";\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("+b+");\n        float avgValue = 0.0;\n        count = 0.0;\n\n        for (int wD = 0; wD < "+h+";\n            wD += "+c+") {\n          int xD = xDCorner + wD;\n\n          if (xD < 0 || xD >= "+t.inDepth+") {\n            continue;\n          }\n\n          for (int wR = 0; wR < "+d+";\n            wR += "+l+") {\n            int xR = xRCorner + wR;\n\n            if (xR < 0 || xR >= "+t.inHeight+") {\n              continue;\n            }\n\n            for (int wC = 0; wC < "+w+"; wC += 4) {\n              int xC = xCCorner + wC * "+f+";\n\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + "+f+", ch),\n                getValue(batch, xD, xR, xC + 2 * "+f+", ch),\n                getValue(batch, xD, xR, xC + 3 * "+f+", ch)\n              );\n\n              "+E+"\n            }\n\n            int xC = xCCorner + "+w+";\n            if ("+(1===k)+") {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                initializationValue,\n                initializationValue,\n                initializationValue\n              );\n\n              "+E+"\n            } else if ("+(2===k)+") {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + "+f+", ch),\n                initializationValue,\n                initializationValue\n              );\n\n              "+E+"\n            } else if ("+(3===k)+") {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + "+f+", ch),\n                getValue(batch, xD, xR, xC + 2 * "+f+", ch),\n                initializationValue\n              );\n\n              "+E+"\n            }\n          }\n          setOutput("+x+");\n        }\n      }\n    ";}},Qa=function Qa(t,e,n,r,i,o,a){this.variableNames=["updates","indices","defaultValue"],this.outputShape=o;var s=sa(i.length),u=sa(o.length),c="";1===n?c="i":2===n&&(c="i, j");var l="getIndices("+c+")",f="";1===r?f="i":2===r&&(f="i, coords[1]");var h="getUpdates("+f+")",d=e>1?"strides[j]":"strides";this.userCode="\n        "+s+" strides = "+s+"("+i+");\n\n        void main() {\n          "+u+" coords = getOutputCoords();\n          float sum = 0.0;\n          bool found = false;\n          for (int i = 0; i < "+t+"; i++) {\n            int flattenedIndex = 0;\n            for (int j = 0; j < "+e+"; j++) {\n              int index = round("+l+");\n              flattenedIndex += index * "+d+";\n            }\n            if (flattenedIndex == coords[0]) {\n              sum += "+h+";\n              found = true;\n            }\n          }\n          setOutput(mix(getDefaultValue(), sum, float(found)));\n        }\n      ";},Za=function(){function t(t){this.variableNames=["source"],this.outputShape=t,this.rank=t.length;var e,n=sa(this.rank),r="uniform int start["+this.rank+"];",i=function(t){if(1===t)return "sourceLoc";if(t<=6)return ts.slice(0,t).map(function(t){return "sourceLoc."+t;}).join(",");throw Error("Slicing for rank "+t+" is not yet supported");}(this.rank);e="\n        "+n+" sourceLoc;\n        "+n+" coords = getOutputCoords();\n        "+t.map(function(t,e){return "sourceLoc."+ts[e]+" = start["+e+"] + coords."+ts[e]+";";}).join("\n")+"\n      ",this.userCode="\n      "+r+"\n      void main() {\n        "+e+"\n        setOutput(getSource("+i+"));\n      }\n    ";}return t.prototype.getCustomSetupFunc=function(t){var e=this;if(t.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the length of start ("+t.length+")");return function(n,r){null==e.startLoc&&(e.startLoc=n.getUniformLocationNoThrow(r,"start"),null==e.startLoc)||n.gl.uniform1iv(e.startLoc,t);};},t;}(),ts=["x","y","z","w","u","v"],es=function(){function t(t){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.rank=t.length;var e=sa(this.rank),n=Xo("coords",this.rank),r=Xo("sourceLoc",this.rank),i=1===this.rank?"sourceLoc":"vec2("+r.slice(-2).join()+")",o="getChannel(getSource("+r.join()+"), "+i+")",a="\n      result.x = "+o+";\n      if (++"+n[this.rank-1]+" < "+t[this.rank-1]+") {\n        ++"+r[this.rank-1]+";\n        result.y = "+o+";\n        --"+r[this.rank-1]+";\n      }\n    ",s=1===this.rank?"":"\n      --"+n[this.rank-1]+";\n      if (++"+n[this.rank-2]+" < "+t[this.rank-2]+") {\n        ++"+r[this.rank-2]+";\n        result.z = "+o+";\n        if (++"+n[this.rank-1]+" < "+t[this.rank-1]+") {\n          ++"+r[this.rank-1]+";\n          result.w = "+o+";\n        }\n      }\n    ",u=this.rank<=4?"sourceLoc = coords +\n            "+e+"("+t.map(function(t,e){return "start["+e+"]";}).join()+");":t.map(function(t,e){return r[e]+" = "+n[e]+" + start["+e+"];";}).join("\n");this.userCode="\n      uniform int start["+this.rank+"];\n      void main() {\n        "+e+" coords = getOutputCoords();\n        "+e+" sourceLoc;\n        "+u+"\n        vec4 result = vec4(0.);\n        "+a+"\n        "+s+"\n        setOutput(result);\n      }\n    ";}return t.prototype.getCustomSetupFunc=function(t){var e=this;if(t.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the length of start ("+t.length+")");return function(n,r){null==e.startLoc&&(e.startLoc=n.getUniformLocationNoThrow(r,"start"),null==e.startLoc)||n.gl.uniform1iv(e.startLoc,t);};},t;}(),ns=function(){function t(t){this.gpgpu=t,this.numUsedTextures=0,this.numFreeTextures=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={};}return t.prototype.acquireTexture=function(t,e,n){var r,i=rs(e,n),o=is(t,i,n);if(o in this.freeTextures||(this.freeTextures[o]=[]),o in this.usedTextures||(this.usedTextures[o]=[]),this.freeTextures[o].length>0){this.numFreeTextures--,this.numUsedTextures++,this.log();var a=this.freeTextures[o].shift();return this.usedTextures[o].push(a),a;}return this.numUsedTextures++,this.log(),i===Gt.PACKED_2X2_FLOAT32?r=this.gpgpu.createPackedMatrixTexture(t[0],t[1]):i===Gt.PACKED_2X2_FLOAT16?r=this.gpgpu.createFloat16PackedMatrixTexture(t[0],t[1]):i===Gt.UNPACKED_FLOAT32?r=this.gpgpu.createFloat32MatrixTexture(t[0],t[1]):i===Gt.UNPACKED_FLOAT16?r=this.gpgpu.createFloat16MatrixTexture(t[0],t[1]):i===Gt.PACKED_4X1_UNSIGNED_BYTE&&(r=this.gpgpu.createUnsignedBytesMatrixTexture(t[0],t[1])),this.usedTextures[o].push(r),r;},t.prototype.releaseTexture=function(t,e,n,r){if(null!=this.freeTextures){var i=is(e,rs(n,r),r);i in this.freeTextures||(this.freeTextures[i]=[]),this.freeTextures[i].push(t),this.numFreeTextures++,this.numUsedTextures--;var o=this.usedTextures[i],a=o.indexOf(t);if(a<0)throw new Error("Cannot release a texture that was never provided by this texture manager");o.splice(a,1),this.log();}},t.prototype.log=function(){if(this.logEnabled){var t=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",this.numFreeTextures+" / "+this.numUsedTextures,"("+t+")");}},t.prototype.getNumUsedTextures=function(){return this.numUsedTextures;},t.prototype.getNumFreeTextures=function(){return this.numFreeTextures;},t.prototype.dispose=function(){var t=this;if(null!=this.freeTextures){for(var e in this.freeTextures){this.freeTextures[e].forEach(function(e){t.gpgpu.deleteMatrixTexture(e);});}for(var e in this.usedTextures){this.usedTextures[e].forEach(function(e){t.gpgpu.deleteMatrixTexture(e);});}this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0;}},t;}();function rs(t,e){if(t===Ht.UPLOAD)return Gt.PACKED_2X2_FLOAT32;if(t===Ht.RENDER||null==t)return function(t){return f().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?t?Gt.PACKED_2X2_FLOAT32:Gt.UNPACKED_FLOAT32:t?Gt.PACKED_2X2_FLOAT16:Gt.UNPACKED_FLOAT16;}(e);if(t===Ht.DOWNLOAD||t===Ht.PIXELS)return Gt.PACKED_4X1_UNSIGNED_BYTE;throw new Error("Unknown logical texture type "+t);}function is(t,e,n){return t[0]+"_"+t[1]+"_"+e+"_"+n;}var os=1.7580993408473768,as=1.0507009873554805,ss=function ss(t,e){this.variableNames=["A"],this.outputShape=t,this.userCode="\n      float unaryOperation(float x) {\n        "+e+"\n      }\n\n      void main() {\n        float x = getAAtOutCoords();\n        float y = unaryOperation(x);\n\n        setOutput(y);\n      }\n    ";},us="if (isnan(x)) return x;",cs="return x;",ls="return abs(x);",fs=us+"\n  return (x < 0.0) ? 0.0 : x;\n",hs=us+"\n  return (x < 0.0) ? 0.0 : min(6.0, x);\n",ds="return (x >= 0.0) ? x : (exp(x) - 1.0);",ps="return -x;",ms="return ceil(x);",gs="return floor(x);",vs="return exp(x);",ys="return exp(x) - 1.0;",bs="return x;",xs="return x;",ws="\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",ks="\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",Es="\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",Cs=function Cs(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.userCode="\n      vec4 unaryOperation(vec4 x) {\n        "+e+"\n      }\n\n      void main() {\n        vec4 x = getAAtOutCoords();\n        vec4 y = unaryOperation(x);\n\n        setOutput(y);\n      }\n    ";},As={};function Os(t,e){if(void 0===e&&(e=!1),"linear"===t)return e?xs:cs;if("relu"===t)return e?ws:fs;if("elu"===t)return e?Es:ds;if("relu6"===t)return e?ks:hs;if("prelu"===t)return e?ga:pa;throw new Error("Activation "+t+" has not been implemented for the WebGL backend.");}var _s=600,Ss=function(t){function e(e){var n,r=t.call(this)||this;if(r.pendingRead=new WeakMap(),r.pendingDisposal=new WeakSet(),r.dataRefCount=new WeakMap(),r.numBytesInGPU=0,r.uploadWaitMs=0,r.downloadWaitMs=0,r.warnedAboutMemory=!1,r.pendingDeletes=0,r.disposed=!1,!f().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(null==e){var i=Jt(f().getNumber("WEBGL_VERSION"));r.binaryCache=(n=f().getNumber("WEBGL_VERSION"))in As?As[n]:(As[n]={},As[n]),r.gpgpu=new Ha(i),r.canvas=i.canvas,r.gpgpuCreatedLocally=!0;}else r.gpgpu=e,r.binaryCache={},r.gpgpuCreatedLocally=!1,r.canvas=e.gl.canvas;return r.textureManager=new ns(r.gpgpu),r.numMBBeforeWarning=null==f().global.screen?1024:f().global.screen.height*f().global.screen.width*window.devicePixelRatio*_s/1024/1024,r.texData=new ho(r,Wt),r;}return s(e,t),e.prototype.numDataIds=function(){return this.texData.numDataIds()+(this.cpuBackend?this.cpuBackend.numDataIds():0)-this.pendingDeletes;},e.prototype.write=function(t,e,n){if(f().getBool("DEBUG")&&this.checkNumericalProblems(t),"complex64"===n&&null!=t)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");var r={};return this.texData.set(r,{shape:e,dtype:n,values:t,usage:Ht.UPLOAD}),r;},e.prototype.move=function(t,e,n,r){if(f().getBool("DEBUG")&&this.checkNumericalProblems(e),"complex64"===r)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(t,{shape:n,dtype:r,values:e,usage:Ht.UPLOAD});},e.prototype.readSync=function(t){var e=this.texData.get(t),n=e.values,r=e.dtype,i=e.complexTensors,o=e.slice,a=e.shape,s=e.isPacked;if(null!=o){var u;u=s?new Cs(a,bs):new ss(a,bs);var c=this.runWebGLProgram(u,[{dataId:t,shape:a,dtype:r}],r),l=this.readSync(c.dataId);return this.disposeData(c.dataId),l;}if(null!=n)return this.convertAndCacheOnCPU(t);if("string"===r)return n;var f,h,d=null!=this.activeTimers;return d&&(f=at()),h="complex64"===r?No(i.real.dataSync(),i.imag.dataSync()):this.getValuesFromTexture(t),d&&(this.downloadWaitMs+=at()-f),this.convertAndCacheOnCPU(t,h);},e.prototype.read=function(t){return u(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,l,h,d,p,m,g,v,y,b,x,w,k,E,C;return c(this,function(c){switch(c.label){case 0:if(this.pendingRead.has(t))return e=this.pendingRead.get(t),[2,new Promise(function(t){return e.push(t);})];if(n=this.texData.get(t),r=n.values,i=n.shape,o=n.slice,a=n.dtype,s=n.complexTensors,u=n.isPacked,null!=o)return l=void 0,l=u?new Cs(i,bs):new ss(i,bs),h=this.runWebGLProgram(l,[{dataId:t,shape:i,dtype:a}],a),d=this.read(h.dataId),this.disposeData(h.dataId),[2,d];if(null!=r)return [2,this.convertAndCacheOnCPU(t)];if(!f().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&2===f().getNumber("WEBGL_VERSION"))throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");return p=null,"complex64"!==a&&f().get("WEBGL_BUFFER_SUPPORTED")&&(m=this.decode(t),g=this.texData.get(m.dataId),p=(C=this.gpgpu).createBufferFromTexture.apply(C,[g.texture].concat(Zt(i)))),this.pendingRead.set(t,[]),"complex64"===a?[3,2]:[4,this.gpgpu.createAndWaitForFence()];case 1:c.sent(),c.label=2;case 2:return "complex64"!==a?[3,4]:[4,Promise.all([s.real.data(),s.imag.data()])];case 3:return y=c.sent(),b=y[0],x=y[1],v=No(b,x),[3,5];case 4:null==p?v=this.getValuesFromTexture(t):(w=T(i),v=this.gpgpu.downloadFloat32MatrixFromBuffer(p,w)),c.label=5;case 5:return null!=m&&this.disposeData(m.dataId),k=this.convertAndCacheOnCPU(t,v),E=this.pendingRead.get(t),this.pendingRead.delete(t),E.forEach(function(t){return t(k);}),this.pendingDisposal.has(t)&&(this.pendingDisposal.delete(t),this.disposeData(t),this.pendingDeletes--),[2,k];}});});},e.prototype.checkNumericalProblems=function(t){if(null!=t)for(var e=0;e<t.length;e++){var n=t[e];if(!oe(n)){if(f().getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))throw Error("The value "+n+" cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'");throw Error("The value "+n+" cannot be represented on this device.");}}},e.prototype.getValuesFromTexture=function(t){var e,n=this.texData.get(t),r=n.shape,i=n.dtype,o=n.isPacked,a=T(r);if(f().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){var s=this.decode(t),u=this.texData.get(s.dataId),c=(e=this.gpgpu).downloadMatrixFromPackedTexture.apply(e,[u.texture].concat(Zt(r))).subarray(0,a);return this.disposeData(s.dataId),c;}var l=f().getBool("WEBGL_PACK")&&!0===o,h=l?Re(r):r,d=l?new function(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=Ht.DOWNLOAD;var e=Yo();this.outputShape=t,this.userCode="\n      "+Zo+"\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    ";}(h):new function(t){this.variableNames=["A"],this.outTexUsage=Ht.DOWNLOAD;var e=Yo();this.outputShape=t,this.userCode="\n      "+Zo+"\n\n      void main() {\n        float x = getAAtOutCoords();\n        "+e.output+" = encode_float(x);\n      }\n    ";}(h),p=this.runWebGLProgram(d,[{shape:h,dtype:i,dataId:t}],"float32"),m=this.texData.get(p.dataId),g=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(m.texture,m.texShape[0],m.texShape[1]).subarray(0,a);return this.disposeData(p.dataId),g;},e.prototype.time=function(t){return u(this,void 0,void 0,function(){var e,n,r,i,o,a,s;return c(this,function(u){switch(u.label){case 0:return e=this.activeTimers,n=[],r=!1,null==this.programTimersStack?(this.programTimersStack=n,r=!0):this.activeTimers.push(n),this.activeTimers=n,t(),i=F(this.activeTimers.map(function(t){return t.query;})).filter(function(t){return null!=t;}),o=F(this.activeTimers.map(function(t){return t.name;})).filter(function(t){return null!=t;}),this.activeTimers=e,r&&(this.programTimersStack=null),a={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null},f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?[4,Promise.all(i)]:[3,2];case 1:return s=u.sent(),a.kernelMs=O(s),a.getExtraProfileInfo=function(){return s.map(function(t,e){return {name:o[e],ms:t};}).map(function(t){return t.name+": "+t.ms;}).join(", ");},[3,3];case 2:a.kernelMs={error:"WebGL query timers are not supported in this environment."},u.label=3;case 3:return this.uploadWaitMs=0,this.downloadWaitMs=0,[2,a];}});});},e.prototype.memory=function(){return {unreliable:!1,numBytesInGPU:this.numBytesInGPU};},e.prototype.startTimer=function(){return f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:at(),endMs:null};},e.prototype.endTimer=function(t){return f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),t):(t.endMs=at(),t);},e.prototype.getQueryTime=function(t){return u(this,void 0,void 0,function(){var e;return c(this,function(n){return f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?[2,this.gpgpu.waitForQueryAndGetTime(t)]:[2,(e=t).endMs-e.startMs];});});},e.prototype.disposeData=function(t){if(!this.pendingDisposal.has(t)){if(this.pendingRead.has(t))return this.pendingDisposal.add(t),void this.pendingDeletes++;if(this.texData.has(t)){this.releaseGPUData(t);var e=this.texData.get(t).complexTensors;null!=e&&(e.real.dispose(),e.imag.dispose()),this.texData.delete(t);}}},e.prototype.releaseGPUData=function(t){var e=this.texData.get(t),n=e.texture,r=e.dtype,i=e.texShape,o=e.usage,a=e.isPacked,s=e.slice,u=s&&s.origDataId||t,c=this.dataRefCount.get(u);c>1?this.dataRefCount.set(u,c-1):(this.dataRefCount.delete(u),null!=n&&(this.numBytesInGPU-=this.computeBytes(i,r),this.textureManager.releaseTexture(n,i,o,a)));var l=this.texData.get(t);l.texture=null,l.texShape=null,l.isPacked=!1,l.slice=null;},e.prototype.getTexture=function(t){return this.uploadToGPU(t),this.texData.get(t).texture;},e.prototype.getDataInfo=function(t){return this.texData.get(t);},e.prototype.getCPUBackend=function(){return f().getBool("WEBGL_CPU_FORWARD")?(null==this.cpuBackend&&(this.cpuBackend=Wt.findBackend("cpu")),this.cpuBackend):null;},e.prototype.shouldExecuteOnCPU=function(t,e){var n=this;return void 0===e&&(e=128),null!=this.getCPUBackend()&&t.every(function(t){return null==n.texData.get(t.dataId).texture&&T(t.shape)<e;});},e.prototype.getGPGPUContext=function(){return this.gpgpu;},e.prototype.complex=function(t,e){var n=this.makeOutput(t.shape,"complex64");return this.texData.get(n.dataId).complexTensors={real:Wt.keep(t.clone()),imag:Wt.keep(e.clone())},n;},e.prototype.real=function(t){return this.texData.get(t.dataId).complexTensors.real.clone();},e.prototype.imag=function(t){return this.texData.get(t.dataId).complexTensors.imag.clone();},e.prototype.slice=function(t,e,n){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.slice(t,e,n);if(0===T(n))return jn([],n,t.dtype);var r=this.texData.get(t.dataId).isPacked,i=Zi(t.shape,e,n);if(r||!i){var o=f().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new es(n):new Za(n),a=o.getCustomSetupFunc(e);return this.compileAndRun(o,[t],null,a);}return this.uploadToGPU(t.dataId),this.shallowSlice(t,e,n);},e.prototype.shallowSlice=function(t,e,n){var r=this.texData.get(t.dataId),i=this.makeOutput(n,t.dtype),o=this.texData.get(i.dataId);Object.assign(o,r),o.shape=n,o.dtype=t.dtype;var a=to(e,t.strides);r.slice&&(a+=r.slice.flatOffset),o.slice={flatOffset:a,origDataId:r.slice&&r.slice.origDataId||t.dataId};var s=this.dataRefCount.get(o.slice.origDataId)||1;return this.dataRefCount.set(o.slice.origDataId,s+1),i;},e.prototype.stridedSlice=function(t,e,n,r){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.stridedSlice(t,e,n,r);var i=Yi(e,n,r);if(i.some(function(t){return 0===t;}))return jn([],i);var o=new function(t,e,n){this.variableNames=["x"],this.outputShape=n;var r=n.length,i=sa(n.length),o=sa(n.length),a="";if(1===r)a="coords * strides + begin";else {var s=0;a=n.map(function(t,e){return s++,1===n.length?"coords * strides["+e+"] + begin["+e+"]":"coords["+(s-1)+"] * strides["+e+"] + begin["+e+"]";}).join(",");}this.userCode="\n      "+i+" begin = "+i+"("+t+");\n      "+i+" strides = "+i+"("+e+");\n\n      void main() {\n        "+o+" coords = getOutputCoords();\n        setOutput(getX("+a+"));\n      }\n    ";}(e,r,i);return this.compileAndRun(o,[t]);},e.prototype.reverse=function(t,e){var n=f().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new function(t,e){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;var n=t.length;if(n>4)throw new Error("WebGL backend: Reverse of rank-"+n+" tensor is not yet supported");this.outputShape=t;var r=Xo("rc",n),i=r[n-1]+" + 1 < "+this.outputShape[n-1],o=r[n-2]+" + 1 < "+this.outputShape[n-2],a=sa(n);function s(n){var r=t.map(function(r,i){return function(n,r){return -1!==e.indexOf(n)&&1!==t[n]?t[n]+" - "+r[n]+" - 1":""+r[n];}(i,n);});return "getChannel(getX("+r.join(",")+"), vec2("+r.slice(-2).join(",")+"))";}this.userCode=1===n?"\n        void main(){\n          int rc = getOutputCoords();\n          vec4 result = vec4(0.);\n          result.r = getChannel(getX("+t[0]+" - rc - 1),\n            "+t[0]+" - rc - 1);\n          if("+i+"){\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          "+a+" rc = getOutputCoords();\n          vec4 result = vec4(0.);\n          result.r = "+s(r.slice())+";\n          if("+i+"){\n            result.g = "+function(t){return t[n-1]="("+t[n-1]+" + 1)",s(t);}(r.slice())+";\n          }\n          if("+o+") {\n            result.b = "+function(t){return t[n-2]="("+t[n-2]+" + 1)",s(t);}(r.slice())+";\n            if("+i+") {\n              result.a = "+function(t){return t[n-1]="("+t[n-1]+" + 1)",t[n-2]="("+t[n-2]+" + 1)",s(t);}(r.slice())+";\n            }\n          }\n          setOutput(result);\n        }\n    ";}(t.shape,e):new function(t,e){this.variableNames=["x"];var n=t.length;if(n>4)throw new Error("WebGL backend: Reverse of rank-"+n+" tensor is not yet supported");if(this.outputShape=t,1!==n){var r=t.map(function(n,r){return function(n){return -1!==e.indexOf(n)&&1!==t[n]?t[n]+" - coords["+n+"] - 1":"coords["+n+"]";}(r);}).join(","),i=sa(n);this.userCode="\n      void main() {\n        "+i+" coords = getOutputCoords();\n        setOutput(getX("+r+"));\n      }\n    ";}else this.userCode="\n        void main() {\n          int coord = getOutputCoords();\n          setOutput(getX("+t[0]+" - coord - 1));\n        }\n      ";}(t.shape,e);return this.compileAndRun(n,[t]);},e.prototype.concat=function(t,e){if("complex64"===t[0].dtype){var n=t.map(function(t){return Rn(t);}),r=t.map(function(t){return Mn(t);});return In(this.concat(n,e),this.concat(r,e));}if(this.shouldExecuteOnCPU(t))return this.cpuBackend.concat(t,e);if(1===t.length)return t[0];if(t.length>f().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){var i=Math.floor(t.length/2),o=this.concat(t.slice(0,i),e),a=this.concat(t.slice(i),e);return this.concat([o,a],e);}if(f().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&t[0].rank>1){var s=new function(t,e){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=Tn(t,e);var n=this.outputShape,r=n.length,i=sa(r),o=Xo("coords",r),a=["x","y","z","w","u","v"].slice(0,r);this.variableNames=t.map(function(t,e){return "T"+e;});var s=new Array(t.length-1);s[0]=t[0][e];for(var u=1;u<s.length;u++){s[u]=s[u-1]+t[u][e];}var c=a[e],l=a.slice(-2),f=a.join(),h="if ("+c+" < "+s[0]+") {\n        return getChannel(\n            getT0("+f+"), vec2("+l.join()+"));\n        }";for(u=1;u<s.length;u++){var d=s[u-1];h+="\n        if ("+c+" < "+s[u]+"  && "+c+" >= "+s[u-1]+") {\n          return getChannel(\n            getT"+u+"("+xa(a,c,d)+"),\n            vec2("+xa(l,c,d)+"));\n        }";}var p=s.length,m=s[s.length-1];h+="\n        return getChannel(\n          getT"+p+"("+xa(a,c,m)+"),\n          vec2("+xa(l,c,m)+"));",this.userCode="\n      float getValue("+a.map(function(t){return "int "+t;})+") {\n        "+h+"\n      }\n\n      void main() {\n        "+i+" coords = getOutputCoords();\n        vec4 result = vec4(getValue("+o+"), 0., 0., 0.);\n\n        "+o[r-1]+" = "+o[r-1]+" + 1;\n        if ("+o[r-1]+" < "+n[r-1]+") {\n          result.g = getValue("+o+");\n        }\n\n        "+o[r-2]+" = "+o[r-2]+" + 1;\n        if ("+o[r-2]+" < "+n[r-2]+") {\n          result.a = getValue("+o+");\n        }\n\n        "+o[r-1]+" = "+o[r-1]+" - 1;\n        if ("+o[r-2]+" < "+n[r-2]+" &&\n            "+o[r-1]+" < "+n[r-1]+") {\n          result.b = getValue("+o+");\n        }\n        setOutput(result);\n      }\n    ";}(t.map(function(t){return t.shape;}),e);return this.compileAndRun(s,t);}var u=Tn(t.map(function(t){return t.shape;}),e),c=t.map(function(t){return t.as2D(-1,T(t.shape.slice(e)));}),l=new function(t){this.outputShape=[],this.outputShape=Tn(t,1),this.variableNames=t.map(function(t,e){return "T"+e;});var e=new Array(t.length-1);e[0]=t[0][1];for(var n=1;n<e.length;n++){e[n]=e[n-1]+t[n][1];}var r=["if (yC < "+e[0]+") setOutput(getT0(yR, yC));"];for(n=1;n<e.length;n++){var i=e[n-1];r.push("else if (yC < "+e[n]+") setOutput(getT"+n+"(yR, yC-"+i+"));");}var o=e.length,a=e[e.length-1];r.push("else setOutput(getT"+o+"(yR, yC-"+a+"));"),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    ";}(c.map(function(t){return t.shape;}));return this.compileAndRun(l,c).reshape(u);},e.prototype.neg=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.neg(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,ps,t.dtype);var e=new ss(t.shape,ps);return this.compileAndRun(e,[t]);},e.prototype.batchMatMul=function(t,e,n,r){var i=n?t.shape[2]:t.shape[1],o=r?e.shape[1]:e.shape[2],a=n?t.shape[1]:t.shape[2],s=t.shape[0];if((1===i||1===o)&&a>1e3){n&&(t=fo(t,[0,2,1])),r&&(e=fo(e,[0,2,1]));var u=1===o?t:t.as3D(s,a,1),c=1===o?2:1,l=1===o?e.as3D(s,1,a):e;return this.multiply(u,l).sum(c,!0);}var f=It(t.dtype,e.dtype),h=new Ka(t.shape,[s,i,o],n,r);return this.compileAndRun(h,[t,e],f);},e.prototype.fusedBatchMatMul=function(t){var e=t.a,n=t.b,r=t.transposeA,i=t.transposeB,o=t.bias,a=t.activation,s=t.preluActivationWeights,u=r?e.shape[2]:e.shape[1],c=i?n.shape[1]:n.shape[2],l=e.shape[0],f=It(e.dtype,n.dtype),h=null!=o,d=null!=s,p=a?Os(a,!0):null,m=new Ka(e.shape,[l,u,c],r,i,h,p,d),g=[e,n];return o&&g.push(o),s&&g.push(s),this.compileAndRun(m,g,f);},e.prototype.multiply=function(t,e){if("complex64"===t.dtype){var n=this.texData.get(t.dataId),r=this.texData.get(e.dataId),i=new la("return areal * breal - aimag * bimag;",t.shape,e.shape),o=new la("return areal * bimag + aimag * breal;",t.shape,e.shape),a=[this.makeComplexComponentTensorInfo(t,n.complexTensors.real),this.makeComplexComponentTensorInfo(t,n.complexTensors.imag),this.makeComplexComponentTensorInfo(e,r.complexTensors.real),this.makeComplexComponentTensorInfo(e,r.complexTensors.imag)],s=this.compileAndRun(i,a),u=this.compileAndRun(o,a),c=this.complex(s,u);return s.dispose(),u.dispose(),c;}if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.multiply(t,e);if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,da,t.dtype);var l=new ma(da,t.shape,e.shape);return this.compileAndRun(l,[t,e],t.dtype);},e.prototype.batchNormalization=function(t,e,n,r,i,o){var a=[t,e,n],s=null;null!=o&&(s=o.shape,a.push(o));var u=null;if(null!=i&&(u=i.shape,a.push(i)),f().getBool("WEBGL_PACK_NORMALIZATION")){var c=new function(t,e,n,r,i,o){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],Ur(t,e),Ur(t,n);var a="vec4(0.0)";null!=r&&(Ur(t,r),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");var s="vec4(1.0)";null!=i&&(Ur(t,i),this.variableNames.push("scale"),s="getScaleAtOutCoords()"),this.outputShape=t,this.userCode="\n      void main() {\n        vec4 offset = "+a+";\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("+o+"));\n\n        setOutput((x - mean) * inv + offset);\n      }\n    ";}(t.shape,e.shape,n.shape,s,u,r);return this.compileAndRun(c,a);}var l=new function(t,e,n,r,i,o){this.outputShape=[],this.variableNames=["x","mean","variance"],Ur(t,e),Ur(t,n);var a="0.0";null!=r&&(Ur(t,r),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");var s="1.0";null!=i&&(Ur(t,i),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 = "+a+";\n        float scale = "+s+";\n        float inv = scale * inversesqrt(variance + float("+o+"));\n        setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n      }\n    ";}(t.shape,e.shape,n.shape,s,u,r);return this.compileAndRun(l,a);},e.prototype.localResponseNormalization4D=function(t,e,n,r,i){var o=f().getBool("WEBGL_PACK_NORMALIZATION")?new function(t,e,n,r,i){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;var o,a=e,s=t[3]-1;this.outputShape=t;var u="float("+n+") + float("+r+") * sum";o=.5===i?"inversesqrt("+u+")":1===i?"1.0/("+u+")":"exp(log("+u+") * float(-"+i+"));",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 - "+a+";\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 = - "+a+"; j <= "+a+"; j++) {\n          ivec2 idx = depth + j;\n          bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n          bvec2 belowUpperBound = lessThanEqual(idx, ivec2("+s+"));\n\n          bool depthInRange = aboveLowerBound.x && belowUpperBound.x;\n          bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;\n\n          if(depthInRange || depthPlusOneInRange){\n            vec4 z = vec4(0.);\n            vec4 xFragAtCurrentDepth;\n            z.xz = cache.xy;\n            if(depthPlusOneInRange && hasNextCol){\n              xFragAtCurrentDepth = idx.y != d ?\n                getX(b, r, c, idx.y) : xFragAtOutputCoords;\n              z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));\n              if(hasNextRow){\n                z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));\n              }\n            }\n            cache.xy = z.yw;\n            sum += z * z;\n          }\n        }\n        vec4 result = xAtOutputCoords * "+o+";\n        setOutput(result);\n      }\n    ";}(t.shape,e,n,r,i):new function(t,e,n,r,i){this.variableNames=["x"],this.outputShape=[];var o,a=e,s=t[3]-1;this.outputShape=t;var u="float("+n+") + float("+r+") * sum";o=.5===i?"inversesqrt("+u+")":1===i?"1.0/("+u+")":"exp(log("+u+") * float(-"+i+"));",this.userCode="\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int r = coords[1];\n        int c = coords[2];\n        int d = coords[3];\n        float x = getX(b, r, c, d);\n        float sum = 0.0;\n        for (int j = -"+a+"; j <= "+a+"; j++) {\n          int idx = d + j;\n          if (idx >= 0 && idx <=  "+s+") {\n            float z = getX(b, r, c, idx);\n            sum += z * z;\n          }\n        }\n        float val = x * "+o+";\n        setOutput(val);\n      }\n    ";}(t.shape,e,n,r,i);return this.compileAndRun(o,[t]);},e.prototype.LRNGrad=function(t,e,n,r,i,o,a){var s=new function(t,e,n,r,i){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=i,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("+i+")\n                * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)\n                / norm;\n              if (k == d) {\n                dyi += pow(norm, -1.0 * "+i+");\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    ";}(e.shape,r,i,o,a);return this.compileAndRun(s,[e,n,t]);},e.prototype.tile=function(t,e){if("string"===t.dtype){var n=this.readSync(t.dataId).map(function(t){return ct(t);});return $o(or(t.shape,t.dtype,n),e);}var r=new function(t,e){this.variableNames=["A"];for(var n=new Array(t.length),r=0;r<n.length;r++){n[r]=t[r]*e[r];}this.outputShape=n,this.rank=n.length;var i=sa(this.rank),o=function(t){var e=t.length;if(e>5)throw Error("Tile for rank "+e+" is not yet supported");if(1===e)return "imod(resRC, "+t[0]+")";for(var n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[],i=0;i<t.length;i++){r.push("imod("+n[i]+", "+t[i]+")");}return r.join();}(t);this.userCode="\n      void main() {\n        "+i+" resRC = getOutputCoords();\n        setOutput(getA("+o+"));\n      }\n    ";}(t.shape,e);return this.compileAndRun(r,[t]);},e.prototype.pad=function(t,e,n){var r=f().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new function(t,e,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e.map(function(e,n){return e[0]+t[n]+e[1];});for(var r=t.length,i=sa(r),o=e.map(function(t){return t[0];}).join(","),a=e.map(function(e,n){return e[0]+t[n];}).join(","),s=Xo("rc",r),u=Xo("source",r),c=s[r-1]+" < "+this.outputShape[r-1],l=1===r?"source":"vec2("+u.slice(-2).join()+")",f=[i+" rc = outputLoc;",s[r-1]+" += 1;\n       if("+c+") {\n      ",1===r?"":"}\n       rc = outputLoc;\n       "+s[r-2]+" += 1;\n       if("+s[r-2]+" < "+this.outputShape[r-2]+") {",1===r?"":"  "+s[r-1]+" += 1;\n         if("+c+") {"],h=1===r?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",d="",p=0,m=1===r?2:4;p<m;p++){d+="\n        "+f[p]+"\n        if ("+h+") {\n          result["+p+"] = float("+n+");\n        } else {\n          "+i+" source = rc - start;\n          result["+p+"] = getChannel(getX("+u.join()+"), "+l+");\n        }\n      ";}d+=1===r?"} ":"}}",this.userCode="\n      const "+i+" start = "+i+"("+o+");\n      const "+i+" end = "+i+"("+a+");\n\n      void main() {\n        "+i+" outputLoc = getOutputCoords();\n        vec4 result = vec4(0.);\n        "+d+"\n        setOutput(result);\n      }\n    ";}(t.shape,e,n):new function(t,e,n){this.variableNames=["x"],this.outputShape=e.map(function(e,n){return e[0]+t[n]+e[1];});var r=t.length,i=sa(r),o=e.map(function(t){return t[0];}).join(","),a=e.map(function(e,n){return e[0]+t[n];}).join(","),s=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);this.userCode=1!==r?"\n      "+i+" start = "+i+"("+o+");\n      "+i+" end = "+i+"("+a+");\n\n      void main() {\n        "+i+" outC = getOutputCoords();\n        if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n          setOutput(float("+n+"));\n        } else {\n          "+i+" coords = outC - start;\n          setOutput(getX("+s+"));\n        }\n      }\n    ":"\n        int start = "+o+";\n        int end = "+a+";\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      ";}(t.shape,e,n);return this.compileAndRun(r,[t]);},e.prototype.gather=function(t,e,n){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.gather(t,e,n);var r=new function(t,e,n){this.variableNames=["A","indices"];var r=t.slice();r[n]=e,this.outputShape=r,this.rank=r.length;var i=sa(this.rank),o=function(t,e){var n=t.length;if(n>4)throw Error("Gather for rank "+n+" is not yet supported");if(1===n)return "int(getIndices(resRC))";for(var r=["resRC.x","resRC.y","resRC.z","resRC.w"],i=[],o=0;o<t.length;o++){o===e?i.push("int(getIndices("+r[o]+"))"):i.push(""+r[o]);}return i.join();}(t,n);this.userCode="\n      void main() {\n        "+i+" resRC = getOutputCoords();\n        setOutput(getA("+o+"));\n      }\n    ";}(t.shape,e.size,n);return this.compileAndRun(r,[t,e]);},e.prototype.batchToSpaceND=function(t,e,n){_(t.rank<=4,function(){return "batchToSpaceND for rank > 4 with a WebGL backend not implemented yet";});var r=e.reduce(function(t,e){return t*e;}),i=yr(t.shape,e,r),o=br(i.length,e.length),a=xr(t.shape,e,r),s=wr(n,e.length),u=kr(a,n,e.length);return fo(t.reshape(i),o).reshape(a).slice(s,u);},e.prototype.spaceToBatchND=function(t,e,n){_(t.rank<=4,function(){return "spaceToBatchND for rank > 4 with a WebGL backend not implemented yet";});var r=e.reduce(function(t,e){return t*e;}),i=[[0,0]];i.push.apply(i,n);for(var o=1+e.length;o<t.shape.length;++o){i.push([0,0]);}var a=t.pad(i),s=yr(a.shape,e,r,!1),u=br(s.length,e.length,!1),c=xr(a.shape,e,r,!1);return fo(a.reshape(s),u).reshape(c);},e.prototype.reduce=function(t,e,n){var r=t.shape[0],i=t.shape[1],o=new function(t,e){this.variableNames=["x"];var n=t.windowSize,r=t.batchSize,i=t.inSize,o=Math.ceil(i/n);this.outputShape=[r,o];var a="0.0",s="";"prod"===e?a="1.0":"min"===e?(a="1.0 / 1e-20",s="min"):"max"===e&&(a="-1.0 / 1e-20",s="max");var u=e+"("+e+"("+e+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"sum"===e?u="sumValue":"prod"===e?u="prodValue":"all"===e?u="allValue":"any"===e&&(u="anyValue");var c=4*Math.floor(n/4),l=n%4,f="\n      if ("+("sum"===e)+") {\n        sumValue += dot(values, ones);\n      } else if ("+("prod"===e)+") {\n        vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n        prodValue *= tmp[0] * tmp[1];\n      } else {\n        minMaxValue = "+s+"(values, minMaxValue);\n      }\n    ",h="vec4";"all"===e?(a="1.0",f="\n        bool reducedAllValue = all(values);\n        float floatedReducedAllValue = float(reducedAllValue);\n        allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n      ",h="bvec4"):"any"===e&&(a="0.0",f="\n        bool reducedAnyValue = any(values);\n        float floatedReducedAnyValue = float(reducedAnyValue);\n        anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n      ",h="bvec4");var d="";i%n>0&&(d="\n        if (inIdx < 0 || inIdx >= "+i+") {\n          return initializationValue;\n        }\n      "),this.userCode="\n      const float initializationValue = "+a+";\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("+a+");\n        float prodValue = 1.0;\n        float sumValue = 0.0;\n        float allValue = 1.0;\n        float anyValue = 0.0;\n\n        for (int i = 0; i < "+c+"; i += 4) {\n          int inIdx = inOffset + i;\n          "+h+" values = "+h+"(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            getValue(batch, inIdx + 3)\n          );\n\n          "+f+"\n        }\n\n        int inIdx = inOffset + "+c+";\n        if ("+(1===l)+") {\n          "+h+" values = "+h+"(\n            getValue(batch, inIdx),\n            initializationValue,\n            initializationValue,\n            initializationValue\n          );\n\n          "+f+"\n        } else if ("+(2===l)+") {\n          "+h+" values = "+h+"(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            initializationValue,\n            initializationValue\n          );\n\n          "+f+"\n        } else if ("+(3===l)+") {\n          "+h+" values = "+h+"(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            initializationValue\n          );\n\n          "+f+"\n        }\n        setOutput("+u+");\n      }\n    ";}({windowSize:Vi(i),inSize:i,batchSize:r},e),a=this.compileAndRun(o,[t],n);return 1===a.shape[1]?a:this.reduce(a,e,n);},e.prototype.argReduce=function(t,e,n){void 0===n&&(n=null);var r=t.shape[0],i=t.shape[1];null!=n&&(r=n.shape[0],i=n.shape[1]);var o=new function(t,e,n){this.variableNames=["A"];var r=t.windowSize,i=t.batchSize,o=t.inSize,a=Math.ceil(o/r);n||this.variableNames.push("bestIndicesA"),this.outputShape=[i,a];var s="max"===e?">":"<",u=n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode="\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n        int outIdx = coords[1];\n        int inOffset = outIdx * "+r+";\n\n        int bestIndex = inOffset;\n        float bestValue = getA(batch, bestIndex);\n\n        for (int i = 0; i < "+r+"; i++) {\n          int inIdx = "+u+";\n          float candidate = getA(batch, inIdx);\n          if (candidate "+s+" bestValue) {\n            bestValue = candidate;\n            bestIndex = inIdx;\n          }\n        }\n        setOutput(float(bestIndex));\n      }\n    ";}({windowSize:Vi(i),inSize:i,batchSize:r},e,null==n),a=[t];null!=n&&a.push(n);var s=this.compileAndRun(o,a,"int32");return 1===s.shape[1]?s:this.argReduce(t,e,s);},e.prototype.argReducePacked=function(t,e,n){void 0===n&&(n=null);var r=null!=n?n.shape:t.shape,i=new function(t,e,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,_(t.length>2,function(){return "Packed arg"+(n.charAt(0).toUpperCase()+n.slice(1))+" supports only inputs with rank above 2.";});var i=t[t.length-1],o=Math.ceil(i/e);this.outputShape=t.slice(0,-1),o>1&&this.outputShape.push(o),r||this.variableNames.push("bestIndicesA");var a,s,u=this.outputShape,c=u.length,l=sa(c),f=Xo("coords",c);if(1===o){var h=sa(s=c+1);a="\n        "+h+" sourceLocR = "+h+"("+f.join()+", 0);\n        ++"+f[c-1]+";\n        "+h+" sourceLocG = "+h+"("+f.join()+", 0);\n        ++"+f[c-2]+";\n        "+h+" sourceLocA = "+h+"("+f.join()+", 0);\n        --"+f[c-1]+";\n        "+h+" sourceLocB = "+h+"("+f.join()+", 0);\n        --"+f[c-2]+";";}else s=c,a="\n        "+l+" sourceLocR = coords;\n        ++"+f[c-1]+";\n        "+l+" sourceLocG = coords;\n        ++"+f[c-2]+";\n        "+l+" sourceLocA = coords;\n        --"+f[c-1]+";\n        "+l+" sourceLocB = coords;\n        --"+f[c-2]+";";var d=["x","y","z","w","u","v"].slice(0,s),p="."+d[s-1],m=d.map(function(t){return "int "+t;}),g=Xo("sourceLocR",s-1).concat("inIdx.r"),v=Xo("sourceLocG",s-1).concat("inIdx.g"),y=Xo("sourceLocB",s-1).concat("inIdx.b"),b=Xo("sourceLocA",s-1).concat("inIdx.a"),x="max"===n?"greaterThan":"lessThan",w=r?"":"\n          inIdx = round(vec4(getBestIndicesAChannel("+g.join()+"),\n                             getBestIndicesAChannel("+v.join()+"),\n                             getBestIndicesAChannel("+y.join()+"),\n                             getBestIndicesAChannel("+b.join()+")));",k="vec4(\n            getAChannel("+g.join()+"),\n            hasNextCol ? getAChannel("+v.join()+") : 0.,\n            hasNextRow ? getAChannel("+y.join()+") : 0.,\n            hasNextRow && hasNextCol ? getAChannel("+b.join()+") : 0.)",E=r?"":"\n      float getBestIndicesAChannel("+m.join()+") {\n        return getChannel(getBestIndicesA("+d.join()+"),\n                                          vec2("+d.slice(-2).join()+"));\n      }";this.userCode="\n      float getAChannel("+m.join()+") {\n        return getChannel(getA("+d.join()+"),\n                               vec2("+d.slice(-2).join()+"));\n      }\n      "+E+"\n      void main() {\n        "+l+" coords = getOutputCoords();\n        bool hasNextCol = "+f[c-1]+" < "+(u[c-1]-1)+";\n        bool hasNextRow = "+f[c-2]+" < "+(u[c-2]-1)+";\n        "+a+"\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 = "+k+";\n\n        for (int i = 0; i < "+e+"; i++) {\n          inIdx = srcIdx;\n          "+w+"\n          vec4 candidate = "+k+";\n          bvec4 nan = isnan(candidate);\n          bvec4 replace = bvec4(\n            vec4("+x+"(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));\n\n          bestValue = vec4(replace.x  ? candidate.x : bestValue.x,\n                           replace.y  ? candidate.y : bestValue.y,\n                           replace.z  ? candidate.z : bestValue.z,\n                           replace.w  ? candidate.w : bestValue.w);\n          bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));\n          srcIdx++;\n        }\n        setOutput(bestIndex);\n      }\n    ";}(r,Vi(r[r.length-1]),e,null==n),o=null==n?[t]:[t,n],a=this.compileAndRun(i,o,"int32");return a.rank===t.rank?this.argReducePacked(t,e,a):a;},e.prototype.sum=function(t,e){On("sum",e,t.rank);var n=Cn(t.shape,e),r=n[0],i=T(n[1]),o=t.as2D(-1,i),a=Rt(t.dtype);return this.reduce(o,"sum",a).reshape(r);},e.prototype.prod=function(t,e){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.prod(t,e);var n=Cn(t.shape,e),r=n[0],i=T(n[1]),o=t.as2D(-1,i),a=Rt(t.dtype);return this.reduce(o,"prod",a).reshape(r);},e.prototype.unsortedSegmentSum=function(t,e,n){var r=0,i=_n([r],t.rank),o=t;null!=i&&(o=fo(t,i),r=Dn(1,t.rank)[0]);var a=function(t,e,n){for(var r=[],i=t.length,o=0;o<i;o++){o!==e?r.push(t[o]):r.push(n);}return r;}(o.shape,r,n),s=T([o.shape[r]]),u=o.as2D(-1,s),c=Rt(t.dtype),l=this.segOpCompute(u,"unsortedSegmentSum",e,c,n).reshape(a);return null!=i&&(l=fo(l,Sn(i))),l;},e.prototype.segOpCompute=function(t,e,n,r,i){var o=t.shape[0],a=t.shape[1],s=function(t,e){var n,r=!1;for(t<=Wi?(n=t,r=!0):n=tt(t,Math.floor(Math.sqrt(t)));!r;){n>e||n===t?r=!0:n=tt(t,n+1);}return n;}(a,i),u=new function(t,e){this.variableNames=["x","segmentIds"];var n=t.windowSize,r=t.batchSize,i=t.inSize,o=t.numSegments,a=o*Math.ceil(i/n);this.outputShape=[r,a];var s=4*Math.floor(n/4),u=n%4,c="\n        sumValue += dot(values, segFilter);\n    ",l="";i%n>0&&(l="\n        if (inIdx < 0 || inIdx >= "+i+") {\n          return initializationValue;\n        }\n      ");var f="";i%n>0&&(f="\n        if (inIdx < 0 || inIdx >= "+i+") {\n          return -1.0;\n        }\n      "),this.userCode="\n      const float initializationValue = 0.0;\n\n      float getValue(int batch, int inIdx) {\n        "+l+"\n        return getX(batch, inIdx);\n      }\n\n      float getSegmentIdAtIndex(int inIdx) {\n        "+f+"\n        return getSegmentIds(inIdx);\n      }\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n        int outIdx = coords[1];\n        int inOffset = int(floor(float(outIdx) / float(\n          "+o+")) * float("+n+"));\n        int currentSeg = int(mod(float(outIdx), float("+o+")));\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    ";}({windowSize:s,inSize:a,batchSize:o,numSegments:i},e),c=this.compileAndRun(u,[t,n],r);return c.shape[1]===i?c:(n=Yn(0,i).tile([a/s]),this.segOpCompute(c,e,n,r,i));},e.prototype.argMinMaxReduce=function(t,e,n){var r=[e];if(On("arg"+n.charAt(0).toUpperCase()+n.slice(1),r,t.rank),!f().getBool("WEBGL_PACK_REDUCE")||t.rank<=2){var i=Cn(t.shape,r),o=i[0],a=T(i[1]),s=t.as2D(-1,a);return this.argReduce(s,n).reshape(o);}return this.argReducePacked(t,n);},e.prototype.argMin=function(t,e){return this.argMinMaxReduce(t,e,"min");},e.prototype.argMax=function(t,e){return this.argMinMaxReduce(t,e,"max");},e.prototype.cumsum=function(t,e,n,r){if(e!==t.rank-1)throw new Error("WebGL cumsum shader expects an inner-most axis="+(t.rank-1)+" but got axis="+e);var i=new function(t,e,n){this.variableNames=["x"],this.outputShape=t;var r=t.length,i=t[t.length-1],o=n?"<":">";this.userCode="\n      int getIndex(int i) {\n        "+(n?"return "+i+" -i - 1;":"return i;")+"\n      }\n\n      void main() {\n        "+sa(r)+" coords = getOutputCoords();\n        int end = "+Ca(r,"coords")+";\n        float val = 0.0;\n        for (int i = "+i+" - 1; i >= 0; i -= 1) {\n          int idx = getIndex(i);\n          if (idx "+o+" end) {\n            continue;\n          }\n          if (idx == end && "+e+") {\n            continue;\n          }\n          "+Ca(r,"coords")+" = idx;\n          val += getX("+function(t,e){if(1===t)return ""+e;if(2===t)return e+".x, "+e+".y";if(3===t)return e+".x, "+e+".y, "+e+".z";if(4===t)return e+".x, "+e+".y, "+e+".z, "+e+".w";throw Error("Cumulative sum for rank "+t+" is not yet supported");}(r,"coords")+");\n        }\n        setOutput(val);\n      }\n    ";}(t.shape,n,r);return this.compileAndRun(i,[t]);},e.prototype.equal=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(equal(a, b));\n","bool");var n=new ma("return float(a == b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool");},e.prototype.notEqual=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(notEqual(a, b));\n","bool");var n=new ma("return float(a != b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool");},e.prototype.less=function(t,e){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.less(t,e);if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(lessThan(a, b));\n","bool");var n=new ma("return float(a < b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool");},e.prototype.lessEqual=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(lessThanEqual(a, b));\n","bool");var n=new ma("return float(a <= b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool");},e.prototype.greater=function(t,e){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.greater(t,e);if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(greaterThan(a, b));\n","bool");var n=new ma("return float(a > b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool");},e.prototype.greaterEqual=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(greaterThanEqual(a, b));\n","bool");var n=new ma("return float(a >= b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool");},e.prototype.logicalNot=function(t){var e=new ss(t.shape,"return float(!(x >= 1.0));");return this.compileAndRun(e,[t]);},e.prototype.logicalAnd=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(\n    vec4(greaterThanEqual(a, vec4(1.0))) *\n    vec4(greaterThanEqual(b, vec4(1.0))));\n","bool");var n=new ma("return float(a >= 1.0 && b >= 1.0);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool");},e.prototype.logicalOr=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return min(\n    vec4(greaterThanEqual(a, vec4(1.0))) +\n    vec4(greaterThanEqual(b, vec4(1.0))),\n    vec4(1.0));\n","bool");var n=new ma("return float(a >= 1.0 || b >= 1.0);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool");},e.prototype.select=function(t,e,n){var r=new function(t,e,n){var r,i;if(this.variableNames=["c","a","b"],this.outputShape=e,n>4)throw Error("Where for rank "+n+" is not yet supported");if(1===n)i="resRC",r="resRC";else {for(var o=["resRC.x","resRC.y","resRC.z","resRC.w"],a=[],s=[],u=0;u<e.length;u++){s.push(""+o[u]),u<t&&a.push(""+o[u]);}r=a.join(),i=s.join();}var c=sa(n);this.userCode="\n      void main() {\n        "+c+" resRC = getOutputCoords();\n        float cVal = getC("+r+");\n        if (cVal >= 1.0) {\n          setOutput(getA("+i+"));\n        } else {\n          setOutput(getB("+i+"));\n        }\n      }\n    ";}(t.rank,e.shape,e.rank);return this.compileAndRun(r,[t,e,n],It(e.dtype,n.dtype));},e.prototype.where=function(t){vn("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");var e=t.dataSync();return Go(t.shape,e);},e.prototype.topk=function(t,e,n){return Ho(t.dataSync(),t.shape,t.dtype,e);},e.prototype.min=function(t,e){On("min",e,t.rank);var n=Cn(t.shape,e),r=n[0],i=T(n[1]),o=t.as2D(-1,i);return this.reduce(o,"min",o.dtype).reshape(r);},e.prototype.minimum=function(t,e){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.minimum(t,e);var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new va("\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 ma("\n  if (isnan(a)) return a;\n  if (isnan(b)) return b;\n\n  return min(a, b);\n",t.shape,e.shape);return this.compileAndRun(n,[t,e]);},e.prototype.mod=function(t,e){var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new va("\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 ma("if (b == 0.0) return NAN;\n  return mod(a, b);",t.shape,e.shape);return this.compileAndRun(n,[t,e]);},e.prototype.max=function(t,e){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.max(t,e);On("max",e,t.rank);var n=Cn(t.shape,e),r=n[0],i=T(n[1]),o=t.as2D(-1,i);return this.reduce(o,"max",o.dtype).reshape(r);},e.prototype.maximum=function(t,e){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.maximum(t,e);var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new va("\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 ma("\n  if (isnan(a)) return a;\n  if (isnan(b)) return b;\n\n  return max(a, b);\n",t.shape,e.shape);return this.compileAndRun(n,[t,e]);},e.prototype.all=function(t,e){On("all",e,t.rank);var n=Cn(t.shape,e),r=n[0],i=T(n[1]),o=t.as2D(-1,i);return this.reduce(o,"all",o.dtype).reshape(r);},e.prototype.any=function(t,e){On("any",e,t.rank);var n=Cn(t.shape,e),r=n[0],i=T(n[1]),o=t.as2D(-1,i);return this.reduce(o,"any",o.dtype).reshape(r);},e.prototype.floorDiv=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  ivec4 ia = round(a);\n  ivec4 ib = round(b);\n  bvec4 cond = notEqual(ib, ivec4(0));\n  ivec4 result = ivec4(0);\n  vec4 s = sign(a) * sign(b);\n\n  // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n  if (cond[0]) {\n    result[0] = idiv(ia[0], ib[0], s[0]);\n  }\n  if (cond[1]) {\n    result[1] = idiv(ia[1], ib[1], s[1]);\n  }\n  if (cond[2]) {\n    result[2] = idiv(ia[2], ib[2], s[2]);\n  }\n  if (cond[3]) {\n    result[3] = idiv(ia[3], ib[3], s[3]);\n  }\n  return vec4(result);\n","int32");var n=new ma("\n  float s = sign(a) * sign(b);\n  int ia = round(a);\n  int ib = round(b);\n  if (ib != 0) {\n    // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n    return float(idiv(ia, ib, s));\n  } else {\n    return NAN;\n  }\n",t.shape,e.shape);return this.compileAndRun(n,[t,e],"int32");},e.prototype.add=function(t,e){if("complex64"===t.dtype&&"complex64"===e.dtype)return this.complexSeparableBinaryOp(t,e,fa);if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.add(t,e);var n=It(t.dtype,e.dtype);if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,fa,n);var r=new ma(fa,t.shape,e.shape);return this.compileAndRun(r,[t,e],n);},e.prototype.packedUnaryOp=function(t,e,n){var r=new Cs(t.shape,e);return this.compileAndRun(r,[t],n);},e.prototype.packedBinaryOp=function(t,e,n,r,i){void 0===i&&(i=!1);var o=new va(n,t.shape,e.shape,i);return this.compileAndRun(o,[t,e],r);},e.prototype.complexSeparableBinaryOp=function(t,e,n){var r=this,i=this.texData.get(t.dataId),o=this.texData.get(e.dataId),a=[[i.complexTensors.real,o.complexTensors.real],[i.complexTensors.imag,o.complexTensors.imag]].map(function(i){var o=i[0],a=i[1],s=r.makeComplexComponentTensorInfo(t,o),u=r.makeComplexComponentTensorInfo(e,a),c=new ma(n,t.shape,e.shape);return r.compileAndRun(c,[s,u],It(o.dtype,a.dtype));}),s=a[0],u=a[1],c=this.complex(s,u);return s.dispose(),u.dispose(),c;},e.prototype.makeComplexComponentTensorInfo=function(t,e){return {dataId:e.dataId,dtype:e.dtype,shape:t.shape};},e.prototype.addN=function(t){if(1===t.length)return t[0];if(t.length>f().get("WEBGL_MAX_TEXTURES_IN_SHADER")){var e=Math.floor(t.length/2),n=this.addN(t.slice(0,e)),r=this.addN(t.slice(e));return this.addN([n,r]);}var i=t.map(function(t){return t.dtype;}).reduce(function(t,e){return It(t,e);}),o=t.map(function(t){return t.shape;}),a=f().getBool("WEBGL_PACK")?new function(t,e){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.variableNames=e.map(function(t,e){return "T"+e;});var n=[];this.variableNames.forEach(function(t){n.push("vec4 v"+t+" = get"+t+"AtOutCoords();");});var r=this.variableNames.map(function(t){return "v"+t;}).join(" + ");this.userCode="\n      void main() {\n        "+n.join("\n        ")+"\n\n        vec4 result = "+r+";\n        setOutput(result);\n      }\n    ";}(t[0].shape,o):new function(t,e){this.outputShape=[],this.outputShape=t,this.variableNames=e.map(function(t,e){return "T"+e;});var n=[];this.variableNames.forEach(function(t){n.push("float v"+t+" = get"+t+"AtOutCoords();");});var r=this.variableNames.map(function(t){return "v"+t;}).join(" + ");this.userCode="\n      void main() {\n        "+n.join("\n        ")+"\n\n        float result = "+r+";\n        setOutput(result);\n      }\n    ";}(t[0].shape,o);return this.compileAndRun(a,t,i);},e.prototype.subtract=function(t,e){if("complex64"===t.dtype&&"complex64"===e.dtype)return this.complexSeparableBinaryOp(t,e,ha);if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.subtract(t,e);var n=It(t.dtype,e.dtype);if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,ha,t.dtype);var r=new ma(ha,t.shape,e.shape);return this.compileAndRun(r,[t,e],n);},e.prototype.pow=function(t,e){var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new va("\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 ma("\nif(a < 0.0 && floor(b) < b){\n  return NAN;\n}\nif (b == 0.0) {\n  return 1.0;\n}\nreturn (round(mod(b, 2.0)) != 1) ?\n    pow(abs(a), b) : sign(a) * pow(abs(a), b);\n",t.shape,e.shape),r=It(t.dtype,e.dtype);return this.compileAndRun(n,[t,e],r);},e.prototype.ceil=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.ceil(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,ms,t.dtype);var e=new ss(t.shape,ms);return this.compileAndRun(e,[t]);},e.prototype.floor=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.floor(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,gs,t.dtype);var e=new ss(t.shape,gs);return this.compileAndRun(e,[t]);},e.prototype.sign=function(t){var e=new ss(t.shape,"\n  if (isnan(x)) { return 0.0; }\n  return sign(x);\n");return this.compileAndRun(e,[t]);},e.prototype.isNaN=function(t){var e=new ss(t.shape,"return float(isnan(x));");return this.compileAndRun(e,[t],"bool");},e.prototype.isInf=function(t){var e=new ss(t.shape,"return float(isinf(x));");return this.compileAndRun(e,[t],"bool");},e.prototype.isFinite=function(t){var e=new ss(t.shape,"return float(!isnan(x) && !isinf(x));");return this.compileAndRun(e,[t],"bool");},e.prototype.round=function(t){var e=new ss(t.shape,"\n  // OpenGL ES does not support round function.\n  // The algorithm is based on banker's rounding.\n  float base = floor(x);\n  if ((x - base) < 0.5) {\n    return floor(x);\n  } else if ((x - base) > 0.5) {\n    return ceil(x);\n  } else {\n    if (mod(base, 2.0) == 0.0) {\n      return base;\n    } else {\n      return base + 1.0;\n    }\n  }\n");return this.compileAndRun(e,[t]);},e.prototype.exp=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.exp(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,vs,t.dtype);var e=new ss(t.shape,vs);return this.compileAndRun(e,[t]);},e.prototype.expm1=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.expm1(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,ys,t.dtype);var e=new ss(t.shape,ys);return this.compileAndRun(e,[t]);},e.prototype.softmax=function(t,e){var n=L([e],t.shape),r=this.max(t,n),i=An(r.shape,n),o=this.subtract(t,r.reshape(i)),a=this.exp(o),s=this.sum(a,n).reshape(i);return Li(a,s);},e.prototype.log=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.log(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,"\n  vec4 result = log(x);\n  vec4 isNaN = vec4(lessThan(x, vec4(0.0)));\n  result.r = isNaN.r == 1.0 ? NAN : result.r;\n  result.g = isNaN.g == 1.0 ? NAN : result.g;\n  result.b = isNaN.b == 1.0 ? NAN : result.b;\n  result.a = isNaN.a == 1.0 ? NAN : result.a;\n\n  return result;\n",t.dtype);var e=new ss(t.shape,"if (x < 0.0) return NAN;\n  return log(x);");return this.compileAndRun(e,[t]);},e.prototype.log1p=function(t){var e=new ss(t.shape,"return log(1.0 + x);");return this.compileAndRun(e,[t]);},e.prototype.sqrt=function(t){var e=new ss(t.shape,"return sqrt(x);");return this.compileAndRun(e,[t]);},e.prototype.rsqrt=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.rsqrt(t);var e=new ss(t.shape,"return inversesqrt(x);");return this.compileAndRun(e,[t]);},e.prototype.reciprocal=function(t){var e=new ss(t.shape,"return 1.0 / x;");return this.compileAndRun(e,[t]);},e.prototype.relu=function(t){var e;return e=f().getBool("WEBGL_PACK")?new Cs(t.shape,ws):new ss(t.shape,fs),this.compileAndRun(e,[t]);},e.prototype.relu6=function(t){var e;return e=f().getBool("WEBGL_PACK")?new Cs(t.shape,ks):new ss(t.shape,hs),this.compileAndRun(e,[t]);},e.prototype.prelu=function(t,e){var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new va(ga,t.shape,e.shape):new ma(pa,t.shape,e.shape);return this.compileAndRun(n,[t,e]);},e.prototype.elu=function(t){if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Es,t.dtype);var e=new ss(t.shape,ds);return this.compileAndRun(e,[t]);},e.prototype.eluDer=function(t,e){var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new va("\n  vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n  return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n",t.shape,e.shape):new ma("return (b >= 1.0) ? a : a * (b + 1.0);",t.shape,e.shape);return this.compileAndRun(n,[t,e]);},e.prototype.selu=function(t){var e=new ss(t.shape,"\n  // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n  // see: https://arxiv.org/abs/1706.02515\n  float scaleAlpha = 1.7580993408473768;\n  float scale = 1.0507009873554805;\n  return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n");return this.compileAndRun(e,[t]);},e.prototype.int=function(t){var e=new ss(t.shape,"return float(int(x));");return this.compileAndRun(e,[t],"int32");},e.prototype.clip=function(t,e,n){var r,i=(r=f().getBool("WEBGL_PACK_CLIP")?new ba(t.shape):new ya(t.shape)).getCustomSetupFunc(e,n);return this.compileAndRun(r,[t],null,i);},e.prototype.abs=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.abs(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,ls,t.dtype);var e=new ss(t.shape,ls);return this.compileAndRun(e,[t]);},e.prototype.complexAbs=function(t){var e=this.texData.get(t.dataId),n=new function(t){this.variableNames=["real","imag"],this.outputShape=t,this.userCode="\n      void main() {\n        float re = abs(getRealAtOutCoords());\n        float im = abs(getImagAtOutCoords());\n        float mx = max(re, im);\n\n        // sadly the length function in glsl is not underflow-safe\n        // (at least not on Intel GPUs). So the safe solution is\n        // to ensure underflow-safety in all cases.\n        setOutput(\n          mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))\n        );\n      }\n    ";}(t.shape),r=[this.makeComplexComponentTensorInfo(t,e.complexTensors.real),this.makeComplexComponentTensorInfo(t,e.complexTensors.imag)];return this.compileAndRun(n,r);},e.prototype.sigmoid=function(t){var e=new ss(t.shape,"return 1.0 / (1.0 + exp(-1.0 * x));");return this.compileAndRun(e,[t]);},e.prototype.softplus=function(t){var e=new ss(t.shape,"\n  float epsilon = 1.1920928955078125e-7;\n  float threshold = log(epsilon) + 2.0;\n\n  bool too_large = x > -threshold;\n  bool too_small = x < threshold;\n\n  float result;\n  float exp_x = exp(x);\n\n  if (too_large){\n    result = x;\n  }\n  else if (too_small){\n    result = exp_x;\n  }\n  else{\n    result = log(exp_x + 1.0);\n  }\n  return result;\n");return this.compileAndRun(e,[t]);},e.prototype.sin=function(t){var e=new ss(t.shape,"if (isnan(x)) return x;\n  return sin(x);\n");return this.compileAndRun(e,[t]);},e.prototype.cos=function(t){var e=new ss(t.shape,"if (isnan(x)) return x;\n  return cos(x);\n");return this.compileAndRun(e,[t]);},e.prototype.tan=function(t){var e=new ss(t.shape,"return tan(x);");return this.compileAndRun(e,[t]);},e.prototype.asin=function(t){var e=new ss(t.shape,"if (isnan(x)) return x;\n  if (abs(x) > 1.) {\n    return NAN;\n  }\n  return asin(x);\n");return this.compileAndRun(e,[t]);},e.prototype.acos=function(t){var e=new ss(t.shape,"if (isnan(x)) return x;\n  if (abs(x) > 1.) {\n    return NAN;\n  }\n  return acos(x);\n");return this.compileAndRun(e,[t]);},e.prototype.atan=function(t){var e=new ss(t.shape,"if (isnan(x)) return x;\n  return atan(x);\n");return this.compileAndRun(e,[t]);},e.prototype.atan2=function(t,e){var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new va("\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 ma("\n  if (isnan(a)) return a;\n  if (isnan(b)) return b;\n\n  return atan(a, b);\n",t.shape,e.shape);return this.compileAndRun(n,[t,e]);},e.prototype.sinh=function(t){var e=new ss(t.shape,"\n  float e2x = exp(x);\n  return (e2x - 1.0 / e2x) / 2.0;\n");return this.compileAndRun(e,[t]);},e.prototype.cosh=function(t){var e=new ss(t.shape,"\n  float e2x = exp(-x);\n  return (e2x + 1.0 / e2x) / 2.0;\n");return this.compileAndRun(e,[t]);},e.prototype.tanh=function(t){var e=new ss(t.shape,"\n  float e2x = exp(-2.0 * abs(x));\n  return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n");return this.compileAndRun(e,[t]);},e.prototype.asinh=function(t){var e=new ss(t.shape,"if (isnan(x)) return x;return log(x + sqrt(x * x + 1.0));");return this.compileAndRun(e,[t]);},e.prototype.acosh=function(t){var e=new ss(t.shape,"if (isnan(x)) return x;\n  if (x < 1.0) return NAN;\n  return log(x + sqrt(x * x - 1.0));");return this.compileAndRun(e,[t]);},e.prototype.atanh=function(t){var e=new ss(t.shape,"if (isnan(x)) return x;\n  if ((x < -1.0) || (x > 1.0)) return NAN;\n  return (log(1.0 + x) - log(1.0 - x)) / 2.0;");return this.compileAndRun(e,[t]);},e.prototype.erf=function(t){var e=new ss(t.shape,'\n  // Error function is calculated approximately with elementary function.\n  // See "Handbook of Mathematical Functions with Formulas,\n  // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n  float p = 0.3275911;\n  float a1 = 0.254829592;\n  float a2 = -0.284496736;\n  float a3 = 1.421413741;\n  float a4 = -1.453152027;\n  float a5 = 1.061405429;\n\n  float sign = sign(x);\n  x = abs(x);\n  float t = 1.0 / (1.0 + p * x);\n  return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));\n');return this.compileAndRun(e,[t]);},e.prototype.step=function(t,e){var n=new ss(t.shape,function(t){return void 0===t&&(t=0),us+"\n    return x > 0.0 ? 1.0 : float("+t+");\n  ";}(e));return this.compileAndRun(n,[t]);},e.prototype.conv2dByMatMul=function(t,e,n,r,i,o){var a=t.shape,s=this.texData.get(t.dataId),u=n.inChannels,c=a[0]*a[1]*a[2],l=n.outChannels,h="channelsLast"===n.dataFormat,d=(1===c||1===l)&&u>1e3,p=a[2]%2!=0&&!!s.isPacked;if(d||!f().getBool("WEBGL_LAZILY_UNPACK")||!f().getBool("WEBGL_PACK_BINARY_OPERATIONS")||!p){var m=h?a[0]*a[1]*a[2]:a[0]*a[2]*a[3],g=this.reshape(t,[1,m,n.inChannels]),v=this.reshape(e,[1,n.inChannels,n.outChannels]);return this.reshape(this.fusedBatchMatMul({a:g,b:v,transposeA:!1,transposeB:!1,bias:r,activation:i,preluActivationWeights:o}),n.outShape);}var y=h?a[0]*a[1]*(a[2]+1):a[0]*a[2]*(a[3]+1),b={dataId:t.dataId,shape:[1,y,n.inChannels],dtype:t.dtype},x=s.shape;s.shape=s.shape.slice(),s.shape[s.shape.length-2]++,_(Be(s.shape,b.shape),function(){return "packed reshape "+s.shape+" to "+b.shape+" isn't free";});var w=this.reshape(e,[1,n.inChannels,n.outChannels]),k=this.fusedBatchMatMul({a:b,b:w,transposeA:!1,transposeB:!1,bias:r,activation:i,preluActivationWeights:o}),E=this.texData.get(k.dataId);return _(E.isPacked,function(){return "batchMatMul result is expected to be packed";}),s.shape=x,E.shape=n.outShape,Wt.makeTensorFromDataId(k.dataId,n.outShape,k.dtype);},e.prototype.conv2dWithIm2Row=function(t,e,n,r,i,o){var a=n.filterWidth,s=n.filterHeight,u=n.inChannels,c=n.outWidth,l=n.outHeight,f="channelsLast"===n.dataFormat,h=a*s*u,d=l*c,p=[h,d],m=t.squeeze([0]),g=e.reshape([1,h,-1]),v=new function(t,e,n){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t;for(var r=n.filterWidth,i=n.inChannels,o=n.strideWidth,a=n.strideHeight,s=n.padInfo,u=n.outWidth,c=n.dilationWidth,l=n.dilationHeight,f=n.dataFormat,h=s.left,d=s.top,p=i*r,m=Yo(),g="channelsLast"===f,v=g?0:1,y=g?1:2,b="",x=0;x<=1;x++){for(var w=0;w<=1;w++){b+="\n          blockIndex = rc.y + "+w+";\n          pos = rc.x + "+x+";\n\n          if(blockIndex < "+t[1]+" && pos < "+t[0]+") {\n            offsetY = int(blockIndex / ("+u+")) * "+a+" - "+d+";\n            d0 = offsetY + "+l+" * (pos / "+p+");\n\n            if(d0 < "+e[v]+" && d0 >= 0) {\n\n              offsetX = int(mod(float(blockIndex), "+u+".) * "+o+". - "+h+".);\n              d1 = offsetX + "+c+" * (int(mod(float(pos), "+p+".) / "+i+".));\n\n              if(d1 < "+e[y]+" && d1 >= 0) {\n\n                ch = int(mod(float(pos), "+i+".));\n\n                if ("+g+") {\n                  innerDims = vec2(d1, ch);\n                  result["+(2*x+w)+"] = getChannel(\n                    getA(d0, int(innerDims.x),\n                    int(innerDims.y)), innerDims);\n                } else {\n                  innerDims = vec2(d0, d1);\n                  result["+(2*x+w)+"] = getChannel(\n                    getA(ch, int(innerDims.x),\n                    int(innerDims.y)), innerDims);\n                }\n              }\n            }\n          }\n        ";}}this.userCode="\n      void main() {\n        ivec2 rc = getOutputCoords();\n\n        vec4 result = vec4(0);\n\n        int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n        vec2 innerDims;\n\n        "+b+"\n\n        "+m.output+" = result;\n      }\n    ";}(p,m.shape,n),y=this.compileAndRun(v,[m]).reshape([1,p[0],p[1]]),b=null!=r,x=null!=o,w=i?Os(i,!0):null,k=new Ka(y.shape,[1,d,n.outChannels],!0,!1,b,w,x),E=[y,g];r&&E.push(r),x&&E.push(o);var C=this.compileAndRun(k,E);return f?C.reshape([1,l,c,n.outChannels]):C.reshape([1,n.outChannels,l,c]);},e.prototype.fusedConv2d=function(t){var e=t.input,n=t.filter,r=t.convInfo,i=t.bias,o=t.activation,a=t.preluActivationWeights;if(1===r.filterHeight&&1===r.filterWidth&&1===r.dilationHeight&&1===r.dilationWidth&&1===r.strideHeight&&1===r.strideWidth&&("SAME"===r.padInfo.type||"VALID"===r.padInfo.type))return this.conv2dByMatMul(e,n,r,i,o,a);if(f().getBool("WEBGL_CONV_IM2COL")&&1===e.shape[0])return this.conv2dWithIm2Row(e,n,r,i,o,a);var s=null!=i,u=null!=a,c=o?Os(o,!1):null,l=new wa(r,s,c,u),h=[e,n];return i&&h.push(i),a&&h.push(a),this.compileAndRun(l,h);},e.prototype.conv2d=function(t,e,n){if(1===n.filterHeight&&1===n.filterWidth&&1===n.dilationHeight&&1===n.dilationWidth&&1===n.strideHeight&&1===n.strideWidth&&("SAME"===n.padInfo.type||"VALID"===n.padInfo.type))return this.conv2dByMatMul(t,e,n);if(f().getBool("WEBGL_CONV_IM2COL")&&1===t.shape[0])return this.conv2dWithIm2Row(t,e,n);var r=new wa(n);return this.compileAndRun(r,[t,e]);},e.prototype.conv2dDerInput=function(t,e,n){var r=new function(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;var e=t.filterHeight,n=t.filterWidth,r=t.strideHeight,i=t.strideWidth,o="channelsLast"===t.dataFormat,a=e-1-t.padInfo.top,s=n-1-t.padInfo.left,u=o?1:2,c=o?2:3,l=o?3:1;this.userCode="\n      const ivec2 pads = ivec2("+a+", "+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) / "+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 = "+n+" - 1 - wC;\n\n            for (int d2 = 0; d2 < "+t.outChannels+"; d2++) {\n\n              if ("+o+") {\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    ";}(n);return this.compileAndRun(r,[t,e]);},e.prototype.conv2dDerFilter=function(t,e,n){var r=new function(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;var e=t.strideHeight,n=t.strideWidth,r=t.padInfo.top,i=t.padInfo.left,o="channelsLast"===t.dataFormat;this.userCode="\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int wR = coords.x;\n        int wC = coords.y;\n        int d1 = coords.z;\n        int d2 = coords.w;\n\n        // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int b = 0; b < "+t.batchSize+"; b++) {\n          for (int yR = 0; yR < "+t.outHeight+"; yR++) {\n            int xR = wR + yR * "+e+" - "+r+";\n\n            if (xR < 0 || xR >= "+t.inHeight+") {\n              continue;\n            }\n\n            for (int yC = 0; yC < "+t.outWidth+"; yC++) {\n              int xC = wC + yC * "+n+" - "+i+";\n\n              if (xC < 0 || xC >= "+t.inWidth+") {\n                continue;\n              }\n\n              if ("+o+") {\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    ";}(n);return this.compileAndRun(r,[t,e]);},e.prototype.fusedDepthwiseConv2D=function(t){var e,n=t.input,r=t.filter,i=t.convInfo,o=t.bias,a=t.activation,s=t.preluActivationWeights,u=f().getBool("WEBGL_PACK_DEPTHWISECONV")&&i.strideWidth<=2&&i.outChannels/i.inChannels==1,c=a?Os(a,u):null,l=[n,r],h=null!=o,d=null!=s;return h&&l.push(o),d&&l.push(s),u?(e=new Ea(i,h,c,d),this.compileAndRun(e,l)):(e=new ka(i,h,c,d),this.compileAndRun(e,l));},e.prototype.depthwiseConv2D=function(t,e,n){var r;return f().getBool("WEBGL_PACK_DEPTHWISECONV")&&n.strideWidth<=2&&n.outChannels/n.inChannels==1?(r=new Ea(n),this.compileAndRun(r,[t,e])):(r=new ka(n),this.compileAndRun(r,[t,e]));},e.prototype.depthwiseConv2DDerInput=function(t,e,n){var r=new function(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;var e=t.filterHeight,n=t.filterWidth,r=t.strideHeight,i=t.strideWidth,o=e-1-t.padInfo.top,a=n-1-t.padInfo.left,s=t.outChannels/t.inChannels;this.userCode="\n      const ivec2 pads = ivec2("+o+", "+a+");\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) / "+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 = "+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    ";}(n);return this.compileAndRun(r,[t,e]);},e.prototype.depthwiseConv2DDerFilter=function(t,e,n){var r=new function(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;var e=t.strideHeight,n=t.strideWidth,r=t.padInfo.top,i=t.padInfo.left,o=t.outChannels/t.inChannels;this.userCode="\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int wR = coords.x;\n        int wC = coords.y;\n        int d1 = coords.z;\n        int dm = coords.w;\n        int d2 = d1 * "+o+" + 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+" - "+i+";\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    ";}(n);return this.compileAndRun(r,[t,e]);},e.prototype.conv3d=function(t,e,n){var r=new function(t){this.variableNames=["x","W"],this.outputShape=t.outShape;var e=t.padInfo.front,n=t.padInfo.top,r=t.padInfo.left,i=t.strideDepth,o=t.strideHeight,a=t.strideWidth,s=t.dilationDepth,u=t.dilationHeight,c=t.dilationWidth,l=t.filterDepth,f=t.filterHeight,h=t.filterWidth,d=4*Math.floor(t.inChannels/4),p=t.inChannels%4;this.userCode="\n      const ivec3 strides = ivec3("+i+", "+o+", "+a+");\n      const ivec3 pads = ivec3("+e+", "+n+", "+r+");\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int d2 = coords.u;\n\n        ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n        int xFCorner = xFRCCorner.x;\n        int xRCorner = xFRCCorner.y;\n        int xCCorner = xFRCCorner.z;\n\n        // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get\n        // y(yF, yR, yC, d2). ? = to be determined. : = across all\n        // values in that axis.\n        float dotProd = 0.0;\n        for (int wF = 0; wF < "+l+"; wF++) {\n          int xF = xFCorner + wF * "+s+";\n\n          if (xF < 0 || xF >= "+t.inDepth+") {\n            continue;\n          }\n\n          for (int wR = 0; wR < "+f+"; wR++) {\n            int xR = xRCorner + wR * "+u+";\n\n            if (xR < 0 || xR >= "+t.inHeight+") {\n              continue;\n            }\n\n            for (int wC = 0; wC < "+h+"; wC++) {\n              int xC = xCCorner + wC * "+c+";\n\n              if (xC < 0 || xC >= "+t.inWidth+") {\n                continue;\n              }\n\n              for (int d1 = 0; d1 < "+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    ";}(n);return this.compileAndRun(r,[t,e]);},e.prototype.conv3dDerInput=function(t,e,n){var r=new function(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;var e=t.filterDepth,n=t.filterHeight,r=t.filterWidth,i=t.strideDepth,o=t.strideHeight,a=t.strideWidth,s=e-1-t.padInfo.front,u=n-1-t.padInfo.top,c=r-1-t.padInfo.left;this.userCode="\n      const ivec3 pads = ivec3("+s+", "+u+", "+c+");\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int d1 = coords.u;\n\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyFCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        float dotProd = 0.0;\n        for (int wF = 0; wF < "+e+"; wF++) {\n          float dyF = float(dyFCorner + wF) / "+i+".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) / "+o+".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) / "+a+".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    ";}(n);return this.compileAndRun(r,[t,e]);},e.prototype.conv3dDerFilter=function(t,e,n){var r=new function(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;var e=t.strideDepth,n=t.strideHeight,r=t.strideWidth,i=t.padInfo.front,o=t.padInfo.top,a=t.padInfo.left;this.userCode="\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int wF = coords.x;\n        int wR = coords.y;\n        int wC = coords.z;\n        int d1 = coords.w;\n        int d2 = coords.u;\n\n        float dotProd = 0.0;\n\n        for (int b = 0; b < "+t.batchSize+"; b++) {\n          for (int yF = 0; yF < "+t.outDepth+"; yF++) {\n            int xF = wF + yF * "+e+" - "+i+";\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+" - "+o+";\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+" - "+a+";\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    ";}(n);return this.compileAndRun(r,[t,e]);},e.prototype.maxPool=function(t,e){var n=new Ya(e,"max",!1);return this.compileAndRun(n,[t]);},e.prototype.avgPool=function(t,e){var n=new Ya(e,"avg",!1);return this.compileAndRun(n,[t],"float32");},e.prototype.maxPoolBackprop=function(t,e,n,r){var i=new Ya(r,"max",!0),o=this.compileAndRun(i,[e]),a=new function(t){this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;var e=t.strideHeight,n=t.strideWidth,r=t.dilationHeight,i=t.effectiveFilterHeight,o=t.effectiveFilterWidth,a=i-1-t.padInfo.top,s=o-1-t.padInfo.left,u=i*o-1;this.userCode="\n      const ivec2 pads = ivec2("+a+", "+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 < "+i+";\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 < "+o+"; 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 * "+o+" + wC;\n            float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n            dotProd += dyValue * mask;\n          }\n        }\n        setOutput(dotProd);\n      }\n    ";}(r),s=this.compileAndRun(a,[t,o],e.dtype);return o.dispose(),s;},e.prototype.avgPoolBackprop=function(t,e,n){var r=new function(t){this.variableNames=["dy"],this.outputShape=t.inShape;var e=t.filterHeight,n=t.filterWidth,r=t.strideHeight,i=t.strideWidth,o=t.dilationHeight,a=t.dilationWidth,s=t.effectiveFilterHeight,u=t.effectiveFilterWidth,c=s-1-t.padInfo.top,l=u-1-t.padInfo.left,f=1/(e*n);this.userCode="\n      const ivec2 pads = ivec2("+c+", "+l+");\n      const float avgMultiplier = float("+f+");\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n\n        ivec2 dyRCCorner = coords.yz - pads;\n        int dyRCorner = dyRCCorner.x;\n        int dyCCorner = dyRCCorner.y;\n\n        // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < "+s+";\n            wR += "+o+") {\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+= "+a+") {\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(b, idyR, idyC, d);\n\n            dotProd += dyValue * avgMultiplier;\n          }\n        }\n        setOutput(dotProd);\n      }\n    ";}(n);return this.compileAndRun(r,[t],e.dtype);},e.prototype.cast=function(t,e){return So(t,e,this);},e.prototype.unstack=function(t,e){for(var n=t.shape[e],r=new Array(t.rank-1),i=0,o=0;o<t.rank;o++){o!==e&&(r[i++]=t.shape[o]);}var a=new Array(t.rank).fill(0),s=t.shape.slice();s[e]=1;var u=new Array(n);for(o=0;o<u.length;o++){a[e]=o,u[o]=this.slice(t,a,s).reshape(r);}return u;},e.prototype.avgPool3d=function(t,e){var n=new Ja(e,"avg",!1);return this.compileAndRun(n,[t],"float32");},e.prototype.avgPool3dBackprop=function(t,e,n){var r=new function(t){this.variableNames=["dy"],this.outputShape=t.inShape;var e=t.filterDepth,n=t.filterHeight,r=t.filterWidth,i=t.strideDepth,o=t.strideHeight,a=t.strideWidth,s=t.dilationDepth,u=t.dilationHeight,c=t.dilationWidth,l=t.effectiveFilterDepth,f=t.effectiveFilterHeight,h=t.effectiveFilterWidth,d=l-1-t.padInfo.front,p=f-1-t.padInfo.top,m=h-1-t.padInfo.left,g=1/(e*n*r);this.userCode="\n      const ivec3 pads = ivec3("+d+", "+p+", "+m+");\n      const float avgMultiplier = float("+g+");\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int ch = coords.u;\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyDCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get\n        // dx(xD, xR, xC, ch).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int wD = 0; wD < "+l+";\n            wD += "+s+") {\n          float dyD = float(dyDCorner + wD) / "+i+".0;\n\n          if (dyD < 0.0 || dyD >= "+t.outDepth+".0 || fract(dyD) > 0.0) {\n            continue;\n          }\n          int idyD = int(dyD);\n\n          for (int wR = 0; wR < "+f+";\n              wR += "+u+") {\n            float dyR = float(dyRCorner + wR) / "+o+".0;\n\n            if (dyR < 0.0 || dyR >= "+t.outHeight+".0 ||\n                fract(dyR) > 0.0) {\n              continue;\n            }\n            int idyR = int(dyR);\n\n            for (int wC = 0; wC < "+h+";\n                wC += "+c+") {\n              float dyC = float(dyCCorner + wC) / "+a+".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    ";}(n);return this.compileAndRun(r,[t],e.dtype);},e.prototype.maxPool3d=function(t,e){var n=new Ja(e,"max",!1);return this.compileAndRun(n,[t],"float32");},e.prototype.maxPool3dBackprop=function(t,e,n,r){var i=new Ja(r,"max",!0),o=this.compileAndRun(i,[e]),a=new function(t){this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;var e=t.strideDepth,n=t.strideHeight,r=t.strideWidth,i=t.dilationDepth,o=t.dilationHeight,a=t.dilationWidth,s=t.effectiveFilterDepth,u=t.effectiveFilterHeight,c=t.effectiveFilterWidth,l=s-1-t.padInfo.front,f=u-1-t.padInfo.top,h=c-1-t.padInfo.left,d=s*u*c-1;this.userCode="\n      const ivec3 pads = ivec3("+l+", "+f+", "+h+");\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int ch = coords.u;\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyDCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get\n        // dx(xD, xR, xC, ch).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int wD = 0; wD < "+s+";\n           wD += "+i+") {\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 += "+o+") {\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 += "+a+") {\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    ";}(r),s=this.compileAndRun(a,[t,o],e.dtype);return o.dispose(),s;},e.prototype.reshape=function(t,e){var n=this.texData.get(t.dataId);if(n.isPacked&&!Be(t.shape,e)&&(null===n.texture||!Be(n.shape,e))){var r=this.packedReshape(t,e);return Wt.makeTensorFromDataId(r.dataId,r.shape,r.dtype);}return Do(t,e);},e.prototype.resizeBilinear=function(t,e,n,r){var i=f().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new function(t,e,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];var i=t[0],o=t[1],a=t[2],s=t[3];this.outputShape=[i,e,n,s];var u=[r&&e>1?o-1:o,r&&n>1?a-1:a],c=[r&&e>1?e-1:e,r&&n>1?n-1:n];this.userCode="\n      const vec3 effectiveInputOverOutputRatioRC = vec3(\n          "+u[0]/c[0]+",\n          "+u[1]/c[1]+",\n          "+u[1]/c[1]+");\n      const vec3 inputShapeRC = vec3("+o+".0, "+a+".0,\n                                     "+a+".0);\n\n      float getAValue(int b, int r, int c, int d) {\n        return getChannel(getA(b, r, c, d), vec2(c, d));\n      }\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        // Calculate values for next column in yRC.z.\n        ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n        // Fractional source index.\n        vec3 sourceFracIndexRC = vec3(yRC) * effectiveInputOverOutputRatioRC;\n\n        // Compute the four integer indices.\n        ivec3 sourceFloorRC = ivec3(sourceFracIndexRC);\n        ivec3 sourceCeilRC = ivec3(\n          min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n        // Should we calculate next column and row elements in 2x2 packed cell.\n        bool hasNextCol = d < "+(s-1)+";\n        bool hasNextRow = coords.z < "+(n-1)+";\n\n        // In parallel, construct four corners for all four components in\n        // packed 2x2 cell.\n        vec4 topLeft = vec4(\n          getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),\n          hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n        vec4 bottomLeft = vec4(\n          getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),\n          hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n        vec4 topRight = vec4(\n          getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),\n          hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n        vec4 bottomRight = vec4(\n          getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),\n          hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n        vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);\n\n        vec4 top = mix(topLeft, topRight, fracRC.yyzz);\n        vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);\n        vec4 newValue = mix(top, bottom, fracRC.x);\n\n        setOutput(newValue);\n      }\n    ";}(t.shape,e,n,r):new function(t,e,n,r){this.variableNames=["A"],this.outputShape=[];var i=t[0],o=t[1],a=t[2],s=t[3];this.outputShape=[i,e,n,s];var u=[r&&e>1?o-1:o,r&&n>1?a-1:a],c=[r&&e>1?e-1:e,r&&n>1?n-1:n];this.userCode="\n      const vec2 effectiveInputOverOutputRatioRC = vec2(\n          "+u[0]/c[0]+",\n          "+u[1]/c[1]+");\n      const vec2 inputShapeRC = vec2("+o+".0, "+a+".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    ";}(t.shape,e,n,r);return this.compileAndRun(i,[t],"float32");},e.prototype.resizeBilinearBackprop=function(t,e,n){var r=new function(t,e,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=e.shape;var r=e.shape,i=r[1],o=r[2],a=t.shape,s=a[1],u=a[2],c=[n&&s>1?i-1:i,n&&u>1?o-1:o],l=[n&&s>1?s-1:s,n&&u>1?u-1:u],f=c[0]/l[0],h=c[1]/l[1],d=1/f,p=1/h,m=2*Math.ceil(d)+2,g=2*Math.ceil(p)+2;this.userCode="\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        int r = coords[1];\n        int c = coords[2];\n\n        float accumulator = 0.0;\n\n        const float heightScale = float("+f+");\n        const float widthScale = float("+h+");\n\n        const float invHeightScale = float("+d+");\n        const float invWidthScale = float("+p+");\n\n        const int winHeight = int("+m+");\n        const int winWidth = int("+g+");\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), "+(i-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), "+(o-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    ";}(t,e,n);return this.compileAndRun(r,[t]);},e.prototype.resizeNearestNeighbor=function(t,e,n,r){var i=new function(t,e,n,r){this.variableNames=["A"],this.outputShape=[];var i=t[0],o=t[1],a=t[2],s=t[3];this.outputShape=[i,e,n,s];var u=[r&&e>1?o-1:o,r&&n>1?a-1:a],c=[r&&e>1?e-1:e,r&&n>1?n-1:n],l=r?"0.5":"0.0";this.userCode="\n      const vec2 effectiveInputOverOutputRatioRC = vec2(\n          "+u[0]/c[0]+",\n          "+u[1]/c[1]+");\n      const vec2 inputShapeRC = vec2("+o+".0, "+a+".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    ";}(t.shape,e,n,r);return this.compileAndRun(i,[t]);},e.prototype.resizeNearestNeighborBackprop=function(t,e,n){var r=new function(t,e,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=e.shape;var r=e.shape,i=r[1],o=r[2],a=t.shape,s=a[1],u=a[2],c=[n&&s>1?i-1:i,n&&u>1?o-1:o],l=[n&&s>1?s-1:s,n&&u>1?u-1:u],f=c[0]/l[0],h=c[1]/l[1],d=1/f,p=1/h,m=2*Math.ceil(d)+2,g=2*Math.ceil(p)+2;this.userCode="\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        int r = coords[1];\n        int c = coords[2];\n\n        float accumulator = 0.0;\n\n        const float heightScale = float("+f+");\n        const float widthScale = float("+h+");\n\n        const float invHeightScale = float("+d+");\n        const float invWidthScale = float("+p+");\n\n        const int winHeight = int("+m+");\n        const int winWidth = int("+g+");\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("+i+") - 1),\n                "+n+" ? float(round(sourceFracRow)) :\n                                  float(floor(sourceFracRow))));\n\n            int sourceNearestCol = int(min(\n                float(int("+o+") - 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    ";}(t,e,n);return this.compileAndRun(r,[t]);},e.prototype.multinomial=function(t,e,n,r){var i=e?t:co(t),o=i.shape[0],a=i.shape[1],s=new Xa(o,a,n),u=s.getCustomSetupFunc(r);return this.compileAndRun(s,[i],"int32",u);},e.prototype.oneHot=function(t,e,n,r){var i=new function(t,e,n,r){this.variableNames=["indices"],this.outputShape=[t,e],this.userCode="\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int index = round(getIndices(coords.x));\n        setOutput(mix(float("+r+"), float("+n+"),\n                      float(index == coords.y)));\n      }\n    ";}(t.size,e,n,r);return this.compileAndRun(i,[t]);},e.prototype.diag=function(t){var e=new function(t){this.variableNames=["X"],this.outputShape=[t,t],this.userCode="\n      void main() {\n          ivec2 coords = getOutputCoords();\n          float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;\n          setOutput(val);\n      }\n    ";}(t.size);return this.compileAndRun(e,[t]);},e.prototype.nonMaxSuppression=function(t,e,n,r,i){return vn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"),Po(t.dataSync(),e.dataSync(),n,r,i);},e.prototype.cropAndResize=function(t,e,n,r,i,o){var a=new function(t,e,n,r,i){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];var o=t[0],a=t[1],s=t[2],u=t[3],c=e[0],l=n[0],f=n[1];this.outputShape=[c,l,f,u];var h="bilinear"===r?1:0,d=[a-1+".0",s-1+".0"],p=d[0],m=d[1],g=l>1?[""+(a-1)/(l-1),"(y2-y1) * height_ratio","y1*"+p+" + float(y)*(height_scale)"]:["0.0","0.0","0.5 * (y1+y2) * "+p],v=g[0],y=g[1],b=g[2],x=f>1?[""+(s-1)/(f-1),"(x2-x1) * width_ratio","x1*"+m+" + float(x)*(width_scale)"]:["0.0","0.0","0.5 * (x1+x2) * "+m],w=x[0],k=x[1],E=x[2];this.userCode="\n      const float height_ratio = float("+v+");\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 >= "+o+") {\n          return;\n        }\n\n        float height_scale = "+y+";\n        float width_scale = "+k+";\n\n        float in_y = "+b+";\n        if( in_y < 0.0 || in_y > "+p+" ) {\n          setOutput(float("+i+"));\n          return;\n        }\n        float in_x = "+E+";\n        if( in_x < 0.0 || in_x > "+m+" ) {\n          setOutput(float("+i+"));\n          return;\n        }\n\n        vec2 sourceFracIndexCR = vec2(in_x,in_y);\n        if("+h+" == 1) {\n          // Compute the four integer indices.\n          ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);\n          ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));\n\n          float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);\n          float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);\n          float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);\n          float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);\n\n          vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n\n          float top = topLeft + (topRight - topLeft) * fracCR.x;\n          float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n          float newValue = top + (bottom - top) * fracCR.y;\n          setOutput(newValue);\n        } else {\n          // Compute the coordinators of nearest neighbor point.\n          ivec2 sourceNearestCR = ivec2(floor(\n            sourceFracIndexCR + vec2(0.5,0.5)));\n          float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);\n          setOutput(newValue);\n        }\n      }\n    ";}(t.shape,e.shape,r,i,o);return this.compileAndRun(a,[t,e,n],"float32");},e.prototype.depthToSpace=function(t,e,n){_(e>1,function(){return "blockSize should be > 1 for depthToSpace, but was: "+e;});var r=t.shape[0],i="NHWC"===n?t.shape[1]:t.shape[2],o="NHWC"===n?t.shape[2]:t.shape[3],a="NHWC"===n?t.shape[3]:t.shape[1],s=i*e,u=o*e,c=a/(e*e),l=new Aa("NHWC"===n?[r,s,u,c]:[r,c,s,u],e,n);return this.compileAndRun(l,[t]);},e.prototype.split=function(t,e,n){return qo(t,e,n);},e.prototype.scatterND=function(t,e,n){var r=Hi(0,t,n),i=r.sliceRank,o=r.numUpdates,a=r.sliceSize,s=r.strides,u=r.outputSize,c=[u/a,a],l=t.reshape([o,i]),f=e.reshape([o,a]);if(0===u)return Do(jn([]),n);var h=Pn(0),d=new Qa(o,i,l.rank,f.rank,s,c);return this.compileAndRun(d,[f,l,h]).reshape(n);},e.prototype.sparseToDense=function(t,e,n,r){var i=Hi(0,t,n),o=i.sliceRank,a=i.numUpdates,s=i.strides,u=i.outputSize,c=new Qa(a,o,t.rank,e.rank,s,[u,1],!1);return this.compileAndRun(c,[e,t,r]).reshape(n);},e.prototype.fft=function(t){return this.fftImpl(t,!1);},e.prototype.ifft=function(t){return this.fftImpl(t,!0);},e.prototype.fftImpl=function(t,e){var n=this.texData.get(t.dataId),r=new Oa("return real * expR - imag * expI;",t.shape,e),i=new Oa("return real * expI + imag * expR;",t.shape,e),o=[this.makeComplexComponentTensorInfo(t,n.complexTensors.real),this.makeComplexComponentTensorInfo(t,n.complexTensors.imag)],a=this.compileAndRun(r,o),s=this.compileAndRun(i,o),u=this.complex(a,s).as2D(t.shape[0],t.shape[1]);return a.dispose(),s.dispose(),u;},e.prototype.gatherND=function(t,e){var n=e.shape,r=n[n.length-1],i=zi(t,e),o=i[0],a=i[1],s=i[2],u=i[3],c=e.reshape([a,r]),l=t.reshape([t.size/s,s]),f=new function(t,e,n){this.sliceDim=t,this.strides=e,this.variableNames=["x","indices"],this.outputShape=n;var r=sa(e.length),i=sa(n.length),o=this.sliceDim>1?"strides[j]":"strides";this.userCode="\n        "+r+" strides = "+r+"("+this.strides+");\n         void main() {\n          "+i+" coords = getOutputCoords();\n          int flattenIndex = 0;\n          for (int j = 0; j < "+this.sliceDim+"; j++) {\n            int index = round(getIndices(coords[0], j));\n            flattenIndex += index * "+o+";\n          }\n          setOutput(getX(flattenIndex, coords[1]));\n        }\n      ";}(r,u,[a,s]);return this.compileAndRun(f,[l,c]).reshape(o);},e.prototype.fill=function(t,e,n){if("string"===(n=n||Q(e))){var r=W(n,T(t));return r.fill(e),Wt.makeTensor(r,t,n,this);}var i=new _a(t,e),o=i.getCustomSetupFunc(e);return this.compileAndRun(i,[],n,o);},e.prototype.onesLike=function(t){if("string"===t.dtype)throw new Error("onesLike is not supported under string dtype");return this.fill(t.shape,1,t.dtype);},e.prototype.zerosLike=function(t){return this.fill(t.shape,"string"===t.dtype?"":0,t.dtype);},e.prototype.linspace=function(t,e,n){return Fo(t,e,n);},e.prototype.makeTensorInfo=function(t,e){var n=this.write(null,t,e);return this.texData.get(n).usage=null,{dataId:n,shape:t,dtype:e};},e.prototype.makeOutput=function(t,e){var n=this.makeTensorInfo(t,e).dataId;return Wt.makeTensorFromDataId(n,t,e,this);},e.prototype.unpackTensor=function(t){var e=new function(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=t;var e=t.length,n=Xo("rc",e),r=sa(e),i=function(t,e){if(1===t)return "rc";for(var n="",r=0;r<t;r++){n+=e[r],r<t-1&&(n+=",");}return n;}(e,n),o=n.slice(-2),a=e<=1?"rc":"vec2("+o.join(",")+")";this.userCode="\n      void main() {\n        "+r+" rc = getOutputCoords();\n        vec4 packedInput = getA("+i+");\n\n        setOutput(getChannel(packedInput, "+a+"));\n      }\n    ";}(t.shape);return this.runWebGLProgram(e,[t],t.dtype);},e.prototype.packTensor=function(t){var e=new function(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=t;var e=t.length;if(0===e)this.userCode="\n        void main() {\n          setOutput(vec4(getA(), 0., 0., 0.));\n        }\n      ";else {var n=Xo("rc",e),r=sa(e),i=function(t,e,n){if(1===t)return "rc > "+e[0];for(var r="",i=t-2;i<t;i++){r+=n[i]+" >= "+e[i],i<t-1&&(r+="||");}return r;}(e,t,n),o=function(t,e,n,r){if(1===t)return "";var i=r.slice(-2);return "\n    int r = "+i[0]+";\n    int c = "+i[1]+";\n    int rp1 = r + 1;\n    int cp1 = c + 1;\n\n    bool cEdge = cp1 >= "+e+";\n    bool rEdge = rp1 >= "+n+";\n  ";}(e,t[t.length-1],t[t.length-2],n),a=function(t,e){var n=t.length,r=function(t,e){for(var n=[],r=0;r<=1;r++){for(var i=0;i<=1;i++){for(var o=(0===r?"r":"rp1")+", "+(0===i?"c":"cp1"),a=2;a<t;a++){o=e[e.length-1-a]+","+o;}n.push(o);}}return n;}(n,e);return 1===n?"getA(rc),\n            rc + 1 >= "+t[0]+" ? 0. : getA(rc + 1),\n            0, 0":"getA("+r[0]+"),\n          cEdge ? 0. : getA("+r[1]+"),\n          rEdge ? 0. : getA("+r[2]+"),\n          rEdge || cEdge ? 0. : getA("+r[3]+")";}(t,n);this.userCode="\n        void main() {\n          "+r+" rc = getOutputCoords();\n\n          if("+i+") {\n            setOutput(vec4(0));\n          } else {\n            "+o+"\n\n            setOutput(vec4("+a+"));\n          }\n        }\n      ";}}(t.shape);return this.runWebGLProgram(e,[t],t.dtype,null,!0);},e.prototype.packedReshape=function(t,e){var n=[Ne(t.shape)].concat(Ie(t.shape)),r={dtype:t.dtype,shape:n,dataId:t.dataId},i=new function(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t;for(var n="",r=0;r<4;r++){var i="thisRC = rc;";r%2==1&&(i+="thisRC.z += 1;"),r>1&&(i+="thisRC.y += 1;"),n+="\n        "+i+"\n        "+(r>0?"if(thisRC.y < rows && thisRC.z < cols){":"")+"\n          int flatIndex = getFlatIndex(thisRC);\n\n          ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);\n          vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n          result["+r+"] =\n            getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n        "+(r>0?"}":"")+"\n      ";}this.userCode="\n      \n    ivec3 inputCoordsFromReshapedOutCoords(int index) {\n      "+Jo(["r","c","d"],e)+"\n      return ivec3(r, c, d);\n    }\n  \n      "+Qo(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    ";}([Ne(e)].concat(Ie(e)),n),o=this.runWebGLProgram(i,[r],t.dtype,null,!0);return {dataId:o.dataId,shape:e,dtype:o.dtype};},e.prototype.decode=function(t){var e,n=this.texData.get(t),r=n.isPacked,i=n.shape,o=n.dtype,a=Re(i);return e=r?new function(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=$t.DENSE;var e=Zt(t),n=Yo();this.outputShape=t,this.userCode="\n      ivec3 outCoordsFromFlatIndex(int index) {\n        "+Jo(["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    ";}(a):new function(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=$t.DENSE;var e=Zt(t),n=Yo();this.outputShape=t,this.userCode="\n      ivec3 outCoordsFromFlatIndex(int index) {\n        "+Jo(["r","c","d"],t)+"\n        return ivec3(r, c, d);\n      }\n\n      void main() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n          vec2("+e[0]+", "+e[1]+"));\n        int index = 4 * (resTexRC.x * "+e[1]+" + resTexRC.y);\n\n        vec4 result = vec4(0.);\n\n        for (int i=0; i<4; i++) {\n          int flatIndex = index + i;\n          ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n          result[i] = getA(rc.x, rc.y, rc.z);\n        }\n\n        "+n.output+" = result;\n      }\n    ";}(a),{dtype:o,shape:i,dataId:this.runWebGLProgram(e,[{shape:a,dtype:o,dataId:t}],o,null,!0).dataId};},e.prototype.runWebGLProgram=function(t,e,n,r,i){var o=this;void 0===i&&(i=!1);var a=this.makeTensorInfo(t.outputShape,n),s=this.texData.get(a.dataId);if(t.packedOutput&&(s.isPacked=!0),t.outPackingScheme===$t.DENSE){var u=Zt(t.outputShape);s.texShape=u.map(function(t){return 2*t;});}if(null!=t.outTexUsage&&(s.usage=t.outTexUsage),0===T(a.shape))return s.values=U(a.dtype,0),a;var c=[],l=e.map(function(e){if("complex64"===e.dtype)throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");var n=o.texData.get(e.dataId);if(null==n.texture){if(!t.packedInputs&&T(e.shape)<=f().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return {shape:e.shape,texData:null,isUniform:!0,uniformValues:n.values};t.packedInputs&&(n.isPacked=!0,n.shape=e.shape);}else if(!!n.isPacked!=!!t.packedInputs)e=n.isPacked?o.unpackTensor(e):o.packTensor(e),c.push(e),n=o.texData.get(e.dataId);else if(n.isPacked&&!Be(n.shape,e.shape)){var r=e,i=e.shape;e.shape=n.shape,e=o.packedReshape(e,i),c.push(e),n=o.texData.get(e.dataId),r.shape=i;}return o.uploadToGPU(e.dataId),{shape:e.shape,texData:n,isUniform:!1};});this.uploadToGPU(a.dataId);var h,d={shape:a.shape,texData:s,isUniform:!1},p=function(t,e,n){var r="";l.concat(n).forEach(function(t){var e=null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0,n=t.isUniform?"uniform":t.texData.texShape;r+=t.shape+"_"+n+"_"+e;});var i=t.userCode;return t.constructor.name+"_"+r+"_"+i;}(t,0,d),m=this.getAndSaveBinary(p,function(){return function(t,e,n,r){var i=e.userCode,o=n.map(function(t,n){var r={logicalShape:t.shape,texShape:t.isUniform?null:t.texData.texShape,isUniform:t.isUniform,isPacked:!t.isUniform&&t.texData.isPacked,flatOffset:null};return null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0&&(r.flatOffset=t.texData.slice.flatOffset),{name:e.variableNames[n],shapeInfo:r};}),a=o.map(function(t){return t.shapeInfo;}),s={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},u=ta(o,s,i,e.packedInputs),c=t.createProgram(u),l=null,h=t.getUniformLocation(c,"NAN",!1);1===f().getNumber("WEBGL_VERSION")&&(l=t.getUniformLocation(c,"INFINITY",!1));for(var d={},p=0;p<e.variableNames.length;p++){var m=e.variableNames[p];d[m]=t.getUniformLocation(c,m,!1),d["offset"+m]=t.getUniformLocation(c,"offset"+m,!1);}return {program:e,source:u,webGLProgram:c,uniformLocations:d,inShapeInfos:a,outShapeInfo:s,infLoc:l,nanLoc:h};}(o.gpgpu,t,l,d);}),g=null!=this.activeTimers;if(g&&(h=this.startTimer()),function(t,e,n,r,i){Ga(e.inShapeInfos,n),Ga([e.outShapeInfo],[r]);var o=r.texData.texture,a=r.texData.texShape;r.texData.isPacked?t.setOutputPackedMatrixTexture(o,a[0],a[1]):t.setOutputMatrixTexture(o,a[0],a[1]),t.setProgram(e.webGLProgram),1===f().getNumber("WEBGL_VERSION")&&null!==e.infLoc&&t.gl.uniform1f(e.infLoc,1/0),null!==e.nanLoc&&t.gl.uniform1f(e.nanLoc,NaN),n.forEach(function(n,r){var i=e.program.variableNames[r],o=e.uniformLocations[i],a=e.uniformLocations["offset"+i];if(null!=o)if(n.isUniform){if(T(n.shape)<2)t.gl.uniform1f(o,n.uniformValues[0]);else {var s=n.uniformValues;s instanceof Float32Array||(s=new Float32Array(s)),t.gl.uniform1fv(o,s);}}else null!=n.texData.slice&&null!=a&&t.gl.uniform1i(a,n.texData.slice.flatOffset),t.setInputMatrixTexture(n.texData.texture,o,r);}),null!=i&&i(t,e.webGLProgram),t.executeProgram();}(this.gpgpu,m,l,d,r),c.forEach(function(t){return o.disposeData(t.dataId);}),g&&(h=this.endTimer(h),this.activeTimers.push({name:t.constructor.name,query:this.getQueryTime(h)})),!f().getBool("WEBGL_LAZILY_UNPACK")&&s.isPacked&&!1===i){var v=this.unpackTensor(a);return this.disposeData(a.dataId),v;}return a;},e.prototype.compileAndRun=function(t,e,n,r,i){void 0===i&&(i=!1),n=n||e[0].dtype;var o=this.runWebGLProgram(t,e,n,r,i);return Wt.makeTensorFromDataId(o.dataId,o.shape,o.dtype);},e.prototype.getAndSaveBinary=function(t,e){return t in this.binaryCache||(this.binaryCache[t]=e()),this.binaryCache[t];},e.prototype.getTextureManager=function(){return this.textureManager;},e.prototype.dispose=function(){var t=this;this.disposed||(f().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach(function(e){t.gpgpu.deleteProgram(t.binaryCache[e].webGLProgram),delete t.binaryCache[e];}),this.textureManager.dispose(),null!=this.canvas&&"undefined"!=typeof HTMLCanvasElement&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0);},e.prototype.floatPrecision=function(){var t=this;return null==this.floatPrecisionValue&&(this.floatPrecisionValue=rn(function(){if(!f().get("WEBGL_RENDER_FLOAT32_ENABLED")){var e=f().getBool("DEBUG");f().set("DEBUG",!1);var n=t.abs(Pn(1e-8)).dataSync()[0];if(f().set("DEBUG",e),n>0)return 32;}return 16;})),this.floatPrecisionValue;},e.prototype.epsilon=function(){return 32===this.floatPrecision()?1e-7:1e-4;},e.prototype.uploadToGPU=function(t){var e,n=this.texData.get(t),r=n.shape,i=n.dtype,o=n.values,a=n.texture,s=n.usage,u=n.isPacked;if(null==a){var c,l=null!=this.activeTimers;l&&(c=at());var f=n.texShape;if(null==f&&(f=Me(r,u),n.texShape=f),null!=o){var h=Re(r),d=void 0,p=f[1],m=f[0],g=o instanceof Uint8Array;u?(p=(e=te(f[0],f[1]))[0],d=new function(t,e,n){void 0===n&&(n=!1),this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var r=Yo(),i=e[0],o=e[1];this.outputShape=t;var a="",s="result";n&&(s="floor(result * 255. + 0.5)");for(var u=0;u<=1;u++){for(var c=0;c<=1;c++){var l=2*u+c;a+="\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 / "+o+";\n              c = imod(flatIndex, "+o+");\n              uv = (vec2(c, r) + halfCR) / vec2("+o+".0, "+i+".0);\n              values = "+r.texture2D+"(A, uv);\n\n              if(offset == 0) {\n                result["+l+"] = values[0];\n              } else if(offset == 1) {\n                result["+l+"] = values[1];\n              } else if(offset == 2) {\n                result["+l+"] = values[2];\n              } else {\n                result["+l+"] = values[3];\n              }\n            }\n          }\n        ";}}this.userCode="\n      "+Qo(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        "+a+"\n\n        "+r.output+" = "+s+";\n      }\n    ";}(h,[m=e[1],p],g)):d=new function(t,e,n){void 0===n&&(n=!1),this.variableNames=["A"];var r=Yo(),i=e[0],o=e[1];this.outputShape=t;var a="result";n&&(a="floor(result * 255. + 0.5)"),this.userCode="\n      "+Qo(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 / "+o+";\n        int c = imod(flatIndex, "+o+");\n        vec2 uv = (vec2(c, r) + halfCR) / vec2("+o+".0, "+i+".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("+a+", 0., 0., 0.);\n      }\n    ";}(h,[m,p],g);var v=this.makeTensorInfo([m,p],i);this.texData.get(v.dataId).usage=g?Ht.PIXELS:Ht.UPLOAD,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(v.dataId),p,m,o);var y=this.runWebGLProgram(d,[v],i,null,!0),b=this.texData.get(y.dataId);n.texture=b.texture,n.texShape=b.texShape,n.isPacked=b.isPacked,n.usage=b.usage,this.disposeData(v.dataId),this.texData.delete(y.dataId),n.values=null,l&&(this.uploadWaitMs+=at()-c);}else {var x=this.acquireTexture(f,s,i,u);n.texture=x;}}},e.prototype.convertAndCacheOnCPU=function(t,e){var n=this.texData.get(t),r=n.dtype;return this.releaseGPUData(t),null!=e&&(n.values=function(t,e){if("float32"===e||"complex64"===e)return t;if("int32"===e||"bool"===e){for(var n="int32"===e?new Int32Array(t.length):new Uint8Array(t.length),r=0;r<n.length;++r){n[r]=Math.round(t[r]);}return n;}throw new Error("Unknown dtype "+e);}(e,r)),n.values;},e.prototype.acquireTexture=function(t,e,n,r){if(this.numBytesInGPU+=this.computeBytes(t,n),!this.warnedAboutMemory&&this.numBytesInGPU>1024*this.numMBBeforeWarning*1024){var i=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn("High memory usage in GPU: "+i+" MB, most likely due to a memory leak");}return this.textureManager.acquireTexture(t,e,r);},e.prototype.computeBytes=function(t,e){return t[0]*t[1]*G(e);},e;}(po);function Ds(t,e){return t(e={exports:{}},e.exports),e.exports;}Vt()&&Wt.registerBackend("webgl",function(){return new Ss();},2),"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==t||"undefined"!=typeof self&&self;var Fs=Ds(function(t){!function(t,e,n){function r(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e;}function i(t,e){var n=new function(t){var e,n=this,r=(e=4022871197,function(t){t=t.toString();for(var n=0;n<t.length;n++){var r=.02519603282416938*(e+=t.charCodeAt(n));r-=e=r>>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e);}return 2.3283064365386963e-10*(e>>>0);});n.next=function(){var t=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=t-(n.c=0|t);},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(t),n.s0<0&&(n.s0+=1),n.s1-=r(t),n.s1<0&&(n.s1+=1),n.s2-=r(t),n.s2<0&&(n.s2+=1),r=null;}(t),i=e&&e.state,o=n.next;return o.int32=function(){return 4294967296*n.next()|0;},o.double=function(){return o()+1.1102230246251565e-16*(2097152*o()|0);},o.quick=o,i&&("object"==_typeof$1(i)&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.alea=i;}(0,t);}),Ts=Ds(function(t){!function(t,e,n){function r(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e;}function i(t,e){var n=new function(t){var e=this,n="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8;},t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++){e.x^=0|n.charCodeAt(r),e.next();}}(t),i=e&&e.state,o=function o(){return (n.next()>>>0)/4294967296;};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);}while(0===t);return t;},o.int32=n.next,o.quick=o,i&&("object"==_typeof$1(i)&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.xor128=i;}(0,t);}),Ns=Ds(function(t){!function(t,e,n){function r(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e;}function i(t,e){var n=new function(t){var e=this,n="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0;},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++){e.x^=0|n.charCodeAt(r),r==n.length&&(e.d=e.x<<10^e.x>>>4),e.next();}}(t),i=e&&e.state,o=function o(){return (n.next()>>>0)/4294967296;};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);}while(0===t);return t;},o.int32=n.next,o.quick=o,i&&("object"==_typeof$1(i)&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.xorwow=i;}(0,t);}),Is=Ds(function(t){!function(t,e,n){function r(t,e){return e.x=t.x.slice(),e.i=t.i,e;}function i(t,e){null==t&&(t=+new Date());var n=new function(t){var e=this;e.next=function(){var t,n,r=e.x,i=e.i;return t=r[i],n=(t^=t>>>7)^t<<24,n^=(t=r[i+1&7])^t>>>10,n^=(t=r[i+3&7])^t>>>3,n^=(t=r[i+4&7])^t<<7,t=r[i+7&7],n^=(t^=t<<13)^t<<9,r[i]=n,e.i=i+1&7,n;},function(t,e){var n,r=[];if(e===(0|e))r[0]=e;else for(e=""+e,n=0;n<e.length;++n){r[7&n]=r[7&n]<<15^e.charCodeAt(n)+r[n+1&7]<<13;}for(;r.length<8;){r.push(0);}for(n=0;n<8&&0===r[n];++n){}for(8==n?r[7]=-1:r[n],t.x=r,t.i=0,n=256;n>0;--n){t.next();}}(e,t);}(t),i=e&&e.state,o=function o(){return (n.next()>>>0)/4294967296;};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);}while(0===t);return t;},o.int32=n.next,o.quick=o,i&&(i.x&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.xorshift7=i;}(0,t);}),Rs=Ds(function(t){!function(t,e,n){function r(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e;}function i(t,e){null==t&&(t=+new Date());var n=new function(t){var e=this;e.next=function(){var t,n,r=e.w,i=e.X,o=e.i;return e.w=r=r+1640531527|0,n=i[o+34&127],t=i[o=o+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,n=i[o]=n^t,e.i=o,n+(r^r>>>16)|0;},function(t,e){var n,r,i,o,a,s=[],u=128;for(e===(0|e)?(r=e,e=null):(e+="\0",r=0,u=Math.max(u,e.length)),i=0,o=-32;o<u;++o){e&&(r^=e.charCodeAt((o+32)%e.length)),0===o&&(a=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,o>=0&&(a=a+1640531527|0,i=0==(n=s[127&o]^=r+a)?i+1:0);}for(i>=128&&(s[127&(e&&e.length||0)]=-1),i=127,o=512;o>0;--o){r=s[i+34&127],n=s[i=i+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,s[i]=r^n;}t.w=a,t.X=s,t.i=i;}(e,t);}(t),i=e&&e.state,o=function o(){return (n.next()>>>0)/4294967296;};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);}while(0===t);return t;},o.int32=n.next,o.quick=o,i&&(i.X&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.xor4096=i;}(0,t);}),Ms=Ds(function(t){!function(t,e,n){function r(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e;}function i(t,e){var n=new function(t){var e=this,n="";e.next=function(){var t=e.b,n=e.c,r=e.d,i=e.a;return t=t<<25^t>>>7^n,n=n-r|0,r=r<<24^r>>>8^i,i=i-t|0,e.b=t=t<<20^t>>>12^n,e.c=n=n-r|0,e.d=r<<16^n>>>16^i,e.a=i-t|0;},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):n+=t;for(var r=0;r<n.length+20;r++){e.b^=0|n.charCodeAt(r),e.next();}}(t),i=e&&e.state,o=function o(){return (n.next()>>>0)/4294967296;};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);}while(0===t);return t;},o.int32=n.next,o.quick=o,i&&("object"==_typeof$1(i)&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.tychei=i;}(0,t);}),js=Ds(function(t){!function(e,r){var i,o=this,a=256,s=6,u="random",c=r.pow(a,s),l=r.pow(2,52),f=2*l,h=a-1;function d(t,n,h){var d=[],y=g(function t(e,n){var r,i=[],o=_typeof$1(e);if(n&&"object"==o)for(r in e){try{i.push(t(e[r],n-1));}catch(t){}}return i.length?i:"string"==o?e:e+"\0";}((n=1==n?{entropy:!0}:n||{}).entropy?[t,v(e)]:null==t?function(){try{var t;return i&&(t=i.randomBytes)?t=t(a):(t=new Uint8Array(a),(o.crypto||o.msCrypto).getRandomValues(t)),v(t);}catch(t){var n=o.navigator,r=n&&n.plugins;return [+new Date(),o,r,o.screen,v(e)];}}():t,3),d),b=new p(d),x=function x(){for(var t=b.g(s),e=c,n=0;t<l;){t=(t+n)*a,e*=a,n=b.g(1);}for(;t>=f;){t/=2,e/=2,n>>>=1;}return (t+n)/e;};return x.int32=function(){return 0|b.g(4);},x.quick=function(){return b.g(4)/4294967296;},x.double=x,g(v(b.S),e),(n.pass||h||function(t,e,n,i){return i&&(i.S&&m(i,b),t.state=function(){return m(b,{});}),n?(r[u]=t,e):t;})(x,y,"global"in n?n.global:this==r,n.state);}function p(t){var e,n=t.length,r=this,i=0,o=r.i=r.j=0,s=r.S=[];for(n||(t=[n++]);i<a;){s[i]=i++;}for(i=0;i<a;i++){s[i]=s[o=h&o+t[i%n]+(e=s[i])],s[o]=e;}(r.g=function(t){for(var e,n=0,i=r.i,o=r.j,s=r.S;t--;){e=s[i=h&i+1],n=n*a+s[h&(s[i]=s[o=h&o+e])+(s[o]=e)];}return r.i=i,r.j=o,n;})(a);}function m(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e;}function g(t,e){for(var n,r=t+"",i=0;i<r.length;){e[h&i]=h&(n^=19*e[h&i])+r.charCodeAt(i++);}return v(e);}function v(t){return String.fromCharCode.apply(0,t);}if(r["seed"+u]=d,g(r.random(),e),t.exports){t.exports=d;try{i=n(390);}catch(t){}}}([],Math);});js.alea=Fs,js.xor128=Ts,js.xorwow=Ns,js.xorshift7=Is,js.xor4096=Rs,js.tychei=Ms;var Bs=js.alea,Ps=Nn({addN_:function addN_(t){_(Array.isArray(t),function(){return "The argument passed to tf.addN() must be a list of tensors";}),_(t.length>=1,function(){return "Must pass at least one tensor to tf.addN(), but got "+t.length;});var e=t.map(function(t,e){return xn(t,"tensors"+e,"addN");}),n=e[0];e.forEach(function(t){if(t.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype");}),e.forEach(function(t){if(!N(t.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape");});var r=e;return Wt.runKernelFunc(function(t,n){return t.addN(e);},r,null,"AddN");}});function Ls(){Qe("tf.batchNormalization() is going away. Use tf.batchNorm() instead, and note the positional argument change of scale, offset, and varianceEpsilon");}function zs(t){return 0===t.rank||1===t.rank?t.as4D(1,1,1,t.size):2===t.rank?t.as4D(1,1,t.shape[0],t.shape[1]):3===t.rank?t.as4D(1,t.shape[0],t.shape[1],t.shape[2]):t;}function Us(t,e,n,r,i,o){null==o&&(o=.001);var a,s,u=xn(t,"x","batchNorm"),c=xn(e,"mean","batchNorm"),l=xn(n,"variance","batchNorm");null!=i&&(a=xn(i,"scale","batchNorm")),null!=r&&(s=xn(r,"offset","batchNorm")),_(c.rank===l.rank,function(){return "Batch normalization gradient requires mean and variance to have equal ranks.";}),_(null==s||c.rank===s.rank,function(){return "Batch normalization gradient requires mean and offset to have equal ranks.";}),_(null==a||c.rank===a.rank,function(){return "Batch normalization gradient requires mean and scale to have equal ranks.";});var f={x:u,scale:a,offset:s,mean:c,variance:l},h={varianceEpsilon:o};return Wt.runKernelFunc(function(t,e){var n=zs(u),r=t.batchNormalization(n,Ws(c),Ws(l),o,Ws(a),Ws(s));return e([u,c,l,a]),r;},f,null,"FusedBatchNorm",h).reshape(u.shape);}function Ws(t){return null==t?null:0===t.rank?t.as1D():1===t.rank?t:2===t.rank?t.as4D(1,1,t.shape[0],t.shape[1]):3===t.rank?t.as4D(1,t.shape[0],t.shape[1],t.shape[2]):t;}var Vs=Nn({batchNormalization_:function batchNormalization_(t,e,n,r,i,o){return void 0===r&&(r=.001),Ls(),Us(t,e,n,o,i,r);}}),qs=Nn({batchNorm_:Us});function $s(t,e,n,r,i,o){var a,s,u=xn(t,"x","batchNorm"),c=xn(e,"mean","batchNorm"),l=xn(n,"variance","batchNorm");return null!=i&&(a=xn(i,"scale","batchNorm")),null!=r&&(s=xn(r,"offset","batchNorm")),_(2===u.rank,function(){return "Error in batchNorm3D: x must be rank 3 but got rank "+u.rank+".";}),_(2===c.rank||1===c.rank,function(){return "Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank "+c.rank+".";}),_(2===l.rank||1===l.rank,function(){return "Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank "+l.rank+".";}),null!=a&&_(2===a.rank||1===a.rank,function(){return "Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank "+a.rank+".";}),null!=s&&_(2===s.rank||1===s.rank,function(){return "Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank "+s.rank+".";}),qs(u,c,l,s,a,o);}var Hs=Nn({batchNormalization2d_:function batchNormalization2d_(t,e,n,r,i,o){return void 0===r&&(r=.001),Ls(),$s(t,e,n,o,i,r);}}),Gs=Nn({batchNorm2d_:$s});function Ks(t,e,n,r,i,o){var a,s,u=xn(t,"x","batchNorm"),c=xn(e,"mean","batchNorm"),l=xn(n,"variance","batchNorm");return null!=i&&(a=xn(i,"scale","batchNorm")),null!=r&&(s=xn(r,"offset","batchNorm")),_(3===u.rank,function(){return "Error in batchNorm3D: x must be rank 3 but got rank "+u.rank+".";}),_(3===c.rank||1===c.rank,function(){return "Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank "+c.rank+".";}),_(3===l.rank||1===l.rank,function(){return "Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank "+l.rank+".";}),null!=a&&_(3===a.rank||1===a.rank,function(){return "Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank "+a.rank+".";}),null!=s&&_(3===s.rank||1===s.rank,function(){return "Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank "+s.rank+".";}),qs(u,c,l,s,a,o);}var Xs=Nn({batchNormalization3d_:function batchNormalization3d_(t,e,n,r,i,o){return void 0===r&&(r=.001),Ls(),Ks(t,e,n,o,i,r);}}),Ys=Nn({batchNorm3d_:Ks});function Js(t,e,n,r,i,o){var a,s,u=xn(t,"x","batchNorm"),c=xn(e,"mean","batchNorm"),l=xn(n,"variance","batchNorm");return null!=i&&(a=xn(i,"scale","batchNorm")),null!=r&&(s=xn(r,"offset","batchNorm")),_(4===u.rank,function(){return "Error in batchNorm4D: x must be rank 4 but got rank "+u.rank+".";}),_(4===c.rank||1===c.rank,function(){return "Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank "+c.rank+".";}),_(4===l.rank||1===l.rank,function(){return "Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank "+l.rank+".";}),null!=a&&_(4===a.rank||1===a.rank,function(){return "Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank "+a.rank+".";}),null!=s&&_(4===s.rank||1===s.rank,function(){return "Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank "+s.rank+".";}),qs(u,c,l,s,a,o);}var Qs=Nn({batchNormalization4d_:function batchNormalization4d_(t,e,n,r,i,o){return void 0===r&&(r=.001),Ls(),Js(t,e,n,o,i,r);}}),Zs=Nn({batchNorm4d_:Js}),tu=Nn({broadcastTo_:function broadcastTo_(t,e){var n=xn(t,"broadcastTo","x"),r=n.shape;if(e.some(function(t){return !(t>0)||t%1!=0;}))throw new Error("broadcastTo(): Invalid broadcast shape ["+e+"].");if(e.length<n.rank)throw new Error("broadcastTo(): shape.length="+e.length+" < input.rank="+n.rank+".");if(e.length>n.rank){for(var i=n.shape.slice();i.length<e.length;){i.unshift(1);}n=n.reshape(i);}for(var o=n.shape,a=Array.from(e),s=e.length-1;s>=0;s--){if(o[s]===e[s])a[s]=1;else if(1!==n.shape[s])throw new Error("broadcastTo(): ["+r+"] cannot be broadcast to ["+e+"].");}var u=a.map(function(t,e){return t>1?e:-1;}).filter(function(t){return t>=0;});if(0===u.length)return n.clone();var c={x:n},l={shape:e,inputShape:o};return Wt.runKernelFunc(function(t){return t.tile(n,a);},c,function(t){return {x:function x(){return t.sum(u,!0);}};},Tr,l);}}),eu=Nn({clone_:function clone_(t){var e=xn(t,"x","clone",null);return Wt.runKernelFunc(function(){return Wt.makeTensorFromDataId(e.dataId,e.shape,e.dtype);},{x:e},null,Ir);}}),nu=Nn({logicalAnd_:function logicalAnd_(t,e){var n=xn(t,"a","logicalAnd","bool"),r=xn(e,"b","logicalAnd","bool");return Ur(n.shape,r.shape),Wt.runKernelFunc(function(t){return t.logicalAnd(n,r);},{a:n,b:r},null,"LogicalAnd");}}),ru=Nn({logicalNot_:function logicalNot_(t){var e=xn(t,"x","logicalNot","bool");return Wt.runKernelFunc(function(t){return t.logicalNot(e);},{$x:e});}}),iu=Nn({logicalOr_:function logicalOr_(t,e){var n=xn(t,"a","logicalOr","bool"),r=xn(e,"b","logicalOr","bool");return Ur(n.shape,r.shape),Wt.runKernelFunc(function(t){return t.logicalOr(n,r);},{$a:n,$b:r});}}),ou=Nn({logicalXor_:function logicalXor_(t,e){var n=xn(t,"a","logicalXor","bool"),r=xn(e,"b","logicalXor","bool");return Ur(n.shape,r.shape),iu(t,e).logicalAnd(nu(t,e).logicalNot());}}),au=Nn({where_:function where_(t,e,n){var r=xn(e,"a","where"),i=xn(n,"b","where"),o=xn(t,"condition","where","bool");return S(r.shape,i.shape,"Error in where: "),1===o.rank?_(o.shape[0]===r.shape[0],function(){return "The first dimension of `a` must match the size of `condition`.";}):S(o.shape,i.shape,"Error in where: "),Wt.runKernelFunc(function(t,e){var n=t.select(o,r,i);return e([o]),n;},{$condition:o,$a:r,$b:i},function(t,e){var n=e[0];return {$condition:function $condition(){return Qn(n).toFloat();},$a:function $a(){return t.mul(n.cast(t.dtype));},$b:function $b(){return t.mul(n.logicalNot().cast(t.dtype));}};});}}),su=function su(t){return u(this,void 0,void 0,function(){var e,n,r;return c(this,function(i){switch(i.label){case 0:return [4,(e=xn(t,"condition","whereAsync","bool")).data()];case 1:return n=i.sent(),r=Go(e.shape,n),t!==e&&e.dispose(),[2,r];}});});},uu=Nn({divNoNan_:function divNoNan_(t,e){var n,r=xn(t,"a","div"),i=xn(e,"b","div");r=(n=Mt(r,i))[0],i=n[1];var o=Li(r,i),a=Qn(o),s=i.equal(a);return au(s,a,o);}}),cu=Nn({tile_:function tile_(t,e){var n=xn(t,"x","tile",null);_(n.rank===e.length,function(){return "Error in transpose: rank of input "+n.rank+" must match length of reps "+e+".";});var r=[n],i={x:n},o={reps:e};return Wt.runKernelFunc(function(t,r){var i=t.tile(n,e);return r([n]),i;},i,null,Rr,o,r);}}),lu=Nn({eye_:function eye_(t,e,n,r){void 0===r&&(r="float32"),null==e&&(e=t);for(var i=or([t,e],r),o=t<=e?t:e,a=0;a<o;++a){i.set(1,a,a);}var s=i.toTensor().as2D(t,e);if(null==n)return s;if(1===n.length)return cu(fr(s,0),[n[0],1,1]);if(2===n.length)return cu(fr(fr(s,0),0),[n[0],n[1],1,1]);if(3===n.length)return cu(fr(fr(fr(s,0),0),0),[n[0],n[1],n[2],1,1]);throw new Error("eye() currently supports only 1D and 2D batchShapes, but received "+n.length+"D.");}}),fu=Nn({multinomial_:function multinomial_(t,e,n,r){void 0===r&&(r=!1);var i=xn(t,"logits","multinomial"),o=i.size,a=i.rank;if(o<2)throw new Error("Error in multinomial: you need at least 2 outcomes, but got "+o+".");if(a>2)throw new Error("Rank of probabilities must be 1 or 2, but is "+a);n=n||Math.random();var s=1===a?i.as2D(1,-1):i,u=Wt.runKernelFunc(function(t){return t.multinomial(s,r,e,n);},{logits2D:s});return 1===a?u.as1D():u;}}),hu=Nn({oneHot_:function oneHot_(t,e,n,r){if(void 0===n&&(n=1),void 0===r&&(r=0),e<2)throw new Error("Error in oneHot: depth must be >=2, but it is "+e);var i=xn(t,"indices","oneHot","int32"),o=i.shape.concat([e]),a={indices:i=i.flatten()},s={depth:e,onValue:n,offValue:r};return Wt.runKernelFunc(function(t,o){return o([i]),t.oneHot(i,e,n,r);},a,null,Nr,s).reshape(o);}}),du=Nn({pad_:function pad_(t,e,n){void 0===n&&(n=0);var r=xn(t,"x","pad");if(0===r.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");var i={paddings:e,constantValue:n},o={x:r};return Wt.runKernelFunc(function(t,i){return i([r]),t.pad(r,e,n);},o,null,Mr,i);}}),pu=Nn({pad1d_:function pad1d_(t,e,n){return void 0===n&&(n=0),_(2===e.length,function(){return "Invalid number of paddings. Must be length of 2.";}),du(t,[e],n);}}),mu=Nn({pad2d_:function pad2d_(t,e,n){return void 0===n&&(n=0),_(2===e.length&&2===e[0].length&&2===e[1].length,function(){return "Invalid number of paddings. Must be length of 2 each.";}),du(t,e,n);}}),gu=Nn({pad3d_:function pad3d_(t,e,n){return void 0===n&&(n=0),_(3===e.length&&2===e[0].length&&2===e[1].length&&2===e[2].length,function(){return "Invalid number of paddings. Must be length of 2 each.";}),du(t,e,n);}}),vu=Nn({pad4d_:function pad4d_(t,e,n){return void 0===n&&(n=0),_(4===e.length&&2===e[0].length&&2===e[1].length&&2===e[2].length&&2===e[3].length,function(){return "Invalid number of paddings. Must be length of 2 each.";}),du(t,e,n);}}),yu=Nn({rand_:function rand_(t,e,n){var r=T(t),i=null;if(null==n||"float32"===n)i=new Float32Array(r);else if("int32"===n)i=new Int32Array(r);else {if("bool"!==n)throw new Error("Unknown data type "+n);i=new Uint8Array(r);}for(var o=0;o<r;o++){i[o]=e();}return Wt.makeTensor(i,t,n);}}),bu=.001,xu=.1;function wu(){return 32===Wt.backend.floatPrecision()?bu:xu;}function ku(t,e,n){var r=!0;if((H(t)||H(e))&&(r=!1),H(t)&&H(e)&&(r=!0),r){var i=t.constructor.name,o=e.constructor.name;if(i!==o)throw new Error("Arrays are of different type. Actual: "+i+". Expected: "+o);}if(Array.isArray(t)&&Array.isArray(e)){var a=yn(t),s=yn(e);if(!N(a,s))throw new Error("Arrays have different shapes. Actual: ["+a+"]. Expected: ["+s+"]");}var u=H(t)?t:F(t),c=H(e)?e:F(e);if(u.length!==c.length)throw new Error("Arrays have different lengths actual: "+u.length+" vs expected: "+c.length+".\nActual:   "+u+".\nExpected: "+c+".");for(var l=0;l<c.length;++l){var f=u[l],h=c[l];if(!n(f,h))throw new Error("Arrays differ: actual["+l+"] = "+f+", expected["+l+"] = "+h+".\nActual:   "+u+".\nExpected: "+c+".");}}function Eu(t,e,n){return !isFinite(t)&&!isFinite(e)||!(isNaN(t)||isNaN(e)||Math.abs(t-e)>n);}var Cu=Object.freeze({TEST_EPSILON_FLOAT16:xu,expectArraysClose:function expectArraysClose(t,e,n){return null==n&&(n=wu()),ku(t,e,function(t,e){return Eu(t,e,n);});},testEpsilon:wu,expectPromiseToFail:function expectPromiseToFail(t,e){t().then(function(){return e.fail();},function(){return e();});},expectArraysEqual:function expectArraysEqual(t,e){var n="string"==typeof e||"number"==typeof e||"boolean"==typeof e?[e]:e;return X(t)||X(t[0])||X(e)||X(e[0])?ku(t,n,function(t,e){return t==e;}):ku(t,e,function(t,e){return Eu(t,e,0);});},expectNumbersClose:function expectNumbersClose(t,e,n){if(null==n&&(n=wu()),!Eu(t,e,n))throw new Error("Numbers differ: actual === "+t+", expected === "+e);},expectValuesInRange:function expectValuesInRange(t,e,n){for(var r=0;r<t.length;r++){if(t[r]<e||t[r]>n)throw new Error("Value out of range:"+t[r]+" low: "+e+", high: "+n);}},expectArrayBuffersEqual:function expectArrayBuffersEqual(t,e){expect(new Float32Array(t)).toEqual(new Float32Array(e));}}),Au=function(){function t(t,e,n,r,i){this.mean=t,this.stdDev=e,this.dtype=n,this.nextVal=NaN,this.truncated=r,this.truncated&&(this.upper=this.mean+2*this.stdDev,this.lower=this.mean-2*this.stdDev);var o=i||Math.random();this.random=Bs(o.toString());}return t.prototype.nextValue=function(){if(!isNaN(this.nextVal)){var t=this.nextVal;return this.nextVal=NaN,t;}for(var e,n,r=!1;!r;){var i=void 0,o=void 0,a=void 0;do{a=(i=2*this.random()-1)*i+(o=2*this.random()-1)*o;}while(a>=1||0===a);var s=Math.sqrt(-2*Math.log(a)/a);e=this.mean+this.stdDev*i*s,n=this.mean+this.stdDev*o*s,this.truncated&&!this.isValidTruncated(e)||(r=!0);}return this.truncated&&!this.isValidTruncated(n)||(this.nextVal=this.convertValue(n)),this.convertValue(e);},t.prototype.convertValue=function(t){return null==this.dtype||"float32"===this.dtype?t:Math.round(t);},t.prototype.isValidTruncated=function(t){return t<=this.upper&&t>=this.lower;},t;}(),Ou=function(){function t(t,e,n,r){this.alpha=t,this.beta=1/e,this.dtype=n;var i=r||Math.random();this.randu=Bs(i.toString()),this.randn=new Au(0,1,n,!1,this.randu()),this.d=t<1?t+2/3:t-1/3,this.c=1/Math.sqrt(9*this.d);}return t.prototype.nextValue=function(){for(var t,e,n,r,i,o;;){do{r=this.randn.nextValue(),o=1+this.c*r;}while(o<=0);if(o*=o*o,e=1-.331*(t=r*r)*t,n=.5*t+this.d*(1-o+Math.log(o)),(i=this.randu())<e||Math.log(i)<n)break;}return o=1/this.beta*this.d*o,this.alpha<1&&(o*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(o);},t.prototype.convertValue=function(t){return "float32"===this.dtype?t:Math.round(t);},t;}(),_u=function(){function t(t,e,n,r){var i=this;if(void 0===t&&(t=0),void 0===e&&(e=1),this.canReturnFloat=function(){return null==i.dtype||"float32"===i.dtype;},this.min=t,this.range=e-t,this.dtype=n,null==r&&(r=Math.random()),"number"==typeof r&&(r=r.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error("The difference between "+t+" - "+e+" <= 1 and dtype is not float");this.random=Bs(r);}return t.prototype.convertValue=function(t){return this.canReturnFloat()?t:Math.round(t);},t.prototype.nextValue=function(){return this.convertValue(this.min+this.range*this.random());},t;}(),Su=Nn({randomGamma_:function randomGamma_(t,e,n,r,i){if(void 0===n&&(n=1),void 0===r&&(r="float32"),null==n&&(n=1),null==r&&(r="float32"),"float32"!==r&&"int32"!==r)throw new Error("Unsupported data type "+r);for(var o=new Ou(e,n,r,i),a=or(t,r),s=0;s<a.values.length;s++){a.values[s]=o.nextValue();}return a.toTensor();}}),Du=Nn({randomNormal_:function randomNormal_(t,e,n,r,i){if(void 0===e&&(e=0),void 0===n&&(n=1),null!=r&&"bool"===r)throw new Error("Unsupported data type "+r);for(var o=new Au(e,n,r,!1,i),a=or(t,r),s=0;s<a.values.length;s++){a.values[s]=o.nextValue();}return a.toTensor();}}),Fu=Nn({randomUniform_:function randomUniform_(t,e,n,r,i){void 0===e&&(e=0),void 0===n&&(n=1),void 0===r&&(r="float32");for(var o=or(t,r),a=new _u(e,n,null,i),s=0;s<o.values.length;s++){o.values[s]=a.nextValue();}return o.toTensor();}}),Tu=Nn({square_:function square_(t){var e=xn(t,"x","square"),n=[e];return Wt.runKernelFunc(function(t,n){return n([e]),t.square(e);},{x:e},null,"Square",{},n,[]);}}),Nu=Nn({squaredDifference_:function squaredDifference_(t,e){var n,r=xn(t,"a","squaredDifference"),i=xn(e,"b","squaredDifference");n=Mt(r,i),r=n[0],i=n[1],Ur(r.shape,i.shape);var o={a:r,b:i},a=[r,i];return Wt.runKernelFunc(function(t,e){var n=t.squaredDifference(r,i);return e([r,i]),n;},o,function(t,e){var n=e[0],r=e[1],i=Pn(2);return {a:function a(){return t.mul(n.sub(r).mul(i));},b:function b(){return t.mul(r.sub(n).mul(i));}};},_r,{},a,[]);}}),Iu=Nn({truncatedNormal_:function truncatedNormal_(t,e,n,r,i){if(void 0===e&&(e=0),void 0===n&&(n=1),null!=r&&"bool"===r)throw new Error("Unsupported data type $ { dtype }");for(var o=new Au(e,n,r,!0,i),a=or(t,r),s=0;s<a.values.length;s++){a.values[s]=o.nextValue();}return a.toTensor();}}),Ru=Nn({equal_:function equal_(t,e){var n,r=xn(t,"a","equal"),i=xn(e,"b","equal");return n=Mt(r,i),r=n[0],i=n[1],Ur(r.shape,i.shape),Wt.runKernelFunc(function(t){return t.equal(r,i);},{$a:r,$b:i});}}),Mu=Nn({equalStrict_:function equalStrict_(t,e){var n=xn(t,"a","equalStrict"),r=xn(e,"b","equalStrict");return S(n.shape,r.shape,"Error in equalStrict: "),n.equal(r);}}),ju=Nn({greater_:function greater_(t,e){var n,r=xn(t,"a","greater"),i=xn(e,"b","greater");return n=Mt(r,i),r=n[0],i=n[1],Ur(r.shape,i.shape),Wt.runKernelFunc(function(t){return t.greater(r,i);},{a:r,b:i},null,"Greater");}}),Bu=Nn({greaterEqual_:function greaterEqual_(t,e){var n,r=xn(t,"a","greaterEqual"),i=xn(e,"b","greaterEqual");return n=Mt(r,i),r=n[0],i=n[1],Ur(r.shape,i.shape),Wt.runKernelFunc(function(t,e){var n=t.greaterEqual(r,i);return e([r,i]),n;},{a:r,b:i},function(t,e){var n=e[0],r=e[1];return {a:function a(){return Qn(n);},b:function b(){return Qn(r);}};},"GreaterEqual");}}),Pu=Nn({greaterEqualStrict_:function greaterEqualStrict_(t,e){var n=xn(t,"a","greaterEqualStrict"),r=xn(e,"b","greaterEqualStrict");return S(n.shape,r.shape,"Error in greaterEqualStrict: "),n.greaterEqual(r);}}),Lu=Nn({greaterStrict_:function greaterStrict_(t,e){var n=xn(t,"a","greaterStrict"),r=xn(e,"b","greaterStrict");return S(n.shape,r.shape,"Error in greaterStrict: "),n.greater(r);}}),zu=Nn({less_:function less_(t,e){var n,r=xn(t,"a","less"),i=xn(e,"b","less");return n=Mt(r,i),r=n[0],i=n[1],Ur(r.shape,i.shape),Wt.runKernelFunc(function(t){return t.less(r,i);},{a:r,b:i},null,"Less");}}),Uu=Nn({lessEqual_:function lessEqual_(t,e){var n,r=xn(t,"a","lessEqual"),i=xn(e,"b","lessEqual");return n=Mt(r,i),r=n[0],i=n[1],Ur(r.shape,i.shape),Wt.runKernelFunc(function(t,e){var n=t.lessEqual(r,i);return e([r,i]),n;},{a:r,b:i},null,"LessEqual");}}),Wu=Nn({lessEqualStrict_:function lessEqualStrict_(t,e){var n=xn(t,"a","lessEqualStrict"),r=xn(e,"b","lessEqualStrict");return S(n.shape,r.shape,"Error in lessEqualStrict: "),n.lessEqual(r);}}),Vu=Nn({lessStrict_:function lessStrict_(t,e){var n=xn(t,"a","lessStrict"),r=xn(e,"b","lessStrict");return S(n.shape,r.shape,"Error in lessStrict: "),n.less(r);}}),qu=Nn({notEqual_:function notEqual_(t,e){var n,r=xn(t,"a","notEqual"),i=xn(e,"b","notEqual");return n=Mt(r,i),r=n[0],i=n[1],Ur(r.shape,i.shape),Wt.runKernelFunc(function(t){return t.notEqual(r,i);},{a:r,b:i},null,"NotEqual");}}),$u=Nn({notEqualStrict_:function notEqualStrict_(t,e){var n=xn(t,"a","notEqualStrict"),r=xn(e,"b","notEqualStrict");return S(n.shape,r.shape,"Error in notEqualStrict: "),n.notEqual(r);}});function Hu(t,e){for(var n=[],r=t;r<e;++r){n.push(r);}return n;}function Gu(t){for(var e=[],n=0;n<t.length;++n){for(var r=0;r<t[n].length;++r){e.push(t[n][r]);}}return e;}var Ku=Nn({gather_:function gather_(t,e,n){void 0===n&&(n=0);var r=xn(t,"x","gather"),i=xn(e,"indices","gather","int32");n=L(n,r.shape)[0];var o=function(t,e,n){for(var r=t.shape[n],i=[],o=1,a=1,s=0;s<n;s++){i.push(t.shape[s]),o*=t.shape[s];}for(s=0;s<e.rank;s++){i.push(e.shape[s]);}for(s=n+1;s<t.rank;s++){i.push(t.shape[s]),a*=t.shape[s];}return {batchSize:o,sliceSize:a,dimSize:r,outputShape:i};}(r,i,n);return Wt.runKernelFunc(function(t,e){var o=t.gather(r,i.flatten(),n);return e([i]),o;},{x:r,indices:i},function(t,e){var i=e[0];return {x:function x(){var e=r.shape,o=i.size,a=e.slice(0,n),s=a.length,u=e.slice(n,e.length).slice(1),c=u.length,l=Hu(0,s),f=Hu(s+1,s+1+c),h=Gu([a,[o],u]),d=t.reshape(h),p=i.reshape([o]),m=Gu([[s],l,f]),g=d.transpose(m),v=Xu(g,p,r.shape[n]),y=Sn(m);return v.transpose(y);},indices:function indices(){return i;}};},"Gather",{axis:n}).reshape(o.outputShape);}}),Xu=Nn({unsortedSegmentSum_:function unsortedSegmentSum_(t,e,n){var r=xn(t,"x","unsortedSegmentSum"),i=xn(e,"segmentIds","unsortedSegmentSum","int32");return _(I(n),function(){return "numSegments must be of dtype int";}),Wt.runKernelFunc(function(t,e){var o=t.unsortedSegmentSum(r,i,n);return e([i]),o;},{$x:r},function(t,e){var n=e[0];return {$x:function $x(){return function(t,e){for(var n=Oi(e,Qn(e)),r=Ku(t,n),i=Bu(e,Pn(0,"int32")),o=r.rank-i.rank,a=0;a<o;++a){i=fr(i,a+1);}i=nu(i,Hn(r.shape,"bool"));var s=Qn(r);return au(i,r,s);}(t,n);}};});}}),Yu=function Yu(t,e,n){return u(this,void 0,void 0,function(){var r,i,o,a,s,u,l,f,h,d,p,m,g;return c(this,function(c){switch(c.label){case 0:for(r=xn(t,"tensor","boolMask"),i=xn(e,"mask","boolMask","bool"),o=null==n?0:n,a=i.rank,s=r.shape,_(a>0,function(){return "mask cannot be scalar";}),S(s.slice(o,o+a),i.shape,"mask's shape must match the first K dimensions of tensor's shape,"),u=1,l=o;l<o+a;l++){u*=s[l];}return f=s.slice(0,o).concat([u],s.slice(o+a)),h=r.reshape(f),d=i.reshape([-1]),[4,su(d)];case 1:return p=c.sent(),m=p.squeeze([1]),g=Ku(h,m,o),t!==r&&r.dispose(),e!==i&&i.dispose(),m.dispose(),h.dispose(),d.dispose(),p.dispose(),[2,g];}});});};function Ju(t,e,n,r,i,o,a){void 0===o&&(o="NHWC"),_(t.length===e.rank,function(){return "Length of inShape ("+t.length+") and rank of dy ("+e.rank+") must match";});var s=t,u=e,c=!1;3===e.rank&&(c=!0,u=e.as4D(1,e.shape[0],e.shape[1],e.shape[2]),s=[1,t[0],t[1],t[2]]),_(4===s.length,function(){return "Error in conv2dDerInput: inShape must be length 4, but got length "+s.length+".";}),_(4===u.rank,function(){return "Error in conv2dDerInput: dy must be rank 4, but got rank "+u.rank;}),_(4===n.rank,function(){return "Error in conv2dDerInput: filter must be rank 4, but got rank "+n.rank;});var l="NHWC"===o?s[3]:s[1],f="NHWC"===o?u.shape[3]:u.shape[1];_(l===n.shape[2],function(){return "Error in conv2dDerInput: depth of input ("+l+") must match input depth for filter "+n.shape[2]+".";}),_(f===n.shape[3],function(){return "Error in conv2dDerInput: depth of output ("+f+") must match output depth for filter "+n.shape[3]+".";}),null!=a&&_(I(i),function(){return "Error in conv2dDerInput: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+i+".";});var h=_o(o),d=yo(s,n.shape,r,1,i,a,!1,h),p=Wt.runKernelFunc(function(t,e){var r=t.conv2dDerInput(u,n,d);return e([n,u]),r;},{dy4D:u,filter:n},function(t,e){var n=e[0],s=e[1];return {dy4D:function dy4D(){return ec(t,n,r,i,o,1,a);},filter:function filter(){return rc(t,s,n.shape,r,i,o,a);}};});return c?p.as3D(p.shape[1],p.shape[2],p.shape[3]):p;}function Qu(t){var e=function(t){return "number"==typeof t?[t,t,t]:2===t.length?[t[0],t[1],1]:t;}(t),n=e[0],r=e[1],i=e[2];return 1===n&&1===r&&1===i;}function Zu(t,e,n,r,i){_(t.length===e.rank,function(){return "Length of inShape ("+t.length+") and rank of dy ("+e.rank+") must match";});var o=t,a=e,s=!1;4===e.rank&&(s=!0,a=e.as5D(1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]),o=[1,t[0],t[1],t[2],t[3]]);var u=o[4],c=a.shape[4];_(5===o.length,function(){return "Error in conv3dDerInput: inShape must be length 5, but got length "+o.length+".";}),_(5===a.rank,function(){return "Error in conv3dDerInput: dy must be rank 5, but got rank "+a.rank;}),_(5===n.rank,function(){return "Error in conv3dDerInput: filter must be rank 5, but got rank "+n.rank;}),_(u===n.shape[3],function(){return "Error in conv3dDerInput: depth of input ("+u+") must match input depth for filter "+n.shape[3]+".";}),_(c===n.shape[4],function(){return "Error in conv3dDerInput: depth of output ("+c+") must match output depth for filter "+n.shape[4]+".";});var l=bo(o,n.shape,r,1,i),f=Wt.runKernelFunc(function(t){return t.conv3dDerInput(a,n,l);},{dy5D:a});return s?f.as4D(f.shape[1],f.shape[2],f.shape[3],f.shape[4]):f;}var tc=Nn({conv1d_:function conv1d_(t,e,n,r,i,o,a){void 0===i&&(i="NWC"),void 0===o&&(o=1);var s=xn(t,"x","conv1d"),u=xn(e,"filter","conv1d"),c=s,l=!1;2===s.rank&&(l=!0,c=s.as3D(1,s.shape[0],s.shape[1])),_(3===c.rank,function(){return "Error in conv1d: input must be rank 3, but got rank "+c.rank+".";}),_(3===u.rank,function(){return "Error in conv1d: filter must be rank 3, but got rank "+u.rank+".";}),null!=a&&_(I(r),function(){return "Error in conv1d: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+r+".";}),_(c.shape[2]===u.shape[1],function(){return "Error in conv1d: depth of input ("+c.shape[2]+") must match input depth for filter "+u.shape[1]+".";}),_(Oo(n,o),function(){return "Error in conv1D: Either stride or dilation must be 1. Got stride "+n+" and dilation '"+o+"'";}),_("NWC"===i,function(){return "Error in conv1d: got dataFormat of "+i+" but only NWC is currently supported.";});var f=u.as4D(1,u.shape[0],u.shape[1],u.shape[2]),h=c.as4D(c.shape[0],1,c.shape[1],c.shape[2]),d=ec(h,f,[1,n],r,"NHWC",[1,o],a);return l?d.as2D(d.shape[2],d.shape[3]):d.as3D(d.shape[0],d.shape[2],d.shape[3]);}}),ec=Nn({conv2d_:function conv2d_(t,e,n,r,i,o,a){void 0===i&&(i="NHWC"),void 0===o&&(o=[1,1]);var s=xn(t,"x","conv2d"),u=xn(e,"filter","conv2d"),c=s,l=!1;3===s.rank&&(l=!0,c=s.as4D(1,s.shape[0],s.shape[1],s.shape[2])),_(4===c.rank,function(){return "Error in conv2d: input must be rank 4, but got rank "+c.rank+".";}),_(4===u.rank,function(){return "Error in conv2d: filter must be rank 4, but got rank "+u.rank+".";}),null!=a&&_(I(r),function(){return "Error in conv2d: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+r+".";});var f="NHWC"===i?c.shape[3]:c.shape[1];_(f===u.shape[2],function(){return "Error in conv2d: depth of input ("+f+") must match input depth for filter "+u.shape[2]+".";}),_(Oo(n,o),function(){return "Error in conv2D: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+o+"'";});var h=_o(i),d=yo(c.shape,u.shape,n,o,r,a,!1,h),p=[u,c],m=Wt.runKernelFunc(function(t,e){var n=t.conv2d(c,u,d);return e([u,c]),n;},{x:c,filter:u},function(t,e){var a=e,s=a[0],u=a[1];return _(Ao(o),function(){return "Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+o+"'";}),{x:function x(){return ic(u.shape,t,s,n,r,i);},filter:function filter(){return rc(u,t,s.shape,n,r,i);}};},"Conv2D",d,p);return l?m.as3D(m.shape[1],m.shape[2],m.shape[3]):m;}}),nc=Nn({conv3d_:function conv3d_(t,e,n,r,i,o){void 0===i&&(i="NDHWC"),void 0===o&&(o=[1,1,1]);var a=xn(t,"x","conv3d"),s=xn(e,"filter","conv3d"),u=a,c=!1;4===a.rank&&(c=!0,u=a.as5D(1,a.shape[0],a.shape[1],a.shape[2],a.shape[3])),_(5===u.rank,function(){return "Error in conv3d: input must be rank 5, but got rank "+u.rank+".";}),_(5===s.rank,function(){return "Error in conv3d: filter must be rank 5, but got rank "+s.rank+".";}),_(u.shape[4]===s.shape[3],function(){return "Error in conv3d: depth of input ("+u.shape[4]+") must match input depth for filter "+s.shape[3]+".";}),_(function(t,e){return Qu(n)||Qu(e);}(0,o),function(){return "Error in conv3D: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+o+"'";}),_("NDHWC"===i,function(){return "Error in conv3d: got dataFormat of "+i+" but only NDHWC is currently supported.";});var l=bo(u.shape,s.shape,n,o,r),f=Wt.runKernelFunc(function(t,e){var n=t.conv3d(u,s,l);return e([u,s]),n;},{x:u,$filter:s},function(t,e){_(Qu(o),function(){return "Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+o+"'";});var i=e[0],a=e[1];return {x:function x(){return Zu(i.shape,t,a,n,r);},$filter:function $filter(){return function(t,e,n,r,i){var o=t;4===t.rank&&(o=t.as5D(1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]));var a=e;4===a.rank&&(a=e.as5D(1,e.shape[0],e.shape[1],e.shape[2],e.shape[3])),_(5===o.rank,function(){return "Error in conv3dDerFilter: input must be rank 5, but got shape "+o.shape+".";}),_(5===a.rank,function(){return "Error in conv3dDerFilter: dy must be rank 5, but got shape "+a.shape+".";}),_(5===n.length,function(){return "Error in conv3dDerFilter: filterShape must be length 5, but got "+n+".";}),_(o.shape[4]===n[3],function(){return "Error in conv3dDerFilter: depth of input "+o.shape[4]+") must match input depth in filter ("+n[3]+".";}),_(a.shape[4]===n[4],function(){return "Error in conv3dDerFilter: depth of dy ("+a.shape[4]+") must match output depth for filter ("+n[4]+").";});var s=bo(o.shape,n,r,1,i);return Wt.runKernelFunc(function(t){return t.conv3dDerFilter(o,a,s);},{x5D:o,dy5D:a});}(i,t,a.shape,n,r);}};});return c?f.as4D(f.shape[1],f.shape[2],f.shape[3],f.shape[4]):f;}}),rc=Nn({conv2dDerFilter_:function conv2dDerFilter_(t,e,n,r,i,o,a){void 0===o&&(o="NHWC");var s=t;3===t.rank&&(s=t.as4D(1,t.shape[0],t.shape[1],t.shape[2]));var u=e;3===u.rank&&(u=e.as4D(1,e.shape[0],e.shape[1],e.shape[2])),_(4===s.rank,function(){return "Error in conv2dDerFilter: input must be rank 4, but got shape "+s.shape+".";}),_(4===u.rank,function(){return "Error in conv2dDerFilter: dy must be rank 4, but got shape "+u.shape+".";}),_(4===n.length,function(){return "Error in conv2dDerFilter: filterShape must be length 4, but got "+n+".";});var c="NHWC"===o?s.shape[3]:s.shape[1],l="NHWC"===o?u.shape[3]:u.shape[1];_(c===n[2],function(){return "Error in conv2dDerFilter: depth of input "+c+") must match input depth in filter ("+n[2]+".";}),_(l===n[3],function(){return "Error in conv2dDerFilter: depth of dy ("+l+") must match output depth for filter ("+n[3]+").";}),null!=a&&_(I(i),function(){return "Error in conv2dDerFilter: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+i+".";});var f=_o(o),h=yo(s.shape,n,r,1,i,a,!1,f);return Wt.runKernelFunc(function(t){return t.conv2dDerFilter(s,u,h);},{x4D:s,dy4D:u});}}),ic=Nn({conv2dDerInput_:Ju}),oc=Nn({depthwiseConv2d_:function depthwiseConv2d_(t,e,n,r,i,o,a){void 0===o&&(o=[1,1]);var s=xn(t,"x","depthwiseConv2d"),u=xn(e,"filter","depthwiseConv2d"),c=s,l=!1;3===s.rank&&(l=!0,c=s.as4D(1,s.shape[0],s.shape[1],s.shape[2])),_(4===c.rank,function(){return "Error in depthwiseConv2d: input must be rank 4, but got rank "+c.rank+".";}),_(4===u.rank,function(){return "Error in depthwiseConv2d: filter must be rank 4, but got rank "+u.rank+".";}),_(c.shape[3]===u.shape[2],function(){return "Error in depthwiseConv2d: number of input channels ("+c.shape[3]+") must match the inChannels dimension in filter "+u.shape[2]+".";}),null==o&&(o=[1,1]),_(Oo(n,o),function(){return "Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+o+"'";}),null!=a&&_(I(r),function(){return "Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+r+".";});var f=yo(c.shape,u.shape,n,o,r,a,!0),h=[c,u],d=Wt.runKernelFunc(function(t,e){var n=t.depthwiseConv2D(c,u,f);return e([c,u]),n;},{x:c,filter:u},function(t,e){_(Ao(o),function(){return "Error in gradient of depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '"+o+"'";});var n=e[0],r=e[1];return {x:function x(){return ac(n.shape,t,r,f);},filter:function filter(){return sc(n,t,r.shape,f);}};},"DepthwiseConv2dNative",f,h);return l?d.as3D(d.shape[1],d.shape[2],d.shape[3]):d;}}),ac=Nn({depthwiseConv2dDerInput_:function depthwiseConv2dDerInput_(t,e,n,r){var i=e,o=!1;3===e.rank&&(o=!0,i=e.as4D(1,e.shape[0],e.shape[1],e.shape[2]));var a=Wt.runKernelFunc(function(t){return t.depthwiseConv2DDerInput(i,n,r);},{dy4D:i});return o?a.as3D(a.shape[1],a.shape[2],a.shape[3]):a;}}),sc=Nn({depthwiseConv2dDerFilter_:function depthwiseConv2dDerFilter_(t,e,n,r){var i=t;3===t.rank&&(i=t.as4D(1,t.shape[0],t.shape[1],t.shape[2]));var o=e;return 3===o.rank&&(o=e.as4D(1,e.shape[0],e.shape[1],e.shape[2])),Wt.runKernelFunc(function(t){return t.depthwiseConv2DDerFilter(i,o,r);},{x4D:i,dy4D:o});}}),uc=Nn({separableConv2d_:function separableConv2d_(t,e,n,r,i,o,a){void 0===o&&(o=[1,1]),void 0===a&&(a="NHWC");var s=xn(t,"x","separableConv2d"),u=xn(e,"depthwiseFilter","separableConv2d"),c=xn(n,"pointwiseFilter","separableConv2d"),l=s,f=!1;if(3===s.rank&&(f=!0,l=s.as4D(1,s.shape[0],s.shape[1],s.shape[2])),"NCHW"===a)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");_(4===l.rank,function(){return "Error in separableConv2d: input must be rank 4, but got rank "+l.rank+".";}),_(4===u.rank,function(){return "Error in separableConv2d: depthwise filter must be rank 4, but got rank "+u.rank+".";}),_(4===c.rank,function(){return "Error in separableConv2d: pointwise filter must be rank 4, but got rank "+u.rank+".";}),_(1===c.shape[0],function(){return "Error in separableConv2d: the first dimension of pointwise filter  must be 1, but got "+c.shape[0]+".";}),_(1===c.shape[1],function(){return "Error in separableConv2d: the second dimension of pointwise filter must be 1, but got "+c.shape[1]+".";});var h=u.shape[2],d=u.shape[3];_(c.shape[2]===h*d,function(){return "Error in separableConv2d: the third dimension of pointwise filter must be "+h*d+", but got "+c.shape[2]+".";});var p=oc(l,u,r,i,a,o),m=ec(p,c,1,"valid",a);return f?m.as3D(m.shape[1],m.shape[2],m.shape[3]):m;}}),cc=Nn({conv2dTranspose_:function conv2dTranspose_(t,e,n,r,i,o){return Ju(n,xn(t,"x","conv2dTranspose"),xn(e,"filter","conv2dTranspose"),r,i,"NHWC",o);}}),lc=Nn({conv3dTranspose_:function conv3dTranspose_(t,e,n,r,i){return Zu(n,xn(t,"x","conv3dTranspose"),xn(e,"filter","conv3dTranspose"),r,i);}}),fc=Nn({matMul_:function matMul_(t,e,n,r){var i;void 0===n&&(n=!1),void 0===r&&(r=!1);var o=xn(t,"a","matMul"),a=xn(e,"b","matMul");i=Mt(o,a),o=i[0],a=i[1];var s=n?o.shape[o.rank-2]:o.shape[o.rank-1],u=r?a.shape[a.rank-1]:a.shape[a.rank-2],c=n?o.shape[o.rank-1]:o.shape[o.rank-2],l=r?a.shape[a.rank-2]:a.shape[a.rank-1],f=o.shape.slice(0,-2),h=a.shape.slice(0,-2),d=T(f),p=T(h);_(o.rank>=2&&a.rank>=2&&o.rank===a.rank,function(){return "Error in matMul: inputs must have the same rank of at least 2, got ranks "+o.rank+" and "+a.rank+".";}),_(N(f,h),function(){return "Error in matMul: outer dimensions ("+f+") and ("+h+") of Tensors with shapes "+o.shape+" and "+a.shape+" must match.";}),_(s===u,function(){return "Error in matMul: inner shapes ("+s+") and ("+u+") of Tensors with shapes "+o.shape+" and "+a.shape+" and transposeA="+n+" and transposeB="+r+" must match.";});var m=o.shape.slice(0,-2).concat([c,l]),g=n?o.as3D(d,s,c):o.as3D(d,c,s),v=r?a.as3D(p,l,u):a.as3D(p,u,l),y={transposeA:n,transposeB:r};return Wt.runKernelFunc(function(t,e){var i=t.batchMatMul(g,v,n,r);return e([g,v]),i;},{a:g,b:v},function(t,e){var i=e,o=i[0],_a3=i[1];return n||r?!n&&r?{a:function a(){return t.matMul(_a3,!1,!1);},b:function b(){return t.matMul(o,!0,!1);}}:n&&!r?{a:function a(){return _a3.matMul(t,!1,!0);},b:function b(){return o.matMul(t,!1,!1);}}:{a:function a(){return _a3.matMul(t,!0,!0);},b:function b(){return t.matMul(o,!0,!0);}}:{a:function a(){return t.matMul(_a3,!1,!0);},b:function b(){return o.matMul(t,!0,!1);}};},"BatchMatMul",y).reshape(m);}}),hc=Nn({dot_:function dot_(t,e){var n=xn(t,"t1","dot"),r=xn(e,"t2","dot");_(!(1!==n.rank&&2!==n.rank||1!==r.rank&&2!==r.rank),function(){return "Error in dot: inputs must all be rank 1 or 2, but got ranks "+n.rank+" and "+r.rank+".";});var i=1===n.rank?n.size:n.shape[1],o=1===r.rank?r.size:r.shape[0];return _(i===o,function(){return "Error in dot: inner dimensions of inputs must match, but got "+i+" and "+o+".";}),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]));}}),dc=Nn({outerProduct_:function outerProduct_(t,e){var n=xn(t,"v1","outerProduct"),r=xn(e,"v2","outerProduct");return _(1===n.rank&&1===r.rank,function(){return "Error in outerProduct: inputs must be rank 1, but got ranks "+n.rank+" and "+r.rank+".";}),n.as2D(-1,1).matMul(r.as2D(1,-1));}}),pc=Nn({reverse_:function reverse_(t,e){var n=xn(t,"x","reverse");if(0===n.rank)return n.clone();var r=L(e,n.shape);return Wt.runKernelFunc(function(t){return t.reverse(n,r);},{$x:n},function(t){return {$x:function $x(){return t.reverse(r);}};}).reshapeAs(n);}}),mc=Nn({reverse1d_:function reverse1d_(t){var e=xn(t,"x","reverse");return _(1===e.rank,function(){return "Error in reverse1D: x must be rank 1 but got rank "+e.rank+".";}),pc(e,0);}}),gc=Nn({reverse2d_:function reverse2d_(t,e){var n=xn(t,"x","reverse");return _(2===n.rank,function(){return "Error in reverse2D: x must be rank 2 but got rank "+n.rank+".";}),pc(n,e);}}),vc=Nn({reverse3d_:function reverse3d_(t,e){var n=xn(t,"x","reverse");return _(3===n.rank,function(){return "Error in reverse3D: x must be rank 3 but got rank "+n.rank+".";}),pc(n,e);}}),yc=Nn({reverse4d_:function reverse4d_(t,e){var n=xn(t,"x","reverse");return _(4===n.rank,function(){return "Error in reverse4D: x must be rank 4 but got rank "+n.rank+".";}),pc(n,e);}});function bc(t,e,n,r,i,o){var a=xn(t,"x","maxPool"),s=a,u=!1;3===a.rank&&(u=!0,s=a.as4D(1,a.shape[0],a.shape[1],a.shape[2])),null==r&&(r=[1,1]),_(4===s.rank,function(){return "Error in maxPool: input must be rank 4 but got rank "+s.rank+".";}),_(Oo(n,r),function(){return "Error in maxPool: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+r+"'";}),null!=o&&_(I(i),function(){return "Error in maxPool: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+i+".";});var c=go(s.shape,e,n,r,i,o);if(1===c.filterWidth&&1===c.filterHeight&&N(c.inShape,c.outShape))return a.clone();var l=[s],f=Wt.runKernelFunc(function(t,e){var n=t.maxPool(s,c);return e([s,n]),n;},{x:s},function(t,o){var a=o[0],s=o[1];return {x:function x(){return function(t,e,n,r,i,o,a,s){var u=xn(t,"dy","maxPoolBackprop"),c=xn(e,"input","maxPoolBackprop"),l=xn(n,"output","maxPoolBackprop");_(c.rank===u.rank,function(){return "Rank of input ("+c.rank+") does not match rank of dy ("+u.rank+")";}),null==o&&(o=[1,1]),_(Oo(i,o),function(){return "Error in maxPoolBackProp: Either strides or dilations must be 1. Got strides "+i+" and dilations '"+o+"'";}),_(4===u.rank,function(){return "Error in maxPoolBackprop: dy must be rank 4 but got rank "+u.rank+".";}),_(4===c.rank,function(){return "Error in maxPoolBackprop: input must be rank 4 but got rank "+c.rank+".";});var f=go(c.shape,r,i,o,a,s);return Wt.runKernelFunc(function(t){return t.maxPoolBackprop(u,c,l,f);},{$dy:u,$input:c});}(t,a,s,e,n,r,i);}};},"MaxPool",c,l);return u?f.as3D(f.shape[1],f.shape[2],f.shape[3]):f;}function xc(t,e,n,r,i,o){var a=xn(t,"x","avgPool","float32");null==r&&(r=[1,1]),_(Oo(n,r),function(){return "Error in avgPool: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+r+"'";});var s=a,u=!1;3===a.rank&&(u=!0,s=a.as4D(1,a.shape[0],a.shape[1],a.shape[2])),_(4===s.rank,function(){return "Error in avgPool: x must be rank 4 but got rank "+s.rank+".";}),null!=o&&_(I(i),function(){return "Error in avgPool: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+i+".";});var c=go(s.shape,e,n,r,i,o);if(1===c.filterWidth&&1===c.filterHeight&&N(c.inShape,c.outShape))return a.clone();var l=Wt.runKernelFunc(function(t){return t.avgPool(s,c);},{x:s},function(t){return {x:function x(){return function(t,e,n,r,i,o){var a=xn(t,"dy","avgPoolBackprop"),s=xn(e,"input","avgPoolBackprop");_(s.rank===a.rank,function(){return "Rank of input ("+s.rank+") does not match rank of dy ("+a.rank+")";}),null==i&&(i=[1,1]),_(Oo(r,i),function(){return "Error in avgPoolBackprop: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+i+"'";});var u=s,c=a,l=!1;3===s.rank&&(l=!0,u=s.as4D(1,s.shape[0],s.shape[1],s.shape[2]),c=a.as4D(1,a.shape[0],a.shape[1],a.shape[2])),_(4===c.rank,function(){return "Error in avgPoolBackprop: dy must be rank 4 but got rank "+c.rank+".";}),_(4===u.rank,function(){return "Error in avgPoolBackprop: input must be rank 4 but got rank "+u.rank+".";});var f=go(u.shape,n,r,i,o),h=Wt.runKernelFunc(function(t){return t.avgPoolBackprop(c,u,f);},{dy4D:c,input4D:u});return l?h.as3D(h.shape[1],h.shape[2],h.shape[3]):h;}(t,s,e,n,r,i);}};},"AvgPool",c);return l=l.cast(a.dtype),u?l.as3D(l.shape[1],l.shape[2],l.shape[3]):l;}var wc=Nn({maxPool_:function maxPool_(t,e,n,r,i){return bc(t,e,n,1,r,i);}}),kc=Nn({avgPool_:function avgPool_(t,e,n,r,i){return xc(t,e,n,1,r,i);}}),Ec=Nn({pool_:function pool_(t,e,n,r,i,o){null==i&&(i=[1,1]),null==o&&(o=1),0===r&&(r="valid");var a=xn(t,"x","maxPool"),s=a,u=!1;3===a.rank&&(u=!0,s=a.as4D(1,a.shape[0],a.shape[1],a.shape[2])),_(Oo(o,i),function(){return "Error in pool: Either strides or dilations must be 1. Got strides "+o+" and dilations '"+i+"'";});var c,l=go(s.shape,e,o,i,r),f=[l.dilationHeight,l.dilationWidth];c="same"===r?function(t,e){var n=t.map(function(t,n){return t+(t-1)*(e[n]-1);}).map(function(t){return t-1;}),r=n.map(function(t){return Math.floor(t/2);}),i=n.map(function(t,e){return t-r[e];});return n.map(function(t,e){return [r[e],i[e]];});}([l.filterHeight,l.filterWidth],f):[[0,0],[0,0]];var h=1===f[0]&&1===f[1],d=function(t,e,n){var r=n.map(function(t){return t[0];}),i=n.map(function(t){return t[1];}),o=t.concat(r,i),a=e.map(function(t,e){return (t-o[e]%t)%t;}),s=i.map(function(t,e){return t+a[e];});return [e.map(function(t,e){return [r[e],s[e]];}),e.map(function(t,e){return [0,a[e]];})];}([l.inHeight,l.inWidth],f,c),p=d[0],m=d[1],g=h?r:"valid",v=h?s:dr(s,f,p),y=("avg"===n?function(){return xc(v,e,o,1,g);}:function(){return bc(v,e,o,1,g);})(),b=h?y:sr(y,f,m);return u?b.as3D(b.shape[1],b.shape[2],b.shape[3]):b;}}),Cc=Nn({maxPool3d_:function maxPool3d_(t,e,n,r,i,o,a){void 0===o&&(o="NDHWC");var s=xn(t,"x","maxPool3d"),u=s,c=!1;4===s.rank&&(c=!0,u=s.as5D(1,s.shape[0],s.shape[1],s.shape[2],s.shape[3])),null==a&&(a=[1,1,1]),_(5===u.rank,function(){return "Error in maxPool3d: x must be rank 5 but got rank "+u.rank+".";}),_("NDHWC"===o,function(){return "Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of "+o;}),_(Oo(n,a),function(){return "Error in maxPool3d: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+a+"'";}),null!=i&&_(I(r),function(){return "Error in maxPool3d: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+r+".";});var l=vo(u.shape,e,n,a,r,i,o),f=Wt.runKernelFunc(function(t,e){var n=t.maxPool3d(u,l);return e([u,n]),n;},{x:u},function(t,o){var s=o[0],u=o[1];return {x:function x(){return function(t,e,n,r,i,o,a,s){var u=xn(t,"dy","maxPool3dBackprop"),c=xn(e,"input","maxPool3dBackprop"),l=xn(n,"output","maxPool3dBackprop"),f=u,h=c,d=l,p=!1;4===c.rank&&(p=!0,f=u.as5D(1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]),h=c.as5D(1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]),d=l.as5D(1,l.shape[0],l.shape[1],l.shape[2],l.shape[3])),_(5===f.rank,function(){return "Error in maxPool3dBackprop: dy must be rank 5 but got rank "+f.rank+".";}),_(5===h.rank,function(){return "Error in maxPool3dBackprop: input must be rank 5 but got rank "+h.rank+".";}),_(5===d.rank,function(){return "Error in maxPool3dBackprop: output must be rank 5 but got rank "+d.rank+".";}),null==o&&(o=[1,1,1]),_(Oo(i,o),function(){return "Error in maxPool3dBackprop: Either strides or dilations must be 1. Got strides "+i+" and dilations '"+o+"'";}),null!=s&&_(I(a),function(){return "Error in maxPool3dBackprop: pad must be an integer when using, dimRoundingMode "+s+" but got pad "+a+".";});var m=vo(h.shape,r,i,o,a,s),g=Wt.runKernelFunc(function(t){return t.maxPool3dBackprop(f,h,d,m);},{dy5D:f,input5D:h});return p?g.as4D(g.shape[1],g.shape[2],g.shape[3],g.shape[4]):g;}(t,s,u,e,n,a,r,i);}};});return c?f.as4D(f.shape[1],f.shape[2],f.shape[3],f.shape[4]):f;}}),Ac=Nn({avgPool3d_:function avgPool3d_(t,e,n,r,i,o,a){void 0===o&&(o="NDHWC");var s=xn(t,"x","avgPool3d","float32"),u=s,c=!1;4===s.rank&&(c=!0,u=s.as5D(1,s.shape[0],s.shape[1],s.shape[2],s.shape[3])),null==a&&(a=[1,1,1]),_(5===u.rank,function(){return "Error in avgPool3d: x must be rank 5 but got rank "+u.rank+".";}),_("NDHWC"===o,function(){return "Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of "+o;}),_(Oo(n,a),function(){return "Error in avgPool3d: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+a+"'";}),null!=i&&_(I(r),function(){return "Error in avgPool3d: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+r+".";});var l=vo(u.shape,e,n,a,r,i,o),f=Wt.runKernelFunc(function(t){return t.avgPool3d(u,l);},{x:u},function(t){return {x:function x(){return function(t,e,n,r,i,o,a){var s=xn(t,"dy","avgPool3dBackprop"),u=xn(e,"input","avgPool3dBackprop"),c=s,l=u,f=!1;4===u.rank&&(f=!0,c=s.as5D(1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]),l=u.as5D(1,u.shape[0],u.shape[1],u.shape[2],u.shape[3])),_(5===c.rank,function(){return "Error in avgPool3dBackprop: dy must be rank 5 but got rank "+c.rank+".";}),_(5===l.rank,function(){return "Error in avgPool3dBackprop: input must be rank 5 but got rank "+l.rank+".";}),null==i&&(i=[1,1,1]),_(Oo(r,i),function(){return "Error in avgPool3dBackprop: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+i+"'";}),null!=a&&_(I(o),function(){return "Error in maxPool3dBackprop: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+o+".";});var h=vo(l.shape,n,r,i,o,a),d=Wt.runKernelFunc(function(t){return t.avgPool3dBackprop(c,l,h);},{dy5D:c,input5D:l});return f?d.as4D(d.shape[1],d.shape[2],d.shape[3],d.shape[4]):d;}(t,u,e,n,a,r,i);}};});return f=f.cast(u.dtype),c?f.as4D(f.shape[1],f.shape[2],f.shape[3],f.shape[4]):f;}}),Oc=Nn({maxPoolWithArgmax_:function maxPoolWithArgmax_(t,e,n,r,i){void 0===i&&(i=!1);var o=xn(t,"x","maxPoolWithArgmax"),a={filterSize:e,strides:n,pad:r,includeBatchInIndex:i},s=Wt.runKernel("MaxPoolWithArgmax",{x:o},a);return {result:s[0],indexes:s[1]};}}),_c=Nn({slice_:function slice_(t,e,n){var r,i,o=xn(t,"x","slice");if(0===o.rank)throw new Error("Slicing scalar is not possible");(r="number"==typeof e?[e].concat(new Array(o.rank-1).fill(0)):e.length<o.rank?e.concat(new Array(o.rank-e.length).fill(0)):e.slice()).forEach(function(t){_(-1!==t,function(){return "slice() does not support negative begin indexing.";});}),i=(i=null==n?new Array(o.rank).fill(-1):"number"==typeof n?[n].concat(new Array(o.rank-1).fill(-1)):n.length<o.rank?n.concat(new Array(o.rank-n.length).fill(-1)):n).map(function(t,e){return t>=0?t:(_(-1===t,function(){return "Negative size values should be exactly -1 but got "+t+" for the slice() size at index "+e+".";}),o.shape[e]-r[e]);}),Ki(o,r,i);var a=o.shape,s={begin:r,size:i};return Wt.runKernelFunc(function(t){return t.slice(o,r,i);},{x:o},function(t){for(var e=[],n=0;n<t.rank;n++){e.push([r[n],a[n]-r[n]-i[n]]);}return {x:function x(){return du(t,e);}};},"Slice",s);}}),Sc=Nn({slice1d_:function slice1d_(t,e,n){var r=xn(t,"x","slice1d");return _(1===r.rank,function(){return "slice1d expects a rank-1 tensor, but got a rank-"+r.rank+" tensor";}),_c(r,[e],[n]);}}),Dc=Nn({slice2d_:function slice2d_(t,e,n){var r=xn(t,"x","slice2d");return _(2===r.rank,function(){return "slice2d expects a rank-2 tensor, but got a rank-"+r.rank+" tensor";}),_c(r,e,n);}}),Fc=Nn({slice3d_:function slice3d_(t,e,n){var r=xn(t,"x","slice3d");return _(3===r.rank,function(){return "slice3d expects a rank-3 tensor, but got a rank-"+r.rank+" tensor";}),_c(r,e,n);}}),Tc=Nn({slice4d_:function slice4d_(t,e,n){var r=xn(t,"x","slice4d");return _(4===r.rank,function(){return "slice4d expects a rank-4 tensor, but got a rank-"+r.rank+" tensor";}),_c(r,e,n);}});function Nc(t,e,n,r,i){return e.rank<n.rank&&(e=e.reshape(An(e.shape,r))),t.rank<n.rank&&(t=t.reshape(An(t.shape,r))),{x:function x(){var r=t.mul(n.equal(e).cast(t.dtype));return null==i?r:r.transpose(i);}};}var Ic=Nn({all_:function all_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=xn(t,"x","all","bool"),i=L(e,r.shape),o=i,a=_n(o,r.rank);null!=a&&(r=r.transpose(a),o=Dn(o.length,r.rank));var s=Wt.runKernelFunc(function(t){return t.all(r,o);},{$x:r});if(n){var u=An(s.shape,i);return s.reshape(u);}return s;}}),Rc=Nn({any_:function any_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=xn(t,"x","any","bool"),i=L(e,r.shape),o=i,a=_n(o,r.rank);null!=a&&(r=r.transpose(a),o=Dn(o.length,r.rank));var s=Wt.runKernelFunc(function(t){return t.any(r,o);},{$x:r});if(n){var u=An(s.shape,i);return s.reshape(u);}return s;}}),Mc=Nn({argMax_:function argMax_(t,e){void 0===e&&(e=0);var n=xn(t,"x","argMax");null==e&&(e=0);var r=L(e,n.shape),i=_n(r,n.rank);null!=i&&(n=n.transpose(i),r=Dn(r.length,n.rank));var o={axis:r[0]},a=[n];return Wt.runKernelFunc(function(t,e){var i=t.argMax(n,r[0]);return e([n]),i;},{x:n},function(t,e){var n=e[0];return {x:function x(){return Qn(n);}};},"ArgMax",o,a);}}),jc=Nn({argMin_:function argMin_(t,e){void 0===e&&(e=0);var n=xn(t,"x","argMin");null==e&&(e=0);var r=L(e,n.shape),i=_n(r,n.rank);return null!=i&&(n=n.transpose(i),r=Dn(r.length,n.rank)),Wt.runKernelFunc(function(t,e){var i=t.argMin(n,r[0]);return e([n]),i;},{$x:n},function(t,e){var n=e[0];return {$x:function $x(){return Qn(n);}};});}}),Bc=Nn({logSumExp_:function logSumExp_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=xn(t,"x","logSumExp"),i=L(e,r.shape),o=r.max(i,!0),a=r.sub(o).exp().sum(i).log(),s=o.reshape(a.shape).add(a);if(n){var u=An(s.shape,i);return s.reshape(u);}return s;}}),Pc=Nn({max_:function max_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=xn(t,"x","max"),i=r,o=L(e,r.shape),a=o,s=_n(a,r.rank);null!=s&&(r=r.transpose(s),a=Dn(a.length,r.rank));var u=[r],c=Wt.runKernelFunc(function(t,e){var n=t.max(r,a);return e([i,n]),n;},{x:r},function(t,e){return Nc(t,e[1],e[0],o,s);},"Max",{axes:a},u,[!0]);if(n){var l=An(c.shape,o);c=c.reshape(l);}return c;}}),Lc=Nn({mean_:function mean_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=xn(t,"x","mean"),i=L(e,r.shape),o=T(Cn(r.shape,i)[1]);return so(function(t){var r=Pn(o);return {value:(r.dtype===t.dtype?t:t.cast(r.dtype)).div(r).sum(e,n),gradFunc:function gradFunc(e){var n=t.shape.slice();return i.forEach(function(t){n[t]=1;}),e.reshape(n).mul(Hn(t.shape,"float32")).div(o);}};})(r);}}),zc=Nn({min_:function min_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=xn(t,"x","min"),i=r,o=L(e,r.shape),a=o,s=_n(a,r.rank);null!=s&&(r=r.transpose(s),a=Dn(a.length,r.rank));var u=[r],c=Wt.runKernelFunc(function(t,e){var n=t.min(r,a);return e([i,n]),n;},{x:r},function(t,e){return Nc(t,e[1],e[0],o,s);},"Min",{axes:a},u,[!0]);if(n){var l=An(c.shape,o);c=c.reshape(l);}return c;}}),Uc=Nn({moments_:function moments_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=L(e,(t=xn(t,"x","moments")).shape),i=t.mean(r,n),o=i.shape;return n||(o=An(i.shape,r)),{mean:i,variance:t.toFloat().sub(i.reshape(o)).square().mean(r,n)};}}),Wc=Nn({sum_:function sum_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=xn(t,"x","sum");"bool"===r.dtype&&(r=r.toInt());var i=L(e,r.shape);return so(function(t){var e=_n(i,t.rank),r=i,o=t;null!=e&&(o=t.transpose(e),r=Dn(r.length,t.rank));var a=function a(e){var n=t.shape.slice();return i.forEach(function(t){n[t]=1;}),e.reshape(n).mul(Hn(t.shape,"float32"));},s={axes:r},u=Wt.runKernelFunc(function(t){return t.sum(o,r);},{x:o},function(t){return {x:function x(){return a(t);}};},"Sum",s);if(n){var c=An(u.shape,i);u=u.reshape(c);}return {value:u,gradFunc:a};})(r);}}),Vc=Nn({prod_:function prod_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=xn(t,"x","prod");"bool"===r.dtype&&(r=r.toInt());var i=L(e,r.shape),o=_n(i,r.rank),a=i,s=r;null!=o&&(s=r.transpose(o),a=Dn(a.length,r.rank));var u=Wt.runKernelFunc(function(t){return t.prod(s,a);},{permutedX:s});if(n){var c=An(u.shape,i);u=u.reshape(c);}return u;}}),qc=Nn({elu_:function elu_(t){var e=xn(t,"x","elu");return Wt.runKernelFunc(function(t,n){var r=t.elu(e);return n([r]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return Wt.runKernelFunc(function(e){return e.eluDer(t,n);},{dy:t,y:n});}};});}}),$c=Nn({leakyRelu_:function leakyRelu_(t,e){void 0===e&&(e=.2);var n=xn(t,"x","leakyRelu");return Oi(Pn(e).mul(n),n);}}),Hc=Nn({prelu_:function prelu_(t,e){var n=xn(t,"x","prelu"),r=xn(e,"alpha","prelu");return Wt.runKernelFunc(function(t,e){var i=t.prelu(n,r);return e([n,r]),i;},{x:n,alpha:r},function(t,e){var n=e[0],r=e[1],i=n.greater(0);return {x:function x(){return au(i,t,t.mul(r));},alpha:function alpha(){var e=au(i,Qn(t),t.mul(n)),o=zr(r.shape,t.shape);return o.length>0&&(e=e.sum(o)),e.reshape(r.shape);}};},"Prelu");}}),Gc=Nn({relu_:function relu_(t){var e=xn(t,"x","relu");return "bool"===e.dtype?e.toInt():Wt.runKernelFunc(function(t,n){var r=t.relu(e);return n([e]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return t.mulStrict(n.step().toFloat());}};},"Relu");}}),Kc=Nn({relu6_:function relu6_(t){var e=xn(t,"x","relu6");return "bool"===e.dtype?e.toInt():Wt.runKernelFunc(function(t,n){var r=t.relu6(e);return n([e]),r;},{x:e},function(t,e){var n=e[0],r=n.lessEqual(6).mul(n.step());return {x:function x(){return t.mulStrict(r.toFloat());}};},"Relu6");}}),Xc=Nn({selu_:function selu_(t){var e=xn(t,"x","selu");return Wt.runKernelFunc(function(t,n){var r=t.selu(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){var e=n.greater(Pn(0)),r=Pn(os),i=Pn(as),o=t.mul(i),a=t.mul(r).mul(n.toFloat().exp());return au(e,o,a);}};});}}),Yc=Nn({localResponseNormalization_:function localResponseNormalization_(t,e,n,r,i){void 0===e&&(e=5),void 0===n&&(n=1),void 0===r&&(r=1),void 0===i&&(i=.5);var o=xn(t,"x","localResponseNormalization");_(4===o.rank||3===o.rank,function(){return "Error in localResponseNormalization: x must be rank 3 or 4 but got\n               rank "+o.rank+".";}),_(I(e),function(){return "Error in localResponseNormalization: depthRadius must be an integer but got depthRadius "+e+".";});var a=o,s=!1;3===o.rank&&(s=!0,a=o.as4D(1,o.shape[0],o.shape[1],o.shape[2]));var u=Wt.runKernelFunc(function(t,o){var s=t.localResponseNormalization4D(a,e,n,r,i);return o([a,s]),s;},{x4D:a},function(t,o){var a=o[0],s=o[1];return {x4D:function x4D(){return Wt.runKernelFunc(function(o){return o.LRNGrad(t,a,s,e,n,r,i);},{});}};});return s?u.as3D(u.shape[1],u.shape[2],u.shape[3]):u;}}),Jc=Nn({norm_:function norm_(t,e,n,r){void 0===e&&(e="euclidean"),void 0===n&&(n=null),void 0===r&&(r=!1);var i=function t(e,n,r){if(void 0===r&&(r=null),0===e.rank)return e.abs();if(1!==e.rank&&null===r)return t(e.reshape([-1]),n,r);if(1===e.rank||"number"==typeof r||Array.isArray(r)&&1===r.length){if(1===n)return e.abs().sum(r);if(n===1/0)return e.abs().max(r);if(n===-1/0)return e.abs().min(r);if("euclidean"===n||2===n)return e.abs().pow(Pn(2,"int32")).sum(r).sqrt();throw new Error("Error in norm: invalid ord value: "+n);}if(Array.isArray(r)&&2===r.length){if(1===n)return e.abs().sum(r[0]).max(r[1]-1);if(n===1/0)return e.abs().sum(r[1]).max(r[0]);if(n===-1/0)return e.abs().sum(r[1]).min(r[0]);if("fro"===n||"euclidean"===n)return e.square().sum(r).sqrt();throw new Error("Error in norm: invalid ord value: "+n);}throw new Error("Error in norm: invalid axis: "+r);}(t=xn(t,"x","norm"),e,n),o=i.shape;if(r){var a=L(n,t.shape);o=An(i.shape,a);}return i.reshape(o);}}),Qc=Nn({basicLSTMCell_:function basicLSTMCell_(t,e,n,r,i,o){var a=xn(t,"forgetBias","basicLSTMCell"),s=xn(e,"lstmKernel","basicLSTMCell"),u=xn(n,"lstmBias","basicLSTMCell"),c=xn(r,"data","basicLSTMCell"),l=xn(i,"c","basicLSTMCell"),f=xn(o,"h","basicLSTMCell"),h=c.concat(f,1).matMul(s).add(u),d=h.shape[0],p=h.shape[1]/4,m=[d,p],g=h.slice([0,0],m),v=h.slice([0,p],m),y=h.slice([0,2*p],m),b=h.slice([0,3*p],m),x=g.sigmoid().mulStrict(v.tanh()).addStrict(l.mulStrict(a.add(y).sigmoid()));return [x,x.tanh().mulStrict(b.sigmoid())];}}),Zc=Nn({multiRNNCell_:function multiRNNCell_(t,e,n,r){for(var i=xn(e,"data","multiRNNCell"),o=wn(n,"c","multiRNNCell"),a=wn(r,"h","multiRNNCell"),s=i,u=[],c=0;c<t.length;c++){var l=t[c](s,o[c],a[c]);u.push(l[0]),u.push(l[1]),s=l[1];}var f=[],h=[];for(c=0;c<u.length;c+=2){f.push(u[c]),h.push(u[c+1]);}return [f,h];}}),tl=Nn({movingAverage_:function movingAverage_(t,e,n,r,i){void 0===i&&(i=!0);var o=xn(t,"v","movingAverage"),a=xn(e,"x","movingAverage"),s=xn(n,"decay","movingAverage");jt(o,a),_(N(o.shape,a.shape),function(){return "Shape mismatch in v and x";});var u=Pn(1),c=u.sub(s),l=a.sub(o).mul(c);if(i){_(null!=r,function(){return "When using zeroDebias: true, step is required.";});var f=xn(r,"step","movingAverage");l=l.div(u.sub(Ri(s,f)));}return o.add(l);}}),el=Nn({stridedSlice_:function stridedSlice_(t,e,n,r,i,o,a,s,u){if(void 0===i&&(i=0),void 0===o&&(o=0),void 0===a&&(a=0),void 0===s&&(s=0),void 0===u&&(u=0),null==r&&(r=new Array(e.length)),0!==a)throw new Error("ellipsis mask is not yet supported");var c=xn(t,"x","stridedSlice"),l=Xi(s),f=c.shape.slice();l.forEach(function(t){e[t]=0,n[t]=1,f.splice(t,0,1);}),c=c.reshape(f);for(var h=0;h<c.rank;h++){e[h]=Ji(i,e,r,c.shape,h),n[h]=Qi(o,n,r,c.shape,h),r[h]=r[h]||1;}var d=Xi(u);d.forEach(function(t){n[t]=e[t]+1,r[t]=1;});var p=Yi(e,n,r),m=p.filter(function(t,e){return -1===d.indexOf(e);});return r.every(function(t){return 1===t;})?_c(c,e,p).reshape(m):Wt.runKernelFunc(function(t){return t.stridedSlice(c,e,n,r);},{$x:c}).reshape(m);}}),nl=Nn({topk_:function topk_(t,e,n){void 0===e&&(e=1),void 0===n&&(n=!0);var r=xn(t,"x","topk");if(0===r.rank)throw new Error("topk() expects the input to be of rank 1 or higher");var i=r.shape[r.shape.length-1];if(e>i)throw new Error("'k' passed to topk() must be <= the last dimension ("+i+") but got "+e);var o=Wt.runKernelFunc(function(t){return t.topk(r,e,n);},{$x:r});return {values:o[0],indices:o[1]};}}),rl=Nn({scatterND_:function scatterND_(t,e,n){var r=xn(t,"indices","scatterND","int32"),i=xn(e,"updates","scatterND");return $i(i,r,n),Wt.runKernelFunc(function(t){return t.scatterND(r,i,n);},{indices:r,updates:i},null,"ScatterNd",{shape:n});}}),il=Nn({fft_:function fft_(t){_("complex64"===t.dtype,function(){return "The dtype for tf.spectral.fft() must be complex64 but got "+t.dtype+".";});var e=t.shape[t.shape.length-1],n=t.size/e,r=t.as2D(n,e);return Wt.runKernelFunc(function(t){return t.fft(r);},{input:t}).reshape(t.shape);}}),ol=Nn({ifft_:function ifft_(t){_("complex64"===t.dtype,function(){return "The dtype for tf.spectral.ifft() must be complex64 but got "+t.dtype+".";});var e=t.shape[t.shape.length-1],n=t.size/e,r=t.as2D(n,e);return Wt.runKernelFunc(function(t){return t.ifft(r);},{input:t}).reshape(t.shape);}}),al=Nn({rfft_:function rfft_(t,e){_("float32"===t.dtype,function(){return "The dtype for rfft() must be real value but got "+t.dtype;});var n,r=t.shape[t.shape.length-1],i=t.size/r;if(null!=e&&e<r){var o=t.shape.map(function(t){return 0;}),a=t.shape.map(function(t){return t;});a[t.shape.length-1]=e,n=t.slice(o,a),r=e;}else if(null!=e&&e>r){var s=t.shape.map(function(t){return t;});s[t.shape.length-1]=e-r,n=t.concat(Gn(s),t.shape.length-1),r=e;}else n=t;var u=n.zerosLike(),c=In(n,u).as2D(i,r),l=il(c),f=Math.floor(r/2)+1,h=Rn(l),d=Mn(l),p=h.split([f,r-f],h.shape.length-1),m=d.split([f,r-f],d.shape.length-1),g=n.shape.slice();return g[n.shape.length-1]=f,In(p[0],m[0]).reshape(g);}}),sl=Nn({irfft_:function irfft_(t){var e=t.shape[t.shape.length-1],n=t.size/e;if(e<=2){var r=t.as2D(n,e),i=ol(r);return Rn(i);}var o=[n,2*(e-1)],a=Rn(t).as2D(n,e),s=Mn(t).as2D(n,e),u=a.slice([0,1],[n,e-2]).reverse(1),c=s.slice([0,1],[n,e-2]).reverse(1).mul(Pn(-1)),l=a.concat(u,1),f=s.concat(c,1);return r=In(l,f).as2D(o[0],o[1]),i=ol(r),Rn(i);}}),ul=Object.freeze({fft:il,ifft:ol,rfft:al,irfft:sl}),cl=Nn({sparseToDense_:function sparseToDense_(t,e,n,r){void 0===r&&(r=0);var i=xn(t,"sparseIndices","sparseToDense","int32"),o=xn(e,"sparseValues","sparseToDense"),a=xn(r,"defaultValue","sparseToDense",o.dtype);return function(t,e,n,r){if("int32"!==t.dtype)throw new Error("tf.sparseToDense() expects the indices to be int32 type, but the dtype was "+t.dtype+".");if(t.rank>2)throw new Error("sparseIndices should be a scalar, vector, or matrix, but got shape "+t.shape+".");var i=t.rank>0?t.shape[0]:1,o=t.rank>1?t.shape[1]:1;if(n.length!==o)throw new Error("outputShape has incorrect number of elements:, "+n.length+", should be: "+o+".");var a=e.size;if(0!==e.rank&&(1!==e.rank||a!==i))throw new Error("sparseValues has incorrect shape "+e.shape+", should be [] or ["+i+"]");if(e.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype");}(i,o,n,a),Wt.runKernelFunc(function(t){return t.sparseToDense(i,o,n,a);},{$sparseIndices:i,$sparseValues:o,$defaultValue:a});}}),ll=Nn({gatherND_:function gatherND_(t,e){var n=xn(e,"indices","gatherND","int32"),r=xn(t,"x","gatherND");return Wt.runKernelFunc(function(t){return t.gatherND(r,n);},{x:r,indices:n},null,"GatherNd");}}),fl=Nn({diag_:function diag_(t){var e=xn(t,"x","diag").flatten(),n=t.shape.concat(t.shape);return Wt.runKernelFunc(function(t){return t.diag(e);},{$x:e}).reshape(n);}}),hl=Nn({dropout_:function dropout_(t,e,n,r){var i=xn(t,"x","dropout");if(_("float32"===i.dtype,function(){return "x has to be a floating point tensor since it's going to be scaled, but got a "+i.dtype+" tensor instead.";}),_(e>=0&&e<1,function(){return "rate must be a float in the range [0, 1), but got "+e+".";}),0===e)return t instanceof At?i.clone():i;var o=function(t,e){if(null==e)return t.shape.slice();if(N(t.shape,e))return e;if(t.shape.length===e.length){for(var n=[],r=0;r<t.shape.length;r++){null==e[r]&&null!=t.shape[r]?n.push(t.shape[r]):n.push(e[r]);}return n;}return e;}(i,n),a=1-e,s=Fu(o,0,1,"float32",r).add(a).floor().div(a);return i.mul(s);}});function dl(t,e,n){for(var r=1-t%2,i=new Float32Array(t),o=0;o<t;++o){var a=2*Math.PI*o/(t+r-1);i[o]=e-n*Math.cos(a);}return Ln(i,"float32");}var pl,ml=Nn({hannWindow_:function hannWindow_(t){return dl(t,.5,.5);}}),gl=Nn({hammingWindow_:function hammingWindow_(t){return dl(t,.54,.46);}}),vl=Nn({frame_:function frame_(t,e,n,r,i){void 0===r&&(r=!1),void 0===i&&(i=0);for(var o=0,a=[];o+e<=t.size;){a.push(_c(t,o,e)),o+=n;}if(r)for(;o<t.size;){var s=o+e-t.size,u=Zn([_c(t,o,e-s),Kn([s],i)]);a.push(u),o+=n;}return 0===a.length?zn([],[0,e]):Zn(a).as2D(a.length,e);}}),yl=Nn({stft_:function stft_(t,e,n,r,i){var o;void 0===i&&(i=ml),null==r&&(o=e,r=Math.floor(Math.pow(2,Math.ceil(Math.log(o)/Math.log(2)))));for(var a=vl(t,e,n),s=Ni(a,i(e)),u=[],c=0;c<a.shape[0];c++){u.push(al(s.slice([c,0],[1,e]),r));}return Zn(u);}}),bl=Object.freeze({hannWindow:ml,hammingWindow:gl,frame:vl,stft:yl}),xl=function xl(t,e,n){return void 0===n&&(n=1),u(this,void 0,void 0,function(){var r,i,o,a,s,u,l,f,h,d,p,m,g,v;return c(this,function(c){switch(c.label){case 0:return r=xn(t,"predictions","inTopK"),i=xn(e,"targets","inTopK"),_(r.rank>1,function(){return "inTopK() expects the predictions to be of rank 2 or higher, but got "+r.rank;}),_(r.rank-1===i.rank,function(){return "predictions rank should be 1 larger than targets rank, but got predictions rank "+r.rank+" and targets rank "+i.rank;}),S(r.shape.slice(0,r.shape.length-1),i.shape,"predictions's shape should be align with the targets' shape, except the last dimension."),o=r.shape[r.shape.length-1],_(n>0&&n<=o,function(){return "'k' passed to inTopK() must be > 0 && <= the predictions last dimension ("+o+"), but got "+n;}),[4,r.data()];case 1:return a=c.sent(),[4,i.data()];case 2:for(s=c.sent(),u=[a.length/o,o],f=u[1],h=U("bool",l=u[0]),d=0;d<l;d++){for(p=d*f,m=a.subarray(p,p+f),g=[],v=0;v<m.length;v++){g.push({value:m[v],index:v});}for(g.sort(function(t,e){return e.value-t.value;}),h[d]=0,v=0;v<n;v++){if(g[v].index===s[d]){h[d]=1;break;}}}return t!==r&&r.dispose(),e!==i&&i.dispose(),[2,jn(h,i.shape,"bool")];}});});};!function(t){t[t.NONE=0]="NONE",t[t.MEAN=1]="MEAN",t[t.SUM=2]="SUM",t[t.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS";}(pl||(pl={}));var wl=Nn({absoluteDifference_:function absoluteDifference_(t,e,n,r){void 0===r&&(r=pl.SUM_BY_NONZERO_WEIGHTS);var i=xn(t,"labels","absoluteDifference"),o=xn(e,"predictions","absoluteDifference"),a=null;null!=n&&(a=xn(n,"weights","absoluteDifference")),S(i.shape,o.shape,"Error in absoluteDifference: ");var s=i.sub(o).abs();return kl(s,a,r);}}),kl=Nn({computeWeightedLoss_:function computeWeightedLoss_(t,e,n){void 0===n&&(n=pl.SUM_BY_NONZERO_WEIGHTS);var r=xn(t,"losses","computeWeightedLoss"),i=null;null!=e&&(i=xn(e,"weights","computeWeightedLoss"));var o=null==i?r:r.mul(i);if(n===pl.NONE)return o;if(n===pl.SUM)return o.sum();if(n===pl.MEAN){if(null==i)return o.mean();var a=r.size/i.size,s=o.sum().div(i.sum());return a>1?s.div(Pn(a)):s;}if(n===pl.SUM_BY_NONZERO_WEIGHTS){if(null==i)return o.sum().div(Pn(r.size));var u=i.mul(Hn(r.shape)).notEqual(Pn(0)).sum().toFloat();return o.sum().div(u);}throw Error("Unknown reduction: "+n);}}),El=Nn({cosineDistance_:function cosineDistance_(t,e,n,r,i){void 0===i&&(i=pl.SUM_BY_NONZERO_WEIGHTS);var o=xn(t,"labels","cosineDistance"),a=xn(e,"predictions","cosineDistance"),s=null;null!=r&&(s=xn(r,"weights","cosineDistance")),S(o.shape,a.shape,"Error in cosineDistance: ");var u=Pn(1).sub(o.mul(a).sum(n,!0));return kl(u,s,i);}}),Cl=Nn({hingeLoss_:function hingeLoss_(t,e,n,r){void 0===r&&(r=pl.SUM_BY_NONZERO_WEIGHTS);var i=xn(t,"labels","hingeLoss"),o=xn(e,"predictions","hingeLoss"),a=null;null!=n&&(a=xn(n,"weights","hingeLoss")),S(i.shape,o.shape,"Error in hingeLoss: ");var s=Pn(1);i=Pn(2).mul(i).sub(s);var u=s.sub(i.mul(o)).relu();return kl(u,a,r);}}),Al=Nn({huberLoss_:function huberLoss_(t,e,n,r,i){void 0===r&&(r=1),void 0===i&&(i=pl.SUM_BY_NONZERO_WEIGHTS);var o=xn(t,"labels","huberLoss"),a=xn(e,"predictions","huberLoss"),s=null;null!=n&&(s=xn(n,"weights","huberLoss")),S(o.shape,a.shape,"Error in huberLoss: ");var u=Pn(r),c=a.sub(o).abs(),l=Si(c,u),f=c.sub(l),h=Pn(.5).mul(l.square()).add(u.mul(f));return kl(h,s,i);}}),Ol=Nn({logLoss_:function logLoss_(t,e,n,r,i){void 0===r&&(r=1e-7),void 0===i&&(i=pl.SUM_BY_NONZERO_WEIGHTS);var o=xn(t,"labels","logLoss"),a=xn(e,"predictions","logLoss"),s=null;null!=n&&(s=xn(n,"weights","logLoss")),S(o.shape,a.shape,"Error in logLoss: ");var u=Pn(1),c=Pn(r),l=o.mul(a.add(c).log()).neg().sub(u.sub(o).mul(u.sub(a).add(c).log()));return kl(l,s,i);}}),_l=Nn({meanSquaredError_:function meanSquaredError_(t,e,n,r){void 0===r&&(r=pl.SUM_BY_NONZERO_WEIGHTS);var i=xn(t,"labels","meanSquaredError"),o=xn(e,"predictions","meanSquaredError"),a=null;null!=n&&(a=xn(n,"weights","meanSquaredError")),S(i.shape,o.shape,"Error in meanSquaredError: ");var s=i.squaredDifference(o);return kl(s,a,r);}}),Sl=Nn({sigmoidCrossEntropy_:function sigmoidCrossEntropy_(t,e,n,r,i){void 0===r&&(r=0),void 0===i&&(i=pl.SUM_BY_NONZERO_WEIGHTS);var o=xn(t,"multiClassLabels","sigmoidCrossEntropy"),a=xn(e,"logits","sigmoidCrossEntropy"),s=null;if(null!=n&&(s=xn(n,"weights","sigmoidCrossEntropy")),S(o.shape,a.shape,"Error in sigmoidCrossEntropy: "),r>0){var u=Pn(r),c=Pn(1),l=Pn(.5);o=o.mul(c.sub(u)).add(l.mul(u));}var f=function(t,e){var n=xn(t,"labels","sigmoidCrossEntropyWithLogits"),r=xn(e,"logits","sigmoidCrossEntropyWithLogits");S(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");var i=r.relu(),o=r.mul(n),a=r.abs().neg().exp().log1p();return i.sub(o).add(a);}(o,a);return kl(f,s,i);}}),Dl=Nn({softmaxCrossEntropy_:function softmaxCrossEntropy_(t,e,n,r,i){void 0===r&&(r=0),void 0===i&&(i=pl.SUM_BY_NONZERO_WEIGHTS);var o=xn(t,"onehotLabels","softmaxCrossEntropy"),a=xn(e,"logits","softmaxCrossEntropy"),s=null;if(null!=n&&(s=xn(n,"weights","softmaxCrossEntropy")),S(o.shape,a.shape,"Error in softmaxCrossEntropy: "),r>0){var u=Pn(r),c=Pn(1),l=Pn(o.shape[1]);o=o.mul(c.sub(u)).add(u.div(l));}var f=function(t,e,n){if(void 0===n&&(n=-1),-1===n&&(n=e.rank-1),n!==e.rank-1)throw Error("Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank "+e.rank+" and dim was "+n);return so(function(t,e,r){var i=e.logSumExp([n],!0),o=e.toFloat().sub(i);return r([t,o]),{value:o.mul(t).neg().sum([n]),gradFunc:function gradFunc(t,e){var r=e[0],i=e[1],o=An(t.shape,[n]);return [t.reshape(o).mul(r.toFloat().sub(i.exp())),t.reshape(o).mul(i.exp().sub(r.toFloat()))];}};})(t,e);}(o,a);return kl(f,s,i);}}),Fl=Object.freeze({get Reduction(){return pl;},absoluteDifference:wl,computeWeightedLoss:kl,cosineDistance:El,hingeLoss:Cl,huberLoss:Al,logLoss:Ol,meanSquaredError:_l,sigmoidCrossEntropy:Sl,softmaxCrossEntropy:Dl});function Tl(t,e){return void 0===e&&(e=!1),Wt.tidy(function(){if(2!==t.shape.length)throw new Error("qr2d() requires a 2D Tensor, but got a "+t.shape.length+"D Tensor.");for(var n=t.shape[0],r=t.shape[1],i=lu(n),o=t.clone(),a=zn([[1]],[1,1]),s=a.clone(),u=n>=r?r:n,c=function c(t){var e,u=o,c=s,l=i;e=Wt.tidy(function(){var e=o.slice([t,t],[n-t,1]),u=e.norm(),c=o.slice([t,t],[1,1]),l=zn([[-1]]).where(c.greater(0),zn([[1]])),f=c.sub(l.mul(u)),h=e.div(f);s=1===h.shape[0]?a.clone():a.concat(h.slice([1,0],[h.shape[0]-1,h.shape[1]]),0);var d=l.matMul(f).div(u).neg(),p=o.slice([t,0],[n-t,r]),m=d.mul(s),g=s.transpose();if(0===t)o=p.sub(m.matMul(g.matMul(p)));else {var v=p.sub(m.matMul(g.matMul(p)));o=o.slice([0,0],[t,r]).concat(v,0);}var y=m.transpose(),b=i.slice([0,t],[n,i.shape[1]-t]);if(0===t)i=b.sub(b.matMul(s).matMul(y));else {var x=b.sub(b.matMul(s).matMul(y));i=i.slice([0,0],[n,t]).concat(x,1);}return [s,o,i];}),s=e[0],o=e[1],i=e[2],on([u,c,l]);},l=0;l<u;++l){c(l);}return !e&&n>r&&(i=i.slice([0,0],[n,r]),o=o.slice([0,0],[r,r])),[i,o];});}var Nl=Nn({bandPart_:function bandPart_(t,e,n){if(e%1!=0)throw new Error("bandPart(): numLower must be an integer, got "+e+".");if(n%1!=0)throw new Error("bandPart(): numUpper must be an integer, got "+n+".");var r=xn(t,"a","bandPart");if(r.rank<2)throw new Error("bandPart(): Rank must be at least 2, got "+r.rank+".");var i=r.shape,o=r.shape.slice(-2),a=o[0],s=o[1];if(!(e<=a))throw new Error("bandPart(): numLower ("+e+") must not be greater than the number of rows ("+a+").");if(!(n<=s))throw new Error("bandPart(): numUpper ("+n+") must not be greater than the number of columns ("+s+").");e<0&&(e=a),n<0&&(n=s);var u=Yn(0,a,1,"int32").reshape([-1,1]),c=Yn(0,s,1,"int32"),l=Bi(u,c),f=nu(l.lessEqual(Pn(+e,"int32")),l.greaterEqual(Pn(-n,"int32"))),h=Gn([a,s],r.dtype);return mr(gr(r.reshape([-1,a,s])).map(function(t){return au(f,t,h);})).reshape(i);}}),Il=Nn({gramSchmidt_:function gramSchmidt_(t){var e;if(Array.isArray(t)){e=!1,_(null!=t&&t.length>0,function(){return "Gram-Schmidt process: input must not be null, undefined, or empty";});for(var n=t[0].shape[0],r=function r(e){_(t[e].shape[0]===n,function(){return "Gram-Schmidt: Non-unique lengths found in the input vectors: ("+t[e].shape[0]+" vs. "+n+")";});},i=1;i<t.length;++i){r(i);}}else e=!0,t=ir(t,t.shape[0],0).map(function(t){return pr(t,[0]);});_(t.length<=t[0].shape[0],function(){return "Gram-Schmidt: Number of vectors ("+t.length+") exceeds number of dimensions ("+t[0].shape[0]+").";});var o=[],a=t,s=function s(t){o.push(Wt.tidy(function(){var e=a[t];if(t>0)for(var n=0;n<t;++n){var r=Wc(o[n].mulStrict(e)).mul(o[n]);e=e.sub(r);}return e.div(Jc(e,"euclidean"));}));};for(i=0;i<t.length;++i){s(i);}return e?mr(o,0):o;}}),Rl=Nn({qr_:function qr_(t,e){if(void 0===e&&(e=!1),t.rank<2)throw new Error("qr() requires input tensor to have a rank >= 2, but got rank "+t.rank);if(2===t.rank)return Tl(t,e);var n=t.shape.slice(0,t.shape.length-2).reduce(function(t,e){return t*e;}),r=[],i=[];return gr(t.reshape([n,t.shape[t.shape.length-2],t.shape[t.shape.length-1]]),0).forEach(function(t){var n=Tl(t,e),o=n[0],a=n[1];r.push(o),i.push(a);}),[mr(r,0).reshape(t.shape),mr(i,0).reshape(t.shape)];}}),Ml=Object.freeze({bandPart:Nl,gramSchmidt:Il,qr:Rl});function jl(t,e,n,r,i,o){null==r&&(r=.5),null==i&&(i=Number.NEGATIVE_INFINITY),null==o&&(o=0);var a=t.shape[0];return n=Math.min(n,a),_(0<=r&&r<=1,function(){return "iouThreshold must be in [0, 1], but was '"+r+"'";}),_(2===t.rank,function(){return "boxes must be a 2D tensor, but was of rank '"+t.rank+"'";}),_(4===t.shape[1],function(){return "boxes must have 4 columns, but 2nd dimension was "+t.shape[1];}),_(1===e.rank,function(){return "scores must be a 1D tensor";}),_(e.shape[0]===a,function(){return "scores has incompatible shape with boxes. Expected "+a+", but was "+e.shape[0];}),_(0<=o&&o<=1,function(){return "softNmsSigma must be in [0, 1], but was '"+o+"'";}),{maxOutputSize:n,iouThreshold:r,scoreThreshold:i,softNmsSigma:o};}var Bl=Nn({resizeBilinear_:function resizeBilinear_(t,e,n){void 0===n&&(n=!1);var r=xn(t,"images","resizeBilinear");_(3===r.rank||4===r.rank,function(){return "Error in resizeBilinear: x must be rank 3 or 4, but got rank "+r.rank+".";}),_(2===e.length,function(){return "Error in resizeBilinear: new shape must 2D, but got shape "+e+".";});var i=r,o=!1;3===r.rank&&(o=!0,i=r.as4D(1,r.shape[0],r.shape[1],r.shape[2]));var a=e[0],s=e[1],u=Wt.runKernelFunc(function(t,e){return e([i]),t.resizeBilinear(i,a,s,n);},{x:i},function(t,e){return {x:function x(){return Wt.runKernelFunc(function(r){return r.resizeBilinearBackprop(t,e[0],n);},{});}};},"ResizeBilinear",{alignCorners:n,newHeight:a,newWidth:s});return o?u.as3D(u.shape[1],u.shape[2],u.shape[3]):u;}}),Pl=Nn({resizeNearestNeighbor_:function resizeNearestNeighbor_(t,e,n){void 0===n&&(n=!1);var r=xn(t,"images","resizeNearestNeighbor");_(3===r.rank||4===r.rank,function(){return "Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank "+r.rank+".";}),_(2===e.length,function(){return "Error in resizeNearestNeighbor: new shape must 2D, but got shape "+e+".";}),_("float32"===r.dtype||"int32"===r.dtype,function(){return "`images` must have `int32` or `float32` as dtype";});var i=r,o=!1;3===r.rank&&(o=!0,i=r.as4D(1,r.shape[0],r.shape[1],r.shape[2]));var a=e[0],s=e[1],u=Wt.runKernelFunc(function(t,e){return e([i]),t.resizeNearestNeighbor(i,a,s,n);},{batchImages:i},function(t,e){return {batchImages:function batchImages(){return Wt.runKernelFunc(function(r){return r.resizeNearestNeighborBackprop(t,e[0],n);},{});}};});return o?u.as3D(u.shape[1],u.shape[2],u.shape[3]):u;}}),Ll=Nn({nonMaxSuppression_:function nonMaxSuppression_(t,e,n,r,i){void 0===r&&(r=.5),void 0===i&&(i=Number.NEGATIVE_INFINITY);var o=xn(t,"boxes","nonMaxSuppression"),a=xn(e,"scores","nonMaxSuppression"),s=jl(o,a,n,r,i);n=s.maxOutputSize,r=s.iouThreshold,i=s.scoreThreshold;var u={maxOutputSize:n,iouThreshold:r,scoreThreshold:i};return Wt.runKernelFunc(function(t){return t.nonMaxSuppression(o,a,n,r,i);},{boxes:o,scores:a},null,"NonMaxSuppressionV3",u);}}),zl=Nn({nonMaxSuppressionWithScore_:function nonMaxSuppressionWithScore_(t,e,n,r,i,o){void 0===r&&(r=.5),void 0===i&&(i=Number.NEGATIVE_INFINITY),void 0===o&&(o=0);var a=xn(t,"boxes","nonMaxSuppression"),s=xn(e,"scores","nonMaxSuppression"),u=jl(a,s,n,r,i,o),c={maxOutputSize:n=u.maxOutputSize,iouThreshold:r=u.iouThreshold,scoreThreshold:i=u.scoreThreshold,softNmsSigma:o=u.softNmsSigma},l=Wt.runKernel("NonMaxSuppressionV5",{boxes:a,scores:s},c);return {selectedIndices:l[0],selectedScores:l[1]};}}),Ul=Nn({cropAndResize_:function cropAndResize_(t,e,n,r,i,o){var a=xn(t,"image","cropAndResize"),s=xn(e,"boxes","cropAndResize","float32"),u=xn(n,"boxInd","cropAndResize","int32");i=i||"bilinear",o=o||0;var c=s.shape[0];return _(4===a.rank,function(){return "Error in cropAndResize: image must be rank 4,but got rank "+a.rank+".";}),_(2===s.rank&&4===s.shape[1],function(){return "Error in cropAndResize: boxes must be have size ["+c+",4] but had shape "+s.shape+".";}),_(1===u.rank&&u.shape[0]===c,function(){return "Error in cropAndResize: boxInd must be have size ["+c+"] but had shape "+s.shape+".";}),_(2===r.length,function(){return "Error in cropAndResize: cropSize must be of length 2, but got length "+r.length+".";}),_(r[0]>=1&&r[1]>=1,function(){return "cropSize must be atleast [1,1], but was "+r;}),_("bilinear"===i||"nearest"===i,function(){return "method must be bilinear or nearest, but was "+i;}),Wt.runKernelFunc(function(t,e){return t.cropAndResize(a,s,u,r,i,o);},{images:a,boxes:s,boxInd:u},null,"CropAndResize",{method:i,extrapolationValue:o,cropSize:r});}}),Wl=Object.freeze({resizeBilinear:Bl,resizeNearestNeighbor:Pl,nonMaxSuppression:Ll,nonMaxSuppressionAsync:function nonMaxSuppressionAsync(t,e,n,r,i){return void 0===r&&(r=.5),void 0===i&&(i=Number.NEGATIVE_INFINITY),u(this,void 0,void 0,function(){var o,a,s,u,l,f,h;return c(this,function(c){switch(c.label){case 0:return o=xn(t,"boxes","nonMaxSuppressionAsync"),a=xn(e,"scores","nonMaxSuppressionAsync"),s=jl(o,a,n,r,i),n=s.maxOutputSize,r=s.iouThreshold,i=s.scoreThreshold,[4,Promise.all([o.data(),a.data()])];case 1:return u=c.sent(),l=u[0],f=u[1],h=Po(l,f,n,r,i),o!==t&&o.dispose(),a!==e&&a.dispose(),[2,h];}});});},nonMaxSuppressionWithScore:zl,nonMaxSuppressionWithScoreAsync:function nonMaxSuppressionWithScoreAsync(t,e,n,r,i,o){return void 0===r&&(r=.5),void 0===i&&(i=Number.NEGATIVE_INFINITY),void 0===o&&(o=0),u(this,void 0,void 0,function(){var a,s,u,l,f,h,d;return c(this,function(c){switch(c.label){case 0:return a=xn(t,"boxes","nonMaxSuppressionAsync"),s=xn(e,"scores","nonMaxSuppressionAsync"),u=jl(a,s,n,r,i,o),n=u.maxOutputSize,r=u.iouThreshold,i=u.scoreThreshold,o=u.softNmsSigma,[4,Promise.all([a.data(),s.data()])];case 1:return l=c.sent(),f=l[0],h=l[1],d=Lo(f,h,n,r,i,o),a!==t&&a.dispose(),s!==e&&s.dispose(),[2,d];}});});},cropAndResize:Ul}),Vl=function Vl(t,e){return !(t>0)||"linear"===e;},ql=function ql(t,e,n){if(null==n||"linear"===n)return t;if("relu"===n)return t.mul(e.step());throw new Error("Gradient for activation "+n+" has not been implemented yet.");},$l=function $l(t,e){var n=e,r=zr(t.shape,e.shape);return r.length>0&&(n=n.sum(r)),n.reshape(t.shape);},Hl=function Hl(t,e,n){if("linear"===e)return t;if("relu"===e)return Gc(t);if("elu"===e)return qc(t);if("relu6"===e)return Kc(t);if("prelu"===e)return Hc(t,n);throw new Error("Unknown fused activation "+e+".");},Gl=Nn({fusedMatMul_:function fusedMatMul_(t){var e,n=t.a,r=t.b,i=t.transposeA,o=void 0!==i&&i,a=t.transposeB,s=void 0!==a&&a,u=t.bias,c=t.activation,l=void 0===c?"linear":c,f=t.preluActivationWeights;if(!1===Vl(Wt.state.gradientDepth,l)){var h=fc(n,r,o,s);return null!=u&&(h=Pr(h,u)),Hl(h,l,f);}var d=xn(n,"a","fused matMul"),p=xn(r,"b","fused matMul");e=Mt(d,p),d=e[0],p=e[1];var m=o?d.shape[d.rank-2]:d.shape[d.rank-1],g=s?p.shape[p.rank-1]:p.shape[p.rank-2],v=o?d.shape[d.rank-1]:d.shape[d.rank-2],y=s?p.shape[p.rank-2]:p.shape[p.rank-1],b=d.shape.slice(0,-2),x=p.shape.slice(0,-2),w=T(b),k=T(x);_(d.rank>=2&&p.rank>=2&&d.rank===p.rank,function(){return "Error in fused matMul: inputs must have the same rank of at least 2, got ranks "+d.rank+" and "+p.rank+".";}),_(N(b,x),function(){return "Error in fused matMul: outer dimensions ("+b+") and ("+x+") of Tensors with shapes "+d.shape+" and "+p.shape+" must match.";}),_(m===g,function(){return "Error in fused matMul: inner shapes ("+m+") and ("+g+") of Tensors with shapes "+d.shape+" and "+p.shape+" and transposeA="+o+" and transposeB="+s+" must match.";});var E,C,A=d.shape.slice(0,-2).concat([v,y]),O=o?d.as3D(w,m,v):d.as3D(w,v,m),S=s?p.as3D(k,y,g):p.as3D(k,g,y);null!=u&&Ur(A,(E=Mt(E=xn(u,"bias","fused matMul"),d)[0]).shape),null!=f&&(C=xn(f,"prelu weights","fused matMul"));var D={a:O,b:S};null!=u&&(D.bias=E),null!=f&&(D.preluActivationWeights=C);var F=[O,S];return Wt.runKernelFunc(function(t,e){var n=t.fusedBatchMatMul({a:O,b:S,transposeA:o,transposeB:s,bias:E,activation:l,preluActivationWeights:C});return e([O,S,n]),n;},D,function(t,e){var n=e[0],r=e[1],i=e[2],_a4=ql(t,i,l),c={};return null!=u&&(c={bias:function bias(){return $l(E,_a4);}}),o||s?!o&&s?Object.assign({a:function a(){return _a4.matMul(r,!1,!1);},b:function b(){return _a4.matMul(n,!0,!1);}},c):o&&!s?Object.assign({a:function a(){return r.matMul(_a4,!1,!0);},b:function b(){return n.matMul(_a4,!1,!1);}},c):Object.assign({a:function a(){return r.matMul(_a4,!0,!0);},b:function b(){return _a4.matMul(n,!0,!0);}},c):Object.assign({a:function a(){return _a4.matMul(r,!1,!0);},b:function b(){return n.matMul(_a4,!0,!1);}},c);},"_FusedMatMul",{transposeA:o,transposeB:s,activation:l},F,[!0]).reshape(A);}}),Kl=Nn({fusedConv2d_:function fusedConv2d_(t){var e=t.x,n=t.filter,r=t.strides,i=t.pad,o=t.dataFormat,a=void 0===o?"NHWC":o,s=t.dilations,u=void 0===s?[1,1]:s,c=t.dimRoundingMode,l=t.bias,f=t.activation,h=void 0===f?"linear":f,d=t.preluActivationWeights;if(h=h||"linear",!1===Vl(Wt.state.gradientDepth,h)){var p=ec(e,n,r,i,a,u,c);return null!=l&&(p=Pr(p,l)),Hl(p,h,d);}var m=xn(e,"x","conv2d"),g=xn(n,"filter","conv2d"),v=m,y=!1;3===m.rank&&(y=!0,v=m.as4D(1,m.shape[0],m.shape[1],m.shape[2])),_(4===v.rank,function(){return "Error in fused conv2d: input must be rank 4, but got rank "+v.rank+".";}),_(4===g.rank,function(){return "Error in fused conv2d: filter must be rank 4, but got rank "+g.rank+".";}),null!=c&&_(I(i),function(){return "Error in fused conv2d: pad must be an integer when using, dimRoundingMode "+c+" but got pad "+i+".";}),_(v.shape[3]===g.shape[2],function(){return "Error in conv2d: depth of input ("+v.shape[3]+") must match input depth for filter "+g.shape[2]+".";}),_(Oo(r,u),function(){return "Error in conv2D: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+u+"'";}),_("NHWC"===a,function(){return "Error in conv2d: got dataFormat of "+a+" but only NHWC is currently supported.";});var b,x,w=yo(v.shape,g.shape,r,u,i,c);null!=l&&(b=Mt(b=xn(l,"bias","fused conv2d"),m)[0],Ur(w.outShape,b.shape)),null!=d&&(x=xn(d,"prelu weights","fused conv2d"));var k={x:v,filter:g};null!=l&&(k.bias=b),null!=d&&(k.preluActivationWeights=x);var E=[g,v],C=Wt.runKernelFunc(function(t,e){var n=t.fusedConv2d({input:v,filter:g,convInfo:w,bias:b,activation:h,preluActivationWeights:x});return e([g,v,n]),n;},k,function(t,e){var n=e,o=n[0],a=n[1],s=n[2],c=ql(t,s,h);_(Ao(u),function(){return "Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+u+"'";});var f={};return null!=l&&(f={bias:function bias(){return $l(b,c);}}),Object.assign({x:function x(){return ic(a.shape,c,o,r,i);},filter:function filter(){return rc(a,c,o.shape,r,i);}},f);},"FusedConv2D",{convInfo:w,activation:h},E,[!0]);return y?C.as3D(C.shape[1],C.shape[2],C.shape[3]):C;}}),Xl=Nn({fusedDepthwiseConv2d_:function fusedDepthwiseConv2d_(t){var e=t.x,n=t.filter,r=t.strides,i=t.pad,o=t.dataFormat,a=void 0===o?"NHWC":o,s=t.dilations,u=void 0===s?[1,1]:s,c=t.dimRoundingMode,l=t.bias,f=t.activation,h=void 0===f?"linear":f,d=t.preluActivationWeights;if(!1===Vl(Wt.state.gradientDepth,h)){var p=oc(e,n,r,i,a,u,c);return null!=l&&(p=Pr(p,l)),Hl(p,h,d);}var m=xn(e,"x","depthwiseConv2d"),g=xn(n,"filter","depthwiseConv2d"),v=m,y=!1;3===m.rank&&(y=!0,v=m.as4D(1,m.shape[0],m.shape[1],m.shape[2])),_(4===v.rank,function(){return "Error in fused depthwiseConv2d: input must be rank 4, but got rank "+v.rank+".";}),_(4===g.rank,function(){return "Error in fused depthwiseConv2d: filter must be rank 4, but got rank "+g.rank+".";}),_(v.shape[3]===g.shape[2],function(){return "Error in fused depthwiseConv2d: number of input channels ("+v.shape[3]+") must match the inChannels dimension in filter "+g.shape[2]+".";}),null==u&&(u=[1,1]),_(Oo(r,u),function(){return "Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+u+"'";}),null!=c&&_(I(i),function(){return "Error in fused depthwiseConv2d: pad must be an integer when using dimRoundingMode "+c+" but got pad "+i+".";});var b,x,w=yo(v.shape,g.shape,r,u,i,c,!0);null!=l&&(b=Mt(b=xn(l,"bias","fused conv2d"),m)[0],Ur(w.outShape,b.shape)),null!=d&&(x=xn(d,"prelu weights","fused depthwiseConv2d"));var k={x:v,filter:g};null!=l&&(k.bias=b),null!=d&&(k.preluActivationWeights=x);var E=[g,v],C=Wt.runKernelFunc(function(t,e){var n=t.fusedDepthwiseConv2D({input:v,filter:g,convInfo:w,bias:b,activation:h,preluActivationWeights:x});return e([g,v,n]),n;},k,function(t,e){_(Ao(u),function(){return "Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '"+u+"'";});var n=e[0],r=e[1],i=e[2],o=ql(t,i,h),a={};return null!=l&&(a={bias:function bias(){return $l(b,o);}}),Object.assign({x:function x(){return ac(r.shape,o,n,w);},filter:function filter(){return sc(r,o,n.shape,w);}},a);},"FusedDepthwiseConv2D",{convInfo:w,activation:h},E,[!0]);return y?C.as3D(C.shape[1],C.shape[2],C.shape[3]):C;}}),Yl=Object.freeze({matMul:Gl,conv2d:Kl,depthwiseConv2d:Xl}),Jl=Object.freeze({image:Wl,linalg:Ml,losses:Fl,spectral:ul,fused:Yl,signal:bl,add:Pr,addN:Ps,batchNorm:qs,batchNormalization:Vs,batchNorm2d:Gs,batchNormalization2d:Hs,batchNorm3d:Ys,batchNormalization3d:Xs,batchNorm4d:Zs,batchNormalization4d:Qs,broadcastTo:tu,clone:eu,div:Li,divNoNan:uu,eye:lu,multinomial:fu,oneHot:hu,pad:du,pad1d:pu,pad2d:mu,pad3d:gu,pad4d:vu,rand:yu,randomGamma:Su,randomNormal:Du,randomUniform:Fu,square:Tu,squaredDifference:Nu,tile:cu,truncatedNormal:Iu,conv1d:tc,conv2d:ec,conv3d:nc,depthwiseConv2d:oc,separableConv2d:uc,conv2dTranspose:cc,conv3dTranspose:lc,op:Nn,booleanMaskAsync:Yu,complex:In,real:Rn,imag:Mn,concat:Zn,concat1d:tr,concat2d:er,concat3d:nr,concat4d:rr,split:ir,matMul:fc,dot:hc,outerProduct:dc,reverse:pc,reverse1d:mc,reverse2d:gc,reverse3d:vc,reverse4d:yc,maxPool:wc,avgPool:kc,pool:Ec,maxPool3d:Cc,avgPool3d:Ac,maxPoolWithArgmax:Oc,slice:_c,slice1d:Sc,slice2d:Dc,slice3d:Fc,slice4d:Tc,abs:Wr,acos:Vr,acosh:qr,asin:$r,asinh:Hr,atan:Gr,atanh:Kr,ceil:Xr,clipByValue:Yr,cos:Jr,cosh:Qr,erf:Zr,exp:ti,expm1:ei,floor:ni,log:ri,log1p:ii,logSigmoid:oi,neg:ai,reciprocal:si,round:ui,rsqrt:ci,sigmoid:li,sign:fi,isNaN:hi,isInf:di,isFinite:pi,sin:mi,sinh:gi,softplus:vi,sqrt:yi,step:bi,tan:xi,tanh:wi,all:Ic,any:Rc,argMax:Mc,argMin:jc,logSumExp:Bc,max:Pc,mean:Lc,min:zc,moments:Uc,sum:Wc,prod:Vc,equal:Ru,equalStrict:Mu,greater:ju,greaterEqual:Bu,greaterEqualStrict:Pu,greaterStrict:Lu,less:zu,lessEqual:Uu,lessEqualStrict:Wu,lessStrict:Vu,notEqual:qu,notEqualStrict:$u,addStrict:ki,atan2:Ei,divStrict:Ci,floorDiv:Ai,maximum:Oi,maximumStrict:_i,minimum:Si,minimumStrict:Di,mod:Fi,modStrict:Ti,mul:Ni,mulStrict:Ii,pow:Ri,powStrict:Mi,squaredDifferenceStrict:ji,sub:Bi,subStrict:Pi,elu:qc,leakyRelu:$c,prelu:Hc,relu:Gc,relu6:Kc,selu:Xc,logicalAnd:nu,logicalNot:ru,logicalOr:iu,logicalXor:ou,where:au,whereAsync:su,buffer:or,print:ar,batchToSpaceND:sr,cast:ur,cumsum:cr,depthToSpace:lr,expandDims:fr,reshape:hr,spaceToBatchND:dr,squeeze:pr,stack:mr,unstack:gr,setdiff1dAsync:vr,fill:Kn,linspace:Xn,ones:Hn,range:Yn,scalar:Pn,tensor:jn,tensor1d:Ln,tensor2d:zn,tensor3d:Un,tensor4d:Wn,tensor5d:Vn,tensor6d:qn,variable:$n,zeros:Gn,onesLike:Jn,zerosLike:Qn,transpose:fo,softmax:co,logSoftmax:lo,localResponseNormalization:Yc,norm:Jc,gather:Ku,unsortedSegmentSum:Xu,basicLSTMCell:Qc,multiRNNCell:Zc,movingAverage:tl,stridedSlice:el,topk:nl,scatterND:rl,fft:il,ifft:ol,rfft:al,irfft:sl,sparseToDense:cl,gatherND:ll,diag:fl,dropout:hl,hannWindow:ml,hammingWindow:gl,frame:vl,stft:yl,inTopKAsync:xl});function Ql(t,e){Array.isArray(t)||(t=[t]),t.forEach(function(t){null!=t&&_("complex64"!==t.dtype,function(){return e+" does not support complex64 tensors.";});});}function Zl(t,e,n,r,i,o){for(var a=i.strideHeight,s=i.strideWidth,u=i.dilationHeight,c=i.dilationWidth,l=i.effectiveFilterHeight,f=i.effectiveFilterWidth,h=i.padInfo.top,d=i.padInfo.left,p="max"===o?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,m=or(i.outShape,n),g=m.values,v=i.outShape[1]*i.outShape[2]*i.outShape[3],y=i.outShape[2]*i.outShape[3],b=i.outShape[3],x=0;x<i.batchSize;++x){for(var w=x*v,k=x*r[0],E=0;E<i.inChannels;++E){for(var C=0;C<i.outHeight;++C){for(var A=C*a-h,O=Math.max(0,A),_=Math.min(i.inHeight,l+A),S=w+C*y,D=0;D<i.outWidth;++D){for(var F=D*s-d,T=Math.max(0,F),N=Math.min(i.inWidth,f+F),I=p,R=0,M=0,j=O;j<_;j+=u){for(var B=k+j*r[1],P=T;P<N;P+=c){var L=t[B+P*r[2]+E];"max"===o&&L>I?I=L:"avg"===o&&(R+=L,M++);}if(isNaN(I))break;}g[S+D*b+E]="avg"===o?R/M:I;}}}}return m;}function tf(t,e,n,r,i,o){void 0===i&&(i=!1),void 0===o&&(o=!1);for(var a=or(r.outShape,"int32"),s=r.strideHeight,u=r.strideWidth,c=r.dilationHeight,l=r.dilationWidth,f=r.effectiveFilterHeight,h=r.effectiveFilterWidth,d=r.padInfo.top,p=r.padInfo.left,m=or(e,n,t),g=0;g<r.batchSize;++g){for(var v=0;v<r.inChannels;++v){for(var y=0;y<r.outHeight;++y){for(var b=y*s-d,x=b;x<0;){x+=c;}for(var w=Math.min(r.inHeight,f+b),k=0;k<r.outWidth;++k){for(var E=k*u-p,C=E;C<0;){C+=l;}for(var A=Math.min(r.inWidth,h+E),O=Number.NEGATIVE_INFINITY,_=-1,S=x;S<w;S+=c){for(var D=S-b,F=C;F<A;F+=l){var T=F-E,N=m.get(g,S,F,v);N>O&&(O=N,_=i?o?((g*r.inHeight+S)*r.inWidth+F)*r.inChannels+v:(S*r.inWidth+F)*r.inChannels+v:D*h+T);}}a.set(_,g,y,k,v);}}}}return a;}function ef(t,e,n,r){if("linear"===n)return t.linear(e);if("relu"===n)return t.relu(e);if("elu"===n)return t.elu(e);if("relu6"===n)return t.relu6(e);if("prelu"===n)return t.prelu(e,r);throw new Error("Activation "+n+" has not been implemented for the CPU backend.");}var nf=function(t){function e(){var e=t.call(this)||this;return e.blockSize=48,e.firstUse=!0,e.data=new ho(e,Wt),e;}return s(e,t),e.prototype.write=function(t,e,n){this.firstUse&&(this.firstUse=!1,f().get("IS_NODE")&&vn("\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============================"));var r={};return this.data.set(r,{values:t,dtype:n}),r;},e.prototype.move=function(t,e,n,r){this.data.set(t,{values:e,dtype:r});},e.prototype.numDataIds=function(){return this.data.numDataIds();},e.prototype.read=function(t){return u(this,void 0,void 0,function(){return c(this,function(e){return [2,this.readSync(t)];});});},e.prototype.readSync=function(t){var e=this.data.get(t),n=e.dtype,r=e.complexTensors;return "complex64"===n?No(this.readSync(r.real.dataId),this.readSync(r.imag.dataId)):this.data.get(t).values;},e.prototype.bufferSync=function(t){var e=this.readSync(t.dataId),n=e;if("string"===t.dtype)try{n=e.map(function(t){return ct(t);});}catch(t){throw new Error("Failed to decode encoded string bytes into utf-8");}return or(t.shape,t.dtype,n);},e.prototype.makeOutput=function(t,e,n){var r=this.write(t,e,n);return Wt.makeTensorFromDataId(r,e,n,this);},e.prototype.disposeData=function(t){if(this.data.has(t)){var e=this.data.get(t).complexTensors;null!=e&&(e.real.dispose(),e.imag.dispose()),this.data.delete(t);}},e.prototype.time=function(t){return u(this,void 0,void 0,function(){var e;return c(this,function(n){return e=at(),t(),[2,{kernelMs:at()-e}];});});},e.prototype.memory=function(){return {unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]};},e.prototype.complex=function(t,e){var n=this.makeOutput(null,t.shape,"complex64");return this.data.get(n.dataId).complexTensors={real:Wt.keep(t.clone()),imag:Wt.keep(e.clone())},n;},e.prototype.real=function(t){return this.data.get(t.dataId).complexTensors.real.clone();},e.prototype.imag=function(t){return this.data.get(t.dataId).complexTensors.imag.clone();},e.prototype.slice=function(t,e,n){if(Ql(t,"slice"),Zi(t.shape,e,n)){var r=to(e,t.strides),i=T(n);return jn(this.readSync(t.dataId).subarray(r,r+i),n,t.dtype);}for(var o=or(n,t.dtype),a=this.bufferSync(t),s=0;s<o.size;++s){var u=o.indexToLoc(s).map(function(t,n){return t+e[n];});o.values[s]=a.get.apply(a,u);}return o.toTensor();},e.prototype.stridedSlice=function(t,e,n,r){Ql(t,"stridedSlice");var i=Yi(e,n,r);if(i.some(function(t){return 0===t;}))return jn([],i);for(var o=or(i,t.dtype),a=this.bufferSync(t),s=0;s<o.size;s++){for(var u=o.indexToLoc(s),c=new Array(u.length),l=0;l<c.length;l++){c[l]=u[l]*r[l]+e[l];}o.set.apply(o,[a.get.apply(a,c)].concat(u));}return o.toTensor();},e.prototype.diag=function(t){for(var e=this.readSync(t.dataId),n=or([t.size,t.size],t.dtype),r=n.values,i=0;i<e.length;i++){r[i*t.size+i]=e[i];}return n.toTensor();},e.prototype.unstack=function(t,e){for(var n=t.shape[e],r=new Array(t.rank-1),i=0,o=0;o<t.rank;o++){o!==e&&(r[i++]=t.shape[o]);}var a=new Array(t.rank).fill(0),s=t.shape.slice();s[e]=1;var u=new Array(n);for(o=0;o<u.length;o++){a[e]=o,u[o]=this.slice(t,a,s).reshape(r);}return u;},e.prototype.reverse=function(t,e){Ql(t,"reverse");for(var n=or(t.shape,t.dtype),r=this.bufferSync(t),i=function i(_i2){var o=n.indexToLoc(_i2),a=o.slice();e.forEach(function(e){return a[e]=t.shape[e]-1-a[e];}),n.set.apply(n,[r.get.apply(r,a)].concat(o));},o=0;o<n.size;o++){i(o);}return n.toTensor();},e.prototype.concat=function(t,e){var n=this;if("complex64"===t[0].dtype){var r=t.map(function(t){return Rn(t);}),i=t.map(function(t){return Mn(t);});return In(this.concat(r,e),this.concat(i,e));}var o=t.map(function(t){var n=T(t.shape.slice(e));return t.as2D(-1,n);}),a=Tn(o.map(function(t){return t.shape;}),1),s=or(a,t[0].dtype).values;if(1===o[0].shape[0]){var u=0;o.forEach(function(t){s.set(n.readSync(t.dataId),u),u+=t.size;});}else {var c=0;o.forEach(function(t){for(var e=n.readSync(t.dataId),r=0,i=0;i<t.shape[0];++i){for(var o=i*a[1]+c,u=0;u<t.shape[1];++u){s[o+u]=e[r++];}}c+=t.shape[1];});}var l=Tn(t.map(function(t){return t.shape;}),e);return jn(s,l,t[0].dtype);},e.prototype.neg=function(t){return Ql(t,"neg"),this.multiply(Pn(-1),t);},e.prototype.add=function(t,e){return "complex64"===t.dtype||"complex64"===e.dtype?this.broadcastedBinaryComplexOp(t.cast("complex64"),e.cast("complex64"),function(t,e,n,r){return {real:t+n,imag:e+r};}):this.broadcastedBinaryOp(t,e,It(t.dtype,e.dtype),function(t,e){return t+e;});},e.prototype.addN=function(t){var e=this;Ql(t,"addN");for(var n=t.map(function(t){return e.readSync(t.dataId);}),r=or(t[0].shape,t[0].dtype),i=r.values,o=0;o<t.length;o++){for(var a=n[o],s=0;s<i.length;s++){i[s]+=a[s];}}return r.toTensor();},e.prototype.softmax=function(t,e){var n=L([e],t.shape),r=this.max(t,n),i=An(r.shape,n),o=this.subtract(t,r.reshape(i)),a=this.exp(o),s=this.sum(a,n).reshape(i);return Li(a,s);},e.prototype.subtract=function(t,e){return "complex64"===t.dtype||"complex64"===e.dtype?this.broadcastedBinaryComplexOp(t.cast("complex64"),e.cast("complex64"),function(t,e,n,r){return {real:t-n,imag:e-r};}):this.broadcastedBinaryOp(t,e,It(t.dtype,e.dtype),function(t,e){return t-e;});},e.prototype.pow=function(t,e){return Ql([t,e],"pow"),this.broadcastedBinaryOp(t,e,t.dtype,function(t,e){return Math.pow(t,e);});},e.prototype.batchMatMul=function(t,e,n,r){Ql([t,e],"matMul");for(var i=n?t.shape[1]:t.shape[2],o=n?t.shape[2]:t.shape[1],a=r?e.shape[1]:e.shape[2],s=t.shape[0],u=this.readSync(t.dataId),c=this.readSync(e.dataId),l=n?[t.strides[0],1,t.strides[1]]:[t.strides[0],t.strides[1],1],f=l[0],h=l[1],d=l[2],p=r?[1,e.strides[1],e.strides[0]]:[e.strides[1],1,e.strides[0]],m=p[0],g=p[1],v=p[2],y=o*a,b=or([s,o,a],t.dtype),x=b.values,w=this.blockSize,k=0;k<s;k++){for(var E=0;E<o;E+=w){for(var C=0;C<a;C+=w){for(var A=0;A<i;A+=w){for(var O=Math.min(E+w,o),_=Math.min(C+w,a),S=Math.min(A+w,i),D=E;D<O;D++){for(var F=C;F<_;F++){for(var T=0,N=A;N<S;N++){T+=u[k*f+D*h+N*d]*c[N*m+F*g+k*v];}x[k*y+(D*a+F)]+=T;}}}}}}return b.toTensor();},e.prototype.fusedBatchMatMul=function(t){var e=t.a,n=t.b,r=t.transposeA,i=t.transposeB,o=t.bias,a=t.activation,s=t.preluActivationWeights,u=this.batchMatMul(e,n,r,i);return o&&(u=this.add(u,o)),a&&(u=ef(this,u,a,s)),u;},e.prototype.multiply=function(t,e){return "complex64"===t.dtype||"complex64"===e.dtype?this.broadcastedBinaryComplexOp(t.cast("complex64"),e.cast("complex64"),function(t,e,n,r){return {real:t*n-e*r,imag:t*r+e*n};}):this.broadcastedBinaryOp(t,e,It(t.dtype,e.dtype),function(t,e){return t*e;});},e.prototype.floorDiv=function(t,e){return Ql([t,e],"floorDiv"),this.broadcastedBinaryOp(t,e,"int32",function(t,e){return Math.floor(t/e);});},e.prototype.sum=function(t,e){Ql(t,"sum"),On("sum",e,t.rank);for(var n=Cn(t.shape,e),r=n[0],i=n[1],o=Gn(r,It(t.dtype,"int32")),a=T(i),s=this.readSync(o.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*a,f=0,h=0;h<a;++h){f+=u[l+h];}s[c]=f;}return o;},e.prototype.prod=function(t,e){Ql(t,"sum");for(var n=Cn(t.shape,e),r=n[0],i=n[1],o=Gn(r,It(t.dtype,"int32")),a=T(i),s=this.readSync(o.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*a,f=1,h=0;h<a;++h){f*=u[l+h];}s[c]=f;}return o;},e.prototype.unsortedSegmentSum=function(t,e,n){Ql(t,"unsortedSegmentSum");for(var r=[],i=t.rank-e.rank,o=0;o<i;++o){e=e.expandDims(o+1);}for(o=0;o<n;++o){var a=Pn(o,"int32"),s=Ru(a,e).asType("float32").mul(t).sum(0);r.push(s);}return mr(r);},e.prototype.argMin=function(t,e){Ql(t,"argMin");var n=[e];On("argMin",n,t.rank);for(var r=Cn(t.shape,n),i=r[0],o=r[1],a=Gn(i,"int32"),s=T(o),u=this.readSync(a.dataId),c=this.readSync(t.dataId),l=0;l<u.length;++l){for(var f=l*s,h=c[f],d=0,p=0;p<s;++p){var m=c[f+p];m<h&&(h=m,d=p);}u[l]=d;}return a;},e.prototype.argMax=function(t,e){Ql(t,"argMax");var n=[e];On("argMax",n,t.rank);for(var r=Cn(t.shape,n),i=r[0],o=r[1],a=Gn(i,"int32"),s=T(o),u=this.readSync(a.dataId),c=this.readSync(t.dataId),l=0;l<u.length;++l){for(var f=l*s,h=c[f],d=0,p=0;p<s;++p){var m=c[f+p];m>h&&(h=m,d=p);}u[l]=d;}return a;},e.prototype.cumsum=function(t,e,n,r){if(Ql(t,"cumsum"),e!==t.rank-1)throw new Error("backend.cumsum in CPU expects an inner-most axis="+(t.rank-1)+" but got axis="+e);for(var i=It(t.dtype,"int32"),o=Gn(t.shape,i),a=this.readSync(o.dataId),s=this.readSync(t.dataId),u=t.shape[t.rank-1],c=r?function(t,e){return t+u-e-1;}:function(t,e){return t+e;},l=0;l<s.length;l+=u){for(var f=0;f<u;f++){var h=c(l,f);if(0===f)a[h]=n?0:s[h];else {var d=c(l,f-1);a[h]=n?s[d]+a[d]:s[h]+a[d];}}}return o;},e.prototype.equal=function(t,e){return Ql([t,e],"equal"),this.broadcastedBinaryOp(t,e,"bool",function(t,e){return t===e?1:0;});},e.prototype.notEqual=function(t,e){return Ql([t,e],"notEqual"),this.broadcastedBinaryOp(t,e,"bool",function(t,e){return t!==e?1:0;});},e.prototype.less=function(t,e){return Ql([t,e],"less"),this.broadcastedBinaryOp(t,e,"bool",function(t,e){return t<e?1:0;});},e.prototype.lessEqual=function(t,e){return Ql([t,e],"lessEqual"),this.broadcastedBinaryOp(t,e,"bool",function(t,e){return t<=e?1:0;});},e.prototype.greater=function(t,e){return Ql([t,e],"greater"),this.broadcastedBinaryOp(t,e,"bool",function(t,e){return t>e?1:0;});},e.prototype.greaterEqual=function(t,e){return Ql([t,e],"greaterEqual"),this.broadcastedBinaryOp(t,e,"bool",function(t,e){return t>=e?1:0;});},e.prototype.logicalNot=function(t){Ql(t,"logicalNot");for(var e=this.readSync(t.dataId),n=new Uint8Array(e.length),r=0;r<e.length;++r){n[r]=e[r]?0:1;}return this.makeOutput(n,t.shape,"bool");},e.prototype.logicalAnd=function(t,e){return Ql([t,e],"logicalAnd"),this.broadcastedBinaryOp(t,e,"bool",function(t,e){return t&&e;});},e.prototype.logicalOr=function(t,e){return Ql([t,e],"logicalOr"),this.broadcastedBinaryOp(t,e,"bool",function(t,e){return t||e;});},e.prototype.select=function(t,e,n){Ql([t,e,n],"select");for(var r=this.readSync(t.dataId),i=this.readSync(e.dataId),o=this.readSync(n.dataId),a=Gn(e.shape,It(e.dtype,n.dtype)),s=this.readSync(a.dataId),u=0,c=0===t.rank||t.rank>1||1===e.rank?1:T(e.shape.slice(1)),l=0;l<r.length;l++){for(var f=0;f<c;f++){1===r[l]?s[u++]=i[l]:s[u++]=o[l];}}return a;},e.prototype.where=function(t){Ql([t],"where");var e=this.readSync(t.dataId);return Go(t.shape,e);},e.prototype.topk=function(t,e,n){return Ql(t,"topk"),Ho(this.readSync(t.dataId),t.shape,t.dtype,e);},e.prototype.min=function(t,e){Ql(t,"min"),On("min",e,t.rank);for(var n=Cn(t.shape,e),r=n[0],i=n[1],o=Gn(r,t.dtype),a=T(i),s=this.readSync(o.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*a,f=u[l],h=0;h<a;++h){var d=u[l+h];d<f&&(f=d);}s[c]=f;}return o;},e.prototype.minimum=function(t,e){return Ql([t,e],"minimum"),this.broadcastedBinaryOp(t,e,t.dtype,function(t,e){return Math.min(t,e);});},e.prototype.mod=function(t,e){return Ql([t,e],"mod"),this.broadcastedBinaryOp(t,e,t.dtype,function(t,e){var n=t%e;return t<0&&e<0||t>=0&&e>=0?n:(n+e)%e;});},e.prototype.max=function(t,e){Ql(t,"max"),On("max",e,t.rank);for(var n=Cn(t.shape,e),r=n[0],i=n[1],o=Gn(r,t.dtype),a=T(i),s=this.readSync(o.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*a,f=u[l],h=0;h<a;++h){var d=u[l+h];d>f&&(f=d);}s[c]=f;}return o;},e.prototype.maximum=function(t,e){return Ql([t,e],"maximum"),this.broadcastedBinaryOp(t,e,t.dtype,function(t,e){return Math.max(t,e);});},e.prototype.all=function(t,e){Ql(t,"all"),On("all",e,t.rank);for(var n=Cn(t.shape,e),r=n[0],i=n[1],o=Gn(r,t.dtype),a=T(i),s=this.readSync(o.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*a,f=u[l],h=0;h<a;++h){var d=u[l+h];f=f&&d;}s[c]=f;}return o;},e.prototype.any=function(t,e){Ql(t,"any"),On("any",e,t.rank);for(var n=Cn(t.shape,e),r=n[0],i=n[1],o=Gn(r,t.dtype),a=T(i),s=this.readSync(o.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*a,f=u[l],h=0;h<a;++h){var d=u[l+h];f=f||d;}s[c]=f;}return o;},e.prototype.squaredDifference=function(t,e){return Ql([t,e],"squaredDifference"),this.broadcastedBinaryOp(t,e,t.dtype,function(t,e){var n=t-e;return n*n;});},e.prototype.ceil=function(t){Ql(t,"ceil");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){n[r]=Math.ceil(e[r]);}return this.makeOutput(n,t.shape,"float32");},e.prototype.floor=function(t){Ql(t,"floor");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){n[r]=Math.floor(e[r]);}return this.makeOutput(n,t.shape,"float32");},e.prototype.sign=function(t){Ql(t,"x");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){e[r]<0?n[r]=-1:e[r]>0?n[r]=1:n[r]=0;}return this.makeOutput(n,t.shape,"float32");},e.prototype.isNaN=function(t){Ql(t,"x");for(var e=this.readSync(t.dataId),n=new Uint8Array(e.length),r=0;r<e.length;++r){Number.isNaN(e[r])&&(n[r]=1);}return this.makeOutput(n,t.shape,"bool");},e.prototype.isInf=function(t){Ql(t,"x");for(var e=this.readSync(t.dataId),n=new Uint8Array(e.length),r=0;r<e.length;++r){Math.abs(e[r])===1/0&&(n[r]=1);}return this.makeOutput(n,t.shape,"bool");},e.prototype.isFinite=function(t){Ql(t,"x");for(var e=this.readSync(t.dataId),n=new Uint8Array(e.length),r=0;r<e.length;++r){Number.isFinite(e[r])&&(n[r]=1);}return this.makeOutput(n,t.shape,"bool");},e.prototype.round=function(t){Ql(t,"round");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var i=Math.floor(e[r]);e[r]-i<.5?n[r]=Math.floor(e[r]):e[r]-i>.5?n[r]=Math.ceil(e[r]):n[r]=i%2==0?i:i+1;}return this.makeOutput(n,t.shape,"float32");},e.prototype.exp=function(t){Ql(t,"exp");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){n[r]=Math.exp(e[r]);}return this.makeOutput(n,t.shape,"float32");},e.prototype.expm1=function(t){Ql(t,"expm1");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){n[r]=Math.expm1(e[r]);}return this.makeOutput(n,t.shape,"float32");},e.prototype.log=function(t){Ql(t,"log");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var i=e[r];n[r]=Math.log(i);}return this.makeOutput(n,t.shape,"float32");},e.prototype.log1p=function(t){Ql(t,"log1p");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var i=e[r];n[r]=Math.log1p(i);}return this.makeOutput(n,t.shape,"float32");},e.prototype.sqrt=function(t){Ql(t,"sqrt");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var i=e[r];n[r]=Math.sqrt(i);}return this.makeOutput(n,t.shape,"float32");},e.prototype.rsqrt=function(t){Ql(t,"rsqrt");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var i=e[r];n[r]=1/Math.sqrt(i);}return this.makeOutput(n,t.shape,"float32");},e.prototype.reciprocal=function(t){Ql(t,"reciprocal");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){n[r]=1/e[r];}return this.makeOutput(n,t.shape,"float32");},e.prototype.linear=function(t){return t;},e.prototype.relu=function(t){Ql(t,"relu");for(var e=Gn(t.shape,t.dtype),n=this.readSync(e.dataId),r=this.readSync(t.dataId),i=0;i<r.length;++i){n[i]=Math.max(0,r[i]);}return e;},e.prototype.relu6=function(t){Ql(t,"relu");for(var e=Gn(t.shape,t.dtype),n=this.readSync(e.dataId),r=this.readSync(t.dataId),i=0;i<r.length;++i){n[i]=Math.min(Math.max(0,r[i]),6);}return e;},e.prototype.prelu=function(t,e){return Ql([t,e],"prelu"),this.broadcastedBinaryOp(t,e,t.dtype,function(t,e){return t<0?e*t:t;});},e.prototype.elu=function(t){Ql(t,"elu");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){var i=n[r];e[r]=i>=0?i:Math.exp(i)-1;}return this.makeOutput(e,t.shape,"float32");},e.prototype.eluDer=function(t,e){Ql([t,e],"eluDer");for(var n=new Float32Array(e.size),r=this.readSync(e.dataId),i=this.readSync(t.dataId),o=0;o<r.length;++o){var a=r[o];n[o]=a>=1?i[o]:i[o]*(a+1);}return this.makeOutput(n,e.shape,"float32");},e.prototype.selu=function(t){Ql(t,"selu");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){var i=n[r];e[r]=i>=0?1.0507009873554805*i:1.7580993408473768*(Math.exp(i)-1);}return this.makeOutput(e,t.shape,"float32");},e.prototype.clip=function(t,e,n){Ql(t,"clip");for(var r=new Float32Array(t.size),i=this.readSync(t.dataId),o=0;o<i.length;++o){var a=i[o];r[o]=a>n?n:a<e?e:a;}return this.makeOutput(r,t.shape,"float32");},e.prototype.abs=function(t){for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.abs(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.complexAbs=function(t){for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<t.size;++r){var i=n[2*r],o=n[2*r+1];e[r]=Math.hypot(i,o);}return this.makeOutput(e,t.shape,"float32");},e.prototype.int=function(t){Ql(t,"int");for(var e=new Int32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=n[r];}return this.makeOutput(e,t.shape,"int32");},e.prototype.sigmoid=function(t){Ql(t,"sigmoid");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=1/(1+Math.exp(-n[r]));}return this.makeOutput(e,t.shape,"float32");},e.prototype.softplus=function(t){Ql(t,"softplus");for(var e=Math.log(1.1920928955078125e-7)+2,n=new Float32Array(t.size),r=this.readSync(t.dataId),i=0;i<r.length;++i){var o,a=r[i]>-e,s=r[i]<e,u=Math.exp(r[i]);o=s?u:a?r[i]:Math.log(1+u),n[i]=o;}return this.makeOutput(n,t.shape,"float32");},e.prototype.sin=function(t){Ql(t,"sin");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.sin(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.cos=function(t){Ql(t,"cos");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.cos(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.tan=function(t){Ql(t,"tan");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.tan(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.asin=function(t){Ql(t,"asin");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.asin(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.acos=function(t){Ql(t,"acos");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.acos(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.atan=function(t){Ql(t,"atan");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.atan(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.atan2=function(t,e){return Ql([t,e],"atan2"),this.broadcastedBinaryOp(t,e,t.dtype,function(t,e){return Math.atan2(t,e);});},e.prototype.sinh=function(t){Ql(t,"sinh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.sinh(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.cosh=function(t){Ql(t,"cosh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.cosh(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.tanh=function(t){Ql(t,"tanh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=R(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.asinh=function(t){Ql(t,"asinh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.asinh(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.acosh=function(t){Ql(t,"acosh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.acosh(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.atanh=function(t){Ql(t,"atanh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.atanh(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.erf=function(t){Ql(t,"erf");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){var i=Math.sign(n[r]),o=Math.abs(n[r]),a=1/(1+.3275911*o);e[r]=i*(1-((((1.061405429*a-1.453152027)*a+1.421413741)*a-.284496736)*a+.254829592)*a*Math.exp(-o*o));}return this.makeOutput(e,t.shape,"float32");},e.prototype.step=function(t,e){void 0===e&&(e=0),Ql(t,"step");for(var n=new Float32Array(t.size),r=this.readSync(t.dataId),i=0;i<r.length;++i){var o=r[i];isNaN(o)?n[i]=NaN:n[i]=o>0?1:e;}return this.makeOutput(n,t.shape,"float32");},e.prototype.fusedConv2d=function(t){var e=t.input,n=t.filter,r=t.convInfo,i=t.bias,o=t.activation,a=t.preluActivationWeights,s=this.conv2d(e,n,r);return i&&(s=this.add(s,i)),o&&(s=ef(this,s,o,a)),s;},e.prototype.conv2d=function(t,e,n){Ql([t,e],"conv2d");for(var r=n.filterHeight,i=n.filterWidth,o=n.dilationHeight,a=n.dilationWidth,s=n.padInfo.left,u=n.padInfo.top,c="channelsLast"===n.dataFormat,l=or(n.outShape,t.dtype),f=t.strides[0],h=c?t.strides[1]:t.strides[2],d=c?t.strides[2]:1,p=c?1:t.strides[1],m=l.strides[0],g=c?l.strides[1]:l.strides[2],v=c?l.strides[2]:1,y=c?1:l.strides[1],b=this.readSync(t.dataId),x=this.readSync(e.dataId),w=l.values,k=0;k<n.batchSize;++k){for(var E=k*f,C=k*m,A=0;A<n.outHeight;++A){for(var O=C+A*g,_=A*n.strideHeight-u,S=0;S<r;S++){var D=_+S*o;if(!(D<0||D>=n.inHeight))for(var F=S*e.strides[0],T=E+D*h,N=0;N<n.outWidth;++N){for(var I=O+N*v,R=N*n.strideWidth-s,M=0;M<i;M++){var j=R+M*a;if(!(j<0||j>=n.inWidth))for(var B=T+j*d,P=F+M*e.strides[1],L=0;L<n.inChannels;++L){for(var z=b[B+L*p],U=0;U<n.outChannels;++U){w[I+U*y]+=z*x[P+U];}P+=n.outChannels;}}}}}}return l.toTensor();},e.prototype.conv3d=function(t,e,n){for(var r=n.filterDepth,i=n.filterHeight,o=n.filterWidth,a=n.dilationDepth,s=n.dilationHeight,u=n.dilationWidth,c=n.padInfo.front,l=n.padInfo.left,f=n.padInfo.top,h=or(n.outShape,t.dtype),d=this.readSync(t.dataId),p=this.readSync(e.dataId),m=h.values,g=0;g<n.batchSize;++g){for(var v=g*t.strides[0],y=g*h.strides[0],b=0;b<n.outDepth;++b){for(var x=y+b*h.strides[1],w=b*n.strideDepth-c,k=0;k<r;k++){var E=w+k*a;if(!(E<0||E>=n.inDepth))for(var C=k*e.strides[0],A=v+E*t.strides[1],O=0;O<n.outHeight;++O){for(var _=x+O*h.strides[2],S=O*n.strideHeight-f,D=0;D<i;D++){var F=S+D*s;if(!(F<0||F>=n.inHeight))for(var T=C+D*e.strides[1],N=A+F*t.strides[2],I=0;I<n.outWidth;++I){for(var R=_+I*n.outChannels,M=I*n.strideWidth-l,j=0;j<o;j++){var B=M+j*u;if(!(B<0||B>=n.inWidth))for(var P=T+j*e.strides[2],L=N+B*n.inChannels,z=P,U=0;U<n.inChannels;++U){for(var W=d[L+U],V=0;V<n.outChannels;++V){m[R+V]+=W*p[z+V];}z+=n.outChannels;}}}}}}}}return h.toTensor();},e.prototype.conv2dDerInput=function(t,e,n){Ql([t,e],"conv2dDerInput");for(var r=or(n.inShape,"float32"),i=r.values,o=this.readSync(t.dataId),a=this.readSync(e.dataId),s=e.strides,u=s[0],c=s[1],l=s[2],f=n.batchSize,h=n.filterHeight,d=n.filterWidth,p=n.inChannels,m=n.inHeight,g=n.inWidth,v=n.outChannels,y=n.outHeight,b=n.outWidth,x=n.strideHeight,w=n.strideWidth,k=n.dataFormat,E=h-1-n.padInfo.top,C=d-1-n.padInfo.left,A="channelsLast"===k,O=r.strides[0],_=A?r.strides[1]:r.strides[2],S=A?r.strides[2]:1,D=A?1:r.strides[1],F=t.strides[0],T=A?t.strides[1]:t.strides[2],N=A?t.strides[2]:1,I=A?1:t.strides[1],R=0;R<f;++R){for(var M=0;M<p;++M){for(var j=0;j<m;++j){for(var B=j-E,P=Math.max(0,Math.ceil(B/x)),L=Math.min(y,(h+B)/x),z=0;z<g;++z){for(var U=z-C,W=Math.max(0,Math.ceil(U/w)),V=Math.min(b,(d+U)/w),q=0,$=P;$<L;++$){for(var H=$*x-B,G=W;G<V;++G){for(var K=F*R+T*$+N*G,X=u*(h-1-H)+c*(d-1-(G*w-U))+l*M,Y=0;Y<v;++Y){q+=o[K+I*Y]*a[X+Y];}}}i[O*R+_*j+S*z+D*M]=q;}}}}return r.toTensor();},e.prototype.conv3dDerInput=function(t,e,n){for(var r=or(n.inShape,"float32"),i=r.values,o=r.strides,a=o[0],s=o[1],u=o[2],c=o[3],l=this.readSync(t.dataId),f=t.strides,h=f[0],d=f[1],p=f[2],m=f[3],g=this.readSync(e.dataId),v=e.strides,y=v[0],b=v[1],x=v[2],w=v[3],k=n.batchSize,E=n.filterDepth,C=n.filterHeight,A=n.filterWidth,O=n.inChannels,_=n.inDepth,S=n.inHeight,D=n.inWidth,F=n.outChannels,T=n.outDepth,N=n.outHeight,I=n.outWidth,R=n.strideDepth,M=n.strideHeight,j=n.strideWidth,B=E-1-n.padInfo.front,P=C-1-n.padInfo.top,L=A-1-n.padInfo.left,z=0;z<k;++z){for(var U=0;U<O;++U){for(var W=0;W<_;++W){for(var V=W-B,q=Math.max(0,Math.ceil(V/R)),$=Math.min(T,(E+V)/R),H=0;H<S;++H){for(var G=H-P,K=Math.max(0,Math.ceil(G/M)),X=Math.min(N,(C+G)/M),Y=0;Y<D;++Y){for(var J=Y-L,Q=Math.max(0,Math.ceil(J/j)),Z=Math.min(I,(A+J)/j),tt=0,et=q;et<$;++et){for(var nt=et*R-V,rt=K;rt<X;++rt){for(var it=rt*M-G,ot=Q;ot<Z;++ot){for(var at=h*z+d*et+p*rt+m*ot,st=y*(E-1-nt)+b*(C-1-it)+x*(A-1-(ot*j-J))+w*U,ut=0;ut<F;++ut){tt+=l[at+ut]*g[st+ut];}}}}i[a*z+s*W+u*H+c*Y+U]=tt;}}}}}return r.toTensor();},e.prototype.conv2dDerFilter=function(t,e,n){Ql([t,e],"conv2dDerFilter");for(var r=n.strideHeight,i=n.strideWidth,o=n.filterHeight,a=n.filterWidth,s="channelsLast"===n.dataFormat,u=or(n.filterShape,"float32"),c=n.padInfo.left,l=n.padInfo.top,f=this.bufferSync(t),h=this.bufferSync(e),d=0;d<o;++d){for(var p=Math.max(0,Math.ceil((l-d)/r)),m=Math.min(n.outHeight,(n.inHeight+l-d)/r),g=0;g<a;++g){for(var v=Math.max(0,Math.ceil((c-g)/i)),y=Math.min(n.outWidth,(n.inWidth+c-g)/i),b=0;b<n.inChannels;++b){for(var x=0;x<n.outChannels;++x){for(var w=0,k=0;k<n.batchSize;++k){for(var E=p;E<m;++E){for(var C=d+E*r-l,A=v;A<y;++A){var O=g+A*i-c;w+=s?f.get(k,C,O,b)*h.get(k,E,A,x):f.get(k,b,C,O)*h.get(k,x,E,A);}}}u.set(w,d,g,b,x);}}}}return u.toTensor();},e.prototype.conv3dDerFilter=function(t,e,n){for(var r=n.strideDepth,i=n.strideHeight,o=n.strideWidth,a=n.filterDepth,s=n.filterHeight,u=n.filterWidth,c=or(n.filterShape,"float32"),l=c.values,f=c.strides,h=f[0],d=f[1],p=f[2],m=f[3],g=this.readSync(e.dataId),v=e.strides,y=v[0],b=v[1],x=v[2],w=v[3],k=this.readSync(t.dataId),E=t.strides,C=E[0],A=E[1],O=E[2],_=E[3],S=n.padInfo.front,D=n.padInfo.left,F=n.padInfo.top,T=0;T<a;++T){for(var N=Math.max(0,Math.ceil((S-T)/r)),I=Math.min(n.outDepth,(n.inDepth+S-T)/r),R=T*h,M=0;M<s;++M){for(var j=Math.max(0,Math.ceil((F-M)/i)),B=Math.min(n.outHeight,(n.inHeight+F-M)/i),P=M*d+R,L=0;L<u;++L){for(var z=Math.max(0,Math.ceil((D-L)/o)),U=Math.min(n.outWidth,(n.inWidth+D-L)/o),W=L*p+P,V=0;V<n.inChannels;++V){for(var q=V*m+W,$=0;$<n.outChannels;++$){for(var H=0,G=0;G<n.batchSize;++G){for(var K=G*C,X=G*y,Y=N;Y<I;++Y){for(var J=(T+Y*r-S)*A+K,Q=Y*b+X,Z=j;Z<B;++Z){for(var tt=(M+Z*i-F)*O+J,et=Z*x+Q,nt=z;nt<U;++nt){var rt=nt*w+et;H+=k[(L+nt*o-D)*_+tt+V]*g[rt+$];}}}}l[q+$]=H;}}}}}return c.toTensor();},e.prototype.fusedDepthwiseConv2D=function(t){var e=t.input,n=t.filter,r=t.convInfo,i=t.bias,o=t.activation,a=t.preluActivationWeights,s=this.depthwiseConv2D(e,n,r);return i&&(s=this.add(s,i)),o&&(s=ef(this,s,o,a)),s;},e.prototype.depthwiseConv2D=function(t,e,n){Ql([t,e],"depthwiseConv2D");for(var r=n.filterHeight,i=n.filterWidth,o=n.dilationHeight,a=n.dilationWidth,s=n.padInfo.left,u=n.padInfo.top,c=n.outChannels/n.inChannels,l=or(n.outShape,t.dtype),f=this.readSync(t.dataId),h=this.readSync(e.dataId),d=l.values,p=0;p<n.batchSize;++p){for(var m=p*t.strides[0],g=p*l.strides[0],v=0;v<n.outHeight;++v){for(var y=g+v*l.strides[1],b=v*n.strideHeight-s,x=0;x<r;++x){var w=b+x*o;if(!(w<0||w>=n.inHeight))for(var k=x*e.strides[0],E=m+w*t.strides[1],C=0;C<n.outWidth;++C){for(var A=y+C*l.strides[2],O=C*n.strideWidth-u,_=0;_<i;++_){var S=O+_*a;if(!(S<0||S>=n.inWidth))for(var D=k+_*e.strides[1],F=E+S*n.inChannels,T=A,N=D,I=0;I<n.inChannels;++I){for(var R=f[F+I],M=0;M<c;++M){d[T+M]+=R*h[N+M];}T+=c,N+=c;}}}}}}return l.toTensor();},e.prototype.depthwiseConv2DDerInput=function(t,e,n){Ql([t,e],"depthwiseConv2DDerInput");for(var r=or(n.inShape,"float32"),i=r.values,o=r.strides,a=o[0],s=o[1],u=o[2],c=this.readSync(t.dataId),l=t.strides,f=l[0],h=l[1],d=l[2],p=this.readSync(e.dataId),m=e.strides,g=m[0],v=m[1],y=m[2],b=n.batchSize,x=n.filterHeight,w=n.filterWidth,k=n.inChannels,E=n.inHeight,C=n.inWidth,A=n.outChannels,O=n.outHeight,_=n.outWidth,S=n.strideHeight,D=n.strideWidth,F=x-1-n.padInfo.top,T=w-1-n.padInfo.left,N=A/k,I=0;I<b;++I){for(var R=0;R<k;++R){for(var M=0;M<E;++M){for(var j=M-F,B=Math.max(0,Math.ceil(j/S)),P=Math.min(O,(x+j)/S),L=0;L<C;++L){for(var z=L-T,U=Math.max(0,Math.ceil(z/D)),W=Math.min(_,(w+z)/D),V=0,q=B;q<P;++q){for(var $=q*S-j,H=U;H<W;++H){for(var G=f*I+h*q+d*H,K=g*(x-1-$)+v*(w-1-(H*D-z))+y*R,X=0;X<N;++X){V+=c[G+(R*N+X)]*p[K+X];}}}i[a*I+s*M+u*L+R]=V;}}}}return r.toTensor();},e.prototype.depthwiseConv2DDerFilter=function(t,e,n){Ql([t,e],"depthwiseConv2DDerFilter");for(var r=n.strideHeight,i=n.strideWidth,o=n.filterHeight,a=n.filterWidth,s=or(n.filterShape,"float32"),u=n.padInfo.left,c=n.padInfo.top,l=n.outChannels/n.inChannels,f=this.bufferSync(t),h=this.bufferSync(e),d=0;d<o;++d){for(var p=Math.max(0,Math.ceil((c-d)/r)),m=Math.min(n.outHeight,(n.inHeight+c-d)/r),g=0;g<a;++g){for(var v=Math.max(0,Math.ceil((u-g)/i)),y=Math.min(n.outWidth,(n.inWidth+u-g)/i),b=0;b<n.outChannels;++b){for(var x=Math.trunc(b/l),w=b%l,k=0,E=0;E<n.batchSize;++E){for(var C=p;C<m;++C){for(var A=d+C*r-c,O=v;O<y;++O){var _=g+O*i-u;k+=f.get(E,A,_,x)*h.get(E,C,O,b);}}}s.set(k,d,g,x,w);}}}return s.toTensor();},e.prototype.tile=function(t,e){return Ql(t,"tile"),$o(this.bufferSync(t),e);},e.prototype.pad=function(t,e,n){Ql(t,"pad");var r=e.map(function(e,n){return e[0]+t.shape[n]+e[1];}),i=e.map(function(t){return t[0];}),o=this.bufferSync(t),a=or(r,t.dtype);0!==n&&a.values.fill(n);for(var s=0;s<t.size;s++){var u=o.indexToLoc(s),c=u.map(function(t,e){return t+i[e];});a.set.apply(a,[o.get.apply(o,u)].concat(c));}return a.toTensor();},e.prototype.gather=function(t,e,n){Ql([t,e],"gather");var r=t.shape.slice(),i=this.readSync(e.dataId);r[n]=i.length;for(var o=or(r,t.dtype),a=this.bufferSync(t),s=0;s<o.size;++s){var u=o.indexToLoc(s),c=u.slice();c[n]=i[u[n]];var l=a.locToIndex(c);o.values[s]=a.values[l];}return o.toTensor();},e.prototype.batchToSpaceND=function(t,e,n){Ql([t],"batchToSpaceND");var r=e.reduce(function(t,e){return t*e;}),i=yr(t.shape,e,r),o=br(i.length,e.length),a=xr(t.shape,e,r),s=wr(n,e.length),u=kr(a,n,e.length);return fo(t.reshape(i),o).reshape(a).slice(s,u);},e.prototype.spaceToBatchND=function(t,e,n){Ql([t],"spaceToBatchND");var r=e.reduce(function(t,e){return t*e;}),i=[[0,0]];i.push.apply(i,n);for(var o=1+e.length;o<t.shape.length;++o){i.push([0,0]);}var a=t.pad(i),s=yr(a.shape,e,r,!1),u=br(s.length,e.length,!1),c=xr(a.shape,e,r,!1);return fo(a.reshape(s),u).reshape(c);},e.prototype.maxPool=function(t,e){return Ql(t,"maxPool"),Zl(this.readSync(t.dataId),t.shape,t.dtype,t.strides,e,"max").toTensor();},e.prototype.maxPoolBackprop=function(t,e,n,r){Ql([e,n],"maxPoolBackprop");for(var i=this.readSync(e.dataId),o=or(r.outShape,e.dtype,tf(i,e.shape,e.dtype,r).values),a=r.strideHeight,s=r.strideWidth,u=r.dilationHeight,c=r.dilationWidth,l=r.effectiveFilterHeight,f=r.effectiveFilterWidth,h=f-1-r.padInfo.left,d=l-1-r.padInfo.top,p=or(e.shape,"float32"),m=this.bufferSync(t),g=0;g<r.batchSize;++g){for(var v=0;v<r.inChannels;++v){for(var y=0;y<r.inHeight;++y){for(var b=0;b<r.inWidth;++b){for(var x=y-d,w=b-h,k=0,E=0;E<l;E+=u){var C=(x+E)/a;if(!(C<0||C>=r.outHeight||Math.floor(C)!==C))for(var A=0;A<f;A+=c){var O=(w+A)/s;if(!(O<0||O>=r.outWidth||Math.floor(O)!==O)){var _=l*f-1-o.get(g,C,O,v)===E*f+A?1:0;0!==_&&(k+=m.get(g,C,O,v)*_);}}}p.set(k,g,y,b,v);}}}}return p.toTensor();},e.prototype.avgPoolBackprop=function(t,e,n){Ql([t,e],"avgPoolBackprop");for(var r=n.strideHeight,i=n.strideWidth,o=n.filterHeight,a=n.filterWidth,s=n.dilationHeight,u=n.dilationWidth,c=n.effectiveFilterHeight,l=n.effectiveFilterWidth,f=l-1-n.padInfo.left,h=c-1-n.padInfo.top,d=or(e.shape,"float32"),p=1/(o*a),m=this.bufferSync(t),g=0;g<n.batchSize;++g){for(var v=0;v<n.inChannels;++v){for(var y=0;y<n.inHeight;++y){for(var b=0;b<n.inWidth;++b){for(var x=y-h,w=b-f,k=0,E=0;E<c;E+=s){var C=(x+E)/r;if(!(C<0||C>=n.outHeight||Math.floor(C)!==C))for(var A=0;A<l;A+=u){var O=(w+A)/i;O<0||O>=n.outWidth||Math.floor(O)!==O||(k+=m.get(g,C,O,v));}}d.set(k*p,g,y,b,v);}}}}return d.toTensor();},e.prototype.pool3d=function(t,e,n){Ql(t,"pool3d");for(var r=e.strideDepth,i=e.strideHeight,o=e.strideWidth,a=e.dilationDepth,s=e.dilationHeight,u=e.dilationWidth,c=e.effectiveFilterDepth,l=e.effectiveFilterHeight,f=e.effectiveFilterWidth,h=e.padInfo.front,d=e.padInfo.top,p=e.padInfo.left,m="max"===n?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,g=this.readSync(t.dataId),v=or(e.outShape,t.dtype),y=v.values,b=e.outShape[1]*e.outShape[2]*e.outShape[3]*e.outShape[4],x=e.outShape[2]*e.outShape[3]*e.outShape[4],w=e.outShape[3]*e.outShape[4],k=e.outShape[4],E=0;E<e.batchSize;++E){for(var C=E*b,A=E*t.strides[0],O=0;O<e.inChannels;++O){for(var _=0;_<e.outDepth;++_){for(var S=_*r-h,D=S;D<0;){D+=a;}for(var F=Math.min(e.inDepth,c+S),T=C+_*x,N=0;N<e.outHeight;++N){for(var I=N*i-d,R=I;R<0;){R+=s;}for(var M=Math.min(e.inHeight,l+I),j=T+N*w,B=0;B<e.outWidth;++B){for(var P=B*o-p,L=P;L<0;){L+=u;}for(var z=Math.min(e.inWidth,f+P),U=j+B*k,W=m,V=0,q=0,$=D;$<F;$+=a){for(var H=A+$*t.strides[1],G=R;G<M;G+=s){for(var K=H+G*t.strides[2],X=L;X<z;X+=u){var Y=g[K+X*t.strides[3]+O];if("max"===n&&Y>W?W=Y:"avg"===n&&(V+=Y,q++),isNaN(W))break;}if(isNaN(W))break;}if(isNaN(W))break;}y[U+O]="avg"===n?V/q:W;}}}}}return v.toTensor();},e.prototype.avgPool3d=function(t,e){return Ql(t,"avgPool3d"),this.pool3d(t,e,"avg").toFloat();},e.prototype.avgPool3dBackprop=function(t,e,n){Ql([t,e],"avgPool3dBackprop");for(var r=n.strideDepth,i=n.strideHeight,o=n.strideWidth,a=n.filterDepth,s=n.filterHeight,u=n.filterWidth,c=n.dilationDepth,l=n.dilationHeight,f=n.dilationWidth,h=n.effectiveFilterDepth,d=n.effectiveFilterHeight,p=n.effectiveFilterWidth,m=h-1-n.padInfo.front,g=p-1-n.padInfo.left,v=d-1-n.padInfo.top,y=or(e.shape,"float32"),b=1/(a*s*u),x=this.bufferSync(t),w=0;w<n.batchSize;++w){for(var k=0;k<n.inChannels;++k){for(var E=0;E<n.inDepth;++E){for(var C=0;C<n.inHeight;++C){for(var A=0;A<n.inWidth;++A){for(var O=E-m,_=C-v,S=A-g,D=0,F=0;F<h;F+=c){var T=(O+F)/r;if(!(T<0||T>=n.outDepth||Math.floor(T)!==T))for(var N=0;N<d;N+=l){var I=(_+N)/i;if(!(I<0||I>=n.outHeight||Math.floor(I)!==I))for(var R=0;R<p;R+=f){var M=(S+R)/o;M<0||M>=n.outWidth||Math.floor(M)!==M||(D+=x.get(w,T,I,M,k));}}}y.set(D*b,w,E,C,A,k);}}}}}return y.toTensor();},e.prototype.maxPool3d=function(t,e){return Ql(t,"maxPool3d"),this.pool3d(t,e,"max").toFloat();},e.prototype.maxPool3dPositions=function(t,e){for(var n=or(e.outShape,"int32"),r=e.strideDepth,i=e.strideHeight,o=e.strideWidth,a=e.dilationDepth,s=e.dilationHeight,u=e.dilationWidth,c=e.effectiveFilterDepth,l=e.effectiveFilterHeight,f=e.effectiveFilterWidth,h=e.padInfo.front,d=e.padInfo.top,p=e.padInfo.left,m=this.bufferSync(t),g=0;g<e.batchSize;++g){for(var v=0;v<e.inChannels;++v){for(var y=0;y<e.outDepth;++y){for(var b=y*r-h,x=b;x<0;){x+=a;}for(var w=Math.min(e.inDepth,c+b),k=0;k<e.outHeight;++k){for(var E=k*i-d,C=E;C<0;){C+=s;}for(var A=Math.min(e.inHeight,l+E),O=0;O<e.outWidth;++O){for(var _=O*o-p,S=_;S<0;){S+=u;}for(var D=Math.min(e.inWidth,f+_),F=Number.NEGATIVE_INFINITY,T=-1,N=x;N<w;N+=a){for(var I=N-b,R=C;R<A;R+=s){for(var M=R-E,j=S;j<D;j+=u){var B=j-_,P=m.get(g,N,R,j,v);P>=F&&(F=P,T=I*l*f+M*l+B);}}}n.set(T,g,y,k,O,v);}}}}}return n.toTensor();},e.prototype.maxPool3dBackprop=function(t,e,n,r){Ql([e,n],"maxPool3dBackprop");for(var i=this.maxPool3dPositions(e,r),o=r.strideDepth,a=r.strideHeight,s=r.strideWidth,u=r.dilationDepth,c=r.dilationHeight,l=r.dilationWidth,f=r.effectiveFilterDepth,h=r.effectiveFilterHeight,d=r.effectiveFilterWidth,p=f-1-r.padInfo.front,m=d-1-r.padInfo.left,g=h-1-r.padInfo.top,v=or(e.shape,"float32"),y=this.bufferSync(i),b=this.bufferSync(t),x=0;x<r.batchSize;++x){for(var w=0;w<r.inChannels;++w){for(var k=0;k<r.inDepth;++k){for(var E=0;E<r.inHeight;++E){for(var C=0;C<r.inWidth;++C){for(var A=k-p,O=E-g,_=C-m,S=0,D=0;D<f;D+=u){var F=(A+D)/o;if(!(F<0||F>=r.outDepth||Math.floor(F)!==F))for(var T=0;T<h;T+=c){var N=(O+T)/a;if(!(N<0||N>=r.outHeight||Math.floor(N)!==N))for(var I=0;I<d;I+=l){var R=(_+I)/s;if(!(R<0||R>=r.outWidth||Math.floor(R)!==R)){var M=f*h*d-1-y.get(x,F,N,R,w)===D*h*d+T*d+I?1:0;0!==M&&(S+=b.get(x,F,N,R,w)*M);}}}}v.set(S,x,k,E,C,w);}}}}}return v.toTensor();},e.prototype.cast=function(t,e){return So(t,e,this);},e.prototype.reshape=function(t,e){return Do(t,e);},e.prototype.avgPool=function(t,e){return Ql(t,"avgPool"),Ql(t,"maxPool"),Zl(this.readSync(t.dataId),t.shape,t.dtype,t.strides,e,"avg").toTensor().toFloat();},e.prototype.resizeBilinear=function(t,e,n,r){Ql(t,"resizeBilinear");for(var i=t.shape,o=i[0],a=i[1],s=i[2],u=i[3],c=this.readSync(t.dataId),l=new Float32Array(T([o,e,n,u])),f=[r&&e>1?a-1:a,r&&n>1?s-1:s],h=[r&&e>1?e-1:e,r&&n>1?n-1:n],d=0,p=f[0]/h[0],m=f[1]/h[1],g=0;g<o;g++){for(var v=0;v<e;v++){for(var y=p*v,b=Math.floor(y),x=y-b,w=Math.min(a-1,Math.ceil(y)),k=g*t.strides[0]+b*t.strides[1],E=g*t.strides[0]+w*t.strides[1],C=0;C<n;C++){for(var A=m*C,O=Math.floor(A),_=A-O,S=Math.min(s-1,Math.ceil(A)),D=k+O*t.strides[2],F=E+O*t.strides[2],N=k+S*t.strides[2],I=E+S*t.strides[2],R=0;R<u;R++){var M=c[D+R],j=c[F+R],B=M+(c[N+R]-M)*_,P=B+(j+(c[I+R]-j)*_-B)*x;l[d++]=P;}}}}return jn(l,[o,e,n,u]);},e.prototype.resizeBilinearBackprop=function(t,e,n){Ql([t,e],"resizeBilinearBackprop");for(var r=e.shape,i=r[0],o=r[1],a=r[2],s=r[3],u=t.shape,c=u[1],l=u[2],f=new Float32Array(i*o*a*s),h=[n&&c>1?o-1:o,n&&l>1?a-1:a],d=[n&&c>1?c-1:c,n&&l>1?l-1:l],p=h[0]/d[0],m=h[1]/d[1],g=this.readSync(t.dataId),v=0,y=0;y<i;y++){for(var b=y*e.strides[0],x=0;x<c;x++){for(var w=x*p,k=Math.floor(w),E=Math.min(Math.ceil(w),o-1),C=b+k*e.strides[1],A=b+E*e.strides[1],O=w-k,_=1-O,S=0;S<l;S++){for(var D=S*m,F=Math.floor(D),T=Math.min(Math.ceil(D),a-1),N=D-F,I=1-N,R=C+F*e.strides[2],M=C+T*e.strides[2],j=A+F*e.strides[2],B=A+T*e.strides[2],P=_*I,L=_*N,z=O*I,U=O*N,W=0;W<s;W++){var V=g[v++];f[R+W]+=V*P,f[M+W]+=V*L,f[j+W]+=V*z,f[B+W]+=V*U;}}}}return Wn(f,[i,a,o,s],e.dtype);},e.prototype.resizeNearestNeighbor=function(t,e,n,r){Ql(t,"resizeNearestNeighbor");for(var i=t.shape,o=i[0],a=i[1],s=i[2],u=i[3],c=this.readSync(t.dataId),l=new Float32Array(o*e*n*u),f=[r&&e>1?a-1:a,r&&n>1?s-1:s],h=[r&&e>1?e-1:e,r&&n>1?n-1:n],d=f[0]/h[0],p=f[1]/h[1],m=0,g=0;g<o;g++){for(var v=g*t.strides[0],y=0;y<e;y++){for(var b=d*y,x=v+Math.min(a-1,r?Math.round(b):Math.floor(b))*t.strides[1],w=0;w<n;w++){for(var k=p*w,E=x+Math.min(s-1,r?Math.round(k):Math.floor(k))*t.strides[2],C=0;C<u;C++){var A=c[E+C];l[m++]=A;}}}}return jn(l,[o,e,n,u],t.dtype);},e.prototype.resizeNearestNeighborBackprop=function(t,e,n){Ql([t,e],"resizeNearestNeighborBackprop");for(var r=e.shape,i=r[0],o=r[1],a=r[2],s=r[3],u=t.shape,c=u[1],l=u[2],f=new Float32Array(i*o*a*s),h=this.readSync(t.dataId),d=[n&&c>1?o-1:o,n&&l>1?a-1:a],p=[n&&c>1?c-1:c,n&&l>1?l-1:l],m=d[0]/p[0],g=d[1]/p[1],v=1/m,y=1/g,b=2*Math.ceil(v)+2,x=2*Math.ceil(y)+2,w=0;w<i;w++){for(var k=w*e.strides[0],E=0;E<o;E++){for(var C=k+E*e.strides[1],A=Math.floor(E*v),O=Math.floor(A-b/2),_=0;_<a;_++){for(var S=C+_*e.strides[2],D=Math.floor(_*y),F=Math.floor(D-x/2),T=0;T<s;T++){for(var N=0,I=0;I<b;I++){var R=I+O;if(!(R<0||R>=c)){var M=k+R*t.strides[1],j=R*m;if(E===Math.min(o-1,n?Math.round(j):Math.floor(j)))for(var B=0;B<x;B++){var P=B+F;if(!(P<0||P>=l)){var L=M+P*t.strides[2],z=P*g;_===Math.min(a-1,n?Math.round(z):Math.floor(z))&&(N+=h[L+T]);}}}}f[S+T]=N;}}}}return Wn(f,e.shape,e.dtype);},e.prototype.batchNormalization=function(t,e,n,r,i,o){Ql([t,e,n,i,o],"batchNorm");for(var a=this.readSync(t.dataId),s=this.readSync(e.dataId),u=this.readSync(n.dataId),c=i?this.readSync(i.dataId):new Float32Array([1]),l=o?this.readSync(o.dataId):new Float32Array([0]),f=new Float32Array(a.length),h=l.length,d=c.length,p=u.length,m=s.length,g=0,v=0,y=0,b=0,x=0;x<a.length;++x){f[x]=l[g++]+(a[x]-s[v++])*c[y++]/Math.sqrt(u[b++]+r),g>=h&&(g=0),v>=m&&(v=0),y>=d&&(y=0),b>=p&&(b=0);}return Wn(f,t.shape);},e.prototype.localResponseNormalization4D=function(t,e,n,r,i){Ql(t,"localResponseNormalization4D");var o=t.shape[3],a=o-1,s=this.readSync(t.dataId),u=t.size,c=new Float32Array(u);function l(t){for(var n=t%o,r=t-n+Math.max(0,n-e),i=t-n+Math.min(n+e,a),u=0;r<=i;r++){var c=s[r];u+=c*c;}return u;}for(var f=0;f<u;f++){var h=l(f),d=s[f]*Math.pow(n+r*h,-i);c[f]=d;}return Wn(c,t.shape);},e.prototype.LRNGrad=function(t,e,n,r,i,o,a){Ql(t,"LRNGrad");for(var s=t.shape[3],u=this.readSync(t.dataId),c=this.readSync(e.dataId),l=this.readSync(n.dataId),f=new Float32Array(t.size),h=t.size,d=0;d<h;d++){for(var p=d%s,m=d-p+Math.max(0,p-r),g=d-p+Math.min(s,p+r+1),v=0,y=m;y<g;y++){v+=Math.pow(c[y],2);}for(v=o*v+i,y=m;y<g;y++){var b=-2*o*a*c[y]*l[d]/v;d===y&&(b+=Math.pow(v,-a)),b*=u[d],f[y]+=b;}}return Wn(f,t.shape);},e.prototype.multinomial=function(t,e,n,r){Ql(t,"multinomial");for(var i=e?t:co(t),o=i.shape[0],a=i.shape[1],s=Gn([o,n],"int32"),u=this.readSync(s.dataId),c=this.readSync(i.dataId),l=0;l<o;++l){var f=l*a,h=new Float32Array(a-1);h[0]=c[f];for(var d=1;d<h.length;++d){h[d]=h[d-1]+c[f+d];}for(var p=Bs(r.toString()),m=l*n,g=0;g<n;++g){var v=p();u[m+g]=h.length;for(var y=0;y<h.length;y++){if(v<h[y]){u[m+g]=y;break;}}}}return s;},e.prototype.oneHot=function(t,e,n,r){Ql(t,"oneHot");var i=new Float32Array(t.size*e);i.fill(r);for(var o=this.readSync(t.dataId),a=0;a<t.size;++a){o[a]>=0&&o[a]<e&&(i[a*e+o[a]]=n);}return zn(i,[t.size,e],"int32");},e.prototype.nonMaxSuppression=function(t,e,n,r,i){return Ql(t,"nonMaxSuppression"),Po(this.readSync(t.dataId),this.readSync(e.dataId),n,r,i);},e.prototype.fft=function(t){return this.fftBatch(t,!1);},e.prototype.ifft=function(t){return this.fftBatch(t,!0);},e.prototype.fftBatch=function(t,e){for(var n=t.shape[0],r=t.shape[1],i=or(t.shape,"float32"),o=or(t.shape,"float32"),a=Rn(t).as2D(n,r),s=Mn(t).as2D(n,r),u=0;u<n;u++){for(var c=a.slice([u,0],[1,r]),l=s.slice([u,0],[1,r]),f=In(c,l),h=this.readSync(this.fftImpl(f,e).dataId),d=0;d<r;d++){var p=Io(h,d);i.values[u*r+d]=p.real,o.values[u*r+d]=p.imag;}}return In(i.toTensor(),o.toTensor()).as2D(n,r);},e.prototype.fftImpl=function(t,e){var n=t.as1D(),r=n.size;if(this.isExponentOf2(r)){var i=this.fftRadix2(n,r,e).as2D(t.shape[0],t.shape[1]);return e&&(i=In(Rn(i).div(Pn(r)),Mn(i).div(Pn(r)))),i;}var o=this.readSync(t.dataId),a=function(t){for(var e=new Float32Array(t.length/2),n=new Float32Array(t.length/2),r=0;r<t.length;r+=2){e[r/2]=t[r],n[r/2]=t[r+1];}return {real:e,imag:n};}(this.fourierTransformByMatmul(o,r,e));return In(a.real,a.imag).as2D(t.shape[0],t.shape[1]);},e.prototype.isExponentOf2=function(t){return 0==(t&t-1);},e.prototype.fftRadix2=function(t,e,n){if(1===e)return t;var r=this.readSync(t.dataId),i=e/2,o=function(t){for(var e=Math.ceil(t.length/4),n=new Float32Array(e),r=new Float32Array(e),i=0;i<t.length;i+=4){n[Math.floor(i/4)]=t[i],r[Math.floor(i/4)]=t[i+1];}return {real:n,imag:r};}(r),a=In(o.real,o.imag).as1D(),s=function(t){for(var e=Math.floor(t.length/4),n=new Float32Array(e),r=new Float32Array(e),i=2;i<t.length;i+=4){n[Math.floor(i/4)]=t[i],r[Math.floor(i/4)]=t[i+1];}return {real:n,imag:r};}(r),u=In(s.real,s.imag).as1D();a=this.fftRadix2(a,i,n),u=this.fftRadix2(u,i,n);var c=function(t,e){for(var n=new Float32Array(t/2),r=new Float32Array(t/2),i=0;i<Math.ceil(t/2);i++){var o=(e?2:-2)*Math.PI*(i/t);n[i]=Math.cos(o),r[i]=Math.sin(o);}return {real:n,imag:r};}(e,n),l=In(c.real,c.imag).mul(u),f=a.add(l),h=a.sub(l),d=Rn(f).concat(Rn(h)),p=Mn(f).concat(Mn(h));return In(d,p).as1D();},e.prototype.fourierTransformByMatmul=function(t,e,n){for(var r=new Float32Array(2*e),i=0;i<e;i++){for(var o=0,a=0,s=0;s<e;s++){var u=Mo(i*s,e,n),c=Io(t,s);o+=c.real*u.real-c.imag*u.imag,a+=c.real*u.imag+c.imag*u.real;}n&&(o/=e,a/=e),Ro(r,o,a,i);}return r;},e.prototype.depthToSpace=function(t,e,n){_("NHWC"===n,function(){return "Only NHWC dataFormat supported on CPU for depthToSpace. Got "+n;}),_(e>1,function(){return "blockSize should be > 1 for depthToSpace, but was: "+e;});for(var r=t.shape[0],i=t.shape[1],o=t.shape[2],a=t.shape[3],s=i*e,u=o*e,c=a/(e*e),l=this.readSync(t.dataId),f=new Float32Array(r*s*u*c),h=0,d=0;d<r;++d){for(var p=0;p<s;++p){for(var m=Math.floor(p/e),g=p%e,v=0;v<u;++v){for(var y=Math.floor(v/e),b=(g*e+v%e)*c,x=0;x<c;++x){var w=x+b+a*(y+o*(m+i*d));f[h++]=l[w];}}}}return Wn(f,[r,s,u,c]);},e.prototype.broadcastedBinaryOp=function(t,e,n,r){var i=Ur(t.shape,e.shape),o=or(i,n),a=this.readSync(t.dataId),s=this.readSync(e.dataId),u=Lr(t.shape,i),c=Lr(e.shape,i),l=o.values;if(u.length+c.length===0)for(var f=0;f<l.length;++f){l[f]=r(a[f%a.length],s[f%s.length]);}else {var h=this.bufferSync(t),d=this.bufferSync(e),p=function p(n){var i=o.indexToLoc(n),f=i.slice(-t.rank);u.forEach(function(t){return f[t]=0;});var p=h.locToIndex(f),m=i.slice(-e.rank);c.forEach(function(t){return m[t]=0;});var g=d.locToIndex(m);l[n]=r(a[p],s[g]);};for(f=0;f<l.length;++f){p(f);}}return o.toTensor();},e.prototype.broadcastedBinaryComplexOp=function(t,e,n){var r=Ur(t.shape,e.shape),i=or(r,"float32"),o=or(r,"float32"),a=this.readSync(t.dataId),s=this.readSync(e.dataId),u=Lr(t.shape,r),c=Lr(e.shape,r),l=i.values,f=o.values;if(u.length+c.length===0)for(var h=0;h<l.length;h++){var d=h%a.length,p=h%s.length,m=n(a[2*d],a[2*d+1],s[2*p],s[2*p+1]);l[h]=m.real,f[h]=m.imag;}else {var g=this.bufferSync(this.data.get(t.dataId).complexTensors.real),v=this.bufferSync(this.data.get(e.dataId).complexTensors.real),y=function y(r){var o=i.indexToLoc(r),h=o.slice(-t.rank);u.forEach(function(t){return h[t]=0;});var d=g.locToIndex(h),p=o.slice(-e.rank);c.forEach(function(t){return p[t]=0;});var m=v.locToIndex(p),y=n(a[2*d],a[2*d+1],s[2*m],s[2*m+1]);l[r]=y.real,f[r]=y.imag;};for(h=0;h<l.length;h++){y(h);}}return this.complex(i.toTensor(),o.toTensor());},e.prototype.split=function(t,e,n){return qo(t,e,n);},e.prototype.dispose=function(){},e.prototype.floatPrecision=function(){return 32;},e.prototype.epsilon=function(){return 1e-7;},e.prototype.cropAndResize=function(t,e,n,r,i,o){for(var a=t.shape,s=a[0],u=a[1],c=a[2],l=a[3],f=e.shape[0],h=r[0],d=r[1],p=or([f,h,d,l],"float32"),m=this.readSync(e.dataId),g=this.readSync(n.dataId),v=this.readSync(t.dataId),y=t.strides,b=p.strides,x=0;x<f;x++){var w=4*x,k=m[w],E=m[w+1],C=m[w+2],A=m[w+3],O=g[x];if(!(O>=s))for(var _=h>1?(C-k)*(u-1)/(h-1):0,S=d>1?(A-E)*(c-1)/(d-1):0,D=0;D<h;D++){var F=h>1?k*(u-1)+D*_:.5*(k+C)*(u-1);if(F<0||F>u-1)for(var T=0;T<d;T++){for(var N=0;N<l;N++){var I=N+T*b[2]+D*b[1]+x*b[0];p.values[I]=o;}}else if("bilinear"===i){var R=Math.floor(F),M=Math.ceil(F),j=F-R;for(T=0;T<d;T++){if(($=d>1?E*(c-1)+T*S:.5*(E+A)*(c-1))<0||$>c-1)for(N=0;N<l;N++){I=N+T*b[2]+D*b[1]+x*b[0],p.values[I]=o;}else {var B=Math.floor($),P=Math.ceil($),L=$-B;for(N=0;N<l;N++){var z=v[I=N+B*y[2]+R*y[1]+O*y[0]],U=v[I=N+P*y[2]+R*y[1]+O*y[0]],W=v[I=N+B*y[2]+M*y[1]+O*y[0]],V=z+(U-z)*L,q=W+(v[I=N+P*y[2]+M*y[1]+O*y[0]]-W)*L;I=N+T*b[2]+D*b[1]+x*b[0],p.values[I]=V+(q-V)*j;}}}}else for(T=0;T<d;++T){var $;if(($=d>1?E*(c-1)+T*S:.5*(E+A)*(c-1))<0||$>c-1)for(N=0;N<l;N++){I=N+T*b[2]+D*b[1]+x*b[0],p.values[I]=o;}else {var H=Math.round($),G=Math.round(F);for(N=0;N<l;N++){var K=N+H*y[2]+G*y[1]+O*y[0],X=N+T*b[2]+D*b[1]+x*b[0];p.values[X]=v[K];}}}}}return p.toTensor();},e.prototype.sparseToDense=function(t,e,n,r){var i=Hi(0,t,n),o=i.sliceRank,a=i.numUpdates,s=i.sliceSize,u=i.strides,c=i.outputSize;return this.scatter(t,e,n,c,s,a,o,u,r,!1);},e.prototype.gatherND=function(t,e){var n=e.shape,r=n[n.length-1],i=zi(t,e),o=i[0],a=i[1],s=i[2],u=i[3];if(0===a)return jn([],o,t.dtype);for(var c=new wt([a,s],t.dtype),l=this.readSync(e.dataId),f=this.readSync(t.dataId),h=0;h<a;h++){for(var d=[],p=0,m=0;m<r;m++){var g=l[h*r+m];p+=g*u[m],d.push(g);}if(p<0||p>=t.size/s)throw new Error("Invalid indices: "+d+" does not index into "+t.shape);for(var v=0;v<s;v++){c.values[h*s+v]=f[p*s+v];}}return c.toTensor().reshape(o);},e.prototype.scatterND=function(t,e,n){var r=Hi(0,t,n),i=r.sliceRank,o=r.numUpdates,a=r.sliceSize,s=r.strides,u=r.outputSize,c=Pn(0);return this.scatter(t,e,n,u,a,o,i,s,c,!0);},e.prototype.fill=function(t,e,n){var r=W(n=n||Q(e),T(t));return r.fill(e),Wt.makeTensor(r,t,n,this);},e.prototype.onesLike=function(t){if("string"===t.dtype)throw new Error("onesLike is not supported for string tensors");return this.fill(t.shape,1,t.dtype);},e.prototype.zerosLike=function(t){var e=W(t.dtype,T(t.shape));return this.makeOutput(e,t.shape,t.dtype);},e.prototype.linspace=function(t,e,n){return Fo(t,e,n);},e.prototype.scatter=function(t,e,n,r,i,o,a,s,u,c){var l=[r/i,i],f=this.readSync(t.dataId),h=this.readSync(e.dataId);if(0===r)return jn([],n,e.dtype);var d=new wt(l,e.dtype);d.values.fill(this.readSync(u.dataId)[0]);for(var p=0;p<o;p++){for(var m=[],g=0,v=0;v<a;v++){var y=f[p*a+v];m.push(y),g+=y*s[v];}if(g<0||g>=r/i)throw new Error("Invalid indices: "+m+" does not index into "+n);for(var b=0;b<i;b++){c?d.values[g*i+b]+=h[p*i+b]:d.values[g*i+b]=0===e.rank?h[0]:h[p*i+b];}}return d.toTensor().reshape(n);},e;}(po);function rf(t,e){return {kernelName:t,backendName:"cpu",kernelFunc:function kernelFunc(n){var r=n.inputs,i=n.backend,o=r,a=o.a,s=o.b,u=i;Ql([a,s],t);var c=u.data.get(a.dataId).values,l=u.data.get(s.dataId).values,f=e(a.shape,s.shape,c,l,a.dtype),h=f[0],d=f[1];return {dataId:u.write(h,d,a.dtype),shape:d,dtype:a.dtype};}};}function of(t){return function(e,n,r,i,o){var a=Ur(e,n),s=a.length,u=et(a),c=U(o,T(a)),l=e.length,f=n.length,h=et(e),d=et(n),p=Lr(e,a),m=Lr(n,a);if(p.length+m.length===0)for(var g=0;g<c.length;++g){c[g]=t(r[g%r.length],i[g%i.length]);}else {var v=function v(e){var n=ft(e,s,u),o=n.slice(-l);p.forEach(function(t){return o[t]=0;});var a=lt(o,l,h),g=n.slice(-f);m.forEach(function(t){return g[t]=0;});var v=lt(g,f,d);c[e]=t(r[a],i[v]);};for(g=0;g<c.length;++g){v(g);}}return [c,a];};}Wt.registerBackend("cpu",function(){return new nf();},1);var af=of(function(t,e){return t/e;}),sf=rf(Ar,af),uf={kernelName:"MaxPoolWithArgmax",backendName:"cpu",kernelFunc:function kernelFunc(t){var e=t.inputs,n=t.attrs,r=t.backend,i=e.x,o=n,a=o.filterSize,s=o.strides,u=o.pad,c=o.includeBatchInIndex,l=r;Ql(i,"MaxPoolWithArgmax");var f=l.data.get(i.dataId).values,h=go(i.shape,a,s,[1,1],u),d=function(t,e,n,r,i){var o=Zl(t,0,n,et(e),i,"max"),a=tf(t,e,n,i,!0,r);return [o.values,a.values];}(f,i.shape,i.dtype,c,h),p=d[0],m=d[1],g=l.write(p,h.outShape,i.dtype),v=l.write(m,h.outShape,i.dtype);return [{dataId:g,shape:h.outShape,dtype:i.dtype},{dataId:v,shape:h.outShape,dtype:"int32"}];}},cf={kernelName:"NonMaxSuppressionV5",backendName:"cpu",kernelFunc:function kernelFunc(t){var e=t.inputs,n=t.backend,r=t.attrs,i=e,o=i.boxes,a=i.scores,s=r,u=s.maxOutputSize,c=s.iouThreshold,l=s.scoreThreshold,f=s.softNmsSigma,h=n;Ql(o,"NonMaxSuppressionWithScore");var d=Lo(h.data.get(o.dataId).values,h.data.get(a.dataId).values,u,c,l,f);return [d.selectedIndices,d.selectedScores];}},lf={kernelName:"Square",backendName:"cpu",kernelFunc:function kernelFunc(t){var e=t.inputs,n=t.backend,r=e.x,i=n;Ql(r,"square");for(var o=i.data.get(r.dataId).values,a=new Float32Array(o.length),s=0;s<o.length;++s){var u=o[s];a[s]=u*u;}return {dataId:i.write(a,r.shape,r.dtype),shape:r.shape,dtype:r.dtype};}},ff=of(function(t,e){var n=t-e;return n*n;});function hf(t,e,n,r,i){for(var o=T(e),a=e.length,s=et(e),u=et(i),c=U(n,T(i)),l=0;l<o;++l){for(var f=ft(l,a,s),h=new Array(f.length),d=0;d<h.length;d++){h[d]=f[r[d]];}c[lt(h,a,u)]=t[l];}return c;}for(var df=0,pf=[cf,lf,rf(_r,ff),sf,{kernelName:"Transpose",backendName:"cpu",kernelFunc:function kernelFunc(t){var e=t.inputs,n=t.attrs,r=t.backend,i=e.x,o=n.perm,a=r;Ql(i,"transpose");for(var s=i.shape.length,u=new Array(s),c=0;c<u.length;c++){u[c]=i.shape[o[c]];}var l=hf(a.data.get(i.dataId).values,i.shape,i.dtype,o,u);return {dataId:a.write(l,u,i.dtype),shape:u,dtype:i.dtype};}},uf];df<pf.length;df++){y(pf[df]);}for(var mf,gf=0,vf=[{kernelName:"FromPixels",backendName:"webgl",kernelFunc:function kernelFunc(t){var e=t.inputs,n=t.backend,r=t.attrs,i=e.pixels,o=r.numChannels,a="undefined"!=typeof HTMLVideoElement&&i instanceof HTMLVideoElement,s="undefined"!=typeof HTMLImageElement&&i instanceof HTMLImageElement,u=a?[i.videoWidth,i.videoHeight]:[i.width,i.height],c=u[0],l=u[1],h=[l,c],d=[l,c,o];(s||a)&&(null==mf&&(mf=document.createElement("canvas").getContext("2d")),mf.canvas.width=c,mf.canvas.height=l,mf.drawImage(i,0,0,c,l),i=mf.canvas);var p=n.makeTensorInfo(h,"int32");n.texData.get(p.dataId).usage=Ht.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(p.dataId),i);var m=f().getBool("WEBGL_PACK")?new function(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var e=Yo(),n=t[0],r=t[1];this.outputShape=t,this.userCode="\n      void main() {\n        ivec3 coords = getOutputCoords();\n        int texR = coords[0];\n        int texC = coords[1];\n        int depth = coords[2];\n\n        vec4 result = vec4(0.);\n\n        for(int row=0; row<=1; row++) {\n          for(int col=0; col<=1; col++) {\n            texC = coords[1] + row;\n            depth = coords[2] + col;\n\n            vec2 uv = (vec2(texC, texR) + halfCR) /\n                       vec2("+r+".0, "+n+".0);\n            vec4 values = "+e.texture2D+"(A, uv);\n            float value;\n            if (depth == 0) {\n              value = values.r;\n            } else if (depth == 1) {\n              value = values.g;\n            } else if (depth == 2) {\n              value = values.b;\n            } else if (depth == 3) {\n              value = values.a;\n            }\n\n            result[row * 2 + col] = floor(value * 255.0 + 0.5);\n          }\n        }\n\n        "+e.output+" = result;\n      }\n    ";}(d):new function(t){this.variableNames=["A"];var e=Yo(),n=t[0],r=t[1];this.outputShape=t,this.userCode="\n      void main() {\n        ivec3 coords = getOutputCoords();\n        int texR = coords[0];\n        int texC = coords[1];\n        int depth = coords[2];\n        vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+r+".0, "+n+".0);\n\n        vec4 values = "+e.texture2D+"(A, uv);\n        float value;\n        if (depth == 0) {\n          value = values.r;\n        } else if (depth == 1) {\n          value = values.g;\n        } else if (depth == 2) {\n          value = values.b;\n        } else if (depth == 3) {\n          value = values.a;\n        }\n\n        setOutput(floor(value * 255.0 + 0.5));\n      }\n    ";}(d),g=n.runWebGLProgram(m,[p],"int32");return n.disposeData(p.dataId),g;}},{kernelName:Ar,backendName:"webgl",kernelFunc:function kernelFunc(t){var e=t.inputs,n=t.backend,r=e;return function(t,e,n){var r=new ma("\nif (a == b) {\n  return 1.0;\n};\nreturn a / b;",t.shape,e.shape);return f().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&(r=new va("\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",t.shape,e.shape,!0)),n.runWebGLProgram(r,[t,e],"float32");}(r.a,r.b,n);}},{kernelName:"NonMaxSuppressionV5",backendName:"webgl",kernelFunc:function kernelFunc(t){var e=t.inputs,n=t.backend,r=t.attrs;vn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var i=e,o=i.boxes,a=i.scores,s=r,u=s.maxOutputSize,c=s.iouThreshold,l=s.scoreThreshold,f=s.softNmsSigma,h=n,d=Lo(h.readSync(o.dataId),h.readSync(a.dataId),u,c,l,f);return [d.selectedIndices,d.selectedScores];}},{kernelName:"Square",backendName:"webgl",kernelFunc:function kernelFunc(t){var e=t.inputs,n=t.backend,r=e.x,i=n,o=new ss(r.shape,"return x * x;");return i.runWebGLProgram(o,[r],r.dtype);}},{kernelName:_r,backendName:"webgl",kernelFunc:function kernelFunc(t){var e=t.inputs,n=t.backend,r=e,i=r.a,o=r.b,a=n,s=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new va("return (a - b) * (a - b);",i.shape,o.shape):new ma("return (a - b) * (a - b);",i.shape,o.shape);return a.compileAndRun(s,[i,o]);}},{kernelName:"Transpose",backendName:"webgl",kernelFunc:function kernelFunc(t){for(var e,n=t.inputs,r=t.attrs,i=t.backend,o=n.x,a=r.perm,s=i,u=o.shape.length,c=new Array(u),l=0;l<c.length;l++){c[l]=o.shape[a[l]];}if(s.shouldExecuteOnCPU([o])){var h=hf(s.texData.get(o.dataId).values,o.shape,o.dtype,a,c);e=s.makeTensorInfo(c,o.dtype),s.texData.get(e.dataId).values=h;}else e=function(t,e,n){var r=f().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new function(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;for(var n=new Array(t.length),r=0;r<n.length;r++){n[r]=t[e[r]];}if(this.outputShape=n,this.rank=n.length,this.rank>6)throw Error("Packed transpose for rank "+this.rank+" is not yet supported.");var i=sa(this.rank),o=Ko("rc",this.rank),a=new Array(this.rank);for(r=0;r<e.length;r++){a[e[r]]=o[r];}var s="vec2("+a.slice(-2).join()+")",u="++"+o[this.rank-1]+" < "+n[this.rank-1],c="getChannel(getA("+a.join()+"), "+s+")";this.userCode="\n    void main() {\n      "+i+" rc = getOutputCoords();\n      vec4 result = vec4(0.);\n      result[0] = "+c+";\n      if("+u+") {\n        result[1] = "+c+";\n      }\n      --"+o[this.rank-1]+";\n      if(++"+o[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    ";}(t.shape,e):new function(t,e){this.variableNames=["A"];for(var n=new Array(t.length),r=0;r<n.length;r++){n[r]=t[e[r]];}this.outputShape=n,this.rank=n.length;var i=sa(this.rank),o=function(t){var e=t.length;if(e>6)throw Error("Transpose for rank "+e+" is not yet supported");for(var n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(e),i=0;i<t.length;i++){r[t[i]]=n[i];}return r.join();}(e);this.userCode="\n    void main() {\n      "+i+" resRC = getOutputCoords();\n      setOutput(getA("+o+"));\n    }\n    ";}(t.shape,e);return n.runWebGLProgram(r,[t],t.dtype);}(o,a,s);return e;}},{kernelName:"MaxPoolWithArgmax",backendName:"webgl",kernelFunc:function kernelFunc(t){var e=t.inputs,n=t.attrs,r=t.backend,i=e.x,o=n,a=o.filterSize,s=o.strides,u=o.pad,c=o.includeBatchInIndex,l=r;_(4===i.shape.length,function(){return "Error in maxPool: input must be rank 4 but got rank "+i.shape.length+".";});var f=[1,1];_(Oo(s,f),function(){return "Error in maxPool: Either strides or dilations must be 1. Got strides "+s+" and dilations '"+f+"'";});var h=go(i.shape,a,s,f,u),d=function(t,e,n,r){var i=new Ya(n,"max",!1),o=r.runWebGLProgram(i,[t],"float32");return i=new Ya(n,"max",!0,!0,e),[o,r.runWebGLProgram(i,[t],"float32")];}(i,c,h,l);return [d[0],d[1]];}}];gf<vf.length;gf++){y(vf[gf]);}for(var yf=0,bf=[{kernelName:Er,inputsToSave:["a","b"],gradFunc:function gradFunc(t,e){var n=e[0],r=e[1],i=Ur(n.shape,r.shape);return {a:function a(){var e=t,r=zr(n.shape,i);return r.length>0&&(e=e.sum(r)),e.reshape(n.shape);},b:function b(){var e=t,n=zr(r.shape,i);return n.length>0&&(e=e.sum(n)),e.reshape(r.shape);}};}},{kernelName:"AddN",saveAllInputs:!0,gradFunc:function gradFunc(t,e){var n={};return e.forEach(function(e,r){n[r]=function(){return t.clone();};}),n;}},{kernelName:Tr,gradFunc:function gradFunc(t,e,n){for(var r=n,i=r.inputShape,o=r.shape,a=Array.from(o),s=i.length-1;s>=0;s--){if(i[s]===o[s])a[s]=1;else if(1!==i[s])throw new Error("broadcastTo(): ["+i+"] cannot be broadcast to ["+o+"].");}var u=[];for(s=0;s<a.length;s++){a[s]>1&&u.push(s);}return {x:function x(){return t.sum(u,!0);}};}},{kernelName:Ar,inputsToSave:["a","b"],gradFunc:function gradFunc(t,e){var n=e[0],r=e[1],i=Ur(n.shape,r.shape);return {a:function a(){var e=Li(t,r.toFloat()),o=zr(n.shape,i);return o.length>0?Wc(e,o).reshape(n.shape):e;},b:function b(){var e=t.mul(n.toFloat()),o=zr(r.shape,i);o.length>0&&(e=Wc(e,o).reshape(r.shape));var a=Tu(r);return ai(Li(e,a.toFloat()));}};}},{kernelName:"FusedBatchNorm",inputsToSave:["x","mean","variance","scale"],gradFunc:function gradFunc(t,e,n){var r=n.varianceEpsilon,i=e[0],o=e[1],a=e[2],s=e[3],u=zs(i),c=null==s?Pn(1):s,l=zr(o.shape,u.shape),f=[];if(1===o.rank){for(var h=0;h<u.shape.length-1;++h){f.push(u.shape[h]);}f.push(1);}var d=Bi(i,o),p=Ni(t,c),m=ci(Pr(a,Pn(r))),g=Ni(Ni(Ni(m,m),m),Pn(-.5));return {x:function x(){return 1===o.rank?hr(Ni(Ni(t,cu(m.as4D(1,1,1,o.shape[0]),f)),c),i.shape):hr(Ni(Ni(t,m),c),i.shape);},mean:function mean(){var t=Ni(Ni(m,Pn(-1)),p);return 1===o.rank&&(t=Wc(t,l)),hr(t,o.shape);},variance:function variance(){var t=Ni(Ni(g,d),p);return 1===o.rank&&(t=Wc(t,l)),hr(t,o.shape);},scale:function scale(){var e=Ni(d,m),n=Ni(t,e);return 1===o.rank&&(n=Wc(n,l)),hr(n,o.shape);},offset:function offset(){var e=t;return 1===o.rank&&(e=Wc(e,l)),hr(e,o.shape);}};}},{kernelName:Ir,gradFunc:function gradFunc(t){return {x:function x(){return t.toFloat();}};}},{kernelName:Nr,inputsToSave:["indices"],gradFunc:function gradFunc(t,e){var n=e[0];return {indices:function indices(){return Gn(n.shape,"float32");}};}},{kernelName:Mr,inputsToSave:["x"],gradFunc:function gradFunc(t,e,n){var r=e[0],i=n.paddings.map(function(t){return t[0];});return {x:function x(){return t.slice(i,r.shape);}};}},{kernelName:"Square",inputsToSave:["x"],gradFunc:function gradFunc(t,e){var n=e[0];return {x:function x(){return t.mul(n.toFloat().mul(2));}};}},{kernelName:_r,inputsToSave:["a","b"],gradFunc:function gradFunc(t,e){var n=e[0],r=e[1],i=Pn(2);return {a:function a(){return Ni(t,Ni(i,Bi(n,r)));},b:function b(){return Ni(t,Ni(i,Bi(r,n)));}};}},{kernelName:Rr,inputsToSave:["x"],gradFunc:function gradFunc(t,e,n){var r=e[0],i=n.reps;return {x:function x(){var e=Qn(r);if(1===r.rank)for(var n=0;n<i[0];++n){e=e.add(t.slice([n*r.shape[0]],[r.shape[0]]));}else if(2===r.rank)for(n=0;n<i[0];++n){for(var o=0;o<i[1];++o){e=e.add(t.slice([n*r.shape[0],o*r.shape[1]],[r.shape[0],r.shape[1]]));}}else if(3===r.rank)for(n=0;n<i[0];++n){for(o=0;o<i[1];++o){for(var a=0;a<i[2];++a){e=e.add(t.slice([n*r.shape[0],o*r.shape[1],a*r.shape[2]],[r.shape[0],r.shape[1],r.shape[2]]));}}}else {if(4!==r.rank)throw new Error("Gradient for tile operation is not implemented for rank-"+r.rank+" tensors yet.");for(n=0;n<i[0];++n){for(o=0;o<i[1];++o){for(a=0;a<i[2];++a){for(var s=0;s<i[3];++s){e=e.add(t.slice([n*r.shape[0],o*r.shape[1],a*r.shape[2],s*r.shape[3]],[r.shape[0],r.shape[1],r.shape[2],r.shape[3]]));}}}}}return e;}};}},{kernelName:"Transpose",gradFunc:function gradFunc(t,e,n){var r=Sn(n.perm);return {x:function x(){return fo(t,r);}};}}];yf<bf.length;yf++){b(bf[yf]);}var xf=function(){function t(){}return t.prototype.fetch=function(t,e){return fetch(t,e);},t.prototype.now=function(){return performance.now();},t.prototype.encode=function(t,e){if("utf-8"!==e&&"utf8"!==e)throw new Error("Browser's encoder only supports utf-8, but got "+e);return null==this.textEncoder&&(this.textEncoder=new TextEncoder()),this.textEncoder.encode(t);},t.prototype.decode=function(t,e){return new TextDecoder(e).decode(t);},t;}();f().get("IS_BROWSER")&&f().setPlatform("browser",new xf());var wf,kf=function(){function t(){this.util=n(388),this.textEncoder=new this.util.TextEncoder();}return t.prototype.fetch=function(t,e){return null!=f().global.fetch?f().global.fetch(t,e):(null==wf&&(wf=n(389)),wf(t,e));},t.prototype.now=function(){var t=r.hrtime();return 1e3*t[0]+t[1]/1e6;},t.prototype.encode=function(t,e){if("utf-8"!==e&&"utf8"!==e)throw new Error("Node built-in encoder only supports utf-8, but got "+e);return this.textEncoder.encode(t);},t.prototype.decode=function(t,e){return 0===t.length?"":new this.util.TextDecoder(e).decode(t);},t;}();f().get("IS_NODE")&&f().setPlatform("node",new kf());var Ef={float32:4,int32:4,uint16:2,uint8:1,bool:1},Cf=4;function Af(t,e){for(var n={},r=0,i=function i(e){var i=e.name,o=e.dtype,a=e.shape,s=T(a),u=void 0;if(("quantization"in e)){var c=e.quantization;if("uint8"!==c.dtype&&"uint16"!==c.dtype)throw new Error("Weight "+e.name+" has unknown quantization dtype "+c.dtype+". Supported quantization dtypes are: 'uint8' and 'uint16'.");var l=Ef[c.dtype],f=t.slice(r,r+s*l),h="uint8"===c.dtype?new Uint8Array(f):new Uint16Array(f);if("float32"===o)u=Float32Array.from(h,function(t){return t*c.scale+c.min;});else {if("int32"!==o)throw new Error("Unsupported dtype in weight '"+i+"': "+o);u=Int32Array.from(h,function(t){return Math.round(t*c.scale+c.min);});}r+=s*l;}else if("string"===o){var d=T(e.shape);u=[];for(var p=0;p<d;p++){var m=new Uint32Array(t.slice(r,r+Cf))[0];r+=Cf;var g=new Uint8Array(t.slice(r,r+m));u.push(g),r+=m;}}else {var v=Ef[o];if(f=t.slice(r,r+s*v),"float32"===o)u=new Float32Array(f);else if("int32"===o)u=new Int32Array(f);else {if("bool"!==o)throw new Error("Unsupported dtype in weight '"+i+"': "+o);u=new Uint8Array(f);}r+=s*v;}n[i]=jn(u,a,o);},o=0,a=e;o<a.length;o++){i(a[o]);}return n;}var Of=void 0!==i&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function _f(t){return Of?i.byteLength(t):new Blob([t]).size;}function Sf(t){var e=0;t.forEach(function(t){e+=t.byteLength;});var n=new Uint8Array(e),r=0;return t.forEach(function(t){n.set(new Uint8Array(t),r),r+=t.byteLength;}),n.buffer;}function Df(t){for(t=t.trim();t.endsWith("/");){t=t.slice(0,t.length-1);}var e=t.split("/");return e[e.length-1];}function Ff(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return {dateSaved:new Date(),modelTopologyType:"JSON",modelTopologyBytes:null==t.modelTopology?0:_f(JSON.stringify(t.modelTopology)),weightSpecsBytes:null==t.weightSpecs?0:_f(JSON.stringify(t.weightSpecs)),weightDataBytes:null==t.weightData?0:t.weightData.byteLength};}var Tf=function(){function t(){this.saveRouters=[],this.loadRouters=[];}return t.getInstance=function(){return null==t.instance&&(t.instance=new t()),t.instance;},t.registerSaveRouter=function(e){t.getInstance().saveRouters.push(e);},t.registerLoadRouter=function(e){t.getInstance().loadRouters.push(e);},t.getSaveHandlers=function(e){return t.getHandlers(e,"save");},t.getLoadHandlers=function(e,n){return t.getHandlers(e,"load",n);},t.getHandlers=function(e,n,r){var i=[];return ("load"===n?t.getInstance().loadRouters:t.getInstance().saveRouters).forEach(function(t){var n=t(e,r);null!==n&&i.push(n);}),i;},t;}(),Nf="://",If=function(){function t(){this.managers={};}return t.getInstance=function(){return null==t.instance&&(t.instance=new t()),t.instance;},t.registerManager=function(e,n){_(null!=e,function(){return "scheme must not be undefined or null.";}),e.endsWith(Nf)&&(e=e.slice(0,e.indexOf(Nf))),_(e.length>0,function(){return "scheme must not be an empty string.";});var r=t.getInstance();_(null==r.managers[e],function(){return "A model store manager is already registered for scheme '"+e+"'.";}),r.managers[e]=n;},t.getManager=function(t){var e=this.getInstance().managers[t];if(null==e)throw new Error("Cannot find model manager for scheme '"+t+"'");return e;},t.getSchemes=function(){return Object.keys(this.getInstance().managers);},t;}();function Rf(t){if(-1===t.indexOf(Nf))throw new Error("The url string provided does not contain a scheme. Supported schemes are: "+If.getSchemes().join(","));return {scheme:t.split(Nf)[0],path:t.split(Nf)[1]};}function Mf(t,e,n){return void 0===n&&(n=!1),u(this,void 0,void 0,function(){var r,i,o,a,s,u,l,f,h;return c(this,function(c){switch(c.label){case 0:return _(t!==e,function(){return "Old path and new path are the same: '"+t+"'";}),_((r=Tf.getLoadHandlers(t)).length>0,function(){return "Copying failed because no load handler is found for source URL "+t+".";}),_(r.length<2,function(){return "Copying failed because more than one ("+r.length+") load handlers for source URL "+t+".";}),i=r[0],_((o=Tf.getSaveHandlers(e)).length>0,function(){return "Copying failed because no save handler is found for destination URL "+e+".";}),_(o.length<2,function(){return "Copying failed because more than one ("+r.length+") save handlers for destination URL "+e+".";}),a=o[0],s=Rf(t).scheme,u=Rf(t).path,l=s===Rf(t).scheme,[4,i.load()];case 1:return f=c.sent(),n&&l?[4,If.getManager(s).removeModel(u)]:[3,3];case 2:c.sent(),c.label=3;case 3:return [4,a.save(f)];case 4:return h=c.sent(),!n||l?[3,6]:[4,If.getManager(s).removeModel(u)];case 5:c.sent(),c.label=6;case 6:return [2,h.modelArtifactsInfo];}});});}var jf="models_store",Bf="model_info_store";function Pf(){if(!f().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");var t=window||self,e=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB||t.shimIndexedDB;if(null==e)throw new Error("The current browser does not appear to support IndexedDB.");return e;}function Lf(t){var e=t.result;e.createObjectStore(jf,{keyPath:"modelPath"}),e.createObjectStore(Bf,{keyPath:"modelPath"});}var zf=function(){function t(t){if(this.indexedDB=Pf(),null==t||!t)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=t;}return t.prototype.save=function(t){return u(this,void 0,void 0,function(){return c(this,function(e){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return [2,this.databaseAction(this.modelPath,t)];});});},t.prototype.load=function(){return u(this,void 0,void 0,function(){return c(this,function(t){return [2,this.databaseAction(this.modelPath)];});});},t.prototype.databaseAction=function(t,e){var n=this;return new Promise(function(t,r){var i=n.indexedDB.open("tensorflowjs",1);i.onupgradeneeded=function(){return Lf(i);},i.onsuccess=function(){var o=i.result;if(null==e){var a=o.transaction(jf,"readonly"),s=a.objectStore(jf).get(n.modelPath);s.onsuccess=function(){if(null==s.result)return o.close(),r(new Error("Cannot find model with path '"+n.modelPath+"' in IndexedDB."));t(s.result.modelArtifacts);},s.onerror=function(t){return o.close(),r(s.error);},a.oncomplete=function(){return o.close();};}else {var u,c=Ff(e),l=o.transaction(Bf,"readwrite"),f=l.objectStore(Bf),h=f.put({modelPath:n.modelPath,modelArtifactsInfo:c});h.onsuccess=function(){var i=(u=o.transaction(jf,"readwrite")).objectStore(jf).put({modelPath:n.modelPath,modelArtifacts:e,modelArtifactsInfo:c});i.onsuccess=function(){return t({modelArtifactsInfo:c});},i.onerror=function(t){var e=(f=l.objectStore(Bf)).delete(n.modelPath);e.onsuccess=function(){return o.close(),r(i.error);},e.onerror=function(t){return o.close(),r(i.error);};};},h.onerror=function(t){return o.close(),r(h.error);},l.oncomplete=function(){null==u?o.close():u.oncomplete=function(){return o.close();};};}},i.onerror=function(t){return r(i.error);};});},t.URL_SCHEME="indexeddb://",t;}(),Uf=function Uf(t){return f().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(zf.URL_SCHEME)?(e=t.slice(zf.URL_SCHEME.length),new zf(e)):null;var e;};Tf.registerSaveRouter(Uf),Tf.registerLoadRouter(Uf);var Wf=function(){function t(){this.indexedDB=Pf();}return t.prototype.listModels=function(){return u(this,void 0,void 0,function(){var t=this;return c(this,function(e){return [2,new Promise(function(e,n){var r=t.indexedDB.open("tensorflowjs",1);r.onupgradeneeded=function(){return Lf(r);},r.onsuccess=function(){var t=r.result,i=t.transaction(Bf,"readonly"),o=i.objectStore(Bf).getAll();o.onsuccess=function(){for(var t={},n=0,r=o.result;n<r.length;n++){var i=r[n];t[i.modelPath]=i.modelArtifactsInfo;}e(t);},o.onerror=function(e){return t.close(),n(o.error);},i.oncomplete=function(){return t.close();};},r.onerror=function(t){return n(r.error);};})];});});},t.prototype.removeModel=function(t){return u(this,void 0,void 0,function(){var e=this;return c(this,function(n){var r;return t=(r=t).startsWith(zf.URL_SCHEME)?r.slice(zf.URL_SCHEME.length):r,[2,new Promise(function(n,r){var i=e.indexedDB.open("tensorflowjs",1);i.onupgradeneeded=function(){return Lf(i);},i.onsuccess=function(){var e,o=i.result,a=o.transaction(Bf,"readwrite"),s=a.objectStore(Bf),u=s.get(t);u.onsuccess=function(){if(null==u.result)return o.close(),r(new Error("Cannot find model with path '"+t+"' in IndexedDB."));var i=s.delete(t),a=function a(){var i=(e=o.transaction(jf,"readwrite")).objectStore(jf).delete(t);i.onsuccess=function(){return n(u.result.modelArtifactsInfo);},i.onerror=function(t){return r(u.error);};};i.onsuccess=a,i.onerror=function(t){return a(),o.close(),r(u.error);};},u.onerror=function(t){return o.close(),r(u.error);},a.oncomplete=function(){null==e?o.close():e.oncomplete=function(){return o.close();};};},i.onerror=function(t){return r(i.error);};})];});});},t;}();if(f().getBool("IS_BROWSER"))try{If.registerManager(zf.URL_SCHEME,new Wf());}catch(a){}var Vf="/",qf="tensorflowjs_models",$f="info",Hf="model_topology",Gf="weight_specs",Kf="weight_data",Xf="model_metadata";function Yf(t){return {info:[qf,t,$f].join(Vf),topology:[qf,t,Hf].join(Vf),weightSpecs:[qf,t,Gf].join(Vf),weightData:[qf,t,Kf].join(Vf),modelMetadata:[qf,t,Xf].join(Vf)};}function Jf(t){var e=t.split(Vf);if(e.length<3)throw new Error("Invalid key format: "+t);return e.slice(1,e.length-1).join(Vf);}var Qf=function(){function t(t){if(!f().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==t||!t)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=t,this.keys=Yf(this.modelPath);}return t.prototype.save=function(t){return u(this,void 0,void 0,function(){var e,n,r;return c(this,function(o){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");e=JSON.stringify(t.modelTopology),n=JSON.stringify(t.weightSpecs),r=Ff(t);try{return this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,e),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,function(t){if(Of)return i.from(t).toString("base64");for(var e=new Uint8Array(t),n="",r=0,o=e.length;r<o;r++){n+=String.fromCharCode(e[r]);}return btoa(n);}(t.weightData)),this.LS.setItem(this.keys.modelMetadata,JSON.stringify({format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,userDefinedMetadata:t.userDefinedMetadata})),[2,{modelArtifactsInfo:r}];}catch(t){throw this.LS.removeItem(this.keys.info),this.LS.removeItem(this.keys.topology),this.LS.removeItem(this.keys.weightSpecs),this.LS.removeItem(this.keys.weightData),this.LS.removeItem(this.keys.modelMetadata),new Error("Failed to save model '"+this.modelPath+"' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes="+r.modelTopologyBytes+", weightSpecsBytes="+r.weightSpecsBytes+", weightDataBytes="+r.weightDataBytes+".");}return [2];});});},t.prototype.load=function(){return u(this,void 0,void 0,function(){var t,e,n,r,o,a,s;return c(this,function(u){if(null==(t=JSON.parse(this.LS.getItem(this.keys.info))))throw new Error("In local storage, there is no model with name '"+this.modelPath+"'");if("JSON"!==t.modelTopologyType)throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");if(e={},null==(n=JSON.parse(this.LS.getItem(this.keys.topology))))throw new Error("In local storage, the topology of model '"+this.modelPath+"' is missing.");if(e.modelTopology=n,null==(r=JSON.parse(this.LS.getItem(this.keys.weightSpecs))))throw new Error("In local storage, the weight specs of model '"+this.modelPath+"' are missing.");if(e.weightSpecs=r,null!=(o=this.LS.getItem(this.keys.modelMetadata))&&(a=JSON.parse(o),e.format=a.format,e.generatedBy=a.generatedBy,e.convertedBy=a.convertedBy,e.userDefinedMetadata=a.userDefinedMetadata),null==(s=this.LS.getItem(this.keys.weightData)))throw new Error("In local storage, the binary weight values of model '"+this.modelPath+"' are missing.");return e.weightData=function(t){if(Of){var e=i.from(t,"base64");return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);}for(var n=atob(t),r=new Uint8Array(n.length),o=0;o<n.length;++o){r.set([n.charCodeAt(o)],o);}return r.buffer;}(s),[2,e];});});},t.URL_SCHEME="localstorage://",t;}(),Zf=function Zf(t){return f().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(Qf.URL_SCHEME)?(e=t.slice(Qf.URL_SCHEME.length),new Qf(e)):null;var e;};Tf.registerSaveRouter(Zf),Tf.registerLoadRouter(Zf);var th=function(){function t(){_(f().getBool("IS_BROWSER"),function(){return "Current environment is not a web browser";}),_("undefined"==typeof window||void 0!==window.localStorage,function(){return "Current browser does not appear to support localStorage";}),this.LS=window.localStorage;}return t.prototype.listModels=function(){return u(this,void 0,void 0,function(){var t,e,n,r,i,o;return c(this,function(a){for(t={},e=qf+Vf,n=Vf+$f,r=0;r<this.LS.length;++r){(i=this.LS.key(r)).startsWith(e)&&i.endsWith(n)&&(o=Jf(i),t[o]=JSON.parse(this.LS.getItem(i)));}return [2,t];});});},t.prototype.removeModel=function(t){return u(this,void 0,void 0,function(){var e,n;return c(this,function(r){var i;if(t=(i=t).startsWith(Qf.URL_SCHEME)?i.slice(Qf.URL_SCHEME.length):i,e=Yf(t),null==this.LS.getItem(e.info))throw new Error("Cannot find model at path '"+t+"'");return n=JSON.parse(this.LS.getItem(e.info)),this.LS.removeItem(e.info),this.LS.removeItem(e.topology),this.LS.removeItem(e.weightSpecs),this.LS.removeItem(e.weightData),[2,n];});});},t;}();if(f().getBool("IS_BROWSER"))try{If.registerManager(Qf.URL_SCHEME,new th());}catch(a){}var eh="model",nh=".json",rh=".weights.bin";function ih(t){return new Promise(function(t){return setTimeout(t);}).then(t);}var oh=function(){function t(e){if(!f().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(t.URL_SCHEME)&&(e=e.slice(t.URL_SCHEME.length)),null!=e&&0!==e.length||(e=eh),this.modelTopologyFileName=e+nh,this.weightDataFileName=e+rh;}return t.prototype.save=function(t){return u(this,void 0,void 0,function(){var e,n,r,i,o,a;return c(this,function(s){switch(s.label){case 0:if("undefined"==typeof document)throw new Error("Browser downloads are not supported in this environment since `document` is not present");if(e=window.URL.createObjectURL(new Blob([t.weightData],{type:"application/octet-stream"})),!(t.modelTopology instanceof ArrayBuffer))return [3,1];throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");case 1:return n=[{paths:["./"+this.weightDataFileName],weights:t.weightSpecs}],r={modelTopology:t.modelTopology,format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,weightsManifest:n},i=window.URL.createObjectURL(new Blob([JSON.stringify(r)],{type:"application/json"})),(o=null==this.jsonAnchor?document.createElement("a"):this.jsonAnchor).download=this.modelTopologyFileName,o.href=i,[4,ih(function(){return o.dispatchEvent(new MouseEvent("click"));})];case 2:return s.sent(),null==t.weightData?[3,4]:((a=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor).download=this.weightDataFileName,a.href=e,[4,ih(function(){return a.dispatchEvent(new MouseEvent("click"));})]);case 3:s.sent(),s.label=4;case 4:return [2,{modelArtifactsInfo:Ff(t)}];}});});},t.URL_SCHEME="downloads://",t;}(),ah=function(){function t(t){if(null==t||t.length<1)throw new Error("When calling browserFiles, at least 1 file is required, but received "+t);this.files=t;}return t.prototype.load=function(){return u(this,void 0,void 0,function(){var t,e,n=this;return c(this,function(r){return t=this.files[0],e=this.files.slice(1),[2,new Promise(function(r,i){var o=new FileReader();o.onload=function(o){var a=JSON.parse(o.target.result),s=a.modelTopology;if(null!=s){0===e.length&&r({modelTopology:s});var u=a.weightsManifest;if(null!=u){var c;try{c=n.checkManifestAndWeightFiles(u,e);}catch(t){return void i(t);}var l=[],f=[],h=[];u.forEach(function(t){t.paths.forEach(function(t){f.push(t),h.push(null);}),l.push.apply(l,t.weights);}),u.forEach(function(t){t.paths.forEach(function(t){var e=new FileReader();e.onload=function(e){var n=e.target.result,i=f.indexOf(t);h[i]=n,-1===h.indexOf(null)&&r({modelTopology:s,weightSpecs:l,weightData:Sf(h),format:a.format,generatedBy:a.generatedBy,convertedBy:a.convertedBy,userDefinedMetadata:a.userDefinedMetadata});},e.onerror=function(e){return i("Failed to weights data from file of path '"+t+"'.");},e.readAsArrayBuffer(c[t]);});});}else i(new Error("weightManifest field is missing from file "+t.name));}else i(new Error("modelTopology field is missing from file "+t.name));},o.onerror=function(e){return i("Failed to read model topology and weights manifest JSON from file '"+t.name+"'. BrowserFiles supports loading Keras-style tf.Model artifacts only.");},o.readAsText(t);})];});});},t.prototype.checkManifestAndWeightFiles=function(t,e){for(var n=[],r=e.map(function(t){return Df(t.name);}),i={},o=0,a=t;o<a.length;o++){a[o].paths.forEach(function(t){var o=Df(t);if(-1!==n.indexOf(o))throw new Error("Duplicate file basename found in weights manifest: '"+o+"'");if(n.push(o),-1===r.indexOf(o))throw new Error("Weight file with basename '"+o+"' is not provided.");i[t]=e[r.indexOf(o)];});}if(n.length!==e.length)throw new Error("Mismatch in the number of files in weights manifest ("+n.length+") and the number of weight files provided ("+e.length+").");return i;},t;}();function sh(t,e,n,r){!function(t){_(null!=t&&Array.isArray(t)&&t.length>0,function(){return "promises must be a none empty array";});}(t),function(t,e){_(t>=0&&t<=1,function(){return "Progress fraction must be in range [0, 1], but got startFraction "+t;}),_(e>=0&&e<=1,function(){return "Progress fraction must be in range [0, 1], but got endFraction "+e;}),_(e>=t,function(){return "startFraction must be no more than endFraction, but got startFraction "+t+" and endFraction "+e;});}(n=null==n?0:n,r=null==r?1:r);var i=0;return Promise.all(t.map(function(o){return o.then(function(o){var a=n+ ++i/t.length*(r-n);return e(a),o;}),o;}));}function uh(t,e){return u(this,void 0,void 0,function(){var n,r,i,o,a,s,u,l,h;return c(this,function(c){switch(c.label){case 0:return null==e&&(e={}),n=null==e.fetchFunc?f().platform.fetch:e.fetchFunc,r=t.map(function(t){return n(t,e.requestInit,{isBinary:!0});}),i=0,o=.5,null!=e.onProgress?[3,2]:[4,Promise.all(r)];case 1:return a=c.sent(),[3,4];case 2:return [4,sh(r,e.onProgress,i,o)];case 3:a=c.sent(),c.label=4;case 4:return s=a.map(function(t){return t.arrayBuffer();}),u=.5,l=1,null!=e.onProgress?[3,6]:[4,Promise.all(s)];case 5:return h=c.sent(),[3,8];case 6:return [4,sh(s,e.onProgress,u,l)];case 7:h=c.sent(),c.label=8;case 8:return [2,h];}});});}function ch(t){var e=this;return function(n,r,i){return void 0===r&&(r=""),u(e,void 0,void 0,function(){var e,o,a,s,u,l,f,h,d,p;return c(this,function(c){switch(c.label){case 0:if(e=n.map(function(){return !1;}),o={},a=null!=i?i.map(function(){return !1;}):[],s=[],n.forEach(function(t,n){var r=0;t.weights.forEach(function(t){var u="quantization"in t?t.quantization.dtype:t.dtype,c=Ef[u]*T(t.shape),l=function l(){e[n]=!0,null==o[n]&&(o[n]=[]),o[n].push({manifestEntry:t,groupOffset:r,sizeBytes:c});};null!=i?i.forEach(function(e,n){e===t.name&&(l(),a[n]=!0);}):l(),s.push(t.name),r+=c;});}),!a.every(function(t){return t;}))throw u=i.filter(function(t,e){return !a[e];}),new Error("Could not find weights in manifest with names: "+u.join(", ")+". \nManifest JSON has weights with names: "+s.join(", ")+".");return l=e.reduce(function(t,e,n){return e&&t.push(n),t;},[]),f=[],l.forEach(function(t){n[t].paths.forEach(function(t){var e=r+(r.endsWith("/")?"":"/")+t;f.push(e);});}),[4,t(f)];case 1:return h=c.sent(),d={},p=0,l.forEach(function(t){for(var e=n[t].paths.length,r=0,i=0;i<e;i++){r+=h[p+i].byteLength;}for(var a=new ArrayBuffer(r),s=new Uint8Array(a),u=0,c=0;c<e;c++){var l=new Uint8Array(h[p+c]);s.set(l,u),u+=l.byteLength;}o[t].forEach(function(t){var e=Af(a.slice(t.groupOffset,t.groupOffset+t.sizeBytes),[t.manifestEntry]);for(var n in e){d[n]=e[n];}}),p+=e;}),[2,d];}});});};}Tf.registerSaveRouter(function(t){return f().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(oh.URL_SCHEME)?function(t){return void 0===t&&(t="model"),new oh(t);}(t.slice(oh.URL_SCHEME.length)):null;});var lh=function(){function t(t,e){if(this.DEFAULT_METHOD="POST",null==e&&(e={}),this.weightPathPrefix=e.weightPathPrefix,this.onProgress=e.onProgress,null!=e.fetchFunc?(_("function"==typeof e.fetchFunc,function(){return "Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)";}),this.fetch=e.fetchFunc):this.fetch=f().platform.fetch,_(null!=t&&t.length>0,function(){return "URL path for http must not be null, undefined or empty.";}),Array.isArray(t)&&_(2===t.length,function(){return "URL paths for http must have a length of 2, (actual length is "+t.length+").";}),this.path=t,null!=e.requestInit&&null!=e.requestInit.body)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=e.requestInit||{};}return t.prototype.save=function(t){return u(this,void 0,void 0,function(){var e,n,r,i;return c(this,function(o){switch(o.label){case 0:if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");return (e=Object.assign({method:this.DEFAULT_METHOD},this.requestInit)).body=new FormData(),n=[{paths:["./model.weights.bin"],weights:t.weightSpecs}],r={modelTopology:t.modelTopology,format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,userDefinedMetadata:t.userDefinedMetadata,weightsManifest:n},e.body.append("model.json",new Blob([JSON.stringify(r)],{type:"application/json"}),"model.json"),null!=t.weightData&&e.body.append("model.weights.bin",new Blob([t.weightData],{type:"application/octet-stream"}),"model.weights.bin"),[4,this.fetch(this.path,e)];case 1:if((i=o.sent()).ok)return [2,{modelArtifactsInfo:Ff(t),responses:[i]}];throw new Error("BrowserHTTPRequest.save() failed due to HTTP response status "+i.status+".");}});});},t.prototype.load=function(){return u(this,void 0,void 0,function(){var t,e,n,r,i,o,a,s,u,l,f,h;return c(this,function(c){switch(c.label){case 0:return [4,this.fetch(this.path,this.requestInit)];case 1:if(!(t=c.sent()).ok)throw new Error("Request to "+this.path+" failed with status code "+t.status+". Please verify this URL points to the model JSON of the model to load.");c.label=2;case 2:return c.trys.push([2,4,,5]),[4,t.json()];case 3:return e=c.sent(),[3,5];case 4:throw c.sent(),n="Failed to parse model JSON of response from "+this.path+".",this.path.endsWith(".pb")?n+=" Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository.":n+=" Please make sure the server is serving valid JSON for this request.",new Error(n);case 5:if(r=e.modelTopology,i=e.weightsManifest,o=e.generatedBy,a=e.convertedBy,s=e.format,u=e.userDefinedMetadata,null==r&&null==i)throw new Error("The JSON from HTTP path "+this.path+" contains neither model topology or manifest for weights.");return null==i?[3,7]:[4,this.loadWeights(i)];case 6:h=c.sent(),l=h[0],f=h[1],c.label=7;case 7:return [2,{modelTopology:r,weightSpecs:l,weightData:f,userDefinedMetadata:u,generatedBy:o,convertedBy:a,format:s}];}});});},t.prototype.loadWeights=function(t){return u(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,l,f,h;return c(this,function(c){switch(c.label){case 0:for(e=Array.isArray(this.path)?this.path[1]:this.path,n=function(t){var e=t.lastIndexOf("/"),n=t.lastIndexOf("?");return [t.substring(0,e)+"/",n>e?t.substring(n):""];}(e),r=n[0],i=n[1],o=this.weightPathPrefix||r,a=[],s=0,u=t;s<u.length;s++){l=u[s],a.push.apply(a,l.weights);}return f=[],t.forEach(function(t){t.paths.forEach(function(t){f.push(o+t+i);});}),[4,uh(f,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress})];case 1:return h=c.sent(),[2,[a,Sf(h)]];}});});},t.URL_SCHEME_REGEX=/^https?:\/\//,t;}();function fh(t){return null!=t.match(lh.URL_SCHEME_REGEX);}var hh=function hh(t,e){return "undefined"==typeof fetch?null:(Array.isArray(t)?t.every(function(t){return fh(t);}):fh(t))?dh(t,{onProgress:e}):null;};function dh(t,e){return new lh(t,e);}Tf.registerSaveRouter(hh),Tf.registerLoadRouter(hh);var ph,mh=function(){function t(t){this.modelArtifacts=t;}return t.prototype.load=function(){return u(this,void 0,void 0,function(){return c(this,function(t){return [2,this.modelArtifacts];});});},t;}(),gh=function(){function t(t){this.saveHandler=t;}return t.prototype.save=function(t){return u(this,void 0,void 0,function(){return c(this,function(e){return [2,this.saveHandler(t)];});});},t;}(),vh=Object.freeze({browserFiles:function browserFiles(t){return new ah(t);},browserHTTPRequest:function browserHTTPRequest(t,e){return dh(t,e);},concatenateArrayBuffers:Sf,decodeWeights:Af,encodeWeights:function encodeWeights(t,e){return u(this,void 0,void 0,function(){var n,r,i,o,a,s=this;return c(this,function(l){switch(l.label){case 0:for(n=[],r=[],i=Array.isArray(t)?t.map(function(t){return t.name;}):Object.keys(t),o=function o(_o2){var a=i[_o2],l=Array.isArray(t)?t[_o2].tensor:t[a];if("float32"!==l.dtype&&"int32"!==l.dtype&&"bool"!==l.dtype&&"string"!==l.dtype)throw new Error("Unsupported dtype in weight '"+a+"': "+l.dtype);var f={name:a,shape:l.shape,dtype:l.dtype};if("string"===l.dtype){var h=new Promise(function(t){return u(s,void 0,void 0,function(){var e,n,r,i,o,a,s;return c(this,function(u){switch(u.label){case 0:return [4,l.bytes()];case 1:for(e=u.sent(),n=e.reduce(function(t,e){return t+e.length;},0)+Cf*e.length,r=new Uint8Array(n),i=0,o=0;o<e.length;o++){a=e[o],s=new Uint8Array(new Uint32Array([a.length]).buffer),r.set(s,i),i+=Cf,r.set(a,i),i+=a.length;}return t(r),[2];}});});});r.push(h);}else r.push(l.data());null!=e&&(f.group=e),n.push(f);},a=0;a<i.length;++a){o(a);}return [4,Promise.all(r)];case 1:return [2,{data:function(t){if(null===t)throw new Error("Invalid input value: "+JSON.stringify(t));var e=0,n=[];t.forEach(function(t){if(e+=t.byteLength,n.push(t.byteLength===t.buffer.byteLength?t:new t.constructor(t)),!(t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array))throw new Error("Unsupported TypedArray subtype: "+t.constructor.name);});var r=new Uint8Array(e),i=0;return n.forEach(function(t){r.set(new Uint8Array(t.buffer),i),i+=t.byteLength;}),r.buffer;}(l.sent()),specs:n}];}});});},fromMemory:function fromMemory(t,e,n,r){return 1===arguments.length?null!=t.modelTopology||null!=t.weightSpecs?new mh(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 mh({modelTopology: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 mh({modelTopology:t,weightSpecs:e,weightData:n,trainingConfig:r}));},getLoadHandlers:function getLoadHandlers(t,e){return Tf.getLoadHandlers(t,e);},getModelArtifactsInfoForJSON:Ff,getSaveHandlers:function getSaveHandlers(t){return Tf.getSaveHandlers(t);},http:dh,isHTTPScheme:fh,loadWeights:function loadWeights(t,e,n,r){return void 0===e&&(e=""),u(this,void 0,void 0,function(){return c(this,function(i){return [2,ch(function(t){return uh(t,{requestInit:r});})(t,e,n)];});});},registerLoadRouter:function registerLoadRouter(t){return Tf.registerLoadRouter(t);},registerSaveRouter:function registerSaveRouter(t){return Tf.registerSaveRouter(t);},weightsLoaderFactory:ch,withSaveHandler:function withSaveHandler(t){return new gh(t);},copyModel:function copyModel(t,e){return u(this,void 0,void 0,function(){return c(this,function(n){return [2,Mf(t,e,!1)];});});},listModels:function listModels(){return u(this,void 0,void 0,function(){var t,e,n,r,i,o,a;return c(this,function(s){switch(s.label){case 0:t=If.getSchemes(),e={},n=0,r=t,s.label=1;case 1:return n<r.length?(i=r[n],[4,If.getManager(i).listModels()]):[3,4];case 2:for(a in o=s.sent()){e[i+Nf+a]=o[a];}s.label=3;case 3:return n++,[3,1];case 4:return [2,e];}});});},moveModel:function moveModel(t,e){return u(this,void 0,void 0,function(){return c(this,function(n){return [2,Mf(t,e,!0)];});});},removeModel:function removeModel(t){return u(this,void 0,void 0,function(){var e;return c(this,function(n){return e=Rf(t),[2,If.getManager(e.scheme).removeModel(e.path)];});});}}),yh=Nn({confusionMatrix_:function confusionMatrix_(t,e,n){var r=xn(t,"labels","confusionMatrix"),i=xn(e,"predictions","confusionMatrix");_(null==n||n>0&&Number.isInteger(n),function(){return "If provided, numClasses must be a positive integer, but got "+n;}),_(1===r.rank,function(){return "Expected the rank of labels to be 1, but got "+r.rank;}),_(1===i.rank,function(){return "Expected the rank of predictions to be 1, but got "+i.rank;}),_(r.shape[0]===i.shape[0],function(){return "Mismatch in the number of examples: "+r.shape[0]+" vs. "+i.shape[0]+". Labels and predictions should have the same number of elements.";}),_(n>0&&Number.isInteger(n),function(){return "numClasses is required to be a positive integer, but got "+n;});var o=hu(r.asType("int32"),n),a=hu(i.asType("int32"),n);return o.transpose().matMul(a).asType("int32");}}),bh=Object.freeze({confusionMatrix:yh}),xh=Nn({fromPixels_:function fromPixels_(t,e){if(void 0===e&&(e=3),e>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==t)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");var n=!1,r=!1,i=!1,o=!1,a=!1;if(t.data instanceof Uint8Array)n=!0;else if("undefined"!=typeof ImageData&&t instanceof ImageData)r=!0;else if("undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement)i=!0;else if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement)o=!0;else {if(null==t.getContext)throw new Error("pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was "+t.constructor.name);a=!0;}if(i&&i&&t.readyState<2)throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the <video> element.");if(null!=m("FromPixels",Wt.backendName))return Wt.runKernel("FromPixels",{pixels:t},{numChannels:e});var s,u,c=i?[t.videoWidth,t.videoHeight]:[t.width,t.height],l=c[0],f=c[1];if(a?s=t.getContext("2d").getImageData(0,0,l,f).data:r||n?s=t.data:(o||i)&&(null==ph&&(ph=document.createElement("canvas").getContext("2d")),ph.canvas.width=l,ph.canvas.height=f,ph.drawImage(t,0,0,l,f),s=ph.getImageData(0,0,l,f).data),4===e)u=new Int32Array(s);else {var h=l*f;u=new Int32Array(h*e);for(var d=0;d<h;d++){for(var p=0;p<e;++p){u[d*e+p]=s[4*d+p];}}}return Un(u,[f,l,e],"int32");}}),wh=Object.freeze({toPixels:function toPixels(t,e){return u(this,void 0,void 0,function(){var n,r,i,o,a,s,u,l,f,h,d,p,m,g,v,y,b,x,w,k,E,C,A;return c(this,function(c){switch(c.label){case 0:if(n=xn(t,"img","toPixels"),t instanceof At||(n=n.toInt()),2!==n.rank&&3!==n.rank)throw new Error("toPixels only supports rank 2 or 3 tensors, got rank "+n.rank+".");if(r=n.shape.slice(0,2),i=r[0],o=r[1],(a=2===n.rank?1:n.shape[2])>4||2===a)throw new Error("toPixels only supports depth of size 1, 3 or 4 but got "+a);return [4,n.data()];case 1:return s=c.sent(),u=n.min(),l=n.max(),[4,Promise.all([u.data(),l.data()])];case 2:if(f=c.sent(),h=f[0],d=f[1],p=h[0],m=d[0],u.dispose(),l.dispose(),"float32"===n.dtype){if(p<0||m>1)throw new Error("Tensor values for a float32 Tensor must be in the range [0 - 1] but got range ["+p+" - "+m+"].");}else {if("int32"!==n.dtype)throw new Error("Unsupported type for toPixels: "+n.dtype+". Please use float32 or int32 tensors.");if(p<0||m>255)throw new Error("Tensor values for a int32 Tensor must be in the range [0 - 255] but got range ["+p+" - "+m+"].");}for(g="float32"===n.dtype?255:1,v=new Uint8ClampedArray(o*i*4),y=0;y<i*o;++y){b=void 0,x=void 0,w=void 0,k=void 0,1===a?(b=s[y]*g,x=s[y]*g,w=s[y]*g,k=255):3===a?(b=s[3*y]*g,x=s[3*y+1]*g,w=s[3*y+2]*g,k=255):4===a&&(b=s[4*y]*g,x=s[4*y+1]*g,w=s[4*y+2]*g,k=s[4*y+3]*g),v[0+(E=4*y)]=Math.round(b),v[E+1]=Math.round(x),v[E+2]=Math.round(w),v[E+3]=Math.round(k);}return null!=e&&(e.width=o,e.height=i,C=e.getContext("2d"),A=new ImageData(v,o,i),C.putImageData(A,0,0)),n!==t&&n.dispose(),[2,v];}});});},fromPixels:xh}),kh=function(){function t(){}return t.prototype.getClassName=function(){return this.constructor.className;},t.fromConfig=function(t,e){return new t(e);},t;}(),Eh=function(){function t(){this.classNameMap={};}return t.getMap=function(){return null==t.instance&&(t.instance=new t()),t.instance;},t.register=function(e){t.getMap().classNameMap[e.className]=[e,e.fromConfig];},t;}();function Ch(t){_(null!=t.className,function(){return "Class being registered does not have the static className property defined.";}),_("string"==typeof t.className,function(){return "className is required to be a string, but got type "+_typeof$1(t.className);}),_(t.className.length>0,function(){return "Class being registered has an empty-string as its className, which is disallowed.";}),Eh.register(t);}var Ah=Object.freeze({Serializable:kh,SerializationMap:Eh,registerClass:Ch}),Oh="1.7.4",_h=Object.freeze({gpgpu_util:$a,webgl_util:Ge,forceHalfFloat:function forceHalfFloat(){f().set("WEBGL_FORCE_F16_TEXTURES",!0);},MathBackendWebGL:Ss,setWebGLContext:Yt,GPGPUContext:Ha}),Sh=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return s(e,t),e.prototype.minimize=function(t,e,n){void 0===e&&(e=!1);var r=this.computeGradients(t,n),i=r.value,o=r.grads;if(null!=n){var a=n.map(function(t){return {name:t.name,tensor:o[t.name]};});this.applyGradients(a);}else this.applyGradients(o);return on(o),e?i:(i.dispose(),null);},Object.defineProperty(e.prototype,"iterations",{get:function get(){return null==this.iterations_&&(this.iterations_=0),this.iterations_;},enumerable:!0,configurable:!0}),e.prototype.incrementIterations=function(){this.iterations_=this.iterations+1;},e.prototype.computeGradients=function(t,e){return ao(t,e);},e.prototype.dispose=function(){null!=this.iterations_&&on(this.iterations_);},e.prototype.saveIterations=function(){return u(this,void 0,void 0,function(){return c(this,function(t){return null==this.iterations_&&(this.iterations_=0),[2,{name:"iter",tensor:Pn(this.iterations_,"int32")}];});});},e.prototype.getWeights=function(){return u(this,void 0,void 0,function(){return c(this,function(t){throw new Error("getWeights() is not implemented for this optimizer yet.");});});},e.prototype.setWeights=function(t){return u(this,void 0,void 0,function(){return c(this,function(t){throw new Error("setWeights() is not implemented for this optimizer class "+this.getClassName());});});},e.prototype.extractIterations=function(t){return u(this,void 0,void 0,function(){var e;return c(this,function(n){switch(n.label){case 0:return e=this,[4,t[0].tensor.data()];case 1:return e.iterations_=n.sent()[0],[2,t.slice(1)];}});});},e;}(kh);Object.defineProperty(Sh,Symbol.hasInstance,{value:function value(t){return null!=t.minimize&&null!=t.computeGradients&&null!=t.applyGradients;}});var Dh=function(t){function e(e,n,r){void 0===r&&(r=null);var i=t.call(this)||this;return i.learningRate=e,i.rho=n,i.epsilon=r,i.accumulatedGrads=[],i.accumulatedUpdates=[],null==r&&(i.epsilon=Wt.backend.epsilon()),i;}return s(e,t),e.prototype.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map(function(t){return t.name;}):Object.keys(t)).forEach(function(n,r){var i=Wt.registeredVariables[n];null==e.accumulatedGrads[r]&&(e.accumulatedGrads[r]={originalName:n+"/accum_grad",variable:rn(function(){return Qn(i).variable(!1);})}),null==e.accumulatedUpdates[r]&&(e.accumulatedUpdates[r]={originalName:n+"/accum_var",variable:rn(function(){return Qn(i).variable(!1);})});var o=Array.isArray(t)?t[r].tensor:t[n];if(null!=o){var a=e.accumulatedGrads[r].variable,s=e.accumulatedUpdates[r].variable;rn(function(){var t=a.mul(e.rho).add(o.square().mul(1-e.rho)),n=s.add(e.epsilon).sqrt().div(a.add(e.epsilon).sqrt()).mul(o),r=s.mul(e.rho).add(n.square().mul(1-e.rho));a.assign(t),s.assign(r);var u=n.mul(-e.learningRate).add(i);i.assign(u);});}}),this.incrementIterations();},e.prototype.dispose=function(){null!=this.accumulatedUpdates&&(on(this.accumulatedGrads.map(function(t){return t.variable;})),on(this.accumulatedUpdates.map(function(t){return t.variable;})));},e.prototype.getWeights=function(){return u(this,void 0,void 0,function(){var t;return c(this,function(e){switch(e.label){case 0:return t=this.accumulatedGrads.concat(this.accumulatedUpdates),[4,this.saveIterations()];case 1:return [2,[e.sent()].concat(t.map(function(t){return {name:t.originalName,tensor:t.variable};}))];}});});},e.prototype.setWeights=function(t){return u(this,void 0,void 0,function(){var e;return c(this,function(n){switch(n.label){case 0:return [4,this.extractIterations(t)];case 1:return t=n.sent(),e=t.length/2,this.accumulatedGrads=t.slice(0,e).map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};}),this.accumulatedUpdates=t.slice(e,2*e).map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};}),[2];}});});},e.prototype.getConfig=function(){return {learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon};},e.fromConfig=function(t,e){return new t(e.learningRate,e.rho,e.epsilon);},e.className="Adadelta",e;}(Sh);Ch(Dh);var Fh=function(t){function e(e,n){void 0===n&&(n=.1);var r=t.call(this)||this;return r.learningRate=e,r.initialAccumulatorValue=n,r.accumulatedGrads=[],r;}return s(e,t),e.prototype.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map(function(t){return t.name;}):Object.keys(t)).forEach(function(n,r){var i=Wt.registeredVariables[n];null==e.accumulatedGrads[r]&&(e.accumulatedGrads[r]={originalName:n+"/accumulator",variable:rn(function(){return Kn(i.shape,e.initialAccumulatorValue).variable(!1);})});var o=Array.isArray(t)?t[r].tensor:t[n];if(null!=o){var a=e.accumulatedGrads[r].variable;rn(function(){var t=a.add(o.square());a.assign(t);var n=o.div(t.add(Wt.backend.epsilon()).sqrt()).mul(-e.learningRate).add(i);i.assign(n);});}}),this.incrementIterations();},e.prototype.dispose=function(){null!=this.accumulatedGrads&&on(this.accumulatedGrads.map(function(t){return t.variable;}));},e.prototype.getWeights=function(){return u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return [4,this.saveIterations()];case 1:return [2,[t.sent()].concat(this.accumulatedGrads.map(function(t){return {name:t.originalName,tensor:t.variable};}))];}});});},e.prototype.setWeights=function(t){return u(this,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return [4,this.extractIterations(t)];case 1:return t=e.sent(),this.accumulatedGrads=t.map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};}),[2];}});});},e.prototype.getConfig=function(){return {learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue};},e.fromConfig=function(t,e){return new t(e.learningRate,e.initialAccumulatorValue);},e.className="Adagrad",e;}(Sh);Ch(Fh);var Th=function(t){function e(e,n,r,i){void 0===i&&(i=null);var o=t.call(this)||this;return o.learningRate=e,o.beta1=n,o.beta2=r,o.epsilon=i,o.accumulatedFirstMoment=[],o.accumulatedSecondMoment=[],rn(function(){o.accBeta1=Pn(n).variable(),o.accBeta2=Pn(r).variable();}),null==i&&(o.epsilon=Wt.backend.epsilon()),o;}return s(e,t),e.prototype.applyGradients=function(t){var e=this,n=Array.isArray(t)?t.map(function(t){return t.name;}):Object.keys(t);rn(function(){var r=Bi(1,e.accBeta1),i=Bi(1,e.accBeta2);n.forEach(function(n,o){var a=Wt.registeredVariables[n];null==e.accumulatedFirstMoment[o]&&(e.accumulatedFirstMoment[o]={originalName:n+"/m",variable:rn(function(){return Qn(a).variable(!1);})}),null==e.accumulatedSecondMoment[o]&&(e.accumulatedSecondMoment[o]={originalName:n+"/v",variable:rn(function(){return Qn(a).variable(!1);})});var s=Array.isArray(t)?t[o].tensor:t[n];if(null!=s){var u=e.accumulatedFirstMoment[o].variable,c=e.accumulatedSecondMoment[o].variable,l=u.mul(e.beta1).add(s.mul(1-e.beta1)),f=c.mul(e.beta2).add(s.square().mul(1-e.beta2)),h=l.div(r),d=f.div(i);u.assign(l),c.assign(f);var p=h.div(d.sqrt().add(e.epsilon)).mul(-e.learningRate).add(a);a.assign(p);}}),e.accBeta1.assign(e.accBeta1.mul(e.beta1)),e.accBeta2.assign(e.accBeta2.mul(e.beta2));}),this.incrementIterations();},e.prototype.dispose=function(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&on(this.accumulatedFirstMoment.map(function(t){return t.variable;})),null!=this.accumulatedSecondMoment&&on(this.accumulatedSecondMoment.map(function(t){return t.variable;}));},e.prototype.getWeights=function(){return u(this,void 0,void 0,function(){var t;return c(this,function(e){switch(e.label){case 0:return t=this.accumulatedFirstMoment.concat(this.accumulatedSecondMoment),[4,this.saveIterations()];case 1:return [2,[e.sent()].concat(t.map(function(t){return {name:t.originalName,tensor:t.variable};}))];}});});},e.prototype.setWeights=function(t){return u(this,void 0,void 0,function(){var e,n=this;return c(this,function(r){switch(r.label){case 0:return [4,this.extractIterations(t)];case 1:return t=r.sent(),rn(function(){n.accBeta1.assign(Ri(n.beta1,n.iterations_+1)),n.accBeta2.assign(Ri(n.beta2,n.iterations_+1));}),e=t.length/2,this.accumulatedFirstMoment=t.slice(0,e).map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};}),this.accumulatedSecondMoment=t.slice(e,2*e).map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};}),[2];}});});},e.prototype.getConfig=function(){return {learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon};},e.fromConfig=function(t,e){return new t(e.learningRate,e.beta1,e.beta2,e.epsilon);},e.className="Adam",e;}(Sh);Ch(Th);var Nh=function(t){function e(e,n,r,i,o){void 0===i&&(i=null),void 0===o&&(o=0);var a=t.call(this)||this;return a.learningRate=e,a.beta1=n,a.beta2=r,a.epsilon=i,a.decay=o,a.accumulatedFirstMoment=[],a.accumulatedWeightedInfNorm=[],rn(function(){a.iteration=Pn(0).variable(),a.accBeta1=Pn(n).variable();}),null==i&&(a.epsilon=Wt.backend.epsilon()),a;}return s(e,t),e.prototype.applyGradients=function(t){var e=this,n=Array.isArray(t)?t.map(function(t){return t.name;}):Object.keys(t);rn(function(){var r=Bi(1,e.accBeta1),i=Li(-e.learningRate,e.iteration.mul(e.decay).add(1));n.forEach(function(n,o){var a=Wt.registeredVariables[n];null==e.accumulatedFirstMoment[o]&&(e.accumulatedFirstMoment[o]={originalName:n+"/m",variable:Qn(a).variable(!1)}),null==e.accumulatedWeightedInfNorm[o]&&(e.accumulatedWeightedInfNorm[o]={originalName:n+"/v",variable:Qn(a).variable(!1)});var s=Array.isArray(t)?t[o].tensor:t[n];if(null!=s){var u=e.accumulatedFirstMoment[o].variable,c=e.accumulatedWeightedInfNorm[o].variable,l=u.mul(e.beta1).add(s.mul(1-e.beta1)),f=c.mul(e.beta2),h=s.abs(),d=f.maximum(h);u.assign(l),c.assign(d);var p=i.div(r).mul(l.div(d.add(e.epsilon))).add(a);a.assign(p);}}),e.iteration.assign(e.iteration.add(1)),e.accBeta1.assign(e.accBeta1.mul(e.beta1));}),this.incrementIterations();},e.prototype.dispose=function(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&on(this.accumulatedFirstMoment.map(function(t){return t.variable;})),null!=this.accumulatedWeightedInfNorm&&on(this.accumulatedWeightedInfNorm.map(function(t){return t.variable;}));},e.prototype.getWeights=function(){return u(this,void 0,void 0,function(){return c(this,function(t){throw new Error("getWeights() is not implemented for Adamax yet.");});});},e.prototype.setWeights=function(t){return u(this,void 0,void 0,function(){return c(this,function(t){throw new Error("setWeights() is not implemented for Adamax yet.");});});},e.prototype.getConfig=function(){return {learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay};},e.fromConfig=function(t,e){return new t(e.learningRate,e.beta1,e.beta2,e.epsilon,e.decay);},e.className="Adamax",e;}(Sh);Ch(Nh);var Ih=function(t){function e(e){var n=t.call(this)||this;return n.learningRate=e,n.setLearningRate(e),n;}return s(e,t),e.prototype.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map(function(t){return t.name;}):Object.keys(t)).forEach(function(n,r){var i=Array.isArray(t)?t[r].tensor:t[n];if(null!=i){var o=Wt.registeredVariables[n];rn(function(){var t=e.c.mul(i).add(o);o.assign(t);});}}),this.incrementIterations();},e.prototype.setLearningRate=function(t){this.learningRate=t,null!=this.c&&this.c.dispose(),this.c=an(Pn(-t));},e.prototype.dispose=function(){this.c.dispose();},e.prototype.getWeights=function(){return u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return [4,this.saveIterations()];case 1:return [2,[t.sent()]];}});});},e.prototype.setWeights=function(t){return u(this,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return [4,this.extractIterations(t)];case 1:if(0!==(t=e.sent()).length)throw new Error("SGD optimizer does not have settable weights.");return [2];}});});},e.prototype.getConfig=function(){return {learningRate:this.learningRate};},e.fromConfig=function(t,e){return new t(e.learningRate);},e.className="SGD",e;}(Sh);Ch(Ih);var Rh=function(t){function e(e,n,r){void 0===r&&(r=!1);var i=t.call(this,e)||this;return i.learningRate=e,i.momentum=n,i.useNesterov=r,i.accumulations=[],i.m=Pn(i.momentum),i;}return s(e,t),e.prototype.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map(function(t){return t.name;}):Object.keys(t)).forEach(function(n,r){var i=Wt.registeredVariables[n];null==e.accumulations[r]&&(e.accumulations[r]={originalName:n+"/momentum",variable:rn(function(){return Qn(i).variable(!1);})});var o=e.accumulations[r].variable,a=Array.isArray(t)?t[r].tensor:t[n];null!=a&&rn(function(){var t,n=e.m.mul(o).add(a);t=e.useNesterov?e.c.mul(a.add(n.mul(e.m))).add(i):e.c.mul(n).add(i),o.assign(n),i.assign(t);});}),this.incrementIterations();},e.prototype.dispose=function(){this.m.dispose(),null!=this.accumulations&&on(this.accumulations.map(function(t){return t.variable;}));},e.prototype.setMomentum=function(t){this.momentum=t;},e.prototype.getWeights=function(){return u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return [4,this.saveIterations()];case 1:return [2,[t.sent()].concat(this.accumulations.map(function(t){return {name:t.originalName,tensor:t.variable};}))];}});});},e.prototype.setWeights=function(t){return u(this,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return [4,this.extractIterations(t)];case 1:return t=e.sent(),this.accumulations=t.map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};}),[2];}});});},e.prototype.getConfig=function(){return {learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov};},e.fromConfig=function(t,e){return new t(e.learningRate,e.momentum,e.useNesterov);},e.className="Momentum",e;}(Ih);Ch(Rh);var Mh=function(t){function e(e,n,r,i,o){void 0===n&&(n=.9),void 0===r&&(r=0),void 0===i&&(i=null),void 0===o&&(o=!1);var a=t.call(this)||this;if(a.learningRate=e,a.decay=n,a.momentum=r,a.epsilon=i,a.accumulatedMeanSquares=[],a.accumulatedMoments=[],a.accumulatedMeanGrads=[],a.centered=o,null==i&&(a.epsilon=Wt.backend.epsilon()),null==e)throw new Error("learningRate for RMSPropOptimizer must be defined.");return a;}return s(e,t),e.prototype.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map(function(t){return t.name;}):Object.keys(t)).forEach(function(n,r){var i=Wt.registeredVariables[n];null==e.accumulatedMeanSquares[r]&&(e.accumulatedMeanSquares[r]={originalName:n+"/rms",variable:rn(function(){return Qn(i).variable(!1);})}),null==e.accumulatedMoments[r]&&(e.accumulatedMoments[r]={originalName:n+"/momentum",variable:rn(function(){return Qn(i).variable(!1);})}),null==e.accumulatedMeanGrads[r]&&e.centered&&(e.accumulatedMeanGrads[r]={originalName:n+"/mg",variable:rn(function(){return Qn(i).variable(!1);})});var o=Array.isArray(t)?t[r].tensor:t[n];if(null!=o){var a=e.accumulatedMeanSquares[r].variable,s=e.accumulatedMoments[r].variable;rn(function(){var t=a.mul(e.decay).add(o.square().mul(1-e.decay));if(e.centered){var n=e.accumulatedMeanGrads[r].variable,u=n.mul(e.decay).add(o.mul(1-e.decay)),c=s.mul(e.momentum).add(o.mul(e.learningRate).div(t.sub(u.square().add(e.epsilon)).sqrt()));a.assign(t),n.assign(u),s.assign(c);var l=i.sub(c);i.assign(l);}else {var f=a.mul(e.decay).add(o.square().mul(1-e.decay));c=s.mul(e.momentum).add(o.mul(e.learningRate).div(f.add(e.epsilon).sqrt())),a.assign(f),s.assign(c),l=i.sub(c),i.assign(l);}});}}),this.incrementIterations();},e.prototype.dispose=function(){null!=this.accumulatedMeanSquares&&on(this.accumulatedMeanSquares.map(function(t){return t.variable;})),null!=this.accumulatedMeanGrads&&this.centered&&on(this.accumulatedMeanGrads.map(function(t){return t.variable;})),null!=this.accumulatedMoments&&on(this.accumulatedMoments.map(function(t){return t.variable;}));},e.prototype.getWeights=function(){return u(this,void 0,void 0,function(){var t;return c(this,function(e){switch(e.label){case 0:return t=this.accumulatedMeanSquares.concat(this.accumulatedMoments),this.centered&&t.push.apply(t,this.accumulatedMeanGrads),[4,this.saveIterations()];case 1:return [2,[e.sent()].concat(t.map(function(t){return {name:t.originalName,tensor:t.variable};}))];}});});},e.prototype.setWeights=function(t){return u(this,void 0,void 0,function(){var e;return c(this,function(n){switch(n.label){case 0:return [4,this.extractIterations(t)];case 1:return t=n.sent(),e=this.centered?t.length/3:t.length/2,this.accumulatedMeanSquares=t.slice(0,e).map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};}),this.accumulatedMoments=t.slice(e,2*e).map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};}),this.centered&&(this.accumulatedMeanGrads=t.slice(2*e,3*e).map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};})),[2];}});});},e.prototype.getConfig=function(){return {learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered};},e.fromConfig=function(t,e){return new t(e.learningRate,e.decay,e.momentum,e.epsilon,e.centered);},e.className="RMSProp",e;}(Sh);Ch(Mh);var jh=function(){function t(){}return t.sgd=function(t){return new Ih(t);},t.momentum=function(t,e,n){return void 0===n&&(n=!1),new Rh(t,e,n);},t.rmsprop=function(t,e,n,r,i){return void 0===e&&(e=.9),void 0===n&&(n=0),void 0===r&&(r=null),void 0===i&&(i=!1),new Mh(t,e,n,r,i);},t.adam=function(t,e,n,r){return void 0===t&&(t=.001),void 0===e&&(e=.9),void 0===n&&(n=.999),void 0===r&&(r=null),new Th(t,e,n,r);},t.adadelta=function(t,e,n){return void 0===t&&(t=.001),void 0===e&&(e=.95),void 0===n&&(n=null),new Dh(t,e,n);},t.adamax=function(t,e,n,r,i){return void 0===t&&(t=.002),void 0===e&&(e=.9),void 0===n&&(n=.999),void 0===r&&(r=null),void 0===i&&(i=0),new Nh(t,e,n,r,i);},t.adagrad=function(t,e){return void 0===e&&(e=.1),new Fh(t,e);},t;}(),Bh={sgd:jh.sgd,momentum:jh.momentum,adadelta:jh.adadelta,adagrad:jh.adagrad,rmsprop:jh.rmsprop,adamax:jh.adamax,adam:jh.adam},Ph="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:void 0!==o?o:function(t){return t();};function Lh(){return new Promise(function(t){return Ph(function(){return t();});});}At.prototype.add=function(t){return Pr(this,t);},At.prototype.broadcastTo=function(t){return tu(this,t);},At.prototype.div=function(t){return Li(this,t);},At.prototype.divNoNan=function(t){return uu(this,t);},At.prototype.squaredDifference=function(t){return Nu(this,t);},At.prototype.tile=function(t){return cu(this,t);},At.prototype.oneHot=function(t,e,n){return void 0===e&&(e=1),void 0===n&&(n=0),hu(this,t,e,n);},At.prototype.transpose=function(t){return fo(this,t);},At.prototype.pad=function(t,e){return du(this,t,e);},At.prototype.batchNorm=function(t,e,n,r,i){return qs(this,t,e,n,r,i);},Et=Jl;}.call(this,n(59),n(75),n(92).Buffer,n(207).setImmediate);},function(t,e,n){function r(t,e,n){return t.fields=e||[],t.fname=n,t;}function i(t){return null==t?null:t.fname;}function o(t){return null==t?null:t.fields;}function a(t){return 1===t.length?s(t[0]):u(t);}n.d(e,"a",function(){return E;}),n.d(e,"b",function(){return x;}),n.d(e,"c",function(){return k;}),n.d(e,"d",function(){return b;}),n.d(e,"e",function(){return w;}),n.d(e,"f",function(){return r;}),n.d(e,"g",function(){return o;}),n.d(e,"h",function(){return i;}),n.d(e,"i",function(){return Y;}),n.d(e,"j",function(){return et;}),n.d(e,"k",function(){return J;}),n.d(e,"l",function(){return tt;}),n.d(e,"m",function(){return ot;}),n.d(e,"n",function(){return at;}),n.d(e,"o",function(){return c;}),n.d(e,"p",function(){return st;}),n.d(e,"q",function(){return ut;}),n.d(e,"r",function(){return ct;}),n.d(e,"s",function(){return v;}),n.d(e,"t",function(){return dt;}),n.d(e,"u",function(){return f;}),n.d(e,"v",function(){return pt;}),n.d(e,"w",function(){return ft;}),n.d(e,"x",function(){return h;}),n.d(e,"y",function(){return d;}),n.d(e,"z",function(){return mt;}),n.d(e,"A",function(){return gt;}),n.d(e,"B",function(){return A;}),n.d(e,"C",function(){return vt;}),n.d(e,"D",function(){return yt;}),n.d(e,"E",function(){return Q;}),n.d(e,"F",function(){return bt;}),n.d(e,"G",function(){return xt;}),n.d(e,"H",function(){return O;}),n.d(e,"I",function(){return wt;}),n.d(e,"J",function(){return kt;}),n.d(e,"K",function(){return Et;}),n.d(e,"L",function(){return Ct;}),n.d(e,"M",function(){return C;}),n.d(e,"N",function(){return Ot;}),n.d(e,"O",function(){return _t;}),n.d(e,"P",function(){return S;}),n.d(e,"Q",function(){return m;}),n.d(e,"R",function(){return Dt;}),n.d(e,"S",function(){return L;}),n.d(e,"T",function(){return z;}),n.d(e,"U",function(){return U;}),n.d(e,"V",function(){return W;}),n.d(e,"W",function(){return T;}),n.d(e,"X",function(){return K;}),n.d(e,"Y",function(){return St;}),n.d(e,"Z",function(){return Ft;}),n.d(e,"Aa",function(){return l;}),n.d(e,"Ba",function(){return Tt;}),n.d(e,"Ca",function(){return Nt;}),n.d(e,"Da",function(){return Rt;}),n.d(e,"Ea",function(){return N;}),n.d(e,"Fa",function(){return jt;}),n.d(e,"Ga",function(){return Mt;}),n.d(e,"Ha",function(){return Bt;}),n.d(e,"Ia",function(){return g;}),n.d(e,"Ja",function(){return X;}),n.d(e,"Ka",function(){return Pt;}),n.d(e,"La",function(){return D;}),n.d(e,"Ma",function(){return p;}),n.d(e,"Na",function(){return q;}),n.d(e,"Oa",function(){return $;}),n.d(e,"Pa",function(){return H;}),n.d(e,"Qa",function(){return G;});var s=function s(t){return function(e){return e[t];};},u=function u(t){var e=t.length;return function(n){for(var _r4=0;_r4<e;++_r4){n=n[t[_r4]];}return n;};};function c(t){throw Error(t);}function l(t){var e=[],n=t.length;var r,i,o,a=null,s=0,u="";function l(){e.push(u+t.substring(r,i)),u="",r=i+1;}for(t+="",r=i=0;i<n;++i){if("\\"===(o=t[i]))u+=t.substring(r,i),u+=t.substring(++i,++i),r=i;else if(o===a)l(),a=null,s=-1;else {if(a)continue;r===s&&'"'===o?(r=i+1,a=o):r===s&&"'"===o?(r=i+1,a=o):"."!==o||s?"["===o?(i>r&&l(),s=r=i+1):"]"===o&&(s||c("Access path missing open bracket: "+t),s>0&&l(),s=0,r=i+1):i>r?l():r=i+1;}}return s&&c("Access path missing closing bracket: "+t),a&&c("Access path missing closing quote: "+t),i>r&&(i++,l()),e;}function f(t,e,n){var i=l(t);return t=1===i.length?i[0]:t,r((n&&n.get||a)(i),[t],e||t);}var h=f("id"),d=r(function(t){return t;},[],"identity"),p=r(function(){return 0;},[],"zero"),m=r(function(){return 1;},[],"one"),g=r(function(){return !0;},[],"true"),v=r(function(){return !1;},[],"false");function y(t,e,n){var r=[e].concat([].slice.call(n));console[t].apply(console,r);}var b=0,x=1,w=2,k=3,E=4;function C(t,e){var n=t||b;return {level:function level(t){return arguments.length?(n=+t,this):n;},error:function error(){return n>=x&&y(e||"error","ERROR",arguments),this;},warn:function warn(){return n>=w&&y(e||"warn","WARN",arguments),this;},info:function info(){return n>=k&&y(e||"log","INFO",arguments),this;},debug:function debug(){return n>=E&&y(e||"log","DEBUG",arguments),this;}};}var A=Array.isArray;function O(t){return t===Object(t);}var _=function _(t){return "__proto__"!==t;};function S(){for(var _len=arguments.length,t=new Array(_len),_key=0;_key<_len;_key++){t[_key]=arguments[_key];}return t.reduce(function(t,e){for(var _n2 in e){if("signals"===_n2)t.signals=F(t.signals,e.signals);else {var _r5="legend"===_n2?{layout:1}:"style"===_n2||null;D(t,_n2,e[_n2],_r5);}}return t;},{});}function D(t,e,n,r){if(!_(e))return;var i,o;if(O(n)&&!A(n))for(i in o=O(t[e])?t[e]:t[e]={},n){r&&(!0===r||r[i])?D(o,i,n[i]):_(i)&&(o[i]=n[i]);}else t[e]=n;}function F(t,e){if(null==t)return e;var n={},r=[];function i(t){n[t.name]||(n[t.name]=1,r.push(t));}return e.forEach(i),t.forEach(i),r;}function T(t){return t[t.length-1];}function N(t){return null==t||""===t?null:+t;}var I=function I(t){return function(e){return t*Math.exp(e);};},R=function R(t){return function(e){return Math.log(t*e);};},M=function M(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t));};},j=function j(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t;};},B=function B(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t);};};function P(t,e,n,r){var i=n(t[0]),o=n(T(t)),a=(o-i)*e;return [r(i-a),r(o-a)];}function L(t,e){return P(t,e,N,d);}function z(t,e){var n=Math.sign(t[0]);return P(t,e,R(n),I(n));}function U(t,e,n){return P(t,e,B(n),B(1/n));}function W(t,e,n){return P(t,e,M(n),j(n));}function V(t,e,n,r,i){var o=r(t[0]),a=r(T(t)),s=null!=e?r(e):(o+a)/2;return [i(s+(o-s)*n),i(s+(a-s)*n)];}function q(t,e,n){return V(t,e,n,N,d);}function $(t,e,n){var r=Math.sign(t[0]);return V(t,e,n,R(r),I(r));}function H(t,e,n,r){return V(t,e,n,B(r),B(1/r));}function G(t,e,n,r){return V(t,e,n,M(r),j(r));}function K(t){return 1+~~(new Date(t).getMonth()/3);}function X(t){return 1+~~(new Date(t).getUTCMonth()/3);}function Y(t){return null!=t?A(t)?t:[t]:[];}function J(t,e,n){var r,i=t[0],o=t[1];return o<i&&(r=o,o=i,i=r),(r=o-i)>=n-e?[e,n]:[i=Math.min(Math.max(i,e),n-r),i+r];}function Q(t){return "function"==typeof t;}var Z="descending";function tt(t,e,n){n=n||{},e=Y(e)||[];var i=[],a=[],s={},u=n.comparator||nt;return Y(t).forEach(function(t,r){null!=t&&(i.push(e[r]===Z?-1:1),a.push(t=Q(t)?t:f(t,null,n)),(o(t)||[]).forEach(function(t){return s[t]=1;}));}),0===a.length?null:r(u(a,i),Object.keys(s));}var et=function et(t,e){return (t<e||null==t)&&null!=e?-1:(t>e||null==e)&&null!=t?1:(e=e instanceof Date?+e:e,(t=t instanceof Date?+t:t)!==t&&e==e?-1:e!=e&&t==t?1:0);},nt=function nt(t,e){return 1===t.length?rt(t[0],e[0]):it(t,e,t.length);},rt=function rt(t,e){return function(n,r){return et(t(n),t(r))*e;};},it=function it(t,e,n){return e.push(0),function(r,i){var o,a=0,s=-1;for(;0===a&&++s<n;){o=t[s],a=et(o(r),o(i));}return a*e[s];};};function ot(t){return Q(t)?t:function(){return t;};}function at(t,e){var n;return function(r){n&&clearTimeout(n),n=setTimeout(function(){return e(r),n=null;},t);};}function st(t){for(var _e2,_n3,_r6=1,_i3=arguments.length;_r6<_i3;++_r6){for(_n3 in _e2=arguments[_r6]){t[_n3]=_e2[_n3];}}return t;}function ut(t,e){var n,r,i,o,a=0;if(t&&(n=t.length))if(null==e){for(r=t[a];a<n&&(null==r||r!=r);r=t[++a]){}for(i=o=r;a<n;++a){null!=(r=t[a])&&(r<i&&(i=r),r>o&&(o=r));}}else {for(r=e(t[a]);a<n&&(null==r||r!=r);r=e(t[++a])){}for(i=o=r;a<n;++a){null!=(r=e(t[a]))&&(r<i&&(i=r),r>o&&(o=r));}}return [i,o];}function ct(t,e){var n=t.length;var r,i,o,a,s,u=-1;if(null==e){for(;++u<n;){if(null!=(i=t[u])&&i>=i){r=o=i;break;}}if(u===n)return [-1,-1];for(a=s=u;++u<n;){null!=(i=t[u])&&(r>i&&(r=i,a=u),o<i&&(o=i,s=u));}}else {for(;++u<n;){if(null!=(i=e(t[u],u,t))&&i>=i){r=o=i;break;}}if(u===n)return [-1,-1];for(a=s=u;++u<n;){null!=(i=e(t[u],u,t))&&(r>i&&(r=i,a=u),o<i&&(o=i,s=u));}}return [a,s];}var lt=Object.prototype.hasOwnProperty;function ft(t,e){return lt.call(t,e);}var ht={};function dt(t){var e,n={};function r(t){return ft(n,t)&&n[t]!==ht;}var i={size:0,empty:0,object:n,has:r,get:function get(t){return r(t)?n[t]:void 0;},set:function set(t,e){return r(t)||(++i.size,n[t]===ht&&--i.empty),n[t]=e,this;},delete:function _delete(t){return r(t)&&(--i.size,++i.empty,n[t]=ht),this;},clear:function clear(){i.size=i.empty=0,i.object=n={};},test:function test(t){return arguments.length?(e=t,i):e;},clean:function clean(){var t={};var r=0;for(var _i4 in n){var _o3=n[_i4];_o3===ht||e&&e(_o3)||(t[_i4]=_o3,++r);}i.size=r,i.empty=0,i.object=n=t;}};return t&&Object.keys(t).forEach(function(e){i.set(e,t[e]);}),i;}function pt(t,e,n,r,i,o){if(!n&&0!==n)return o;var a=+n;var s,u=t[0],c=T(t);c<u&&(s=u,u=c,c=s),s=Math.abs(e-u);var l=Math.abs(c-e);return s<l&&s<=a?r:l<=a?i:o;}function mt(t,e,n){var r=t.prototype=Object.create(e.prototype);return Object.defineProperty(r,"constructor",{value:t,writable:!0,enumerable:!0,configurable:!0}),st(r,n);}function gt(t,e,n,r){var i,o=e[0],a=e[e.length-1];return o>a&&(i=o,o=a,a=i),n=void 0===n||n,r=void 0===r||r,(n?o<=t:o<t)&&(r?t<=a:t<a);}function vt(t){return "boolean"==typeof t;}function yt(t){return "[object Date]"===Object.prototype.toString.call(t);}function bt(t){return t&&Q(t[Symbol.iterator]);}function xt(t){return "number"==typeof t;}function wt(t){return "[object RegExp]"===Object.prototype.toString.call(t);}function kt(t){return "string"==typeof t;}function Et(t,e,n){t&&(t=e?Y(t).map(function(t){return t.replace(/\\(.)/g,"$1");}):Y(t));var i=t&&t.length,o=n&&n.get||a,s=function s(t){return o(e?[t]:l(t));};var u;if(i){if(1===i){var _e3=s(t[0]);u=function u(t){return ""+_e3(t);};}else {var _e4=t.map(s);u=function u(t){var n=""+_e4[0](t),r=0;for(;++r<i;){n+="|"+_e4[r](t);}return n;};}}else u=function u(){return "";};return r(u,t,"key");}function Ct(t,e){var n=t[0],r=T(t),i=+e;return i?1===i?r:n+i*(r-n):n;}var At=1e4;function Ot(t){var e,n,r;t=+t||At;var i=function i(){e={},n={},r=0;},o=function o(i,_o4){return ++r>t&&(n=e,e={},r=1),e[i]=_o4;};return i(),{clear:i,has:function has(t){return ft(e,t)||ft(n,t);},get:function get(t){return ft(e,t)?e[t]:ft(n,t)?o(t,n[t]):void 0;},set:function set(t,n){return ft(e,t)?e[t]=n:o(t,n);}};}function _t(t,e,n,r){var i=e.length,o=n.length;if(!o)return e;if(!i)return n;var a=r||new e.constructor(i+o);var s=0,u=0,c=0;for(;s<i&&u<o;++c){a[c]=t(e[s],n[u])>0?n[u++]:e[s++];}for(;s<i;++s,++c){a[c]=e[s];}for(;u<o;++u,++c){a[c]=n[u];}return a;}function St(t,e){var n="";for(;--e>=0;){n+=t;}return n;}function Dt(t,e,n,r){var i=n||" ",o=t+"",a=e-o.length;return a<=0?o:"left"===r?St(i,a)+o:"center"===r?St(i,~~(a/2))+o+St(i,Math.ceil(a/2)):o+St(i,a);}function Ft(t){return t&&T(t)-t[0]||0;}function Tt(t){return A(t)?"["+t.map(Tt)+"]":O(t)||kt(t)?JSON.stringify(t).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):t;}function Nt(t){return null==t||""===t?null:!(!t||"false"===t||"0"===t)&&!!t;}var It=function It(t){return xt(t)?t:yt(t)?t:Date.parse(t);};function Rt(t,e){return e=e||It,null==t||""===t?null:e(t);}function Mt(t){return null==t||""===t?null:t+"";}function jt(t){var e={},n=t.length;for(var _r7=0;_r7<n;++_r7){e[t[_r7]]=!0;}return e;}function Bt(t,e,n,r){var i=null!=r?r:"…",o=t+"",a=o.length,s=Math.max(0,e-i.length);return a<=e?o:"left"===n?i+o.slice(a-s):"center"===n?o.slice(0,Math.ceil(s/2))+i+o.slice(a-~~(s/2)):o.slice(0,s)+i;}function Pt(t,e,n){if(t)if(e){var _r8=t.length;for(var _i5=0;_i5<_r8;++_i5){var _r9=e(t[_i5]);_r9&&n(_r9,_i5,t);}}else t.forEach(n);}},function(t,e,n){n.r(e);var r=n(0),_i6=function i(t,e){return (_i6=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e;}||function(t,e){for(var n in e){e.hasOwnProperty(n)&&(t[n]=e[n]);}})(t,e);};/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function o(t,e){function n(){this.constructor=t;}_i6(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n());}var a,_s2=function s(){return (_s2=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){for(var i in e=arguments[n]){Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);}}return t;}).apply(this,arguments);};function u(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});}function c(t,e){var n,r,i,o,a={label:0,sent:function sent(){if(1&i[0])throw i[1];return i[1];},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this;}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;){try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue;}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break;}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break;}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break;}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(t,a);}catch(t){o=[6,t],r=0;}finally{n=i=0;}}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:!0};}([o,s]);};}}function l(){return null==a&&(a=Object(r.backend)().epsilon()),a;}var f=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r;}return o(e,t),e;}(Error),h=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r;}return o(e,t),e;}(Error),d=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r;}return o(e,t),e;}(Error),p=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r;}return o(e,t),e;}(Error),m=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r;}return o(e,t),e;}(Error);!function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r;}o(e,t);}(Error);function g(t,e){if(Array.isArray(t)){for(var n=[],r=0;r<e;r++){n=n.concat(t);}return n;}return (n=new Array(e)).fill(t),n;}function v(t,e){if(!t)throw new m(e);}function y(t,e){for(var n=0,r=0,i=t;r<i.length;r++){i[r]===e&&n++;}return n;}function b(t){return 1===t.length?t[0]:t;}function x(t){return Array.isArray(t)?t:[t];}function w(t){var e=t.replace(/(.)([A-Z][a-z0-9]+)/g,"$1_$2").replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase();return "_"!==e[0]?e:"private"+e;}function k(t){return t.length<=1?t:-1===t.indexOf("_")?t:t.replace(/[_]+(\w|$)/g,function(t,e){return e.toUpperCase();});}var E={};function C(t){if(null===t||void 0===t)return null;var e={};return e.className=t.getClassName(),e.config=t.getConfig(),e;}function A(t,e,n,r,i){var o,a,u;if(void 0===e&&(e={}),void 0===n&&(n={}),void 0===r&&(r="object"),void 0===i&&(i=!1),"string"==typeof t){var c=t,l=void 0;if(c in n)l=n[c];else if(c in E)l=E[c];else if(null==(l=e[c]))throw new d("Unknown "+r+": "+t+". This may be due to one of the following reasons:\n1. The "+r+" is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom "+r+" is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().");return l;}var f=t;if(null==f.className||null==f.config)throw new d(r+": Improper config format: "+JSON.stringify(f)+".\n'className' and 'config' must set.");var h=f.className,p=void 0,m=void 0;if(h in n?(p=(o=n[h])[0],m=o[1]):h in E?(p=(a=E.className)[0],m=a[1]):h in e&&(p=(u=e[h])[0],m=u[1]),null==p)throw new d("Unknown "+r+": "+h+". This may be due to one of the following reasons:\n1. The "+r+" is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom "+r+" is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().");if(null!=m){for(var g={},v=0,y=Object.keys(E);v<y.length;v++){g[A=y[v]]=E[A];}for(var b=0,x=Object.keys(n);b<x.length;b++){g[A=x[b]]=n[A];}f.config.customObjects=g;for(var w=_s2({},E),k=0,C=Object.keys(n);k<C.length;k++){var A=C[k];E[A]=n[A];}!function t(e){if(null!=e&&"object"==_typeof$1(e))if(Array.isArray(e))e.forEach(function(e){return t(e);});else for(var n=0,r=Object.keys(e);n<r.length;n++){var i=r[n],o=e[i];null!=o&&"object"==_typeof$1(o)&&(Array.isArray(o)||"ndarray"!==o.type||"number"!=typeof o.value?t(o):e[i]=o.value);}}(f.config);var O=m(p,f.config,n,i);return E=_s2({},w),O;}w=_s2({},E);for(var _=0,S=Object.keys(n);_<S.length;_++){A=S[_],E[A]=n[A];}return O=new p(f.config),E=_s2({},w),O;}function O(t,e){return -1*function(t,e){return t<e?-1:t>e?1:0;}(t,e);}function _(t){if(null==t)return t;for(var e=[],n=0,r=t;n<r.length;n++){var i=r[n];-1===e.indexOf(i)&&e.push(i);}return e;}function S(t){if(null==t)throw new d("Invalid value in obj: "+JSON.stringify(t));for(var e in t){if(t.hasOwnProperty(e))return !1;}return !0;}function D(t,e,n){if(null!=n&&t.indexOf(n)<0)throw new d(n+" is not a valid "+e+".  Valid values are "+t+" or null/undefined.");}function F(t,e,n,r){return void 0===n&&(n=0),void 0===r&&(r=1/0),v(n>=0),v(r>=n),Array.isArray(t)&&t.length>=n&&t.length<=r&&t.every(function(t){return _typeof$1(t)===e;});}function T(t,e){Array.isArray(t)?(r.util.assert(t.length>0,function(){return e+" is unexpectedly an empty array.";}),t.forEach(function(t,n){return T(t,"element "+(n+1)+" of "+e);})):r.util.assert(Number.isInteger(t)&&t>0,function(){return "Expected "+e+" to be a positive integer, but got "+function t(e){return null===e?"null":Array.isArray(e)?"["+e.map(function(e){return t(e);}).join(",")+"]":"string"==typeof e?'"'+e+'"':""+e;}(t)+".";});}function N(t){return "relu"===t?"relu":"linear"===t?"linear":"elu"===t?"elu":null;}function I(t,e){return Object(r.tidy)(function(){return Object(r.sqrt)(Object(r.sum)(Object(r.mulStrict)(t,t),e,!0));});}var R=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.getConfig=function(){return {};},e;}(r.serialization.Serializable),M=function(t){function e(e){var n=t.call(this)||this;return n.defaultMaxValue=2,n.defaultAxis=0,n.maxValue=null!=e.maxValue?e.maxValue:n.defaultMaxValue,n.axis=null!=e.axis?e.axis:n.defaultAxis,n;}return o(e,t),e.prototype.apply=function(t){var e=this;return Object(r.tidy)(function(){var n=I(t,e.axis),i=Object(r.clipByValue)(n,0,e.maxValue);return Object(r.mul)(t,Object(r.div)(i,Object(r.add)(l(),n)));});},e.prototype.getConfig=function(){return {maxValue:this.maxValue,axis:this.axis};},e.className="MaxNorm",e;}(R);r.serialization.registerClass(M);var j=function(t){function e(e){var n=t.call(this)||this;return n.defaultAxis=0,n.axis=null!=e.axis?e.axis:n.defaultAxis,n;}return o(e,t),e.prototype.apply=function(t){var e=this;return Object(r.tidy)(function(){return Object(r.div)(t,Object(r.add)(l(),I(t,e.axis)));});},e.prototype.getConfig=function(){return {axis:this.axis};},e.className="UnitNorm",e;}(R);r.serialization.registerClass(j);var B=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.apply=function(t){return Object(r.relu)(t);},e.className="NonNeg",e;}(R);r.serialization.registerClass(B);var P=function(t){function e(e){var n=t.call(this)||this;return n.defaultMinValue=0,n.defaultMaxValue=1,n.defaultRate=1,n.defaultAxis=0,n.minValue=null!=e.minValue?e.minValue:n.defaultMinValue,n.maxValue=null!=e.maxValue?e.maxValue:n.defaultMaxValue,n.rate=null!=e.rate?e.rate:n.defaultRate,n.axis=null!=e.axis?e.axis:n.defaultAxis,n;}return o(e,t),e.prototype.apply=function(t){var e=this;return Object(r.tidy)(function(){var n=I(t,e.axis),i=Object(r.add)(Object(r.mul)(e.rate,Object(r.clipByValue)(n,e.minValue,e.maxValue)),Object(r.mul)(1-e.rate,n));return Object(r.mul)(t,Object(r.div)(i,Object(r.add)(l(),n)));});},e.prototype.getConfig=function(){return {minValue:this.minValue,maxValue:this.maxValue,rate:this.rate,axis:this.axis};},e.className="MinMaxNorm",e;}(R);r.serialization.registerClass(P);var L={maxNorm:"MaxNorm",minMaxNorm:"MinMaxNorm",nonNeg:"NonNeg",unitNorm:"UnitNorm"};function z(t){return C(t);}function U(t,e){return void 0===e&&(e={}),A(t,r.serialization.SerializationMap.getMap().classNameMap,e,"constraint");}function W(t){return null==t?null:"string"==typeof t?U({className:t in L?L[t]:t,config:{}}):t instanceof R?t:U(t);}var V=Object.freeze({maxNorm:function maxNorm(t){return new M(t);},unitNorm:function unitNorm(t){return new j(t);},nonNeg:function nonNeg(){return new B();},minMaxNorm:function minMaxNorm(t){return new P(t);}}),q=["channelsFirst","channelsLast"],$=["valid","same","causal"],H=["max","avg"],G=["sum","mul","concat","ave"],K=new Map();function X(t){D(q,"DataFormat",t);}function Y(t){D($,"PaddingMode",t);}function J(t){D(H,"PoolMode",t);}var Q=[],Z="/";function tt(t,e){Q.push(t);try{var n=e();return Q.pop(),n;}catch(t){throw Q.pop(),t;}}function et(t){if(!it(t))throw new Error("Not a valid tensor name: '"+t+"'");return (0===Q.length?"":Q.join(Z)+Z)+t;}function nt(t){if(!it(t))throw new Error("Not a valid tensor name: '"+t+"'");K.has(t)||K.set(t,0);var e=K.get(t);if(K.set(t,K.get(t)+1),e>0){var n=t+"_"+e;return K.set(n,1),n;}return t;}var rt=new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);function it(t){return !!t.match(rt);}function ot(t){return t===parseInt(t.toString(),10);}function at(t,e,n){null==e&&(e=0),null==n&&(n=t.length);for(var r=1,i=e;i<n;++i){r*=t[i];}return r;}function st(t){return t=Array.isArray(t)?new Float32Array(t):t,Object(r.tensor1d)(t);}function ut(t){return Object(r.min)(st(t)).dataSync()[0];}function ct(t){return Object(r.max)(st(t)).dataSync()[0];}function lt(t,e){if(e<t)throw new d("end ("+e+") < begin ("+t+") is forbidden.");for(var n=[],r=t;r<e;++r){n.push(r);}return n;}function ft(t,e){return t.asType(e);}function ht(t,e){void 0===e&&(e=-1);var n=t.shape.slice();return e<0&&(e=n.length+e+1),n.splice(e,0,1),t.reshape(n);}function dt(t,e,n){return Object(r.tidy)(function(){switch(t.rank){case 1:return Object(r.slice1d)(t,e,n);case 2:return Object(r.slice2d)(t,[e,0],[n,t.shape[1]]);case 3:return Object(r.slice3d)(t,[e,0,0],[n,t.shape[1],t.shape[2]]);case 4:return Object(r.slice4d)(t,[e,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3]]);case 5:return Object(r.slice)(t,[e,0,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3],t.shape[4]]);case 6:return Object(r.slice)(t,[e,0,0,0,0,0],[n,t.shape[1],t.shape[2],t.shape[3],t.shape[4],t.shape[5]]);default:throw new d("sliceAlongFirstAxis() received an unsupported tensor rank: "+t.rank);}});}function pt(t,e,n){return Object(r.tidy)(function(){switch(t.rank){case 1:return Object(r.slice1d)(t,e,n);case 2:return Object(r.slice2d)(t,[0,e],[t.shape[0],n]);case 3:return Object(r.slice3d)(t,[0,0,e],[t.shape[0],t.shape[1],n]);case 4:return Object(r.slice4d)(t,[0,0,0,e],[t.shape[0],t.shape[1],t.shape[2],n]);default:throw new d("sliceAlongLastAxis() received an unsupported tensor rank: "+t.rank);}});}function mt(t,e,n,i){return Object(r.tidy)(function(){switch(t.rank){case 1:return Object(r.slice1d)(t,e,n);case 2:switch(i){case 1:return dt(t,e,n);case 2:return pt(t,e,n);default:throw new d("The axis is not within the rank of the tensor "+i);}case 3:switch(i){case 1:return dt(t,e,n);case 2:return Object(r.slice3d)(t,[0,e,0],[t.shape[0],n,t.shape[2]]);case 3:return pt(t,e,n);default:throw new d("The axis is not within the rank of the tensor "+i);}case 4:switch(i){case 1:return dt(t,e,n);case 2:return Object(r.slice4d)(t,[0,e,0,0],[t.shape[0],n,t.shape[2],t.shape[3]]);case 3:return Object(r.slice4d)(t,[0,0,e,0],[t.shape[0],t.shape[1],n,t.shape[3]]);case 4:return pt(t,e,n);default:throw new d("The axis is not within the rank of the tensor "+i);}default:throw new d("sliceAlongLastAxis() received an unsupported tensor rank: "+t.rank);}});}function gt(t,e){var n;return void 0===e&&(e=-1),e<0&&(e=0!==(n=t[0].rank)?n:0),e===t[0].rank&&(e=-1),Object(r.concat)(t,e);}function vt(t,e){switch(t.rank){case 1:return Object(r.concat1d)([t,e]);case 2:return Object(r.concat2d)([t,e],0);case 3:return Object(r.concat3d)([t,e],0);case 4:return Object(r.concat4d)([t,e],0);default:throw new d("concatAlongFirstAxis() received an unsupported tensor rank: "+t.rank);}}function yt(t,e){if(Array.isArray(e)||(e=[e]),t.rank!==e.length)throw new d("The length of input n ("+e.length+") does not match the number of dimensions in input x ("+t.rank+")");return Object(r.tile)(t,e);}function bt(t,e,n,i,o){return void 0===e&&(e=0),void 0===n&&(n=1),Object(r.randomNormal)(t,e,n,i,o);}function xt(t,e,n,i){if(t.rank<2||e.rank<2)throw new p("dot requires both inputs to be rank >= 2 but got x shape = "+t.shape+" and y shape = "+e.shape);if(e.rank>=3&&t.shape.slice(-1)[0]!==(f=e.shape.slice(-2)[0]))throw new p("If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = "+t.shape+" and  y shape = "+e.shape);if(2===t.rank&&2===e.rank){var o=!1,a=!1;return r.fused.matMul({a:t,b:e,transposeA:o,transposeB:a,bias:i?Et(t.rank,i,"channelsLast"):null,activation:n});}var s=t.shape.slice(),u=s.pop();t=t.reshape([-1,u]);var c=e.shape.slice(),l=c.pop(),f=c.pop(),h=c.concat([l]),d=Array.from({length:e.rank},function(t,n){return 0===n?e.rank-2:n<=e.rank-2?n-1:n;});e=e.transpose(d).reshape([f,-1]);var m=s.concat(h);return o=!1,a=!1,r.fused.matMul({a:t,b:e,transposeA:o,transposeB:a,bias:i?Et(t.rank,i,"channelsLast"):null,activation:n}).reshape(m);}function wt(t,e,n){return Object(r.tidy)(function(){return e=Array.isArray(e)?Object(r.tensor1d)(e,"int32"):e.toInt(),Object(r.gather)(t,e,n);});}function kt(t){return Object(r.mulStrict)(t,t);}function Et(t,e,n){var r=e.shape;if(1!==e.rank&&e.rank!==t)throw new d("Unexpected bias dimensions: "+e.rank+"; expected it to be 1 or "+t);if(5===t){if("channelsFirst"===n)return 1===r.length?e.reshape([1,r[0],1,1,1]):e.reshape([1,r[3],r[0],r[1],r[2]]);if("channelsLast"===n)return 1===r.length?e.reshape([1,1,1,1,r[0]]):e.reshape([1].concat(r));}else if(4===t){if("channelsFirst"===n)return 1===r.length?e.reshape([1,r[0],1,1]):e.reshape([1,r[2],r[0],r[1]]);if("channelsLast"===n)return 1===r.length?e.reshape([1,1,1,r[0]]):e.reshape([1].concat(r));}else if(3===t){if("channelsFirst"===n)return 1===r.length?e.reshape([1,r[0],1]):e.reshape([1,r[1],r[0]]);if("channelsLast"===n)return 1===r.length?e.reshape([1,1,r[0]]):e.reshape([1].concat(r));}else if(t<3)return e;throw new d("Unsupported input rank by biasAdd: "+e.rank);}function Ct(t,e,n){return Object(r.tidy)(function(){return null==n&&(n="channelsLast"),X(n),t.add(Et(t.rank,e,n));});}function At(t,e,n,i){return Object(r.tidy)(function(){return Object(r.dropout)(t,e,n,i);});}function Ot(t,e,n){return void 0===n&&(n=!1),n?t():e();}var _t=["fanIn","fanOut","fanAvg"],St=["normal","uniform","truncatedNormal"];var Dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.fromConfigUsesCustomObjects=function(){return !1;},e.prototype.getConfig=function(){return {};},e;}(r.serialization.Serializable),Ft=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.apply=function(t,e){return Object(r.zeros)(t,e);},e.className="Zeros",e;}(Dt);r.serialization.registerClass(Ft);var Tt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.apply=function(t,e){return Object(r.ones)(t,e);},e.className="Ones",e;}(Dt);r.serialization.registerClass(Tt);var Nt=function(t){function e(e){var n=t.call(this)||this;if("object"!=_typeof$1(e))throw new d("Expected argument of type ConstantConfig but got "+e);if(void 0===e.value)throw new d("config must have value set but got "+e);return n.value=e.value,n;}return o(e,t),e.prototype.apply=function(t,e){var n=this;return Object(r.tidy)(function(){return Object(r.mul)(Object(r.scalar)(n.value),Object(r.ones)(t,e));});},e.prototype.getConfig=function(){return {value:this.value};},e.className="Constant",e;}(Dt);r.serialization.registerClass(Nt);var It=function(t){function e(e){var n=t.call(this)||this;return n.DEFAULT_MINVAL=-.05,n.DEFAULT_MAXVAL=.05,n.minval=e.minval||n.DEFAULT_MINVAL,n.maxval=e.maxval||n.DEFAULT_MAXVAL,n.seed=e.seed,n;}return o(e,t),e.prototype.apply=function(t,e){return Object(r.randomUniform)(t,this.minval,this.maxval,e);},e.prototype.getConfig=function(){return {minval:this.minval,maxval:this.maxval,seed:this.seed};},e.className="RandomUniform",e;}(Dt);r.serialization.registerClass(It);var Rt=function(t){function e(e){var n=t.call(this)||this;return n.DEFAULT_MEAN=0,n.DEFAULT_STDDEV=.05,n.mean=e.mean||n.DEFAULT_MEAN,n.stddev=e.stddev||n.DEFAULT_STDDEV,n.seed=e.seed,n;}return o(e,t),e.prototype.apply=function(t,e){if("float32"!==(e=e||"float32")&&"int32"!==e)throw new p("randomNormal does not support dType "+e+".");return bt(t,this.mean,this.stddev,e,this.seed);},e.prototype.getConfig=function(){return {mean:this.mean,stddev:this.stddev,seed:this.seed};},e.className="RandomNormal",e;}(Dt);r.serialization.registerClass(Rt);var Mt=function(t){function e(e){var n=t.call(this)||this;return n.DEFAULT_MEAN=0,n.DEFAULT_STDDEV=.05,n.mean=e.mean||n.DEFAULT_MEAN,n.stddev=e.stddev||n.DEFAULT_STDDEV,n.seed=e.seed,n;}return o(e,t),e.prototype.apply=function(t,e){if("float32"!==(e=e||"float32")&&"int32"!==e)throw new p("truncatedNormal does not support dType "+e+".");return Object(r.truncatedNormal)(t,this.mean,this.stddev,e,this.seed);},e.prototype.getConfig=function(){return {mean:this.mean,stddev:this.stddev,seed:this.seed};},e.className="TruncatedNormal",e;}(Dt);r.serialization.registerClass(Mt);var jt=function(t){function e(e){var n=t.call(this)||this;return n.gain=null!=e.gain?e.gain:1,n;}return o(e,t),e.prototype.apply=function(t,e){var n=this;return Object(r.tidy)(function(){if(2!==t.length||t[0]!==t[1])throw new d("Identity matrix initializer can only be used for 2D square matrices.");return Object(r.mul)(n.gain,Object(r.eye)(t[0]));});},e.prototype.getConfig=function(){return {gain:this.gain};},e.className="Identity",e;}(Dt);r.serialization.registerClass(jt);var Bt=function(t){function e(e){var n=t.call(this)||this;if(e.scale<0)throw new d("scale must be a positive float. Got: "+e.scale);return n.scale=null==e.scale?1:e.scale,n.mode=null==e.mode?"fanIn":e.mode,function(t){D(_t,"FanMode",t);}(n.mode),n.distribution=null==e.distribution?"normal":e.distribution,function(t){D(St,"Distribution",t);}(n.distribution),n.seed=e.seed,n;}return o(e,t),e.prototype.apply=function(t,e){var n=function(t,e){var n,r;if(void 0===e&&(e="channelsLast"),X(e),2===t.length)n=t[0],r=t[1];else if(-1!==[3,4,5].indexOf(t.length)){if("channelsFirst"===e){var i=at(t,2);n=t[1]*i,r=t[0]*i;}else "channelsLast"===e&&(i=at(t,0,t.length-2),n=t[t.length-2]*i,r=t[t.length-1]*i);}else {var o=at(t);n=Math.sqrt(o),r=Math.sqrt(o);}return [n,r];}(t),i=n[0],o=n[1],a=this.scale;if("fanIn"===this.mode?a/=Math.max(1,i):"fanOut"===this.mode?a/=Math.max(1,o):a/=Math.max(1,(i+o)/2),"normal"===this.distribution){var s=Math.sqrt(a);if("float32"!==(e=e||"float32")&&"int32"!==e)throw new p(this.getClassName()+" does not support dType "+e+".");return Object(r.truncatedNormal)(t,0,s,e,this.seed);}var u=Math.sqrt(3*a);return Object(r.randomUniform)(t,-u,u,e);},e.prototype.getConfig=function(){return {scale:this.scale,mode:this.mode,distribution:this.distribution,seed:this.seed};},e.className="VarianceScaling",e;}(Dt);r.serialization.registerClass(Bt);var Pt=function(t){function e(e){return t.call(this,{scale:1,mode:"fanAvg",distribution:"uniform",seed:null==e?null:e.seed})||this;}return o(e,t),e.prototype.getClassName=function(){return Bt.className;},e.className="GlorotUniform",e;}(Bt);r.serialization.registerClass(Pt);var Lt=function(t){function e(e){return t.call(this,{scale:1,mode:"fanAvg",distribution:"normal",seed:null==e?null:e.seed})||this;}return o(e,t),e.prototype.getClassName=function(){return Bt.className;},e.className="GlorotNormal",e;}(Bt);r.serialization.registerClass(Lt);var zt=function(t){function e(e){return t.call(this,{scale:2,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})||this;}return o(e,t),e.prototype.getClassName=function(){return Bt.className;},e.className="HeNormal",e;}(Bt);r.serialization.registerClass(zt);var Ut=function(t){function e(e){return t.call(this,{scale:2,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})||this;}return o(e,t),e.prototype.getClassName=function(){return Bt.className;},e.className="HeUniform",e;}(Bt);r.serialization.registerClass(Ut);var Wt=function(t){function e(e){return t.call(this,{scale:1,mode:"fanIn",distribution:"normal",seed:null==e?null:e.seed})||this;}return o(e,t),e.prototype.getClassName=function(){return Bt.className;},e.className="LeCunNormal",e;}(Bt);r.serialization.registerClass(Wt);var Vt=function(t){function e(e){return t.call(this,{scale:1,mode:"fanIn",distribution:"uniform",seed:null==e?null:e.seed})||this;}return o(e,t),e.prototype.getClassName=function(){return Bt.className;},e.className="LeCunNormal",e;}(Bt);r.serialization.registerClass(Vt);var qt=function(t){function e(e){var n=t.call(this)||this;if(n.DEFAULT_GAIN=1,n.gain=null==e.gain?n.DEFAULT_GAIN:e.gain,n.seed=e.seed,null!=n.seed)throw new p("Random seed is not implemented for Orthogonal Initializer yet.");return n;}return o(e,t),e.prototype.apply=function(t,e){var n=this;return Object(r.tidy)(function(){if(2!==t.length)throw new p("The Orthogonal Initializer does not support non-2D shapes yet.");t[0]*t[1]>2e3&&console.warn("Orthogonal initializer is being called on a matrix with more than 2000 ("+t[0]*t[1]+") elements: Slowness may result.");var e=bt(t[0]>t[1]?[t[1],t[0]]:t,0,1,"float32"),i=r.linalg.gramSchmidt(e);return t[0]>t[1]&&(i=i.transpose()),Object(r.mul)(n.gain,i);});},e.prototype.getConfig=function(){return {gain:this.gain,seed:this.seed};},e.className="Orthogonal",e;}(Dt);r.serialization.registerClass(qt);var $t={constant:"Constant",glorotNormal:"GlorotNormal",glorotUniform:"GlorotUniform",heNormal:"HeNormal",heUniform:"HeUniform",identity:"Identity",leCunNormal:"LeCunNormal",leCunUniform:"LeCunUniform",ones:"Ones",orthogonal:"Orthogonal",randomNormal:"RandomNormal",randomUniform:"RandomUniform",truncatedNormal:"TruncatedNormal",varianceScaling:"VarianceScaling",zeros:"Zeros"};function Ht(t,e){return void 0===e&&(e={}),A(t,r.serialization.SerializationMap.getMap().classNameMap,e,"initializer");}function Gt(t){return C(t);}function Kt(t){if("string"==typeof t){var e=t in $t?$t[t]:t;if("GlorotNormal"===e)return new Lt();if("GlorotUniform"===e)return new Pt();if("HeNormal"===e)return new zt();if("HeUniform"===e)return new Ut();if("LeCunNormal"===e)return new Wt();if("LeCunUniform"===e)return new Vt();var n={};return n.className=e,n.config={},Ht(n);}return t instanceof Dt?t:Ht(t);}var Xt=Object.freeze({zeros:function zeros(){return new Ft();},ones:function ones(){return new Tt();},constant:function constant(t){return new Nt(t);},randomUniform:function randomUniform(t){return new It(t);},randomNormal:function randomNormal(t){return new Rt(t);},truncatedNormal:function truncatedNormal(t){return new Mt(t);},identity:function identity(t){return new jt(t);},varianceScaling:function varianceScaling(t){return new Bt(t);},glorotUniform:function glorotUniform(t){return new Pt(t);},glorotNormal:function glorotNormal(t){return new Lt(t);},heNormal:function heNormal(t){return new zt(t);},heUniform:function heUniform(t){return new Ut(t);},leCunNormal:function leCunNormal(t){return new Wt(t);},leCunUniform:function leCunUniform(t){return new Vt(t);},orthogonal:function orthogonal(t){return new qt(t);}}),Yt=0;function Jt(){return Yt++;}var Qt={};function Zt(t){return void 0===t&&(t=""),t in Qt||(Qt[t]=0),Qt[t]+=1,t+Qt[t].toString();}function te(t){return Array.isArray(t)&&Array.isArray(t[0]);}function ee(t){return 0===t.length?[]:Array.isArray(t[0])?t:[t];}function ne(t){var e;if(Array.isArray(t)){if(1!==t.length)throw new d("Expected Tensor length to be 1; got "+t.length);e=t[0];}else e=t;return e;}function re(t){if(Array.isArray(t)&&Array.isArray(t[0])){if(1===t.length)return (t=t)[0];throw new d("Expected exactly 1 Shape; got "+t.length);}return t;}function ie(t){for(var e=0,n=0,r=t;n<r.length;n++){var i=r[n];0===i.shape.length?e+=1:e+=i.shape.reduce(function(t,e){return t*e;});}return e;}var oe="Variable",ae=function(){function t(t,e,n,i,o){void 0===e&&(e="float32"),void 0===n&&(n=oe),void 0===i&&(i=!0),void 0===o&&(o=null),this.dtype=null==e?"float32":e,this.shape=t.shape,this.id=Jt(),n=null==n?oe:n,this.originalName=et(n),this.name=nt(this.originalName),this.trainable_=i,this.constraint=o,this.val=Object(r.variable)(t,this.trainable_,this.name,this.dtype);}return t.prototype.read=function(){return this.assertNotDisposed(),this.val;},t.prototype.write=function(t){return this.assertNotDisposed(),function(t,e){if(t.shape.toString()!==e.shape.toString())throw new Error("Shape mismatch: "+JSON.stringify(t.shape)+" vs. "+JSON.stringify(e.shape));}(this.val,t),this.val.id!==t.id&&(this.val.assign(t),null!=this.constraint&&this.val.assign(this.constraint.apply(this.val))),this;},t.prototype.dispose=function(){this.assertNotDisposed(),this.val.dispose();},t.prototype.assertNotDisposed=function(){if(this.val.isDisposed)throw new Error("LayersVariable "+this.name+" is already disposed.");},Object.defineProperty(t.prototype,"trainable",{get:function get(){return this.trainable_;},set:function set(t){this.trainable_=t,this.val.trainable=t;},enumerable:!0,configurable:!0}),t;}();function se(t){return t.map(function(t){return t.read();});}function ue(t){t.forEach(function(t){t[0].write(t[1]);});}var ce=function ce(t){this.dtype=t.dtype,this.shape=t.shape,null!=t.shape?this.ndim=t.shape.length:this.ndim=t.ndim,this.maxNDim=t.maxNDim,this.minNDim=t.minNDim,this.axes=t.axes||{};},le=function le(t,e,n,r,i,o,a){this.dtype=t,this.shape=e,this.sourceLayer=n,this.inputs=r,this.callArgs=i,this.outputTensorIndex=a,this.id=Jt(),null!=o&&(this.originalName=et(o),this.name=nt(this.originalName)),this.rank=e.length;},fe=0,he=function(){function t(t,e){this.callArgs=e,this.id=fe++,this.outboundLayer=t.outboundLayer,this.inboundLayers=t.inboundLayers,this.nodeIndices=t.nodeIndices,this.tensorIndices=t.tensorIndices,this.inputTensors=t.inputTensors,this.outputTensors=t.outputTensors,this.inputMasks=t.inputMasks,this.outputMasks=t.outputMasks,this.inputShapes=t.inputShapes,this.outputShapes=t.outputShapes;for(var n=0,r=t.inboundLayers;n<r.length;n++){var i=r[n];null!=i&&i.outboundNodes.push(this);}t.outboundLayer.inboundNodes.push(this);}return t.prototype.getConfig=function(){for(var t=[],e=0,n=this.inboundLayers;e<n.length;e++){var r=n[e];null!=r?t.push(r.name):t.push(null);}return {outboundLayer:this.outboundLayer?this.outboundLayer.name:null,inboundLayers:t,nodeIndices:this.nodeIndices,tensorIndices:this.tensorIndices};},t;}(),de=0,pe=function(t){function e(e){var n=t.call(this)||this;n._callHook=null,n._addedWeightNames=[],n._stateful=!1,n.id=de++,n.activityRegularizer=null,n.inputSpec=null,n.supportsMasking=!1,n._trainableWeights=[],n._nonTrainableWeights=[],n._losses=[],n._updates=[],n._built=!1,n.inboundNodes=[],n.outboundNodes=[];var r=e.name;if(!r){var i=n.getClassName();r=w(i)+"_"+Zt(i);}if(n.name=r,n.trainable_=null==e.trainable||e.trainable,null!=e.inputShape||null!=e.batchInputShape){var o=void 0;if(null!=e.batchInputShape)o=e.batchInputShape;else if(null!=e.inputShape){var a=null;null!=e.batchSize&&(a=e.batchSize),o=[a].concat(e.inputShape);}n.batchInputShape=o;var s=e.dtype;null==s&&(s=e.inputDType),null==s&&(s="float32"),n.dtype=s;}return null!=e.weights?n.initialWeights=e.weights:n.initialWeights=null,n._refCount=null,n.fastWeightInitDuringBuild=!1,n;}return o(e,t),e.nodeKey=function(t,e){return t.name+"_ib-"+e.toString();},e.prototype.getNodeAtIndex=function(t,e){if(0===this.inboundNodes.length)throw new h("The layer has never been called and thus has no defined "+e+".");if(this.inboundNodes.length<=t)throw new d("Asked to get "+e+" at node "+t+", but the layer has only "+this.inboundNodes.length+" inbound nodes.");return this.inboundNodes[t];},e.prototype.getInputAt=function(t){return b(this.getNodeAtIndex(t,"input").inputTensors);},e.prototype.getOutputAt=function(t){return b(this.getNodeAtIndex(t,"output").outputTensors);},Object.defineProperty(e.prototype,"input",{get:function get(){if(this.inboundNodes.length>1)throw new f("Layer "+this.name+' has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use `getInputAt(nodeIndex)` instead.');if(0===this.inboundNodes.length)throw new f("Layer "+this.name+" is not connected, no input to return.");return b(this.getNodeAtIndex(0,"input").inputTensors);},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"output",{get:function get(){if(0===this.inboundNodes.length)throw new f("Layer "+this.name+" has no inbound nodes.");if(this.inboundNodes.length>1)throw new f("Layer "+this.name+' has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use `getOutputAt(nodeIndex)` instead.');return b(this.getNodeAtIndex(0,"output").outputTensors);},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"losses",{get:function get(){return this._losses;},enumerable:!0,configurable:!0}),e.prototype.calculateLosses=function(){return this.losses.map(function(t){return t();});},Object.defineProperty(e.prototype,"updates",{get:function get(){return this._updates;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"built",{get:function get(){return this._built;},set:function set(t){this._built=t;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"trainable",{get:function get(){return this.trainable_;},set:function set(t){this._trainableWeights.forEach(function(e){return e.trainable=t;}),this.trainable_=t;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"trainableWeights",{get:function get(){return this.trainable_?this._trainableWeights.filter(function(t){return t.trainable;}):[];},set:function set(t){this._trainableWeights=t;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nonTrainableWeights",{get:function get(){return this.trainable?this._trainableWeights.filter(function(t){return !t.trainable;}).concat(this._nonTrainableWeights):this._trainableWeights.concat(this._nonTrainableWeights);},set:function set(t){this._nonTrainableWeights=t;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"weights",{get:function get(){return this.trainableWeights.concat(this.nonTrainableWeights);},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stateful",{get:function get(){return this._stateful;},enumerable:!0,configurable:!0}),e.prototype.resetStates=function(){if(!this.stateful)throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.");},e.prototype.assertInputCompatibility=function(t){if(t=x(t),null!=this.inputSpec&&0!==this.inputSpec.length){var e=x(this.inputSpec);if(t.length!==e.length)throw new d("Layer "+this.name+" expects "+e.length+" inputs, but it received "+t.length+" input tensors. Input received: "+t);for(var n=0;n<t.length;n++){var r=t[n],i=e[n];if(null!=i){var o=r.rank;if(null!=i.ndim&&o!==i.ndim)throw new d("Input "+n+" is incompatible with layer "+this.name+": expected ndim="+i.ndim+", found ndim="+o);if(null!=i.maxNDim&&o>i.maxNDim)throw new d("Input "+n+" is incompatible with layer "+this.name+": expected max_ndim="+i.maxNDim+", found ndim="+o);if(null!=i.minNDim&&o<i.minNDim)throw new d("Input "+n+" is incompatible with layer "+this.name+": expected min_ndim="+i.minNDim+", found ndim="+o+".");if(null!=i.dtype&&r.dtype!==i.dtype)throw new d("Input "+n+" is incompatible with layer "+this.name+" : expected dtype="+i.dtype+", found dtype="+r.dtype+".");if(i.axes){var a=r.shape;for(var s in i.axes){var u=Number(s),c=i.axes[s],l=u>=0?a[u]:a[a.length+u];if(null!=c&&-1===[c,null].indexOf(l))throw new d("Input "+n+" is incompatible with layer "+this.name+": expected axis "+u+" of input shape to have value "+c+" but got shape "+a+".");}}if(null!=i.shape)for(var f=0;f<i.shape.length;++f){var h=i.shape[f],p=r.shape[f];if(null!=h&&null!=p&&h!==p)throw new d("Input "+n+" is incompatible with layer "+this.name+": expected shape="+i.shape+", found shape="+r.shape+".");}}}}},e.prototype.call=function(t,e){return t;},e.prototype.invokeCallHook=function(t,e){null!=this._callHook&&this._callHook(t,e);},e.prototype.setCallHook=function(t){this._callHook=t;},e.prototype.clearCallHook=function(){this._callHook=null;},e.prototype.apply=function(t,e){var n=this;e=e||{},this.assertNotDisposed();for(var r=x(t),i=!0,o=0,a=r;o<a.length;o++){if(!(a[o]instanceof le)){i=!1;break;}}for(var s=!0,u=0,c=r;u<c.length;u++){if(c[u]instanceof le){s=!1;break;}}if(i===s)throw new d("Arguments to apply() must be all SymbolicTensors or all Tensors");return tt(this.name,function(){if(!n.built){n.assertInputCompatibility(t);for(var i=[],o=0,a=x(t);o<a.length;o++){var u=a[o];i.push(u.shape);}n.build(b(i)),n.built=!0,n.initialWeights&&n.setWeights(n.initialWeights),null===n._refCount&&s&&(n._refCount=1);}if(n.assertInputCompatibility(t),s){for(var c=[],l=0,f=x(g=n.call(t,e));l<f.length;l++){var h=f[l];-1!==r.indexOf(h)&&(h=h.clone()),c.push(h);}if(g=b(c),null!=n.activityRegularizer)throw new p("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return g;}var d=function(t){for(var e=[],n=0,r=t=x(t);n<r.length;n++){var i=r[n];e.push(i.shape);}return b(e);}(t),m=n.computeOutputShape(d),g=void 0,v="float32";if(n.warnOnIncompatibleInputShape(Array.isArray(t)?d[0]:d),g=null!=m&&m.length>0&&Array.isArray(m[0])?m.map(function(r,i){return new le(v,r,n,x(t),e,n.name,i);}):new le(v,m,n,x(t),e,n.name),n.addInboundNode(t,g,null,null,d,m,e),n._refCount++,null!=n.activityRegularizer)throw new p("Layer invocation in the presence of activity regularizer(s) is not supported yet.");return g;});},e.prototype.warnOnIncompatibleInputShape=function(t){if(null!=this.batchInputShape)if(t.length!==this.batchInputShape.length)console.warn("The rank of the input tensor provided (shape: "+JSON.stringify(t)+") does not match that of the batchInputShape ("+JSON.stringify(this.batchInputShape)+") of the layer "+this.name);else {var e=!1;this.batchInputShape.forEach(function(n,r){null!=n&&null!=t[r]&&t[r]!==n&&(e=!0);}),e&&console.warn("The shape of the input tensor ("+JSON.stringify(t)+") does not match the expectation of layer "+this.name+": "+JSON.stringify(this.batchInputShape));}},Object.defineProperty(e.prototype,"outputShape",{get:function get(){if(null==this.inboundNodes||0===this.inboundNodes.length)throw new f("The layer "+this.name+" has never been called and thus has no defined output shape.");for(var t=[],e=0,n=this.inboundNodes;e<n.length;e++){var r=n[e],i=JSON.stringify(r.outputShapes);-1===t.indexOf(i)&&t.push(i);}if(1===t.length){var o=this.inboundNodes[0].outputShapes;return Array.isArray(o)&&Array.isArray(o[0])&&1===o.length?o[0]:o;}throw new f("The layer "+this.name+' has multiple inbound nodes with different output shapes. Hence the notion of "outut shape" is ill-defined for the layer.');},enumerable:!0,configurable:!0}),e.prototype.countParams=function(){if(!this.built)throw new h("You tried to call countParams() on "+this.name+", but the layer is not built yet. Build it first by calling build(batchInputShape).");return ie(this.weights);},e.prototype.build=function(t){this.built=!0;},e.prototype.getWeights=function(t){return void 0===t&&(t=!1),se(t?this.trainableWeights:this.weights);},e.prototype.setWeights=function(t){var e=this;Object(r.tidy)(function(){var n=e.weights;if(n.length!==t.length)throw new d('You called setWeights(weights) on layer "'+e.name+'" with a weight list of length '+t.length+", but the layer was expecting "+n.length+" weights. Provided weights: "+t+"...");if(0!==n.length){for(var i=[],o=se(n),a=0;a<o.length;++a){var s=o[a],u=n[a],c=t[a];if(!r.util.arraysEqual(s.shape,c.shape))throw new d("Layer weight shape "+s.shape+" not compatible with provided weight shape "+c.shape);i.push([u,c]);}ue(i);}});},e.prototype.addWeight=function(t,e,n,r,i,o,a){if(-1!==this._addedWeightNames.indexOf(t))throw new d("Duplicate weight name "+t+" for layer "+this.name);this._addedWeightNames.push(t),null==n&&(n="float32"),this.fastWeightInitDuringBuild&&(r=Kt("zeros"));var s=r.apply(e,n),u=new ae(s,n,t,o,a);return s.dispose(),null!=i&&this.addLoss(function(){return i.apply(u.read());}),null==o&&(o=!0),o?this._trainableWeights.push(u):this._nonTrainableWeights.push(u),u;},e.prototype.setFastWeightInitDuringBuild=function(t){this.fastWeightInitDuringBuild=t;},e.prototype.addLoss=function(t){var e;null==t||Array.isArray(t)&&0===t.length||(t=x(t),void 0!==this._losses&&null!==this._losses&&(e=this.losses).push.apply(e,t));},e.prototype.computeOutputShape=function(t){return t;},e.prototype.computeMask=function(t,e){var n=this;if(!this.supportsMasking){if(null!=e){if(!Array.isArray(e))throw new TypeError("Layer "+this.name+" does not support masking, but was passed an inputMask.");e.forEach(function(t){if(null!=t)throw new TypeError("Layer "+n.name+" does not support masking, but was passed an inputMask.");});}return null;}return e;},e.prototype.addInboundNode=function(t,e,n,r,i,o,a){void 0===a&&(a=null);var s=x(t);e=x(e),n=x(n),r=x(r),i=ee(i),o=ee(o);for(var u=[],c=[],l=[],f=0,h=s;f<h.length;f++){var d=h[f];u.push(d.sourceLayer),c.push(d.nodeIndex),l.push(d.tensorIndex);}new he({outboundLayer:this,inboundLayers:u,nodeIndices:c,tensorIndices:l,inputTensors:s,outputTensors:e,inputMasks:n,outputMasks:r,inputShapes:i,outputShapes:o},a);for(var p=0;p<e.length;p++){e[p].sourceLayer=this,e[p].nodeIndex=this.inboundNodes.length-1,e[p].tensorIndex=p;}},e.prototype.getConfig=function(){var t={name:this.name,trainable:this.trainable};return null!=this.batchInputShape&&(t.batchInputShape=this.batchInputShape),null!=this.dtype&&(t.dtype=this.dtype),t;},e.prototype.disposeWeights=function(){return this.weights.forEach(function(t){return t.dispose();}),this.weights.length;},e.prototype.assertNotDisposed=function(){if(0===this._refCount)throw new Error("Layer '"+this.name+"' is already disposed.");},e.prototype.dispose=function(){if(!this.built)throw new Error("Cannot dispose Layer "+this.name+" because it has not been built yet.");if(null===this._refCount)throw new Error("Cannot dispose Layer "+this.name+" because it has not been used yet.");this.assertNotDisposed();var t=0;return 0==--this._refCount&&(t=this.disposeWeights()),{refCountAfterDispose:this._refCount,numDisposedVariables:t};},e;}(r.serialization.Serializable);var me,ge=function(t){function e(e){var n=t.call(this,{dtype:e.dtype,name:null!=e.name?e.name:Zt("input").toString()})||this;if(null==e.batchSize&&(e.batchSize=null),null==e.sparse&&(e.sparse=!1),n.trainable=!1,n.built=!0,n.sparse=e.sparse,null!=e.inputShape&&null!=e.batchInputShape)throw new d("Only provide the inputShape OR batchInputShape argument to inputLayer, not both at the same time.");var r=e.batchInputShape;if(null==r){if(null==e.inputShape)throw new d("An InputLayer should be passed either a `batchInputShape` or an `inputShape`.");r=[e.batchSize].concat(e.inputShape);}else if(null!=e.batchSize)throw new d("Cannot specify batchSize if batchInputShape is specified when creating an InputLayer.");var i=e.dtype||"float32";n.batchInputShape=r,n.dtype=i,n.inputSpec=[{shape:r}];var o=new le(n.dtype,n.batchInputShape,n,[],{},n.name);return o.nodeIndex=0,o.tensorIndex=0,new he({outboundLayer:n,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:[o],outputTensors:[o],inputMasks:[null],outputMasks:[null],inputShapes:[r],outputShapes:[r]}),n;}return o(e,t),e.prototype.apply=function(t,e){throw new d("Cannot pass any input to an InputLayer's apply() method. InputLayer name: "+this.name);},e.prototype.dispose=function(){return {refCountAfterDispose:this._refCount,numDisposedVariables:0};},e.prototype.getConfig=function(){return {batchInputShape:this.batchInputShape,dtype:this.dtype,sparse:this.sparse,name:this.name};},e.className="InputLayer",e;}(pe);function ve(t){if(null==t.batchShape&&null==t.shape)throw new Error("Please provide to Input either a `shape` or a `batchShape` argument. Note that `shape` does not include the batch dimension.");if(null!=t.batchShape&&null!=t.shape)throw new d("Please provide either a `shape` or `batchShape` argument to Input, but not both.");var e=t.batchShape;null!=t.shape&&null==e&&(e=[null].concat(t.shape));var n=t.dtype;return null==n&&(n="float32"),new ge({batchInputShape:e,name:t.name,dtype:n,sparse:t.sparse}).inboundNodes[0].outputTensors[0];}function ye(t){return u(this,void 0,void 0,function(){var e,n,i,o,a,s,u,l;return c(this,function(c){switch(c.label){case 0:if(null==t)return [2];for(o in e=[],n=[],i=[],t){"number"!=typeof(a=t[o])&&(s=a,e.push(s.data()),n.push(o),i.push(s));}return e.length>0?[4,Promise.all(e)]:[3,2];case 1:for(u=c.sent(),l=0;l<u.length;++l){t[n[l]]=u[l][0];}Object(r.dispose)(i),c.label=2;case 2:return [2];}});});}function be(t){if(null!=t)for(var e in t){var n=t[e];"number"!=typeof n&&n.dispose();}}r.serialization.registerClass(ge),function(t){t[t.SILENT=0]="SILENT",t[t.VERBOSE=1]="VERBOSE";}(me||(me={}));var xe=125,we=function(){function t(){this.validationData=null;}return t.prototype.setParams=function(t){this.params=t;},t.prototype.onEpochBegin=function(t,e){return u(this,void 0,void 0,function(){return c(this,function(t){return [2];});});},t.prototype.onEpochEnd=function(t,e){return u(this,void 0,void 0,function(){return c(this,function(t){return [2];});});},t.prototype.onBatchBegin=function(t,e){return u(this,void 0,void 0,function(){return c(this,function(t){return [2];});});},t.prototype.onBatchEnd=function(t,e){return u(this,void 0,void 0,function(){return c(this,function(t){return [2];});});},t.prototype.onTrainBegin=function(t){return u(this,void 0,void 0,function(){return c(this,function(t){return [2];});});},t.prototype.onTrainEnd=function(t){return u(this,void 0,void 0,function(){return c(this,function(t){return [2];});});},t.prototype.setModel=function(t){},t;}(),ke=function(){function t(t,e){void 0===e&&(e=10),null==t&&(t=[]),this.callbacks=t,this.queueLength=e;}return t.prototype.append=function(t){this.callbacks.push(t);},t.prototype.setParams=function(t){for(var e=0,n=this.callbacks;e<n.length;e++){n[e].setParams(t);}},t.prototype.setModel=function(t){for(var e=0,n=this.callbacks;e<n.length;e++){n[e].setModel(t);}},t.prototype.onEpochBegin=function(t,e){return u(this,void 0,void 0,function(){var n,r;return c(this,function(i){switch(i.label){case 0:null==e&&(e={}),n=0,r=this.callbacks,i.label=1;case 1:return n<r.length?[4,r[n].onEpochBegin(t,e)]:[3,4];case 2:i.sent(),i.label=3;case 3:return n++,[3,1];case 4:return [2];}});});},t.prototype.onEpochEnd=function(t,e){return u(this,void 0,void 0,function(){var n,r;return c(this,function(i){switch(i.label){case 0:null==e&&(e={}),n=0,r=this.callbacks,i.label=1;case 1:return n<r.length?[4,r[n].onEpochEnd(t,e)]:[3,4];case 2:i.sent(),i.label=3;case 3:return n++,[3,1];case 4:return [2];}});});},t.prototype.onBatchBegin=function(t,e){return u(this,void 0,void 0,function(){var n,r;return c(this,function(i){switch(i.label){case 0:null==e&&(e={}),n=0,r=this.callbacks,i.label=1;case 1:return n<r.length?[4,r[n].onBatchBegin(t,e)]:[3,4];case 2:i.sent(),i.label=3;case 3:return n++,[3,1];case 4:return [2];}});});},t.prototype.onBatchEnd=function(t,e){return u(this,void 0,void 0,function(){var n,r;return c(this,function(i){switch(i.label){case 0:null==e&&(e={}),n=0,r=this.callbacks,i.label=1;case 1:return n<r.length?[4,r[n].onBatchEnd(t,e)]:[3,4];case 2:i.sent(),i.label=3;case 3:return n++,[3,1];case 4:return [2];}});});},t.prototype.onTrainBegin=function(t){return u(this,void 0,void 0,function(){var e,n;return c(this,function(r){switch(r.label){case 0:null==t&&(t={}),e=0,n=this.callbacks,r.label=1;case 1:return e<n.length?[4,n[e].onTrainBegin(t)]:[3,4];case 2:r.sent(),r.label=3;case 3:return e++,[3,1];case 4:return [2];}});});},t.prototype.onTrainEnd=function(t){return u(this,void 0,void 0,function(){var e,n;return c(this,function(r){switch(r.label){case 0:null==t&&(t={}),e=0,n=this.callbacks,r.label=1;case 1:return e<n.length?[4,n[e].onTrainEnd(t)]:[3,4];case 2:r.sent(),r.label=3;case 3:return e++,[3,1];case 4:return [2];}});});},t;}(),Ee=function(t){function e(){return t.call(this)||this;}return o(e,t),e.prototype.onEpochBegin=function(t){return u(this,void 0,void 0,function(){return c(this,function(t){return this.seen=0,this.totals={},[2];});});},e.prototype.onBatchEnd=function(t,e){return u(this,void 0,void 0,function(){var t,n,i,o,a=this;return c(this,function(s){for(o in null==e&&(e={}),t=null==e.size?0:e.size,this.seen+=t,n=function n(_n4){var o=e[_n4];if("number"==typeof o)i.totals.hasOwnProperty(_n4)||(i.totals[_n4]=0),i.totals[_n4]=i.totals[_n4]+o*t;else {var s=void 0;_n4 in i.totals?s=i.totals[_n4]:i.totals[_n4]=0;var u=Object(r.tidy)(function(){return Object(r.add)(a.totals[_n4],Object(r.mul)(o,t));});i.totals[_n4]=u,null!=s&&s.dispose();}},i=this,e){n(o);}return [2];});});},e.prototype.onEpochEnd=function(t,e){return u(this,void 0,void 0,function(){var t,n,i,o,a,s=this;return c(this,function(u){if(null!=e)for(t=function t(_t2){if(null==n.totals[_t2])return "continue";"number"==typeof n.totals[_t2]?e[_t2]=n.totals[_t2]/n.seen:Object(r.tidy)(function(){var n=Object(r.mul)(Object(r.div)(1,s.seen),s.totals[_t2]);e[_t2]=n,s.totals[_t2].dispose(),Object(r.keep)(e[_t2]);});},n=this,i=0,o=this.params.metrics;i<o.length;i++){a=o[i],t(a);}return [2];});});},e;}(we),Ce=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.onTrainBegin=function(t){return u(this,void 0,void 0,function(){return c(this,function(t){return this.epoch=[],this.history={},[2];});});},e.prototype.onEpochEnd=function(t,e){return u(this,void 0,void 0,function(){var n;return c(this,function(r){for(n in null==e&&(e={}),this.epoch.push(t),e){null==this.history[n]&&(this.history[n]=[]),this.history[n].push(e[n]);}return [2];});});},e.prototype.syncData=function(){return u(this,void 0,void 0,function(){var t,e,n,r,i,o,a,s,u;return c(this,function(c){switch(c.label){case 0:for(r in t=[],e=[],n=[],this.history){for(i=this.history[r],o=0;o<i.length;++o){"number"!=typeof i[o]&&(a=i[o],t.push(a.data()),e.push(r),n.push(o));}}return [4,Promise.all(t)];case 1:for(s=c.sent(),u=0;u<s.length;++u){this.history[e[u]][n[u]].dispose(),this.history[e[u]][n[u]]=s[u][0];}return [2];}});});},e;}(we),Ae=function(t){function e(e,n){var i=t.call(this)||this;if(i.currentEpoch=0,i.yieldEvery=n||"auto","auto"===i.yieldEvery&&(i.yieldEvery=xe),"never"===i.yieldEvery&&null!=e.onYield)throw new Error("yieldEvery is `never` but you provided an `onYield` callback. Either change `yieldEvery` or remove the callback");return r.util.isNumber(i.yieldEvery)&&(i.maybeWait=function(t,e){var n,i=r.util.now();return function(){for(var o=[],a=0;a<arguments.length;a++){o[a]=arguments[a];}var s=r.util.now();return s-i<e?n:(i=s,n=t.apply(void 0,o));};}(i.maybeWait.bind(i),i.yieldEvery)),i.trainBegin=e.onTrainBegin,i.trainEnd=e.onTrainEnd,i.epochBegin=e.onEpochBegin,i.epochEnd=e.onEpochEnd,i.batchBegin=e.onBatchBegin,i.batchEnd=e.onBatchEnd,i.yield=e.onYield,i;}return o(e,t),e.prototype.maybeWait=function(t,e,n){return u(this,void 0,void 0,function(){var i;return c(this,function(o){switch(o.label){case 0:return i=[],null==this.yield?[3,2]:[4,ye(n)];case 1:o.sent(),i.push(this.yield(t,e,n)),o.label=2;case 2:return i.push(Object(r.nextFrame)()),[4,Promise.all(i)];case 3:return o.sent(),[2];}});});},e.prototype.onEpochBegin=function(t,e){return u(this,void 0,void 0,function(){return c(this,function(n){switch(n.label){case 0:return this.currentEpoch=t,null==this.epochBegin?[3,3]:[4,ye(e)];case 1:return n.sent(),[4,this.epochBegin(t,e)];case 2:n.sent(),n.label=3;case 3:return [2];}});});},e.prototype.onEpochEnd=function(t,e){return u(this,void 0,void 0,function(){var n;return c(this,function(i){switch(i.label){case 0:return n=[],null==this.epochEnd?[3,2]:[4,ye(e)];case 1:i.sent(),n.push(this.epochEnd(t,e)),i.label=2;case 2:return "epoch"===this.yieldEvery&&n.push(Object(r.nextFrame)()),[4,Promise.all(n)];case 3:return i.sent(),[2];}});});},e.prototype.onBatchBegin=function(t,e){return u(this,void 0,void 0,function(){return c(this,function(n){switch(n.label){case 0:return null==this.batchBegin?[3,3]:[4,ye(e)];case 1:return n.sent(),[4,this.batchBegin(t,e)];case 2:n.sent(),n.label=3;case 3:return [2];}});});},e.prototype.onBatchEnd=function(t,e){return u(this,void 0,void 0,function(){var n;return c(this,function(i){switch(i.label){case 0:return n=[],null==this.batchEnd?[3,2]:[4,ye(e)];case 1:i.sent(),n.push(this.batchEnd(t,e)),i.label=2;case 2:return "batch"===this.yieldEvery?n.push(Object(r.nextFrame)()):r.util.isNumber(this.yieldEvery)&&n.push(this.maybeWait(this.currentEpoch,t,e)),[4,Promise.all(n)];case 3:return i.sent(),[2];}});});},e.prototype.onTrainBegin=function(t){return u(this,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return null==this.trainBegin?[3,3]:[4,ye(t)];case 1:return e.sent(),[4,this.trainBegin(t)];case 2:e.sent(),e.label=3;case 3:return [2];}});});},e.prototype.onTrainEnd=function(t){return u(this,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return null==this.trainEnd?[3,3]:[4,ye(t)];case 1:return e.sent(),[4,this.trainEnd(t)];case 2:e.sent(),e.label=3;case 3:return [2];}});});},e;}(we);function Oe(t,e){return null==t&&(t={}),t instanceof we?[t]:Array.isArray(t)&&t[0]instanceof we?t:x(t).map(function(t){return new Ae(t,e);});}var _e=function(){function t(){}return t.registerCallbackConstructor=function(e,n){r.util.assert(e>=0&&Number.isInteger(e),function(){return "Verbosity level is expected to be an integer >= 0, but got "+e;}),t.checkForDuplicate(n),null==t.constructors[e]&&(t.constructors[e]=[]),t.constructors[e].push(n);},t.checkForDuplicate=function(e){for(var n in t.constructors){t.constructors[+n].forEach(function(t){if(t===e)throw new d("Duplicate callback constructor.");});}},t.clear=function(){t.constructors={};},t.createCallbacks=function(e){var n=[];for(var r in t.constructors){var i=+r;e>=i&&n.push.apply(n,t.constructors[i]);}return n.map(function(t){return new t();});},t.constructors={},t;}();function Se(t,e,n,r,i,o,a,s,u){var c=new Ce(),l=[new Ee()].concat(_e.createCallbacks(e));null!=t&&l.push.apply(l,t),l.push(c);var f=new ke(l);return f.setParams({epochs:n,initialEpoch:r,samples:i,steps:o,batchSize:a,verbose:e,doValidation:s,metrics:u}),{callbackList:f,history:c};}function De(t,e,n){return void 0===e&&(e={}),void 0===n&&(n=!1),A(t,r.serialization.SerializationMap.getMap().classNameMap,e,"layer",n);}function Fe(t,e){return Object(r.tidy)(function(){"float32"!==t.dtype&&(t=t.asType("float32"));var n=Object(r.sum)(kt(t),e,!0),i=Object(r.fill)(n.shape,l()),o=Object(r.sqrt)(Object(r.maximum)(n,i));return Object(r.div)(t,o);});}function Te(t,e){return Object(r.tidy)(function(){return Object(r.mean)(kt(Object(r.sub)(e,t)),-1);});}function Ne(t,e){return Object(r.tidy)(function(){return Object(r.mean)(Object(r.abs)(Object(r.sub)(e,t)),-1);});}function Ie(t,e){return Object(r.tidy)(function(){var n=Object(r.sub)(t,e),i=Object(r.clipByValue)(Object(r.abs)(t),l(),Number.MAX_VALUE),o=Object(r.abs)(Object(r.div)(n,i));return Object(r.mul)(100,Object(r.mean)(o,-1));});}function Re(t,e,n){return void 0===n&&(n=!1),Object(r.tidy)(function(){if(n)e=Object(r.softmax)(e);else {var i=Object(r.sum)(e,e.shape.length-1,!0);e=Object(r.div)(e,i);}return e=Object(r.clipByValue)(e,l(),1-l()),Object(r.neg)(Object(r.sum)(Object(r.mul)(t.toFloat(),Object(r.log)(e)),e.shape.length-1));});}function Me(t,e){return Object(r.tidy)(function(){var n=Object(r.floor)(function(t){var e=[at(t.shape)];return t.reshape(e);}(t)).toInt(),i=(e=Object(r.clipByValue)(e,l(),1-l())).shape;return Re(Object(r.oneHot)(n,i[i.length-1]).reshape(i),e,!1);});}function je(t,e){return Object(r.tidy)(function(){var n;return n=Object(r.clipByValue)(e,l(),1-l()),n=Object(r.log)(Object(r.div)(n,Object(r.sub)(1,n))),Object(r.mean)(function(t,e){if(!r.util.arraysEqual(t.shape,e.shape))throw new d("logits and labels must have the same shape, but got shapes "+JSON.stringify(t.shape)+" and "+JSON.stringify(e.shape));return Object(r.tidy)(function(){var n=e.relu(),r=e.abs().neg();return n.sub(e.mul(t)).add(r.exp().log1p());});}(t,n),-1);});}function Be(t,e){return Object(r.tidy)(function(){var n=Fe(t,-1),i=Fe(e,-1),o=Object(r.mul)(n,i);return Object(r.neg)(Object(r.sum)(o,-1));});}var Pe={meanSquaredError:Te,meanAbsoluteError:Ne,meanAbsolutePercentageError:Ie,meanSquaredLogarithmicError:function meanSquaredLogarithmicError(t,e){return Object(r.tidy)(function(){var n=Object(r.clipByValue)(e,l(),Number.MAX_VALUE),i=Object(r.log)(Object(r.add)(1,n)),o=Object(r.clipByValue)(t,l(),Number.MAX_VALUE),a=Object(r.log)(Object(r.add)(1,o));return Object(r.mean)(kt(Object(r.sub)(i,a)),-1);});},squaredHinge:function squaredHinge(t,e){return Object(r.tidy)(function(){var n=Object(r.maximum)(0,Object(r.sub)(1,Object(r.mul)(t,e)));return Object(r.mean)(kt(n),-1);});},hinge:function hinge(t,e){return Object(r.tidy)(function(){var n=Object(r.maximum)(0,Object(r.sub)(1,Object(r.mul)(t,e)));return Object(r.mean)(n,-1);});},categoricalHinge:function categoricalHinge(t,e){return Object(r.tidy)(function(){var n=Object(r.sum)(Object(r.mul)(t,e),-1),i=Object(r.max)(Object(r.mul)(Object(r.sub)(1,t),e),-1);return Object(r.maximum)(0,Object(r.add)(1,Object(r.sub)(i,n)));});},logcosh:function logcosh(t,e){return Object(r.tidy)(function(){var n=Math.log(2),i=Object(r.sub)(e,t),o=Object(r.sub)(Object(r.add)(i,Object(r.softplus)(Object(r.mul)(-2,i))),n);return Object(r.mean)(o,-1);});},categoricalCrossentropy:Re,sparseCategoricalCrossentropy:Me,binaryCrossentropy:je,kullbackLeiblerDivergence:function kullbackLeiblerDivergence(t,e){return Object(r.tidy)(function(){var n=Object(r.clipByValue)(t,l(),1),i=Object(r.clipByValue)(e,l(),1);return Object(r.sum)(Object(r.mul)(t,Object(r.log)(Object(r.div)(n,i))),-1);});},poisson:function poisson(t,e){return Object(r.tidy)(function(){var n=Object(r.log)(Object(r.add)(l(),e));return Object(r.mean)(Object(r.sub)(e,Object(r.mul)(t,n)),-1);});},cosineProximity:Be};function Le(t){if("string"==typeof t){if(t in Pe)return Pe[t];var e="Unknown loss "+t;throw t.toLowerCase().includes("softmaxcrossentropy")&&(e="Unknown loss "+t+'. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy'),new d(e);}return t;}function ze(t,e){return Object(r.tidy)(function(){var n=Object(r.mul)(.5,Object(r.onesLike)(e)),i=ft(Object(r.greater)(e,n),t.dtype);return Object(r.mean)(Object(r.equal)(t,i),-1);});}function Ue(t,e){return Object(r.tidy)(function(){return ft(Object(r.equal)(Object(r.argMax)(t,-1),Object(r.argMax)(e,-1)),"float32");});}function We(t,e){return Object(r.tidy)(function(){return Object(r.logicalAnd)(t.equal(1),e.equal(1)).sum().cast("float32");});}function Ve(t,e){return Object(r.tidy)(function(){var n=We(t,e),i=function(t,e){return Object(r.tidy)(function(){return Object(r.logicalAnd)(t.equal(0),e.equal(1)).sum().cast("float32");});}(t,e),o=n.add(i);return Object(r.where)(Object(r.greater)(o,0),n.div(o),0).cast("float32");});}function qe(t,e){return Object(r.tidy)(function(){var n=We(t,e),i=function(t,e){return Object(r.tidy)(function(){return Object(r.logicalAnd)(t.equal(1),e.equal(0)).sum().cast("float32");});}(t,e),o=n.add(i);return Object(r.where)(Object(r.greater)(o,0),n.div(o),0).cast("float32");});}function $e(t,e){return je(t,e);}function He(t,e){return t.rank===e.rank&&(t=t.squeeze([t.rank-1])),(e=e.argMax(-1)).dtype!==t.dtype&&(e=e.asType(t.dtype)),Object(r.equal)(t,e).asType("float32");}var Ge=Re,Ke=Me,Xe={binaryAccuracy:ze,categoricalAccuracy:Ue,precision:Ve,categoricalCrossentropy:Ge,sparseCategoricalCrossentropy:Ke,mse:Te,MSE:Te,mae:Ne,MAE:Ne,mape:Ie,MAPE:Ie,cosine:Be};function Ye(t){if(v(null!==t,"Unknown LossOrMetricFn "+t),"string"==typeof t)return t;for(var e=void 0,n=0,r=Object.keys(Pe);n<r.length;n++){var i=r[n];if(Pe[i]===t){e=i;break;}}if(void 0!==e)return e;for(var o=0,a=Object.keys(Xe);o<a.length;o++){if(i=a[o],Xe[i]===t){e=i;break;}}return void 0!==e?e:t.name;}var Je=1048576;function Qe(t,e,n){if(void 0===n&&(n=!1),null==t||"object"!=_typeof$1(t)||Object.getPrototypeOf(t)!==Object.prototype||!function t(e){if(null===e)return !0;if("object"==_typeof$1(e)){if(Object.getPrototypeOf(e)===Object.prototype){for(var n=0,r=Object.keys(e);n<r.length;n++){var i=r[n];if("string"!=typeof i)return !1;if(!t(e[i]))return !1;}return !0;}if(Array.isArray(e)){for(var o=0,a=e;o<a.length;o++){if(!t(a[o]))return !1;}return !0;}return !1;}var s=_typeof$1(e);return "string"===s||"number"===s||"boolean"===s;}(t))throw new Error("User-defined metadata is expected to be a JSON object, but is not.");if(n){var r=JSON.stringify(t);r.length>Je&&console.warn('User-defined metadata of model "'+e+'" 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 <= "+Je+".");}}function Ze(t,e,n,r){void 0===r&&(r=console.log);var i,o=function(t){var e=!0,n=[],r=[];for(var i in t.nodesByDepth){n.push(t.nodesByDepth[i]);}for(var o=0,a=n;o<a.length;o++){var s=a[o];if(s.length>1||1===s.length&&s[0].inboundLayers.length>1){e=!1;break;}r.push.apply(r,s);}if(e)for(var u=0,c=t.layers;u<c.length;u++){for(var l=!1,f=0,h=c[u].inboundNodes;f<h.length;f++){var d=h[f];if(-1!==r.indexOf(d)){if(l){e=!1;break;}l=!0;}}if(!e)break;}return e;}(t),a=["Layer (type)","Output shape","Param #"];if(o?(e=e||65,n=n||[.45,.85,1]):(e=e||98,n=n||[.33,.55,.67,1]),n[n.length-1]<=1&&(n=n.map(function(t){return Math.floor(e*t);})),!o)for(var s in a.push("Receives inputs"),i=[],t.nodesByDepth){i.push.apply(i,t.nodesByDepth[s]);}r("_".repeat(e)),tn(a,n,r),r("=".repeat(e));for(var u=t.layers,c=0;c<u.length;++c){o?en(u[c],n,r):nn(u[c],n,i,r),r((c===u.length-1?"=":"_").repeat(e));}t.checkTrainableWeightsConsistency();var l=function(t){return null!=t.collectedTrainableWeights?ie(t.collectedTrainableWeights):ie(t.trainableWeights);}(t),f=ie(t.nonTrainableWeights);r("Total params: "+(l+f)),r("Trainable params: "+l),r("Non-trainable params: "+f),r("_".repeat(e));}function tn(t,e,n){void 0===n&&(n=console.log);for(var r="",i=0;i<t.length;++i){i>0&&(r=r.slice(0,r.length-1)+" "),r=(r+=t[i]).slice(0,e[i]),r+=" ".repeat(e[i]-r.length);}n(r);}function en(t,e,n){var r;try{r=JSON.stringify(t.outputShape);}catch(t){r="multiple";}tn([t.name+" ("+t.getClassName()+")",r,t.countParams().toString()],e,n);}function nn(t,e,n,r){var i;try{i=JSON.stringify(t.outputShape);}catch(t){i="multiple";}for(var o=[],a=0,s=t.inboundNodes;a<s.length;a++){var u=s[a];if(!(null!=n&&n.length>0&&-1===n.indexOf(u)))for(var c=0;c<u.inboundLayers.length;++c){var l=u.inboundLayers[c].name,f=u.nodeIndices[c],h=u.tensorIndices[c];o.push(l+"["+f+"]["+h+"]");}}var d=t.name,p=t.getClassName(),m=0===o.length?"":o[0];for(tn([d+" ("+p+")",i,t.countParams().toString(),m],e,r),c=1;c<o.length;++c){tn(["","","",o[c]],e,r);}}function rn(t,e,n){return ("inboundNodes"===t||"outputLayers"===t||"inputLayers"===t)&&0===e&&"string"==typeof n;}function on(t,e){if(null===t)return null;if("string"==typeof t)return k(t);if("number"==typeof t||"boolean"==typeof t)return t;if(t instanceof Array){for(var n=[],r=t.length,i=0;i<r;++i){var o=t[i];rn(e,i,o)?n.push(o):n.push(on(o,e));}return n;}for(var a={},s=0,u=Object.keys(t);s<u.length;s++){var c=u[s],l=t[c];if("name"===c&&"string"==typeof l)a[c]=l;else {var f=k(c);a[f]=on(l,f);}}return a;}var an=function(){function t(e){if(this.id2Value={},this.id2Mask={},this.name2Id={},e instanceof t)for(var n in e.id2Value){this.id2Value[n]=e.id2Value[n],n in e.id2Mask&&(this.id2Mask[n]=e.id2Mask[n]);}else {if(null==e)return;for(var r=0,i=e;r<i.length;r++){var o=i[r];this.add(o.key,o.value);}}}return t.prototype.add=function(t,e,n){if(null!=this.id2Value[t.id])throw new d("Duplicate key: name="+t.name+", id="+t.id);return this.id2Value[t.id]=function(t,e){if(null==t.dtype||t.dtype===e.dtype)return e;try{return Object(r.cast)(e,t.dtype);}catch(n){throw new d("The dtype of the feed ("+e.dtype+") can not be cast to the dtype of the key '"+t.name+"' ("+t.dtype+").");}}(t,e),this.name2Id[t.name]=t.id,null!=n&&(this.id2Mask[t.id]=n),this;},t.prototype.addFeed=function(t){this.add(t.key,t.value);},t.prototype.hasKey=function(t){return null!=this.id2Value[t.id];},t.prototype.names=function(){return Object.keys(this.name2Id);},t.prototype.getValue=function(t){if(t instanceof le){if(null==this.id2Value[t.id])throw new d("Nonexistent key: "+t.name);return this.id2Value[t.id];}var e=this.name2Id[t];if(null==e)throw new d("Feed dict has no SymbolicTensor name: "+t);return this.id2Value[e];},t.prototype.getMask=function(t){if(t instanceof le){if(null==this.id2Value[t.id])throw new d("Nonexistent key: "+t.name);return this.id2Mask[t.id];}var e=this.name2Id[t];if(null==e)throw new d("Feed dict has no SymbolicTensor name: "+t);return this.id2Mask[e];},t.prototype.disposeMasks=function(){null!=this.id2Mask&&Object(r.dispose)(this.id2Mask);},t;}(),sn={},un={};function cn(t,e,n,i){for(var o=null!=n&&n.training,a=Array.isArray(t),s=a?t:[t],u=s.map(function(t){return t.name;}),c=[],l=e.names(),f=0,h=u;f<h.length;f++){var d=h[f];-1!==l.indexOf(d)?c.push(e.getValue(d)):c.push(null);}null!=i&&(i.maxNumTensors=-1/0,i.minNumTensors=1/0);var p,m,g=u.join(",")+"|"+e.names().join(",");if(null==sn[g]){var v=function(t,e){r.util.assert(null!=t&&t.length>0,function(){return "Expected at least one fetch, got none";});var n=[],i={};if(1===t.length){var o=ln(t[0],e);n=o.sorted,i=o.recipientMap;}else for(var a=new Set(),s=0,u=t;s<u.length;s++){for(var c=ln(u[s],e),l=c.sorted,f=c.recipientMap,h=0,d=l;h<d.length;h++){var p=d[h];a.has(p.name)||(n.push(p),a.add(p.name));}var m=function m(t){null==i[t]&&(i[t]=new Set()),f[t].forEach(function(e){return i[t].add(e);});};for(var g in f){m(g);}}return {sorted:n,recipientCounts:function(t){var e={};for(var n in t){e[n]=t[n].size;}return e;}(i)};}(s,e);p=v.sorted,m=v.recipientCounts,sn[g]=p,un[g]=m;}p=sn[g],m={},o||Object.assign(m,un[g]);for(var y=new an(e),b=0;b<p.length;++b){if(null!=i){var w=Object(r.memory)().numTensors;w>i.maxNumTensors&&(i.maxNumTensors=w),w<i.minNumTensors&&(i.minNumTensors=w);}var k=p[b],E=k.sourceLayer;if(!(E instanceof ge)){for(var C=[],A=[],O=[],_=!1,S=0,D=k.inputs;S<D.length;S++){var F=D[S],T=y.getValue(F),N=y.getMask(F);C.push(T),A.push(N),null!=N&&(_=!0),o||(m[F.name]--,0!==m[F.name]||e.hasKey(F)||-1!==u.indexOf(F.name)||T.isDisposed||!0===F.sourceLayer.stateful||O.push(T));}_&&((n=n||{}).mask=A[0]);var I=x(E.apply(C,n)),R=null;E.supportsMasking&&(R=E.computeMask(C,A));for(var M=fn(k),j=Array.isArray(M)?M:[M],B=0;B<j.length;++B){y.hasKey(j[B])||y.add(j[B],I[B],Array.isArray(R)?R[0]:R);var P=u.indexOf(j[B].name);-1!==P&&(c[P]=I[B]);}o||Object(r.dispose)(O);}}return y.disposeMasks(),a?c:c[0];}function ln(t,e){for(var n=new Set(),r=[],i={},o=0,a=e.names();o<a.length;o++){var s=a[o];n.add(s);}var u=[],c=[];for(u.push(t);u.length>0;){var l=u[u.length-1];if(n.has(l.name))u.pop();else {var f=c[c.length-1]===u.length-1;if(0===l.inputs.length||f)u.pop(),r.push(l),n.add(l.name),f&&c.pop();else {c.push(u.length-1);for(var h=0,d=l.inputs;h<d.length;h++){var p=d[h];null==i[p.name]&&(i[p.name]=new Set()),i[p.name].add(l.name),n.has(p.name)||u.push(p);}}}}return {sorted:r,recipientMap:i};}function fn(t){var e;if(1===t.sourceLayer.inboundNodes.length)e=t.sourceLayer.output;else {for(var n=null,r=0;r<t.sourceLayer.inboundNodes.length;++r){for(var i=0,o=t.sourceLayer.inboundNodes[r].outputTensors;i<o.length;i++){if(o[i].id===t.id){n=r;break;}}}e=t.sourceLayer.getOutputAt(n);}return e;}function hn(t,e){return function(t,e,n){var r=e.length;if(null==t||Array.isArray(t)&&0===t.length)return e.map(function(t){return null;});if(1===r)return Array.isArray(t)&&1===t.length?t:"object"==_typeof$1(t)&&e[0]in t?[t[e[0]]]:[t];if(Array.isArray(t)){if(t.length!==r)throw new Error("Provided "+n+" is an array of "+t.length+" element(s), but the model has "+r+" outputs. Make sure a set of weights is provided for each model output.");return t;}if("object"==_typeof$1(t)&&Object.keys(t).length>0&&"object"==_typeof$1(t[Object.keys(t)[0]])){var i=[];return e.forEach(function(e){e in t?i.push(t[e]):i.push(null);}),i;}throw new Error("The model has multiple ("+r+") outputs, so "+n+" must be either an array with "+r+" elements or an object with "+e+" keys. Provided "+n+" not understood: "+JSON.stringify(t));}(t,e,"classWeight");}function dn(t,e,n,i){return u(this,void 0,void 0,function(){var o,a,s,u,l;return c(this,function(c){switch(c.label){case 0:if(null!=e||null!=i)throw new Error("Support sampleWeight is not implemented yet");return null==n?[3,2]:(o=Object(r.tidy)(function(){if(1===t.shape.length)return t.clone();if(2===t.shape.length){if(t.shape[1]>1)return t.argMax(1);if(1===t.shape[1])return t.reshape([t.shape[0]]);throw new Error("Encountered unexpected last-dimension size ("+t.shape[1]+") during handling of class weights. The size is expected to be >= 1.");}throw new Error("Unexpected rank of target (y) tensor ("+t.rank+") during handling of class weights. The rank is expected to be 1 or 2.");}),u=(s=Array).from,[4,o.data()]);case 1:return a=u.apply(s,[c.sent()]),Object(r.dispose)(o),l=[],a.forEach(function(t){if(null==n[t])throw new Error("classWeight must contain all classes in the training data. The class "+t+" exists in the data but not in classWeight");l.push(n[t]);}),[2,Object(r.tensor1d)(l,"float32")];case 2:return [2,null];}});});}function pn(t,e){return Object(r.mul)(t,e);}var mn=32;function gn(t,e){var n,i,o=e;n=o.xs,i=o.ys,r.util.assert(null!=n&&null!=i,function(){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 "+e;});var a=vn("input",t.inputNames,n),s=vn("output",t.outputNames,i),u=a[0].shape[0];r.util.assert(a.length===t.inputs.length,function(){return "LayersModel has "+t.inputs.length+" inputs, but the dataset provides "+a.length+" inputs.  (Expected input keys: "+JSON.stringify(t.inputNames)+")";}),r.util.assert(s.length===t.outputs.length,function(){return "LayersModel has "+t.outputs.length+" outputs, but the dataset provides "+s.length+" outputs.  (Expected output keys: "+JSON.stringify(t.outputNames)+")";});for(var c=function c(e){r.util.assert(a[e].shape[0]===u,function(){return "Batch size mismatch: input "+t.inputNames[e]+" has "+a[e].shape[0]+"; expected  "+u+" based on input "+t.inputNames[0]+".";});},l=0;l<a.length;l++){c(l);}for(var f=function f(e){r.util.assert(s[e].shape[0]===u,function(){return "Batch size mismatch: output "+t.outputNames[e]+" has "+s[e].shape[0]+"; expected  "+u+" based on input "+t.inputNames[0]+".";});},h=0;h<s.length;h++){f(h);}return {xs:a,ys:s};}function vn(t,e,n){if(n instanceof r.Tensor)return [n];if(Array.isArray(n))return r.util.assert(n.length===e.length,function(){return "Received an array of "+n.length+" Tensors, but expected "+e.length+" to match the "+t+" keys "+e+".";}),n;for(var i=[],o=0,a=e;o<a.length;o++){var s=a[o];if(null==n[s])throw new d("The feature data generated by the dataset lacks the required "+t+" key '"+s+"'.");i.push(n[s]);}return i;}function yn(t,e,n){return u(this,void 0,void 0,function(){var i,o,a,s,u,l,f,h,d,m,g,v,y,b,w,k,E,C,A,O,_,S,D,F,T,N,I,R,M,j,B,P,L,z;return c(this,function(c){switch(c.label){case 0:if(i=null!=n.batchesPerEpoch,r.util.assert(null!=t.optimizer,function(){return "You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig).";}),r.util.assert(null!=n,function(){return "For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call.";}),r.util.assert(null!=n.epochs&&n.epochs>0&&Number.isInteger(n.epochs),function(){return "For fitDataset(), config.epochs is expected to be a positive integer, but got "+n.epochs;}),r.util.assert(!i||n.batchesPerEpoch>0&&Number.isInteger(n.batchesPerEpoch),function(){return "For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got "+n.batchesPerEpoch;}),r.util.assert(null==n.validationSplit,function(){return "`validationSplit` is not supported by `fitDataset()`. Use validationData instead.";}),t.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");t.isTraining=!0,c.label=1;case 1:return c.trys.push([1,,26,27]),o=null!=n.validationData,a=void 0,s=void 0,o&&(bn(n.validationData)?r.util.assert(null==n.validationBatches||n.validationBatches>0&&Number.isInteger(n.validationBatches),function(){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;}):(u=function(t){if(3===t.length)throw new p("Validation with sample weights is not implemented yet.");return {xs:t[0],ys:t[1]};}(n.validationData),a=u.xs,s=u.ys)),l=t.makeTrainFunction(),f=t.getDedupedMetricsNames(),h=void 0,h=o?f.slice().concat(f.map(function(t){return "val_"+t;})):f.slice(),d=Oe(n.callbacks,n.yieldEvery),m=null==n.verbose?1:n.verbose,g=Se(d,m,n.epochs,null,null,function(t,e){var n=null;return null!=e.batchesPerEpoch?n=e.batchesPerEpoch:Number.isFinite(t.size)&&(n=t.size),n;}(e,n),null,o,h),v=g.callbackList,y=g.history,v.setModel(t),t.history=y,[4,v.onTrainBegin()];case 2:return c.sent(),t.stopTraining_=!1,b=null==n.initialEpoch?0:n.initialEpoch,[4,e.iterator()];case 3:w=c.sent(),c.label=4;case 4:return b<n.epochs?(k={},[4,v.onEpochBegin(b)]):[3,23];case 5:return c.sent(),E=0,C=0,i?[3,7]:[4,e.iterator()];case 6:w=c.sent(),c.label=7;case 7:return !i||E<n.batchesPerEpoch?[4,w.next()]:[3,21];case 8:return A=c.sent(),i&&A.done?(console.warn("You provided `batchesPerEpoch` as "+n.batchesPerEpoch+", but your dataset iterator ran out of data after "+E+" 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==A.value?[3,15]:(O=gn(t,A.value),_=O.xs,S=O.ys,(D={}).batch=C,D.size=_[0].shape[0],[4,v.onBatchBegin(C,D)]);case 9:if(c.sent(),F=[],null==n.classWeight)return [3,13];T=hn(n.classWeight,t.outputNames),z=0,c.label=10;case 10:return z<T.length?(I=(N=F).push,[4,dn(S[z],null,T[z])]):[3,13];case 11:I.apply(N,[c.sent()]),c.label=12;case 12:return ++z,[3,10];case 13:for(R=_.concat(S).concat(F),M=l(R),Object(r.dispose)(R),z=0;z<f.length;++z){j=f[z],B=M[z],D[j]=B,Object(r.keep)(B);}return [4,v.onBatchEnd(C,D)];case 14:c.sent(),be(D),C++,E++,c.label=15;case 15:return (i?E>=n.batchesPerEpoch:A.done)?o?(P=void 0,bn(n.validationData)?(L=x,[4,t.evaluateDataset(n.validationData,{batches:n.validationBatches})]):[3,17]):[3,19]:[3,20];case 16:return P=L.apply(void 0,[c.sent()]),[3,18];case 17:P=x(t.evaluate(a,s,{batchSize:null==n.validationBatchSize?mn:n.validationBatchSize,verbose:0})),c.label=18;case 18:for(z=0;z<t.metricsNames.length;++z){k["val_"+t.metricsNames[z]]=P[z];}c.label=19;case 19:return [3,21];case 20:return t.stopTraining_?[3,21]:[3,7];case 21:return [4,v.onEpochEnd(b,k)];case 22:return c.sent(),b++,t.stopTraining_?[3,23]:[3,4];case 23:return [4,v.onTrainEnd()];case 24:return c.sent(),[4,t.history.syncData()];case 25:return c.sent(),[2,t.history];case 26:return t.isTraining=!1,[7];case 27:return [2];}});});}function bn(t){return "function"==typeof t.iterator;}function xn(t){r.util.assert(t>0&&Number.isInteger(t),function(){return "batchSize is required to be a positive integer, but got "+t;});}function wn(t,e,n){return null==t?[null]:Array.isArray(t)?t.map(function(t){return dt(t,e,n-e);}):dt(t,e,n-e);}function kn(t,e){return Object(r.tidy)(function(){return null==t?null:Array.isArray(t)?t.map(function(t){return kn(t,e);}):wt(t,"int32"===e.dtype?e:e.toInt());});}function En(t,e){for(var n=[],r=0,i=null;r<t;){(i=r+e)>=t&&(i=t),n.push([r,i]),r=i;}return n;}function Cn(t,e,n,i){return void 0===i&&(i={}),u(this,void 0,void 0,function(){var o,a,s,l,f,h,m,g,v,y,b,x,w,k,E,C,A,O,_,S,D,F;return c(this,function(T){switch(T.label){case 0:if(t.isTraining)throw new Error("Cannot start training because another fit() call is ongoing.");t.isTraining=!0,T.label=1;case 1:return T.trys.push([1,,7,8]),xn(g=null==i.batchSize?32:i.batchSize),v=!1,[4,t.standardizeUserData(e,n,i.sampleWeight,i.classWeight,v,g)];case 2:if(y=T.sent(),o=y[0],a=y[1],m=y[2],b=!1,x=void 0,!(null!=i.validationData&&i.validationData.length>0))return [3,4];if(b=!0,2!==i.validationData.length)throw 3===i.validationData.length?new p("validationData including sample weights is not supported yet."):new d("When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; "+i.validationData+" is invalid.");return s=i.validationData[0],l=i.validationData[1],w=!0,[4,t.standardizeUserData(s,l,null,null,w,g)];case 3:return k=T.sent(),f=k[0],h=k[1],x=f.concat(h),[3,5];case 4:null!=i.validationSplit&&i.validationSplit>0&&i.validationSplit<1?(b=!0,E=Math.floor(o[0].shape[0]*(1-i.validationSplit)),C=o[0].shape[0],f=wn(o,E,C),o=wn(o,0,E),h=wn(a,E,C),a=wn(a,0,E),x=f.concat(h)):null!=i.validationSteps&&(b=!0),T.label=5;case 5:return A=o.concat(a).concat(m),t.checkTrainableWeightsConsistency(),O=t.makeTrainFunction(),_=t.getDedupedMetricsNames(),S=void 0,D=void 0,b?(t.makeTestFunction(),S=t.testFunction,D=_.slice().concat(_.map(function(t){return "val_"+t;}))):(S=null,x=[],D=_.slice()),F=Oe(i.callbacks,i.yieldEvery),[4,function(t,e,n,i,o,a,s,l,f,h,m,g,v,y,b){return u(this,void 0,void 0,function(){var u,x,w,k,E,C,A,O;return c(this,function(_){switch(_.label){case 0:if(null==o&&(o=32),null==a&&(a=1),null==m&&(m=!0),null==v&&(v=0),u=!1,null!=f&&null!=h&&(u=!0),null!=b&&(u=!0,null==y))throw new d("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");return null!=(x=t.checkNumSamples(n,o,y,"steps_per_epoch"))&&(w=lt(0,x)),null==s&&(s=1),k=Se(l,s,a,v,x,y,o,u,g),E=k.callbackList,C=k.history,E.setModel(t),t.history=C,[4,E.onTrainBegin()];case 1:_.sent(),t.stopTraining_=!1,A=function A(a){var s,l,d,g,v;return c(this,function(b){switch(b.label){case 0:return [4,E.onEpochBegin(a)];case 1:if(b.sent(),s={},null==y)return [3,2];throw new p("stepsPerEpoch mode is not implemented yet.");case 2:if("batch"===m)throw new p("batch shuffling is not implemneted yet");m&&r.util.shuffle(w),l=Object(r.tensor1d)(w),d=En(x,o),g=function g(a){var p;return c(this,function(c){switch(c.label){case 0:return p={},[4,E.onBatchBegin(a,p)];case 1:return c.sent(),Object(r.tidy)(function(){var c=d[a][0],m=d[a][1],g=dt(l,c,m-c);p.batch=a,p.size=m-c;for(var v=kn(n,g),y=e(v),b=0;b<i.length;++b){var x=i[b],w=y[b];p[x]=w,Object(r.keep)(w);}if(a===d.length-1&&u){var k=t.testLoop(f,h,o);for(b=0;b<i.length;++b){x=i[b],w=k[b],Object(r.keep)(w),s["val_"+x]=w;}}}),[4,E.onBatchEnd(a,p)];case 2:return c.sent(),be(p),t.stopTraining_?[2,"break"]:[2];}});},v=0,b.label=3;case 3:return v<d.length?[5,g(v)]:[3,6];case 4:if("break"===b.sent())return [3,6];b.label=5;case 5:return ++v,[3,3];case 6:l.dispose(),b.label=7;case 7:return [4,E.onEpochEnd(a,s)];case 8:return b.sent(),t.stopTraining_?[2,"break"]:[2];}});},O=v,_.label=2;case 2:return O<a?[5,A(O)]:[3,5];case 3:if("break"===_.sent())return [3,5];_.label=4;case 4:return ++O,[3,2];case 5:return [4,E.onTrainEnd()];case 6:return _.sent(),[4,t.history.syncData()];case 7:return _.sent(),[2,t.history];}});});}(t,O,A,_,g,i.epochs,i.verbose,F,S,x,i.shuffle,D,i.initialEpoch,null,null)];case 6:return [2,T.sent()];case 7:return t.isTraining=!1,On(o,e),On(a,n),On(f,s),On(h,l),null!=m&&Object(r.dispose)(m),[7];case 8:return [2];}});});}function An(t){var e=[];t instanceof r.Tensor&&(t=[t]);for(var n=0;n<t.length;++n){var i=t[n];if(1===i.rank)e.push(ht(i,1));else {if(0===i.rank)throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar).");e.push(i);}}return e;}function On(t,e){if(null!=t){var n=[];if(e instanceof r.Tensor)n.push(e.id);else if(Array.isArray(e))e.forEach(function(t){return n.push(t.id);});else if(null!=e)for(var i in e){var o=e[i];n.push(o.id);}var a=[];if(t instanceof r.Tensor)-1===n.indexOf(t.id)&&a.push(t);else if(Array.isArray(t))t.forEach(function(t){-1===n.indexOf(t.id)&&a.push(t);});else if(null!=t)for(var s in t){var u=t[s];-1===n.indexOf(u.id)&&a.push(u);}a.forEach(function(t){t.isDisposed||t.dispose();});}}function _n(t){return Array.isArray(t);}function Sn(t){return !function(t){return t instanceof r.Tensor;}(t)&&!_n(t);}function Dn(t,e,n,r,i){if(void 0===r&&(r=!0),void 0===i&&(i=""),null==e||0===e.length){if(null!=t){var o=!1;if(_n(t)&&t.length>0)o=!0;else if(Sn(t)){for(var a in t){if(t.hasOwnProperty(a)){o=!0;break;}}}else o=!0;if(o)throw new d("Error when checking model "+i+" expected no data, but got "+t);}return [];}if(null==t)return e.map(function(t){return null;});var s;if(Sn(t)){t=t,s=[];for(var u=0,c=e;u<c.length;u++){var l=c[u];if(null==t[l])throw new d('No data provided for "'+l+'". Need data for each key in: '+e);s.push(t[l]);}}else if(_n(t)){if((t=t).length!==e.length)throw new d("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 "+e.length+" Tensor(s), but instead got the following list of Tensor(s): "+t);s=t;}else {if(t=t,e.length>1)throw new d("The model "+i+" expects "+e.length+" Tensor(s), but only received one Tensor. Found: Tensor with shape "+t.shape);s=[t];}if(s=An(s),null!=n)for(var f=0;f<e.length;++f){if(null!=n[f]){var h=s[f];if(h.shape.length!==n[f].length)throw new d("Error when checking "+i+": expected "+e[f]+" to have "+n[f].length+" dimension(s). but got array with shape "+h.shape);for(var p=0;p<n[f].length;++p){if(0!==p||r){var m=h.shape[p],g=n[f][p];if(null!=g&&g>=0&&m!==g)throw new d("Error when checking "+i+": expected "+e[f]+" to have shape ["+n[f]+"], but got array with shape ["+h.shape+"].");}}}}return s;}function Fn(t,e,n,r,i){var o;if(void 0===r&&(r=!0),void 0===i&&(i=""),Array.isArray(t)){if(t.length!==e.length)throw new d("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 "+e.length+" Tensor(s), but instead got "+t.length+" Tensors(s).");o=t;}else {if(e.length>1)throw new d("The model expects "+e.length+" "+i+" Tensors, but only received one Tensor. Found: array with shape "+JSON.stringify(t.shape)+".");o=[t];}if(null!=n)for(var a=0;a<e.length;++a){if(null!=n[a]){var s=o[a];if(s.shape.length!==n[a].length)throw new d("Error when checking "+i+": expected "+e[a]+" to have "+n[a].length+" dimension(s), but got array with shape "+JSON.stringify(s.shape));for(var u=0;u<n[a].length;++u){if(0!==u||r){var c=s.shape[u],l=n[a][u];if(null!=l&&l!==c)throw new d("Error when checking "+i+": expected "+e[a]+" to have shape "+JSON.stringify(n[a])+" but got array with shape "+JSON.stringify(s.shape)+".");}}}}}var Tn=function(t){function e(e){var n=t.call(this,e)||this;return n.isTraining=!1,n;}return o(e,t),e.prototype.summary=function(t,e,n){if(void 0===n&&(n=console.log),!this.built)throw new d("This model has never been called, thus its weights have not been created yet. So no summary can be displayed. Build the model first (e.g., by calling it on some test data).");Ze(this,t,e,n);},e.prototype.compile=function(t){var e=this;if(null==t.loss&&(t.loss=[]),this.loss=t.loss,"string"==typeof t.optimizer)this.optimizer_=function(t){var e={Adagrad:function Adagrad(){return r.train.adagrad(.01);},Adadelta:function Adadelta(){return r.train.adadelta(1,.95,l());},Adam:function Adam(){return r.train.adam(.001,.9,.999,l());},Adamax:function Adamax(){return r.train.adamax(.002,.9,.999,l(),0);},RMSProp:function RMSProp(){return r.train.rmsprop(.001,.9,0,l());},SGD:function SGD(){return r.train.sgd(.01);}};if(e.adagrad=e.Adagrad,e.adadelta=e.Adadelta,e.adam=e.Adam,e.adamax=e.Adamax,e.rmsprop=e.RMSProp,e.sgd=e.SGD,t in e)return e[t]();throw new d("Unknown Optimizer "+t);}(t.optimizer),this.isOptimizerOwned=!0;else {if(!(t.optimizer instanceof r.Optimizer))throw new d("User-defined optimizer must be an instance of tf.Optimizer.");this.optimizer_=t.optimizer,this.isOptimizerOwned=!1;}var n=[];if(Array.isArray(t.loss)||"string"==typeof t.loss||"function"==typeof t.loss){if(Array.isArray(t.loss)){if(t.loss.length!==this.outputs.length)throw new d("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="+t.loss+".");var i=t.loss;n=i.map(function(t){return Le(t);});}else {var o=Le(t.loss);this.outputs.forEach(function(t){n.push(o);});}}else {for(var a in t.loss=t.loss,t.loss){if(-1===this.outputNames.indexOf(a))throw new d('Unknown entry in loss dictionary: "'+a+'". Only expected the following keys: '+this.outputNames);}for(var s=0,u=this.outputNames;s<u.length;s++){var c=u[s];null==t.loss[c]&&console.warn('Output "'+c+'" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to '+c+" during training"),n.push(Le(t.loss[c]));}}this.lossFunctions=n,this.feedOutputNames=[],this.feedOutputShapes=[],this.feedLossFns=[];for(var f=0;f<this.outputs.length;++f){var h=this.internalOutputShapes[f],p=this.outputNames[f];this.feedOutputNames.push(p),this.feedOutputShapes.push(h),this.feedLossFns.push(this.lossFunctions[f]);}var m=[];this.metrics=t.metrics,this.metricsNames=["loss"],this.metricsTensors=[],tt("loss",function(){for(var t=0;t<e.outputs.length;++t){if(-1===m.indexOf(t)){var n=e.lossFunctions[t];e.outputs.length>1&&(e.metricsTensors.push([n,t]),e.metricsNames.push(e.outputNames[t]+"_loss"));}}});var g=function(t,e){if(null==t||Array.isArray(t)&&0===t.length)return e.map(function(t){return [];});var n;if("string"==typeof t||"function"==typeof t)n=[t];else {if(!Array.isArray(t)&&"object"!=_typeof$1(t))throw new TypeError("Type of metrics argument not understood. Expected an string,function, Array, or Object, found: "+t);n=t;}if(Array.isArray(n))return e.map(function(t){return n;});for(var r=[],i=0,o=e;i<o.length;i++){var a=o[i],s=n.hasOwnProperty(a)?n[a]:[];Array.isArray(s)||(s=[s]),r.push(s);}return r;}(t.metrics,this.outputNames);tt("metric",function(){for(var t=function t(_t3){if(-1!==m.indexOf(_t3))return "continue";!function(n){for(var r,i,o,a=function a(n){if("string"==typeof n&&-1!==["accuracy","acc","crossentropy","ce"].indexOf(n)){var a=e.internalOutputShapes[_t3];1===a[a.length-1]||e.lossFunctions[_t3]===je?-1!==["accuracy","acc"].indexOf(n)?i=ze:-1!==["crossentropy","ce"].indexOf(n)&&(i=$e):e.lossFunctions[_t3]===Me?-1!==["accuracy","acc"].indexOf(n)?i=He:-1!==["crossentropy","ce"].indexOf(n)&&(i=Ke):-1!==["accuracy","acc"].indexOf(n)?i=Ue:-1!==["crossentropy","ce"].indexOf(n)&&(i=Ge);var s=void 0;-1!==["accuracy","acc"].indexOf(n)?s="acc":-1!==["crossentropy","ce"].indexOf(n)&&(s="ce"),o=i,r=""+s;}else {var u=function(t){if("string"==typeof t&&(t in Xe))return Xe[t];if("string"!=typeof t&&null!=t)return t;throw new d("Unknown metric "+t);}(n);o=u,r=""+Ye(n);}var c;tt(r,function(){c=o;}),function(t,n,r){e.outputNames.length>1&&(n=e.outputNames[t]+"_"+n),e.metricsNames.push(n),e.metricsTensors.push([r,t]);}(_t3,r,c);},s=0,u=g[_t3];s<u.length;s++){a(u[s]);}}();},n=0;n<e.outputs.length;++n){t(n);}}),this.collectedTrainableWeights=this.trainableWeights;},e.prototype.checkTrainableWeightsConsistency=function(){null!=this.collectedTrainableWeights&&this.trainableWeights.length!==this.collectedTrainableWeights.length&&console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?");},e.prototype.evaluate=function(t,e,n){void 0===n&&(n={});var r=null==n.batchSize?32:n.batchSize;xn(r);var i=this.standardizeUserDataXY(t,e,!0,r);try{var o=i[0].concat(i[1]);this.makeTestFunction();var a=this.testFunction;return b(this.testLoop(a,o,r,n.verbose,n.steps));}finally{On(i[0],t),On(i[1],e);}},e.prototype.evaluateDataset=function(t,e){return u(this,void 0,void 0,function(){return c(this,function(n){return this.makeTestFunction(),[2,function(t,e,n){return u(this,void 0,void 0,function(){var i,o,a,s,u,l,f,h,d,m;return c(this,function(g){switch(g.label){case 0:if(i=null!=(n=n||{}).batches,o=t.testFunction,a=[],n.verbose>0)throw new p("Verbose mode is not implemented yet.");return r.util.assert(!i||n.batches>0&&Number.isInteger(n.batches),function(){return "Test loop expects `batches` to be a positive integer, but received "+JSON.stringify(n.batches);}),function(t){return "function"==typeof t.next;}(e)?(u=e,[3,3]):[3,1];case 1:return [4,e.iterator()];case 2:u=g.sent(),g.label=3;case 3:s=u,l=0,f=0,h=function h(){var e;return c(this,function(u){switch(u.label){case 0:return [4,s.next()];case 1:return e=u.sent(),a=Object(r.tidy)(function(){if(e.value){var n=gn(t,e.value),i=n.xs,s=n.ys,u=i.concat(s),c=Object(r.tidy)(function(){return o(u);});if(Object(r.dispose)(u),0===f)for(var h=0;h<c.length;++h){a.push(Object(r.scalar)(0));}var d=u[0].shape[0],p=function p(t){var e=c[t],n=a[t];a[t]=Object(r.tidy)(function(){return Object(r.add)(a[t],Object(r.mul)(d,e));}),f>0&&Object(r.dispose)(n);};for(h=0;h<c.length;++h){p(h);}Object(r.dispose)(c),l+=d,++f;}return a;}),e.done?(i&&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];}});},g.label=4;case 4:return !i||f<n.batches?[5,h()]:[3,6];case 5:return "break"===g.sent()?[3,6]:[3,4];case 6:for(d=0;d<a.length;++d){m=a[d],a[d]=Object(r.div)(a[d],l),Object(r.dispose)(m);}return [2,b(a)];}});});}(this,t,e)];});});},e.prototype.checkNumSamples=function(t,e,n,r){var i;if(void 0===r&&(r="steps"),null!=n){if(i=null,null!=e)throw new d("If "+r+" is set, batchSize must be null or undefined.Got batchSize = "+e);}else {if(null==t)throw new d("Either the input data should have a defined shape, or "+r+" shoud be specified.");i=Array.isArray(t)?t[0].shape[0]:t.shape[0];}return i;},e.prototype.execute=function(t,e){if(Array.isArray(e)&&0===e.length)throw new d("`outputs` is an empty Array, which is not allowed.");var n=Array.isArray(e),i=n?e:[e],o=this.retrieveSymbolicTensors(i),a=new an();if(t instanceof r.Tensor&&(t=[t]),Array.isArray(t)){if(t.length!==this.inputs.length)throw new d("The number of inputs provided ("+t.length+") does not match the number of inputs of this model ("+this.inputs.length+").");for(var s=0;s<this.inputs.length;++s){a.add(this.inputs[s],t[s]);}}else for(var u=0,c=this.inputs;u<c.length;u++){var l=c[u],f=t[l.name];if(null==f)throw new d("No value is provided for the model's input "+l.name);a.add(l,f);}var h=cn(o,a);return n?h:h[0];},e.prototype.retrieveSymbolicTensors=function(t){for(var e=g(null,t.length),n=t.length,r=0,i=this.layers;r<i.length;r++){for(var o=i[r],a=Array.isArray(o.output)?o.output:[o.output],s=a.map(function(t){return t.name;}),u=0;u<t.length;++u){var c=s.indexOf(t[u]);if(-1!==c&&(e[u]=a[c],n--),0===n)break;}if(0===n)break;}if(n>0){var l=[];throw e.forEach(function(e,n){null==e&&l.push(t[n]);}),new d("Cannot find SymbolicTensors for output name(s): "+JSON.stringify(l));}return e;},e.prototype.predictLoop=function(t,e,n){var i=this;return void 0===e&&(e=32),void 0===n&&(n=!1),Object(r.tidy)(function(){var o=i.checkNumSamples(t);if(n)throw new p("Verbose predictLoop() is not implemented yet.");for(var a=En(o,e),s=i.outputs.map(function(t){return [];}),u=function u(e){Object(r.tidy)(function(){var n=a[e][0],r=a[e][1],o=wn(t,n,r),s=[];if(Array.isArray(o))for(var u=0;u<o.length;++u){s.push({key:i.inputs[u],value:o[u]});}else s.push({key:i.inputs[0],value:o});var c=new an(s);return cn(i.outputs,c);}).forEach(function(t,e){return s[e].push(t);});},c=0;c<a.length;++c){u(c);}return b(s.map(function(t){return Object(r.concat)(t,0);}));});},e.prototype.predict=function(t,e){void 0===e&&(e={});var n=An(t);Fn(n,this.inputNames,this.feedInputShapes,!1);try{var r=null==e.batchSize?32:e.batchSize;return xn(r),this.predictLoop(n,r);}finally{On(n,t);}},e.prototype.predictOnBatch=function(t){Fn(t,this.inputNames,this.feedInputShapes,!0);var e=(Array.isArray(t)?t[0]:t).shape[0];return this.predictLoop(t,e);},e.prototype.standardizeUserDataXY=function(t,e,n,i){if(null==this.optimizer_)throw new h("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");for(var o=[],a=0;a<this.feedOutputShapes.length;++a){var s=this.feedOutputShapes[a];this.feedLossFns[a]===Me?o.push(s.slice(0,s.length-1).concat([1])):o.push(s);}if(function(t,e,n){var i=_(t.map(function(t){return t.shape[0];}));i.sort();var o=_(e.map(function(t){return t.shape[0];}));if(o.sort(),i.length>1)throw new d("All input Tensors (x) should have the same number of samples. Got array shapes: "+JSON.stringify(t.map(function(t){return t.shape;})));if(o.length>1)throw new d("All target Tensors (y) should have the same number of samples. Got array shapes: "+JSON.stringify(e.map(function(t){return t.shape;})));if(i.length>0&&o.length>0&&!r.util.arraysEqual(i,o))throw new d("Input Tensors should have the same number of samples as target Tensors. Found "+i[0]+" input sample(s) and "+o[0]+" target sample(s).");}(t=Dn(t,this.feedInputNames,this.feedInputShapes,!1,"input"),e=Dn(e,this.feedOutputNames,o,!1,"target")),function(t,e,n){for(var r=[Te,je,Re],i=0;i<t.length;++i){var o=t[i],a=e[i],s=n[i];if(null!=a){if(a===Re&&1===o.shape[o.shape.length-1])throw new d("You are passing a target array of shape "+o.shape+" while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].");if(-1!==r.indexOf(a))for(var u=o.shape.slice(1),c=s.slice(1),l=0;l<u.length;++l){var f=u[l],h=c[l];if(null!=h&&f!==h)throw new d("A target Tensor with shape "+o.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.");}}}}(e,this.feedLossFns,this.feedOutputShapes),this.stateful&&null!=i&&i>0&&t[0].shape[0]%i!=0)throw new d("In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size "+i+". Found: "+t[0].shape[0]+" sample(s).");return [t,e];},e.prototype.standardizeUserData=function(t,e,n,r,i,o){return void 0===i&&(i=!0),u(this,void 0,void 0,function(){var a,s,u,l,f,h,d,p;return c(this,function(c){switch(c.label){case 0:if(a=this.standardizeUserDataXY(t,e,i,o),s=a[0],u=a[1],null!=n)throw new Error("sample weight is not supported yet.");if(l=null,null==r)return [3,4];f=hn(r,this.outputNames),l=[],h=0,c.label=1;case 1:return h<f.length?(p=(d=l).push,[4,dn(u[h],null,f[h])]):[3,4];case 2:p.apply(d,[c.sent()]),c.label=3;case 3:return ++h,[3,1];case 4:return [2,[s,u,l]];}});});},e.prototype.testLoop=function(t,e,n,i,o){var a=this;return void 0===i&&(i=0),Object(r.tidy)(function(){var s=a.checkNumSamples(e,n,o,"steps"),u=[];if(i>0)throw new p("Verbose mode is not implemented yet.");if(null!=o)throw new p("steps mode in testLoop() is not implemented yet");for(var c=En(s,n),l=Object(r.tensor1d)(lt(0,s)),f=0;f<c.length;++f){var h=c[f][0],d=c[f][1],m=dt(l,h,d-h),g=kn(e,m),v=t(g);if(0===f)for(var y=0;y<v.length;++y){u.push(Object(r.scalar)(0));}for(y=0;y<v.length;++y){var b=v[y];u[y]=Object(r.add)(u[y],Object(r.mul)(d-h,b));}}for(y=0;y<u.length;++y){u[y]=Object(r.div)(u[y],s);}return u;});},e.prototype.getDedupedMetricsNames=function(){for(var t=this.metricsNames,e=[],n=0;n<t.length;++n){var r=t[n],i=r;y(t,r)>1&&(i+="_"+y(t.slice(0,n),r)),e.push(i);}return e;},e.prototype.makeTrainFunction=function(){var t=this;return function(e){var n=[],i=e.slice(0,t.inputs.length),o=e.slice(t.inputs.length,t.inputs.length+t.outputs.length),a=e.slice(t.inputs.length+t.outputs.length,t.inputs.length+2*t.outputs.length),s=[],u=t.collectedTrainableWeights.map(function(t){return t.read();});return [t.optimizer_.minimize(function(){for(var e=[],u=0;u<t.inputs.length;++u){e.push({key:t.inputs[u],value:i[u]});}var c,l=new an(e),f=cn(t.outputs,l,{training:!0});for(u=0;u<t.lossFunctions.length;++u){var h=(0, t.lossFunctions[u])(o[u],f[u]);null!=a[u]&&(h=pn(h,a[u]));var d=Object(r.mean)(h);n.push(d),c=0===u?h:Object(r.add)(c,h);}for(u=0;u<t.metricsTensors.length;++u){var p=void 0;if(t.outputs.length>1&&u<t.outputs.length)p=n[u];else {var m=t.metricsTensors[u][0],g=t.metricsTensors[u][1];p=Object(r.mean)(m(o[g],f[g]));}Object(r.keep)(p),s.push(p);}return c=Object(r.mean)(c),t.calculateLosses().forEach(function(t){c=Object(r.add)(c,t);}),c;},!0,u)].concat(s);};},e.prototype.makeTestFunction=function(){var t=this;this.testFunction=function(e){return Object(r.tidy)(function(){for(var n,i=[],o=e.slice(0,t.inputs.length),a=e.slice(t.inputs.length,t.inputs.length+t.outputs.length),s=[],u=0;u<t.inputs.length;++u){s.push({key:t.inputs[u],value:o[u]});}var c=new an(s),l=cn(t.outputs,c);for(u=0;u<t.lossFunctions.length;++u){var f=t.lossFunctions[u],h=Object(r.mean)(f(a[u],l[u]));n=0===u?h:Object(r.add)(n,h),i.push(n);}for(u=0;u<t.metricsTensors.length;++u){var d=t.metricsTensors[u][0],p=t.metricsTensors[u][1],m=Object(r.mean)(d(a[p],l[p]));i.push(m);}return i;});};},e.prototype.fit=function(t,e,n){return void 0===n&&(n={}),u(this,void 0,void 0,function(){return c(this,function(r){return [2,Cn(this,t,e,n)];});});},e.prototype.fitDataset=function(t,e){return u(this,void 0,void 0,function(){return c(this,function(n){return [2,yn(this,t,e)];});});},e.prototype.trainOnBatch=function(t,e){return u(this,void 0,void 0,function(){var n,i,o,a,s,u,l,f,h;return c(this,function(c){switch(c.label){case 0:return [4,this.standardizeUserData(t,e)];case 1:n=c.sent(),i=n[0],o=n[1],a=this.makeTrainFunction(),s=a(i.concat(o)),u=[],l=0,f=s,c.label=2;case 2:return l<f.length?[4,f[l].data()]:[3,5];case 3:h=c.sent(),u.push(h[0]),c.label=4;case 4:return l++,[3,2];case 5:return Object(r.dispose)(s),[2,b(u)];}});});},e.prototype.getNamedWeights=function(t){for(var e=[],n=null!=t&&t.trainableOnly,r=n?this.trainableWeights:this.weights,i=this.getWeights(n),o=0;o<r.length;++o){n&&!r[o].trainable||e.push({name:r[o].originalName,tensor:i[o]});}return e;},Object.defineProperty(e.prototype,"stopTraining",{get:function get(){return this.stopTraining_;},set:function set(t){this.stopTraining_=t;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"optimizer",{get:function get(){return this.optimizer_;},set:function set(t){this.optimizer_!==t&&(this.optimizer_=t,this.isOptimizerOwned=!1);},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){var e=t.prototype.dispose.call(this);if(0===e.refCountAfterDispose&&null!=this.optimizer&&this.isOptimizerOwned){var n=Object(r.memory)().numTensors;this.optimizer_.dispose(),e.numDisposedVariables+=n-Object(r.memory)().numTensors;}return e;},e.prototype.getLossIdentifiers=function(){var t;if("string"==typeof this.loss)t=w(this.loss);else if(Array.isArray(this.loss)){for(var e=0,n=this.loss;e<n.length;e++){if("string"!=typeof n[e])throw new Error("Serialization of non-string loss is not supported.");}t=this.loss.map(function(t){return w(t);});}else {var r=Object.keys(this.loss);t={};for(var i=this.loss,o=0,a=r;o<a.length;o++){var s=a[o];if("string"!=typeof i[s])throw new Error("Serialization of non-string loss is not supported.");t[s]=w(i[s]);}}return t;},e.prototype.getMetricIdentifiers=function(){if("string"==typeof this.metrics||"function"==typeof this.metrics)return [w(Ye(this.metrics))];if(Array.isArray(this.metrics))return this.metrics.map(function(t){return w(Ye(t));});var t={};for(var e in this.metrics){t[e]=w(Ye(this.metrics[e]));}return t;},e.prototype.getTrainingConfig=function(){return {loss:this.getLossIdentifiers(),metrics:this.getMetricIdentifiers(),optimizer_config:{class_name:this.optimizer.getClassName(),config:this.optimizer.getConfig()}};},e.prototype.loadTrainingConfig=function(t){if(null!=t.weighted_metrics)throw new Error("Loading weight_metrics is not supported yet.");if(null!=t.loss_weights)throw new Error("Loading loss_weights is not supported yet.");if(null!=t.sample_weight_mode)throw new Error("Loading sample_weight_mode is not supported yet.");var e,n,r=De(on(t.optimizer_config));if("string"==typeof t.loss)e=k(t.loss);else if(Array.isArray(t.loss))e=t.loss.map(function(t){return k(t);});else if(null!=t.loss)for(var i in e={},t.loss){e[i]=k(t.loss[i]);}if(Array.isArray(t.metrics))n=t.metrics.map(function(t){return k(t);});else if(null!=t.metrics)for(var i in n={},t.metrics){n[i]=k(t.metrics[i]);}this.compile({loss:e,metrics:n,optimizer:r});},e.prototype.save=function(t,e){return u(this,void 0,void 0,function(){var n,i,o,a,s,u,l,f,h,p,m,g,v,y;return c(this,function(c){switch(c.label){case 0:if("string"==typeof t){if(0===(n=r.io.getSaveHandlers(t)).length)throw new d("Cannot find any save handlers for URL '"+t+"'");if(n.length>1)throw new d("Found more than one ("+n.length+") save handlers for URL '"+t+"'");t=n[0];}if(null==t.save)throw new d("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return [4,r.io.encodeWeights(this.getNamedWeights(e))];case 1:return i=c.sent(),o=!1,a=null,s=this.toJSON(a,o),u={modelTopology:s,format:"layers-model",generatedBy:"TensorFlow.js tfjs-layers v1.7.4",convertedBy:null},null!=e&&e.includeOptimizer&&null!=this.optimizer?(u.trainingConfig=this.getTrainingConfig(),l="optimizer",g=(m=r.io).encodeWeights,[4,this.optimizer.getWeights()]):[3,4];case 2:return [4,g.apply(m,[c.sent(),l])];case 3:f=c.sent(),h=f.data,p=f.specs,(y=i.specs).push.apply(y,p),i.data=r.io.concatenateArrayBuffers([i.data,h]),c.label=4;case 4:return null!=this.userDefinedMetadata&&(v=!0,Qe(this.userDefinedMetadata,this.name,v),u.userDefinedMetadata=this.userDefinedMetadata),u.weightData=i.data,u.weightSpecs=i.specs,[2,t.save(u)];}});});},e.prototype.setUserDefinedMetadata=function(t){Qe(t,this.name),this.userDefinedMetadata=t;},e.prototype.getUserDefinedMetadata=function(){return this.userDefinedMetadata;},e.className="Model",e;}(function(t){function e(n){var r=t.call(this,{})||this;if(r.containerNodes=new Set(),r.name=n.name,null==r.name){var i=r.getClassName().toLowerCase();r.name=Zt(i);}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],_(r.inputs).length!==r.inputs.length)throw new d("The list of inputs passed to the model is redundant. All inputs should only appear once. Found: "+r.inputs.map(function(t){return t.name;}));_(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(t){return t.name;})),r.inputLayers=[],r.inputLayersNodeIndices=[],r.inputLayersTensorIndices=[],r.outputLayers=[],r.outputLayersNodeIndices=[],r.outputLayersTensorIndices=[],r.layers=[],r.internalContainerRefs=[];for(var o=0,a=r.outputs;o<a.length;o++){var s=(T=a[o]).sourceLayer,u=T.nodeIndex,c=T.tensorIndex;r.outputLayers.push(s),r.outputLayersNodeIndices.push(u),r.outputLayersTensorIndices.push(c);}for(var l=0,f=r.inputs;l<f.length;l++){s=(T=f[l]).sourceLayer,u=T.nodeIndex,c=T.tensorIndex,v(0===u,"input layer has >1 nodes"),v(0===c,"input layer has >1 tensors"),r.inputLayers.push(s),r.inputLayersNodeIndices.push(u),r.inputLayersTensorIndices.push(c);}r.inputNames=[],r.outputNames=[],r.feedInputShapes=[],r.feedInputNames=[],r.feedOutputNames=[];for(var p=0;p<r.inputLayers.length;p++){if(!((s=r.inputLayers[p])instanceof ge))throw new TypeError("Input layers to a LayersModel must be InputLayer objects. Received inputs: "+n.inputs+". Input "+p+" (0-based) originates from layer type "+s.getClassName()+".");r.inputNames.push(s.name),r.feedInputShapes.push(s.batchInputShape),r.feedInputNames.push(s.name);}for(var m=0,g=r.outputLayers;m<g.length;m++){s=g[m],r.outputNames.push(s.name);}r.internalInputShapes=r.inputs.map(function(t){return t.shape;}),r.internalOutputShapes=r.outputs.map(function(t){return t.shape;});for(var y={},b={},x={},w={},k={},E=[],C=function C(t,n,i,o,a,s){null!=o&&null!=a&&null!=s||(o=t.sourceLayer,a=t.nodeIndex,s=t.tensorIndex);var u=o.inboundNodes[a];if(-1!==i.indexOf(u))throw new h("The tensor "+t.name+' at layer "'+o.name+'" is part of a cycle.');if(-1===n.indexOf(u)){r.containerNodes.add(e.nodeKey(o,a)),(o.id in k)||(k[o.id]=Object.keys(k).length),-1===i.indexOf(u)&&i.push(u);for(var c=u.inboundLayers.length,l=0;l<c;l++){var f=u.inputTensors[l],d=u.inboundLayers[l],p=u.nodeIndices[l],m=u.tensorIndices[l];C(f,n,i,d,p,m);}for(n.push(u);i.indexOf(u)>=0;){i.splice(i.indexOf(u),1);}E.push(u);}},A=[],S=[],D=0,F=r.outputs;D<F.length;D++){var T=F[D];C(T,A,S);}for(var N=0,I=E.slice().reverse();N<I.length;N++){b[(et=I[N]).id]=et,et.id in y||(y[et.id]=0);var R=y[et.id],M=null==x[et.outboundLayer.id]?0:x[et.outboundLayer.id];for(R=Math.max(R,M),x[et.outboundLayer.id]=R,w[et.outboundLayer.id]=et.outboundLayer,y[et.id]=R,p=0;p<et.inboundLayers.length;p++){var j=et.inboundLayers[p],B=(u=et.nodeIndices[p],j.inboundNodes[u]),P=null==y[B.id]?0:y[B.id];y[B.id]=Math.max(R+1,P),b[B.id]=B;}}var L={};for(var z in y){(R=y[z])in L||(L[R]=[]),L[R].push(b[z]);}var U={};for(var W in x){(R=x[W])in U||(U[R]=[]),U[R].push(w[W]);}var V=Object.keys(U).map(function(t){return parseInt(t,10);}).sort(O);r.layers=[];for(var q=0,$=V;q<$.length;q++){var H=U[R=$[q]];H.sort(function(t,e){var n=k[t.id],r=k[e.id];return n<r?-1:n>r?1:0;});for(var G=0,K=H;G<K.length;G++){(s=K[G])instanceof e&&r.internalContainerRefs.push(s),r.layers.push(s);}}r.layersByDepth=U,V=Object.keys(L).map(function(t){return parseInt(t,10);}).sort(O);for(var X=r.inputs.slice(),Y=[],J=0,Q=V;J<Q.length;J++){for(var Z=0,tt=L[R=Q[J]];Z<tt.length;Z++){var et;if(null!=(s=(et=tt[Z]).outboundLayer)){for(var nt=0,rt=et.inputTensors;nt<rt.length;nt++){if(T=rt[nt],-1===X.indexOf(T))throw new h("Graph disconnected: cannot obtain value for tensor "+T+' at layer "'+s.name+'". The following previous layers were accessed without issue: '+Y);}for(var it=0,ot=et.outputTensors;it<ot.length;it++){T=ot[it],X.push(T);}Y.push(s.name);}}}r.nodesByDepth=L;for(var at=r.layers.map(function(t){return t.name;}),st=function st(t){var e=at.filter(function(e){return e===t;}).length;if(1!==e)throw new h('The name "'+t+'" is used '+e+" times in the model. All layer names should be unique. Layer names: "+JSON.stringify(at));},ut=0,ct=at;ut<ct.length;ut++){st(ct[ut]);}return r.outboundNodes=[],r.inboundNodes=[],new he({outboundLayer:r,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:r.inputs,outputTensors:r.outputs,inputMasks:r.inputs.map(function(t){return null;}),outputMasks:r.outputs.map(function(t){return null;}),inputShapes:r.inputs.map(function(t){return t.shape;}),outputShapes:r.outputs.map(function(t){return t.shape;})}),r.built=!0,r._refCount=1,r;}return o(e,t),e.prototype.assertNotDisposed=function(){if(0===this._refCount)throw new Error("Container '"+this.name+"' is already disposed.");},e.prototype.dispose=function(){this.assertNotDisposed();var t={refCountAfterDispose:null,numDisposedVariables:0};if(0==--this._refCount){for(var e=0,n=this.layers;e<n.length;e++){var r=n[e];t.numDisposedVariables+=r.dispose().numDisposedVariables;}for(var i=0,o=this.internalContainerRefs;i<o.length;i++){var a=o[i];t.numDisposedVariables+=a.dispose().numDisposedVariables;}}return t.refCountAfterDispose=this._refCount,t;},Object.defineProperty(e.prototype,"trainable",{get:function get(){return this.trainable_;},set:function set(t){this.layers.forEach(function(e){e._trainableWeights.forEach(function(e){return e.trainable=t;});}),this.trainable_=t;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"trainableWeights",{get:function get(){if(this._trainableWeights.length>0)throw new d("Container instance unexpectedly contains _trainableWeights.The trainable weights of a Container are a union of the trainable weights of its consituent Layers. Its own _trainableWeights must remain an empty Array.");if(!this.trainable)return [];for(var t=[],e=0,n=this.layers;e<n.length;e++){var r=n[e];t=t.concat(r.trainableWeights);}return t;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nonTrainableWeights",{get:function get(){for(var t=[],e=0,n=this.layers;e<n.length;e++){var r=n[e];t.push.apply(t,r.nonTrainableWeights);}if(!this.trainable){for(var i=[],o=0,a=this.layers;o<a.length;o++){r=a[o],i.push.apply(i,r.trainableWeights);}return i.concat(t);}return t;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"weights",{get:function get(){return this.trainableWeights.concat(this.nonTrainableWeights);},enumerable:!0,configurable:!0}),e.prototype.loadWeights=function(t,e){void 0===e&&(e=!0);for(var n={},r=0,i=0,o=this.layers;i<o.length;i++){for(var a=0,s=o[i].weights;a<s.length;a++){var u=s[a];if(null!=n[u.originalName])throw new d("Duplicate weight name: "+u.originalName);n[u.originalName]=u,r++;}}var c=[];for(var l in t){if(null!=n[l])c.push([n[l],t[l]]);else if(e)throw new d("Provided weight data has no target variable: "+l);delete n[l];}if(e){var f=[];for(var h in n){f.push(h);}if(f.length>0)throw new d(f.length+" of "+r+" weights are not set: "+f);}ue(c);},e.prototype.updatedConfig=function(){var t=this.getConfig(),e={};return e.className=this.getClassName(),e.config=t,e.kerasVersion="tfjs-layers 1.7.4",e.backend="TensorFlow.js",e;},e.prototype.toJSON=function(t,e){void 0===e&&(e=!0);var n=function t(e,n){if(null===e||void 0===e)return null;if("string"==typeof e)return w(e);if("number"==typeof e||"boolean"==typeof e)return e;if(e instanceof Array){for(var r=[],i=e.length,o=0;o<i;++o){var a=e[o];rn(n,o,a)?r.push(a):r.push(t(a,n));}return r;}for(var s={},u=0,c=Object.keys(e);u<c.length;u++){var l=c[u],f=e[l];s[w(l)]="name"!==l&&"className"!==l||"string"!=typeof f?t(f,l):f;}return s;}(this.updatedConfig());return e?JSON.stringify(n):n;},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){t=x(t);for(var r=new an(),i=0;i<n.inputs.length;++i){r.add(n.inputs[i],t[i]);}return cn(n.outputs,r,e);});},e.prototype.computeMask=function(t,e){var n=this;return Object(r.tidy)(function(){var r;return t=x(t),r=null==e?g(null,t.length):x(e),n.runInternalGraph(t,r)[1];});},e.prototype.computeOutputShape=function(t){var e=ee(t);if(e.length!==this.inputLayers.length)throw new d("Invalid inputShape argument "+t+": model has "+this.inputLayers.length+" tensor inputs.");for(var n={},r=0;r<e.length;r++){var i=this.inputLayers[r],o=e[r];n[_=i.name+"_0_0"]=o;}var a=Object.keys(this.nodesByDepth).map(function(t){return parseInt(t,10);}).sort(O);if(a.length>1)for(var s=0,u=a;s<u.length;s++){for(var c=u[s],l=0,f=this.nodesByDepth[c];l<f.length;l++){var h=f[l];if(i=h.outboundLayer,-1===this.inputLayers.map(function(t){return t.id;}).indexOf(i.id)){for(var p=[],m=0;m<h.inboundLayers.length;m++){var g=h.inboundLayers[m],y=h.nodeIndices[m],x=h.tensorIndices[m],w=n[_=g.name+"_"+y+"_"+x];p.push(w);}var k=ee(i.computeOutputShape(b(p))),E=i.inboundNodes.indexOf(h);for(m=0;m<k.length;m++){n[_=i.name+"_"+E+"_"+m]=k[m];}}}}var C=[],A=[];for(r=0;r<this.outputLayers.length;r++){i=this.outputLayers[r],E=this.outputLayersNodeIndices[r],x=this.outputLayersTensorIndices[r];var _=i.name+"_"+E+"_"+x;A.push(_);}for(r=0;r<A.length;r++){var S=A[r];v(S in n),C.push(n[S]);}return b(C);},e.prototype.runInternalGraph=function(t,e){null==e&&(e=g(null,t.length));for(var n={},r=0;r<this.inputs.length;++r){var i=this.inputs[r],o=t[r],a=e[r];n[i.id]=[o,a];}for(var s=0,u=Object.keys(this.nodesByDepth).map(function(t){return parseInt(t,10);}).sort(O);s<u.length;s++){for(var c=u[s],l=0,f=this.nodesByDepth[c];l<f.length;l++){for(var h=f[l],d=h.outboundLayer,m=h.inputTensors,y=h.outputTensors,b=new Array(),w=0,k=m;w<k.length;w++){(i=k[w]).id in n&&b.push(n[i.id]);}if(b.length===m.length){var E={},C=void 0,A=void 0,_=void 0,S=void 0;if(null!=h.callArgs&&(E=h.callArgs),1===b.length){var D=b[0],F=D[0],T=D[1];null==E.mask&&(E.mask=T),_=x(d.call(F,E)),S=x(d.computeMask(F,T)),C=[F],A=[T];}else C=b.map(function(t){return t[0];}),A=b.map(function(t){return t[1];}),null==E.mask&&(E.mask=A),_=x(d.call(C,E)),S=x(d.computeMask(C,A));if(d.activityRegularizer)throw new p("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");for(r=0;r<y.length;++r){i=y[r],o=_[r],a=S[r],n[i.id]=[o,a];}}}}for(var N=[],I=[],R=[],M=0,j=this.outputs;M<j.length;M++){v((i=j[M]).id in n,"Could not compute output "+i.name+" : "+i.id);var B=n[i.id],P=B[0];a=B[1],R.push(P.shape),N.push(P),I.push(a);}return [N,I,R];},e.prototype.buildNodeConversionMap=function(t){for(var n,r={},i=0,o=this.layers;i<o.length;i++){var a=o[i];n=a instanceof e?1:0;for(var s=0;s<a.inboundNodes.length;s++){var u=e.nodeKey(a,s);this.containerNodes.has(u)&&(r[u]=n,n+=1);}}return r;},e.prototype.getLayer=function(t,e){if(null!=e){if(this.layers.length<=e)throw new d("Was asked to retrieve layer at index "+e+", but model only has "+this.layers.length+" layer(s).");return this.layers[e];}if(null==t)throw new d("Provide either a layer name or layer index");for(var n=0,r=this.layers;n<r.length;n++){var i=r[n];if(i.name===t)return i;}throw new d("No such layer: "+t);},e.prototype.calculateLosses=function(){var t=this;return Object(r.tidy)(function(){for(var n=[],r=0,i=t.layers;r<i.length;r++){for(var o=i[r],a=0;a<o.inboundNodes.length;++a){var s=e.nodeKey(o,a);t.containerNodes.has(s)&&n.push.apply(n,o.calculateLosses());}}return n;});},e.prototype.getConfig=function(){for(var t={name:this.name},n=this.buildNodeConversionMap(this.layers),r=[],i=0,o=this.layers;i<o.length;i++){for(var a=(x=o[i]).getClassName(),s=x.getConfig(),u=[],c=0;c<x.inboundNodes.length;c++){var l=x.inboundNodes[c],f=e.nodeKey(x,c),h={};if(this.containerNodes.has(f)){if(l.callArgs)try{JSON.stringify(l.callArgs),h=l.callArgs;}catch(t){console.warn("Layer "+x.name+" was passed non-serializable keyword arguments: "+l.callArgs+". They will not be included in the serialized model (and thus will be missing at deserialization time)."),h={};}if(l.inboundLayers.length>0){for(var d=[],p=0;p<l.inboundLayers.length;p++){var m=l.inboundLayers[p],g=l.nodeIndices[p],v=l.tensorIndices[p];null==(k=n[e.nodeKey(m,g)])&&(k=0),d.push([m.name,k,v,h]);}u.push(d);}}}var y={};y.name=x.name,y.className=a,y.config=s,y.inboundNodes=u,r.push(y);}t.layers=r;var b=[];for(p=0;p<this.inputLayers.length;p++){var x=this.inputLayers[p];g=this.inputLayersNodeIndices[p],f=e.nodeKey(x,g),this.containerNodes.has(f)&&(null!==(k=n[f])&&void 0!==k||(k=0),v=this.inputLayersTensorIndices[p],b.push([x.name,k,v]));}t.inputLayers=b;var w=[];for(p=0;p<this.outputLayers.length;p++){var k;if(x=this.outputLayers[p],g=this.outputLayersNodeIndices[p],f=e.nodeKey(x,g),this.containerNodes.has(f))null!==(k=n[f])&&void 0!==k||(k=0),v=this.outputLayersTensorIndices[p],w.push([x.name,k,v]);}return t.outputLayers=w,t;},e.fromConfig=function(t,e,n,r){void 0===r&&(r=!1);var i={},o={};function a(t,e){t.name in o?o[t.name].push(e):o[t.name]=[e];}function s(t,e){for(var n,r=[],o=0,s=e;o<s.length;o++){var u=s[o],c=u[0],l=u[1],f=u[2];if(n=null==u[3]?{}:u[3],!(c in i))return void a(t,e);var h=i[c];if(h.inboundNodes.length<=l)return void a(t,e);var d=h.inboundNodes[l];r.push(d.outputTensors[f]);}r.length>0&&t.apply(b(r),n);}function u(t){var n=t.name,o=De(t,null!=e.customObjects?e.customObjects:{});o.setFastWeightInitDuringBuild(r),i[n]=o,t.inboundNodes.forEach(function(t){if(!(t instanceof Array))throw new d("Corrupted configuration, expected array for nodeData: "+t);a(o,t);});}for(var c=e.name,l=e.layers,f=0,h=l;f<h.length;f++){u(g=h[f]);}for(;!S(o);){for(var p=0,m=l;p<m.length;p++){var g=m[p];if((I=i[g.name]).name in o){var y=o[I.name];delete o[I.name];for(var x=0,w=y;x<w.length;x++){s(I,w[x]);}}}}for(var k=[],E=[],C=0,A=e.inputLayers;C<A.length;C++){var O=(g=A[C])[0],_=g[1],D=g[2];v(O in i);var F=(I=i[O]).inboundNodes[_].outputTensors;k.push(F[D]);}for(var T=0,N=e.outputLayers;T<N.length;T++){var I;O=(g=N[T])[0],_=g[1],D=g[2],v(O in i),F=(I=i[O]).inboundNodes[_].outputTensors,E.push(F[D]);}return new t({inputs:k,outputs:E,name:c});},Object.defineProperty(e.prototype,"stateful",{get:function get(){if(this._stateful)throw new d("Container instance unexpectedly has _stateful = true. The statefulness of a Container is determined by the Layers it contains. Its _stateful property must remain the default false.");for(var t=0,e=this.layers;t<e.length;t++){if(e[t].stateful)return !0;}return !1;},enumerable:!0,configurable:!0}),e.prototype.resetStates=function(){var t=this;Object(r.tidy)(function(){t.layers.forEach(function(t){t.stateful&&t.resetStates();});});},e;}(pe));function Nn(t,e){return u(this,void 0,void 0,function(){var n;return c(this,function(i){if(null==e&&(e={}),"string"==typeof t){if(0===(n=r.io.getLoadHandlers(t,e.onProgress)).length)n.push(r.io.browserHTTPRequest(t,e));else if(n.length>1)throw new d("Found more than one ("+n.length+") load handlers for URL '"+t+"'");t=n[0];}return [2,function(t,e,n){return u(this,void 0,void 0,function(){var i,o,a,s,u,l,f,h,p;return c(this,function(c){switch(c.label){case 0:if(null==n&&(n={}),null==t.load)throw new d("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");return [4,t.load()];case 1:if(i=c.sent(),null!=(o=i.modelTopology).model_config&&(o=o.model_config),a=null==n.strict||n.strict,s=null!=i.weightData&&null!=i.weightSpecs&&a,u=De(on(o),e,s),null!=(l=i.trainingConfig)&&u.loadTrainingConfig(l),null!=i.userDefinedMetadata&&u.setUserDefinedMetadata(i.userDefinedMetadata),null==i.weightData)return [3,4];if(null==i.weightSpecs)throw new d("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");return f=function(t,e){var n=r.io.decodeWeights(t,e),i={},o=[];return e.forEach(function(t){"optimizer"===t.group?o.push({name:t.name,tensor:n[t.name]}):i[t.name]=n[t.name];}),{modelWeights:i,optimizerWeights:o};}(i.weightData,i.weightSpecs),h=f.modelWeights,p=f.optimizerWeights,u.loadWeights(h,a),null!=u.optimizer&&p.length>0?[4,u.optimizer.setWeights(p)]:[3,3];case 2:c.sent(),c.label=3;case 3:Object(r.dispose)(h),Object(r.dispose)(p.map(function(t){return t.tensor;})),c.label=4;case 4:return [2,u];}});});}(t,void 0,e)];});});}r.serialization.registerClass(Tn);var In=function(t){function e(e){var n=t.call(this,{inputs:[],outputs:[]})||this;if(e=e||{},n.trainable=!0,n.built=!1,n.name=null!=e.name?e.name:Zt("sequential_"),null!=e.layers)for(var r=0,i=e.layers;r<i.length;r++){var o=i[r];n.add(o);}return n;}return o(e,t),e.prototype.checkShape=function(t){if(t.inboundNodes[0].outputTensors[0].shape.some(function(t){return t<0;}))throw new d("Negative dimension size caused by adding layer "+t.name+" with input shape ["+t.inboundNodes[0].inputTensors[0].shape+"]");},e.prototype.add=function(t){var n,r=t instanceof e||t instanceof Tn;if(r){if(1!==(n=t).outputs.length)throw new d("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");if(1!==n.inputs.length)throw new d("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.");}if(0===this.outputs.length){if(0===t.inboundNodes.length){if(null==t.batchInputShape)throw new d("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");var i=ve({batchShape:t.batchInputShape,dtype:t.dtype,name:t.name+"_input"});t.apply(i);}if(r)this.outputs=n.outputs,this.inputs=n.inputs;else {if(1!==t.inboundNodes.length)throw new d("A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer "+t.name+" which has "+t.inboundNodes.length+" pre-existing inbound connections.");if(1!==t.inboundNodes[0].outputTensors.length)throw new d("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(t),this.outputs=[t.inboundNodes[0].outputTensors[0]],this.inputs=function t(e,n,r){if((null==n||null!=r&&r>0)&&(n=e.sourceLayer,r=e.nodeIndex),0===n.inboundNodes.length)return [e];var i=n.inboundNodes[r];if(0===i.inboundLayers.length)return i.inputTensors;for(var o=[],a=0;a<i.inboundLayers.length;a++){for(var s=0,u=t(i.inputTensors[a],i.inboundLayers[a],i.nodeIndices[a]);s<u.length;s++){var c=u[s];-1===o.indexOf(c)&&o.push(c);}}return o;}(this.outputs[0]);}this.inboundNodes=[],new he({outboundLayer:this,inboundLayers:[],nodeIndices:[],tensorIndices:[],inputTensors:this.inputs,outputTensors:this.outputs,inputMasks:g(null,this.inputs.length),outputMasks:[null],inputShapes:this.inputs.map(function(t){return t.shape;}),outputShapes:this.outputs[0].shape});}else {var o=t.apply(this.outputs[0]);if(Array.isArray(o))throw new TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");this.checkShape(t),this.outputs=[o],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape];}this.layers.push(t),this.built=!1;},e.prototype.pop=function(){if(0===this.layers.length)throw new TypeError("There are no layers in the model.");if(this.layers.pop(),0===this.layers.length)this.outputs=[],this.inboundNodes=[],this.outboundNodes=[];else {var t=this.layers.length-1;this.layers[t].outboundNodes=[],this.outputs=[this.layers[t].output],this.inboundNodes[0].outputTensors=this.outputs,this.inboundNodes[0].outputShapes=[this.outputs[0].shape];}},e.prototype.call=function(t,e){return null==this.model&&this.build(),this.model.call(t,e);},e.prototype.build=function(t){if(re(t),0===this.inputs.length||0===this.outputs.length)throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");this.model=new Tn({inputs:this.inputs,outputs:this.outputs[0],name:this.name+"_model"}),this.model.trainable=this.trainable,this.supportsMasking=this.model.supportsMasking,this.inputLayers=this.model.inputLayers,this.inputLayersNodeIndices=this.model.inputLayersNodeIndices,this.inputLayersTensorIndices=this.model.inputLayersTensorIndices,this.outputLayers=this.model.outputLayers,this.outputLayersNodeIndices=this.model.outputLayersNodeIndices,this.outputLayersTensorIndices=this.model.outputLayersTensorIndices,this.nodesByDepth=this.model.nodesByDepth,this.containerNodes=this.model.containerNodes,this.outputNames=this.model.outputNames,this.inputNames=this.model.inputNames,this.built=!0;},e.prototype.countParams=function(){return this.built||this.build(),t.prototype.countParams.call(this);},e.prototype.summary=function(e,n,r){void 0===r&&(r=console.log),this.built||this.build(),t.prototype.summary.call(this,e,n,r);},e.prototype.setWeights=function(t){null==this.model&&this.build(),this.model.setWeights(t);},e.prototype.evaluate=function(t,e,n){if(void 0===n&&(n={}),!this.built)throw new h("The model needs to be compiled before being used.");return this.model.evaluate(t,e,n);},e.prototype.evaluateDataset=function(t,e){return u(this,void 0,void 0,function(){return c(this,function(n){if(!this.built)throw new h("The model needs to be compiled before being used.");return [2,this.model.evaluateDataset(t,e)];});});},e.prototype.predict=function(t,e){return void 0===e&&(e={}),null==this.model&&this.build(),this.model.predict(t,e);},e.prototype.predictOnBatch=function(t){return null==this.model&&this.build(),this.model.predictOnBatch(t);},e.prototype.compile=function(t){this.build(),this.model.compile(t),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;},Object.defineProperty(e.prototype,"optimizer",{get:function get(){return null==this.model?void 0:this.model.optimizer;},set:function set(t){this.model.optimizer=t;},enumerable:!0,configurable:!0}),e.prototype.fit=function(t,e,n){return void 0===n&&(n={}),u(this,void 0,void 0,function(){return c(this,function(r){if(!this.built)throw new h("The model needs to be compiled before being used.");return [2,this.model.fit(t,e,n)];});});},e.prototype.fitDataset=function(t,e){return u(this,void 0,void 0,function(){return c(this,function(n){if(!this.built)throw new h("The model needs to be compiled before being used.");return [2,this.model.fitDataset(t,e)];});});},e.prototype.trainOnBatch=function(t,e){return u(this,void 0,void 0,function(){return c(this,function(n){return [2,this.model.trainOnBatch(t,e)];});});},e.fromConfig=function(t,n,i,o){var a;void 0===o&&(o=!1);var s={};if(n instanceof Array){if(null==n[0].className||"Merge"===n[0].className)throw new d("Legacy serialization format not supported yet.");a=n;}else r.util.assert(null!=n.layers,function(){return "When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field.";}),a=n.layers,delete n.layers,s=n;var u=new t(s);if(!(u instanceof e))throw new p("Sequential.fromConfig called on non-Sequential input: "+u);for(var c=0,l=a;c<l.length;c++){var f=De(l[c],void 0,o);o&&f.setFastWeightInitDuringBuild(!0),u.add(f);}return u;},Object.defineProperty(e.prototype,"stopTraining",{get:function get(){if(null==this.model)throw new d("Cannot get the stopTraining property of a sequential model before it is compiled.");return this.model.stopTraining;},set:function set(t){if(null==this.model)throw new d("Cannot set the stopTraining property of a sequential model before it is compiled.");this.model.stopTraining=t;},enumerable:!0,configurable:!0}),e.prototype.getConfig=function(){for(var t=[],e=0,n=this.layers;e<n.length;e++){var r=n[e],i={};i.className=r.getClassName(),i.config=r.getConfig(),t.push(i);}return {name:this.name,layers:t};},e.className="Sequential",e;}(Tn);function Rn(t){return new Tn(t);}function Mn(t){return new In(t);}function jn(t,e){return null==e&&(e={}),Nn(t,e);}function Bn(t){return ve(t);}function Pn(t,e){_e.registerCallbackConstructor(t,e);}r.serialization.registerClass(In);var Ln=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.getConfig=function(){return {};},e;}(r.serialization.Serializable),zn=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.apply=function(t,e){return void 0===e&&(e=1),function(t,e){if(void 0===e&&(e=1),1!==e)throw new p("Support for alpha values other than 1 ("+e+") is not implemented yet.");return Object(r.elu)(t);}(t,e);},e.className="elu",e;}(Ln);r.serialization.registerClass(zn);var Un=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.apply=function(t){return Object(r.selu)(t);},e.className="selu",e;}(Ln);r.serialization.registerClass(Un);var Wn=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.apply=function(t){return Object(r.relu)(t);},e.className="relu",e;}(Ln);r.serialization.registerClass(Wn);var Vn=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.apply=function(t){return Object(r.tidy)(function(){return Object(r.minimum)(6,Object(r.relu)(t));});},e.className="relu6",e;}(Ln);r.serialization.registerClass(Vn);var qn=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.apply=function(t){return t;},e.className="linear",e;}(Ln);r.serialization.registerClass(qn);var $n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.apply=function(t){return Object(r.sigmoid)(t);},e.className="sigmoid",e;}(Ln);r.serialization.registerClass($n);var Hn=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.apply=function(t){return function(t){return Object(r.tidy)(function(){var e=Object(r.add)(.5,Object(r.mul)(.2,t));return Object(r.clipByValue)(e,0,1);});}(t);},e.className="hardSigmoid",e;}(Ln);r.serialization.registerClass(Hn);var Gn=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.apply=function(t){return Object(r.softplus)(t);},e.className="softplus",e;}(Ln);r.serialization.registerClass(Gn);var Kn=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.apply=function(t){return function(t){return Object(r.tidy)(function(){return Object(r.div)(t,Object(r.abs)(t).add(1));});}(t);},e.className="softsign",e;}(Ln);r.serialization.registerClass(Kn);var Xn=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.apply=function(t){return Object(r.tanh)(t);},e.className="tanh",e;}(Ln);r.serialization.registerClass(Xn);var Yn=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.apply=function(t,e){return void 0===e&&(e=-1),Object(r.softmax)(t,e);},e.className="softmax",e;}(Ln);r.serialization.registerClass(Yn);var Jn=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.apply=function(t,e){return void 0===e&&(e=-1),Object(r.logSoftmax)(t,e);},e.className="logSoftmax",e;}(Ln);function Qn(t){return t.getClassName();}function Zn(t,e){return void 0===e&&(e={}),A(t,r.serialization.SerializationMap.getMap().classNameMap,e,"activation");}function tr(t){var e;return null==t?Zn(e={className:"linear",config:{}}):"string"==typeof t?((e={}).className=t,e.config={},Zn(e)):t instanceof Ln?t:Zn(t);}function er(t){if(null!=t&&"object"!=_typeof$1(t))throw new Error("Argument to L1L2 regularizer's constructor is expected to be an object, but received: "+t);}r.serialization.registerClass(Jn);var nr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e;}(r.serialization.Serializable),rr=function(t){function e(e){var n=t.call(this)||this;return er(e),n.l1=null==e||null==e.l1?.01:e.l1,n.l2=null==e||null==e.l2?.01:e.l2,n.hasL1=0!==n.l1,n.hasL2=0!==n.l2,n;}return o(e,t),e.prototype.apply=function(t){var e=this;return Object(r.tidy)(function(){var n=Object(r.zeros)([1]);return e.hasL1&&(n=Object(r.add)(n,Object(r.sum)(Object(r.mul)(e.l1,Object(r.abs)(t))))),e.hasL2&&(n=Object(r.add)(n,Object(r.sum)(Object(r.mul)(e.l2,kt(t))))),n.asScalar();});},e.prototype.getConfig=function(){return {l1:this.l1,l2:this.l2};},e.fromConfig=function(t,e){return new t({l1:e.l1,l2:e.l2});},e.className="L1L2",e;}(nr);r.serialization.registerClass(rr);var ir={l1l2:"L1L2"};function or(t){return C(t);}function ar(t,e){return void 0===e&&(e={}),A(t,r.serialization.SerializationMap.getMap().classNameMap,e,"regularizer");}function sr(t){return null==t?null:"string"==typeof t?ar({className:t in ir?ir[t]:t,config:{}}):t instanceof nr?t:ar(t);}var ur=function(t){function e(e){var n=t.call(this,null==e?{}:e)||this;return n.supportsMasking=!0,null!=e&&(n.maxValue=e.maxValue),n;}return o(e,t),e.prototype.call=function(t,e){t=ne(t);var n=Object(r.relu)(t);return null!=this.maxValue&&(n=Object(r.clipByValue)(n,0,this.maxValue)),n;},e.prototype.computeOutputShape=function(t){return t;},e.prototype.getConfig=function(){var e={maxValue:this.maxValue},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="ReLU",e;}(pe);r.serialization.registerClass(ur);var cr=function(t){function e(e){var n=t.call(this,null==e?{}:e)||this;return n.DEFAULT_ALPHA=.3,null==e&&(e={}),n.alpha=null==e.alpha?n.DEFAULT_ALPHA:e.alpha,n;}return o(e,t),e.prototype.call=function(t,e){var n=ne(t);return Object(r.leakyRelu)(n,this.alpha);},e.prototype.computeOutputShape=function(t){return t;},e.prototype.getConfig=function(){var e={alpha:this.alpha},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="LeakyReLU",e;}(pe);r.serialization.registerClass(cr);var lr=function(t){function e(e){var n=t.call(this,null==e?{}:e)||this;if(n.DEFAULT_ALPHA_INITIALIZER="zeros",null==e&&(e={}),n.supportsMasking=!0,n.alphaInitializer=Kt(e.alphaInitializer||n.DEFAULT_ALPHA_INITIALIZER),n.alphaRegularizer=sr(e.alphaRegularizer),n.alphaConstraint=W(e.alphaConstraint),null==e.sharedAxes)n.sharedAxes=null;else if(Array.isArray(e.sharedAxes))n.sharedAxes=e.sharedAxes;else {if("number"!=typeof e.sharedAxes)throw new d("Expected sharedAxes to be a number or an array of numbers, but got "+e.sharedAxes);n.sharedAxes=[e.sharedAxes];}return n;}return o(e,t),e.prototype.build=function(t){var e=(t=re(t)).slice(1);if(null!=this.sharedAxes)for(var n=0,r=this.sharedAxes;n<r.length;n++){e[(o=r[n])-1]=1;}this.alpha=this.addWeight("alpha",e,"float32",this.alphaInitializer,this.alphaRegularizer,!0,this.alphaConstraint);var i={};if(null!=this.sharedAxes)for(var o=1;o<t.length;++o){i[o]=t[o];}this.inputSpec=[new ce({ndim:t.length,axes:i})],this.built=!0;},e.prototype.call=function(t,e){return t=ne(t),Object(r.prelu)(t,this.alpha.read());},e.prototype.getConfig=function(){var e={alphaInitializer:Gt(this.alphaInitializer),alphaRegularizer:or(this.alphaRegularizer),alphaConstraint:z(this.alphaConstraint),sharedAxes:this.sharedAxes},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="PReLU",e;}(pe);r.serialization.registerClass(lr);var fr=function(t){function e(e){var n=t.call(this,null==e?{}:e)||this;if(n.DEFAULT_ALPHA=1,null==e&&(e={}),null!=e.alpha&&e.alpha!==n.DEFAULT_ALPHA)throw new p("Non-default alpha value ("+e.alpha+") is not supported by the ELU layer yet.");return n.alpha=null==e.alpha?n.DEFAULT_ALPHA:e.alpha,n;}return o(e,t),e.prototype.call=function(t,e){var n=ne(t);return Object(r.elu)(n);},e.prototype.computeOutputShape=function(t){return t;},e.prototype.getConfig=function(){var e={alpha:this.alpha},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="ELU",e;}(pe);r.serialization.registerClass(fr);var hr=function(t){function e(e){var n=t.call(this,null==e?{}:e)||this;return n.DEFAULT_THETA=1,null==e&&(e={}),n.theta=null==e.theta?n.DEFAULT_THETA:e.theta,n;}return o(e,t),e.prototype.call=function(t,e){var n=ne(t);return n.mul(ft(n.greater(this.theta),"float32"));},e.prototype.computeOutputShape=function(t){return t;},e.prototype.getConfig=function(){var e={theta:this.theta},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="ThresholdedReLU",e;}(pe);r.serialization.registerClass(hr);var dr=function(t){function e(e){var n=t.call(this,null==e?{}:e)||this;return n.DEFAULT_AXIS=1,null==e&&(e={}),n.softmax=new Yn().apply,n.axis=null==e.axis?n.DEFAULT_AXIS:e.axis,n;}return o(e,t),e.prototype.call=function(t,e){var n=ne(t);return this.softmax(n,this.axis);},e.prototype.computeOutputShape=function(t){return t;},e.prototype.getConfig=function(){var e={axis:this.axis},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="Softmax",e;}(pe);function pr(t,e,n){if("number"==typeof t)return g(t,e);if(t.length!==e)throw new d("The "+n+" argument must be an integer or tuple of "+e+" integers. Received: "+t.length+" elements.");for(var r=0;r<e;++r){var i=t[r];if(!ot(i))throw new d("The "+n+" argument must be an integer or tuple of "+e+" integers. Received: "+JSON.stringify(t)+" including a non-integer number "+i);}return t;}function mr(t,e,n,r,i){return void 0===i&&(i=1),null==t?t:(o="same"===n?t:t-(e+(e-1)*(i-1))+1,Math.floor((o+r-1)/r));var o;}function gr(t,e,n,r){if(null==t)return null;if("valid"===r)t=t*e+ct([n-e,0]);else {if("same"!==r)throw new d("Unsupport padding mode: "+r+".");t*=e;}return t;}function vr(t,e){return Object(r.tidy)(function(){return X(e),"channelsFirst"===e?Object(r.transpose)(t,[0,2,3,1]):t;});}function yr(t,e){return Object(r.tidy)(function(){return X(e),"channelsFirst"===e?Object(r.transpose)(t,[0,2,3,4,1]):t;});}function br(t,e,n,i,o,a,s,u){return void 0===i&&(i=[1,1]),void 0===o&&(o="valid"),void 0===u&&(u=null),Object(r.tidy)(function(){if(null==a&&(a="channelsLast"),X(a),3!==t.rank&&4!==t.rank)throw new d("conv2dWithBiasActivation expects input to be of rank 3 or 4, but received "+t.rank+".");if(3!==e.rank&&4!==e.rank)throw new d("conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received "+t.rank+".");var c=vr(t,a);if("causal"===o)throw new p("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");return c=r.fused.conv2d({x:c,filter:e,strides:i,pad:"same"===o?"same":"valid",dilations:s,dataFormat:"NHWC",bias:n,activation:u}),"channelsFirst"===a&&(c=Object(r.transpose)(c,[0,3,1,2])),c;});}r.serialization.registerClass(dr);var xr=function(t){function e(n,r){var i=t.call(this,r)||this;if(i.bias=null,i.DEFAULT_KERNEL_INITIALIZER="glorotNormal",i.DEFAULT_BIAS_INITIALIZER="zeros",e.verifyArgs(r),i.rank=n,T(i.rank,"rank"),1!==i.rank&&2!==i.rank&&3!==i.rank)throw new p("Convolution layer for rank other than 1, 2, or 3 ("+i.rank+") is not implemented yet.");if(i.kernelSize=pr(r.kernelSize,n,"kernelSize"),i.strides=pr(null==r.strides?1:r.strides,n,"strides"),i.padding=null==r.padding?"valid":r.padding,Y(i.padding),i.dataFormat=null==r.dataFormat?"channelsLast":r.dataFormat,X(i.dataFormat),i.activation=tr(r.activation),i.useBias=null==r.useBias||r.useBias,i.biasInitializer=Kt(r.biasInitializer||i.DEFAULT_BIAS_INITIALIZER),i.biasConstraint=W(r.biasConstraint),i.biasRegularizer=sr(r.biasRegularizer),i.activityRegularizer=sr(r.activityRegularizer),i.dilationRate=pr(null==r.dilationRate?1:r.dilationRate,n,"dilationRate"),1===i.rank&&Array.isArray(i.dilationRate)&&1!==i.dilationRate.length)throw new d("dilationRate must be a number or an array of a single number for 1D convolution, but received "+JSON.stringify(i.dilationRate));if(2===i.rank){if("number"==typeof i.dilationRate)i.dilationRate=[i.dilationRate,i.dilationRate];else if(2!==i.dilationRate.length)throw new d("dilationRate must be a number or array of two numbers for 2D convolution, but received "+JSON.stringify(i.dilationRate));}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 d("dilationRate must be a number or array of three numbers for 3D convolution, but received "+JSON.stringify(i.dilationRate));return i;}return o(e,t),e.verifyArgs=function(t){if(v("kernelSize"in t,"required key 'kernelSize' not in config"),"number"!=typeof t.kernelSize&&!F(t.kernelSize,"number",1,3))throw new d("BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received "+JSON.stringify(t.kernelSize)+".");},e.prototype.getConfig=function(){var e={kernelSize:this.kernelSize,strides:this.strides,padding:this.padding,dataFormat:this.dataFormat,dilationRate:this.dilationRate,activation:Qn(this.activation),useBias:this.useBias,biasInitializer:Gt(this.biasInitializer),biasRegularizer:or(this.biasRegularizer),activityRegularizer:or(this.activityRegularizer),biasConstraint:z(this.biasConstraint)},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e;}(pe),wr=function(t){function e(n,r){var i=t.call(this,n,r)||this;return i.kernel=null,e.verifyArgs(r),i.filters=r.filters,T(i.filters,"filters"),i.kernelInitializer=Kt(r.kernelInitializer||i.DEFAULT_KERNEL_INITIALIZER),i.kernelConstraint=W(r.kernelConstraint),i.kernelRegularizer=sr(r.kernelRegularizer),i;}return o(e,t),e.prototype.build=function(t){var e;t=re(t);var n="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[n])throw new d("The channel dimension of the input should be defined. Found "+t[n]);var r=t[n],i=this.kernelSize.concat([r,this.filters]);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=[{ndim:this.rank+2,axes:(e={},e[n]=r,e)}],this.built=!0;},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){var e;t=ne(t);var i=null==n.bias?null:n.bias.read(),o=N(n.activation.getClassName());if(null!=o&&2===n.rank)e=br(t,n.kernel.read(),i,n.strides,n.padding,n.dataFormat,n.dilationRate,o);else {if(1===n.rank)e=function(t,e,n,i,o,a,s){return void 0===i&&(i=1),void 0===o&&(o="valid"),void 0===s&&(s=1),Object(r.tidy)(function(){if(null==a&&(a="channelsLast"),X(a),3!==t.shape.length)throw new d("The input of a conv1dWithBias operation should be 3, but is "+t.shape.length+" instead.");if(3!==e.shape.length)throw new d("The kernel for a conv1dWithBias operation should be 3, but is "+e.shape.length+" instead");if(null!=n&&1!==n.shape.length)throw new d("The bias for a conv1dWithBias operation should be 1, but is "+e.shape.length+" instead");if("channelsFirst"===a&&(t=Object(r.transpose)(t,[0,2,1])),"causal"===o)throw new p("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");var u=Object(r.conv1d)(t,e,i,"same"===o?"same":"valid","NWC",s);return null!=n&&(u=Ct(u,n)),u;});}(t,n.kernel.read(),i,n.strides[0],n.padding,n.dataFormat,n.dilationRate[0]);else if(2===n.rank)e=br(t,n.kernel.read(),i,n.strides,n.padding,n.dataFormat,n.dilationRate);else {if(3!==n.rank)throw new p("convolutions greater than 3D are not implemented yet.");e=function(t,e,n,i,o,a,s){return void 0===i&&(i=[1,1,1]),void 0===o&&(o="valid"),Object(r.tidy)(function(){if(null==a&&(a="channelsLast"),X(a),4!==t.rank&&5!==t.rank)throw new d("conv3dWithBias expects input to be of rank 4 or 5, but received "+t.rank+".");if(4!==e.rank&&5!==e.rank)throw new d("conv3dWithBias expects kernel to be of rank 4 or 5, but received "+t.rank+".");var u=yr(t,a);if("causal"===o)throw new p("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");return u=Object(r.conv3d)(u,e,i,"same"===o?"same":"valid","NDHWC",s),null!=n&&(u=Ct(u,n)),"channelsFirst"===a&&(u=Object(r.transpose)(u,[0,4,1,2,3])),u;});}(t,n.kernel.read(),i,n.strides,n.padding,n.dataFormat,n.dilationRate);}null!=n.activation&&(e=n.activation.apply(e));}return e;});},e.prototype.computeOutputShape=function(t){t=re(t);for(var e=[],n="channelsLast"===this.dataFormat?t.slice(1,t.length-1):t.slice(2),r=0;r<n.length;++r){var i=mr(n[r],this.kernelSize[r],this.padding,this.strides[r],"number"==typeof this.dilationRate?this.dilationRate:this.dilationRate[r]);e.push(i);}var o=[t[0]];return "channelsLast"===this.dataFormat?(o=o.concat(e)).push(this.filters):(o.push(this.filters),o=o.concat(e)),o;},e.prototype.getConfig=function(){var e={filters:this.filters,kernelInitializer:Gt(this.kernelInitializer),kernelRegularizer:or(this.kernelRegularizer),kernelConstraint:z(this.kernelConstraint)},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.verifyArgs=function(t){if(!("filters"in t)||"number"!=typeof t.filters||t.filters<1)throw new d("Convolution layer expected config.filters to be a 'number' > 0 but got "+JSON.stringify(t.filters));},e;}(xr),kr=function(t){function e(n){var r=t.call(this,2,n)||this;return e.verifyArgs(n),r;}return o(e,t),e.prototype.getConfig=function(){var e=t.prototype.getConfig.call(this);return delete e.rank,e;},e.verifyArgs=function(t){if("number"!=typeof t.kernelSize&&!F(t.kernelSize,"number",1,2))throw new d("Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received "+JSON.stringify(t.kernelSize)+".");},e.className="Conv2D",e;}(wr);r.serialization.registerClass(kr);var Er=function(t){function e(n){var r=t.call(this,3,n)||this;return e.verifyArgs(n),r;}return o(e,t),e.prototype.getConfig=function(){var e=t.prototype.getConfig.call(this);return delete e.rank,e;},e.verifyArgs=function(t){if("number"!=typeof t.kernelSize&&(!Array.isArray(t.kernelSize)||1!==t.kernelSize.length&&3!==t.kernelSize.length))throw new d("Conv3D expects config.kernelSize to be number or [number, number, number], but received "+JSON.stringify(t.kernelSize)+".");},e.className="Conv3D",e;}(wr);r.serialization.registerClass(Er);var Cr=function(t){function e(e){var n=t.call(this,e)||this;if(n.inputSpec=[new ce({ndim:4})],"same"!==n.padding&&"valid"!==n.padding)throw new d("Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode "+n.padding);return n;}return o(e,t),e.prototype.build=function(t){var e;if(4!==(t=re(t)).length)throw new d("Input should have rank 4; Received input shape: "+JSON.stringify(t));var n="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[n])throw new d("The channel dimension of the inputs should be defined. Found `None`.");var r=t[n],i=this.kernelSize.concat([this.filters,r]);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 ce({ndim:4,axes:(e={},e[n]=r,e)})],this.built=!0;},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){var e=ne(t);if(4!==e.shape.length)throw new d("Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-"+e.shape.length);var i,o,a=e.shape,s=a[0];"channelsFirst"===n.dataFormat?(i=2,o=3):(i=1,o=2);var u=a[i],c=a[o],l=n.kernelSize[0],f=n.kernelSize[1],h=n.strides[0],p=n.strides[1],m=[s,gr(u,h,l,n.padding),gr(c,p,f,n.padding),n.filters];"channelsLast"!==n.dataFormat&&(e=Object(r.transpose)(e,[0,2,3,1]));var g=Object(r.conv2dTranspose)(e,n.kernel.read(),m,n.strides,n.padding);return "channelsLast"!==n.dataFormat&&(g=Object(r.transpose)(g,[0,3,1,2])),null!=n.bias&&(g=Ct(g,n.bias.read(),n.dataFormat)),null!=n.activation&&(g=n.activation.apply(g)),g;});},e.prototype.computeOutputShape=function(t){var e,n,r,i=(t=re(t)).slice();"channelsFirst"===this.dataFormat?(e=1,n=2,r=3):(e=3,n=1,r=2);var o=this.kernelSize[0],a=this.kernelSize[1],s=this.strides[0],u=this.strides[1];return i[e]=this.filters,i[n]=gr(i[n],s,o,this.padding),i[r]=gr(i[r],u,a,this.padding),i;},e.prototype.getConfig=function(){var e=t.prototype.getConfig.call(this);return delete e.dilationRate,e;},e.className="Conv2DTranspose",e;}(kr);r.serialization.registerClass(Cr);var Ar=function(t){function e(e){return t.call(this,2,e)||this;}return o(e,t),e.className="SeparableConv2D",e;}(function(t){function e(e,n){var r=t.call(this,e,n)||this;if(r.DEFAULT_DEPTHWISE_INITIALIZER="glorotUniform",r.DEFAULT_POINTWISE_INITIALIZER="glorotUniform",r.depthwiseKernel=null,r.pointwiseKernel=null,null==n.filters)throw new d("The `filters` configuration field is required by SeparableConv, but is unspecified.");if(null!=n.kernelInitializer||null!=n.kernelRegularizer||null!=n.kernelConstraint)throw new d("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");if(null!=n.padding&&"same"!==n.padding&&"valid"!==n.padding)throw new d("SeparableConv"+r.rank+"D supports only padding modes: 'same' and 'valid', but received "+JSON.stringify(n.padding));return r.depthMultiplier=null==n.depthMultiplier?1:n.depthMultiplier,r.depthwiseInitializer=Kt(n.depthwiseInitializer||r.DEFAULT_DEPTHWISE_INITIALIZER),r.depthwiseRegularizer=sr(n.depthwiseRegularizer),r.depthwiseConstraint=W(n.depthwiseConstraint),r.pointwiseInitializer=Kt(n.depthwiseInitializer||r.DEFAULT_POINTWISE_INITIALIZER),r.pointwiseRegularizer=sr(n.pointwiseRegularizer),r.pointwiseConstraint=W(n.pointwiseConstraint),r;}return o(e,t),e.prototype.build=function(t){var e;if((t=re(t)).length<this.rank+2)throw new d("Inputs to SeparableConv"+this.rank+"D should have rank "+(this.rank+2)+", but received input shape: "+JSON.stringify(t));var n="channelsFirst"===this.dataFormat?1:t.length-1;if(null==t[n]||t[n]<0)throw new d("The channel dimension of the inputs should be defined, but found "+JSON.stringify(t[n]));for(var r=t[n],i=this.kernelSize.concat([r,this.depthMultiplier]),o=[],a=0;a<this.rank;++a){o.push(1);}o.push(r*this.depthMultiplier,this.filters),this.depthwiseKernel=this.addWeight("depthwise_kernel",i,"float32",this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.pointwiseKernel=this.addWeight("pointwise_kernel",o,"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 ce({ndim:this.rank+2,axes:(e={},e[n]=r,e)})],this.built=!0;},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){var e;if(t=ne(t),1===n.rank)throw new p("1D separable convolution is not implemented yet.");return 2===n.rank&&("channelsFirst"===n.dataFormat&&(t=Object(r.transpose)(t,[0,2,3,1])),e=Object(r.separableConv2d)(t,n.depthwiseKernel.read(),n.pointwiseKernel.read(),n.strides,n.padding,n.dilationRate,"NHWC")),n.useBias&&(e=Ct(e,n.bias.read(),n.dataFormat)),null!=n.activation&&(e=n.activation.apply(e)),"channelsFirst"===n.dataFormat&&(e=Object(r.transpose)(e,[0,3,1,2])),e;});},e.prototype.getConfig=function(){var e=t.prototype.getConfig.call(this);return delete e.rank,delete e.kernelInitializer,delete e.kernelRegularizer,delete e.kernelConstraint,e.depthwiseInitializer=Gt(this.depthwiseInitializer),e.pointwiseInitializer=Gt(this.pointwiseInitializer),e.depthwiseRegularizer=or(this.depthwiseRegularizer),e.pointwiseRegularizer=or(this.pointwiseRegularizer),e.depthwiseConstraint=z(this.depthwiseConstraint),e.pointwiseConstraint=z(this.pointwiseConstraint),e;},e.className="SeparableConv",e;}(wr));r.serialization.registerClass(Ar);var Or=function(t){function e(n){var r=t.call(this,1,n)||this;return e.verifyArgs(n),r.inputSpec=[{ndim:3}],r;}return o(e,t),e.prototype.getConfig=function(){var e=t.prototype.getConfig.call(this);return delete e.rank,delete e.dataFormat,e;},e.verifyArgs=function(t){if("number"!=typeof t.kernelSize&&!F(t.kernelSize,"number",1,1))throw new d("Conv1D expects config.kernelSize to be number or number[] with length 1, but received "+JSON.stringify(t.kernelSize)+".");},e.className="Conv1D",e;}(wr);r.serialization.registerClass(Or);var _r=function(t){function e(e){var n=t.call(this,e)||this;return "number"==typeof e.cropping?n.cropping=[[e.cropping,e.cropping],[e.cropping,e.cropping]]:"number"==typeof e.cropping[0]?n.cropping=[[e.cropping[0],e.cropping[0]],[e.cropping[1],e.cropping[1]]]:n.cropping=e.cropping,n.dataFormat=void 0===e.dataFormat?"channelsLast":e.dataFormat,n.inputSpec=[{ndim:4}],n;}return o(e,t),e.prototype.computeOutputShape=function(t){return "channelsFirst"===this.dataFormat?[t[0],t[1],t[2]-this.cropping[0][0]-this.cropping[0][1],t[3]-this.cropping[1][0]-this.cropping[1][1]]:[t[0],t[1]-this.cropping[0][0]-this.cropping[0][1],t[2]-this.cropping[1][0]-this.cropping[1][1],t[3]];},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){return t=ne(t),"channelsLast"===n.dataFormat?mt(mt(t,n.cropping[0][0],t.shape[1]-n.cropping[0][0]-n.cropping[0][1],2),n.cropping[1][0],t.shape[2]-n.cropping[1][1]-n.cropping[1][0],3):mt(mt(t,n.cropping[0][0],t.shape[2]-n.cropping[0][0]-n.cropping[0][1],3),n.cropping[1][0],t.shape[3]-n.cropping[1][1]-n.cropping[1][0],4);});},e.prototype.getConfig=function(){var e={cropping:this.cropping,dataFormat:this.dataFormat},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="Cropping2D",e;}(pe);r.serialization.registerClass(_r);var Sr=function(t){function e(e){var n=t.call(this,e)||this;return n.DEFAULT_SIZE=[2,2],n.inputSpec=[{ndim:4}],n.size=null==e.size?n.DEFAULT_SIZE:e.size,n.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,n;}return o(e,t),e.prototype.computeOutputShape=function(t){if("channelsFirst"===this.dataFormat){var e=null==t[2]?null:this.size[0]*t[2],n=null==t[3]?null:this.size[1]*t[3];return [t[0],t[1],e,n];}return e=null==t[1]?null:this.size[0]*t[1],n=null==t[2]?null:this.size[1]*t[2],[t[0],e,n,t[3]];},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){var e=ne(t),i=e.shape;if("channelsFirst"===n.dataFormat){e=Object(r.transpose)(e,[0,2,3,1]);var o=n.size[0]*i[2],a=n.size[1]*i[3],s=e.resizeNearestNeighbor([o,a]);return Object(r.transpose)(s,[0,3,1,2]);}return o=n.size[0]*i[1],a=n.size[1]*i[2],e.resizeNearestNeighbor([o,a]);});},e.prototype.getConfig=function(){var e={size:this.size,dataFormat:this.dataFormat},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="UpSampling2D",e;}(pe);r.serialization.registerClass(Sr);var Dr=function(t){function e(e){var n=t.call(this,2,e)||this;return n.depthwiseKernel=null,n.depthMultiplier=null==e.depthMultiplier?1:e.depthMultiplier,n.depthwiseInitializer=Kt(e.depthwiseInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.depthwiseConstraint=W(e.depthwiseConstraint),n.depthwiseRegularizer=sr(e.depthwiseRegularizer),n;}return o(e,t),e.prototype.build=function(t){if((t=re(t)).length<4)throw new d("Inputs to DepthwiseConv2D should have rank 4. Received input shape: "+JSON.stringify(t)+".");var e="channelsFirst"===this.dataFormat?1:3;if(null==t[e]||t[e]<0)throw new d("The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not ("+t[e]+").");var n=t[e],r=[this.kernelSize[0],this.kernelSize[1],n,this.depthMultiplier];this.depthwiseKernel=this.addWeight("depthwise_kernel",r,null,this.depthwiseInitializer,this.depthwiseRegularizer,!0,this.depthwiseConstraint),this.useBias?this.bias=this.addWeight("bias",[n*this.depthMultiplier],null,this.biasInitializer,this.biasRegularizer,!0,this.biasConstraint):this.bias=null,this.built=!0;},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){var e=function(t,e,n,i,o,a){return void 0===n&&(n=[1,1]),void 0===i&&(i="valid"),Object(r.tidy)(function(){null==o&&(o="channelsLast"),X(o);var s=vr(t,o);if(4!==t.rank)throw new d("Input for depthwiseConv2d is required to be 4-D, but is instead "+t.rank+"-D");if(4!==e.rank)throw new d("depthwiseKernel is required to be 4-D, but is instead "+e.rank+"-D");return s=Object(r.depthwiseConv2d)(s,e,n,"same"===i?"same":"valid","NHWC",a),"channelsFirst"===o&&(s=Object(r.transpose)(s,[0,3,1,2])),s;});}(t=ne(t),n.depthwiseKernel.read(),n.strides,n.padding,n.dataFormat,null);return n.useBias&&(e=Ct(e,n.bias.read(),n.dataFormat)),null!=n.activation&&(e=n.activation.apply(e)),e;});},e.prototype.computeOutputShape=function(t){t=re(t);var e="channelsFirst"===this.dataFormat?t[2]:t[1],n="channelsFirst"===this.dataFormat?t[3]:t[2],r="channelsFirst"===this.dataFormat?t[1]*this.depthMultiplier:t[3]*this.depthMultiplier,i=mr(e,this.kernelSize[0],this.padding,this.strides[0]),o=mr(n,this.kernelSize[1],this.padding,this.strides[1]);return "channelsFirst"===this.dataFormat?[t[0],r,i,o]:[t[0],i,o,r];},e.prototype.getConfig=function(){var e=t.prototype.getConfig.call(this);return e.depthMultiplier=this.depthMultiplier,e.depthwiseInitializer=Gt(this.depthwiseInitializer),e.depthwiseRegularizer=or(this.depthwiseRegularizer),e.depthwiseConstraint=z(this.depthwiseRegularizer),e;},e.className="DepthwiseConv2D",e;}(xr);r.serialization.registerClass(Dr);var Fr=function(t){function e(e){var n=t.call(this,e)||this;return n.rate=Math.max(Math.min(e.rate,1),0),n.noiseShape=e.noiseShape,n.seed=e.seed,n.supportsMasking=!0,n;}return o(e,t),e.prototype.getNoiseShape=function(t){if(null==this.noiseShape)return this.noiseShape;for(var e=t.shape,n=[],r=0;r<this.noiseShape.length;++r){n.push(null==this.noiseShape[r]?e[r]:this.noiseShape[r]);}return n;},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){n.invokeCallHook(t,e);var r=ne(t);if(0<n.rate&&n.rate<1){var i=null!=e.training&&e.training,o=n.getNoiseShape(r);return Ot(function(){return At(r,n.rate,o,n.seed);},function(){return r;},i);}return t;});},e.prototype.getConfig=function(){var e={rate:this.rate,noiseShape:this.noiseShape,seed:this.seed},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.prototype.dispose=function(){return t.prototype.dispose.call(this);},e.className="Dropout",e;}(pe);r.serialization.registerClass(Fr);var Tr=function(t){function e(e){var n=t.call(this,e)||this;return n.inputSpec=[{ndim:3}],n;}return o(e,t),e.prototype.getNoiseShape=function(t){var e=t.shape;return [e[0],1,e[2]];},e.className="SpatialDropout1D",e;}(Fr);r.serialization.registerClass(Tr);var Nr=function(t){function e(e){var n=t.call(this,e)||this;if(n.activation=null,n.useBias=!0,n.kernel=null,n.bias=null,n.DEFAULT_KERNEL_INITIALIZER="glorotNormal",n.DEFAULT_BIAS_INITIALIZER="zeros",null==e.batchInputShape&&null==e.inputShape&&null!=e.inputDim){var r=null;null!=e.batchSize&&(r=e.batchSize),n.batchInputShape=[r,e.inputDim];}return n.units=e.units,T(n.units,"units"),n.activation=tr(e.activation),null!=e.useBias&&(n.useBias=e.useBias),n.kernelInitializer=Kt(e.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.biasInitializer=Kt(e.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.kernelConstraint=W(e.kernelConstraint),n.biasConstraint=W(e.biasConstraint),n.kernelRegularizer=sr(e.kernelRegularizer),n.biasRegularizer=sr(e.biasRegularizer),n.activityRegularizer=sr(e.activityRegularizer),n.supportsMasking=!0,n.inputSpec=[{minNDim:2}],n;}return o(e,t),e.prototype.build=function(t){var e,n=(t=re(t))[t.length-1];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=[{minNDim:2,axes:(e={},e[-1]=n,e)}],this.built=!0;},e.prototype.computeOutputShape=function(t){var e=(t=re(t)).slice();return e[e.length-1]=this.units,e;},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){n.invokeCallHook(t,e);var r,i=ne(t),o=N(n.activation.getClassName());return null!=o?r=xt(i,n.kernel.read(),o,n.bias?n.bias.read():null):(r=xt(i,n.kernel.read()),null!=n.bias&&(r=Ct(r,n.bias.read())),null!=n.activation&&(r=n.activation.apply(r))),r;});},e.prototype.getConfig=function(){var e={units:this.units,activation:Qn(this.activation),useBias:this.useBias,kernelInitializer:Gt(this.kernelInitializer),biasInitializer:Gt(this.biasInitializer),kernelRegularizer:or(this.kernelRegularizer),biasRegularizer:or(this.biasRegularizer),activityRegularizer:or(this.activityRegularizer),kernelConstraint:z(this.kernelConstraint),biasConstraint:z(this.biasConstraint)},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="Dense",e;}(pe);r.serialization.registerClass(Nr);var Ir=function(t){function e(e){var n=this;return e=e||{},(n=t.call(this,e)||this).inputSpec=[{minNDim:3}],n.dataFormat=e.dataFormat,n;}return o(e,t),e.prototype.computeOutputShape=function(t){for(var e=0,n=(t=re(t)).slice(1);e<n.length;e++){if(null==n[e])throw new d('The shape of the input to "Flatten" is not fully defined (got '+t.slice(1)+'). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.');}return [t[0],at(t,1)];},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){n.invokeCallHook(t,e);var r=ne(t);if("channelsFirst"===n.dataFormat&&r.rank>1){for(var i=[0],o=2;o<r.rank;++o){i.push(o);}i.push(1),r=r.transpose(i);}return function(t){if(t.rank<=1)throw new d("batchFlatten requires a minimum rank of 2. Got rank: "+t.rank+".");var e=[t.shape[0],at(t.shape,1)];return t.reshape(e);}(r);});},e.prototype.getConfig=function(){var e={};null!=this.dataFormat&&(e.dataFormat=this.dataFormat);var n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="Flatten",e;}(pe);r.serialization.registerClass(Ir);var Rr=function(t){function e(e){var n=t.call(this,e)||this;return n.supportsMasking=!0,n.activation=tr(e.activation),n;}return o(e,t),e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){n.invokeCallHook(t,e);var r=ne(t);return n.activation.apply(r);});},e.prototype.getConfig=function(){var e={activation:Qn(this.activation)},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="Activation",e;}(pe);r.serialization.registerClass(Rr);var Mr=function(t){function e(e){var n=t.call(this,e)||this;return n.n=e.n,n.inputSpec=[{ndim:2}],n;}return o(e,t),e.prototype.computeOutputShape=function(t){return [t[0],this.n,t[1]];},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){return function(t,e){return Object(r.tidy)(function(){if(2!==t.shape.length)throw new d("repeat() expects a rank-2 tensor, but received a rank-"+t.shape.length+" tensor.");return yt(ht(t,1),[1,e,1]);});}(t=ne(t),n.n);});},e.prototype.getConfig=function(){var e={n:this.n},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="RepeatVector",e;}(pe);r.serialization.registerClass(Mr);var jr=function(t){function e(e){var n=t.call(this,e)||this;n.targetShape=e.targetShape;for(var r=0;r<n.targetShape.length;++r){n.isUnknown(n.targetShape[r])&&(n.targetShape[r]=null);}return n;}return o(e,t),e.prototype.isUnknown=function(t){return t<0||null==t;},e.prototype.fixUnknownDimension=function(t,e){for(var n="Total size of new array must be unchanged.",r=e.slice(),i=1,o=null,a=0;a<r.length;++a){var s=r[a];if(this.isUnknown(s)){if(null!==o)throw new d("Can only specifiy one unknown dimension.");o=a;}else i*=s;}var u=at(t);if(null!==o){if(0===i||u%i!=0)throw new d(n);r[o]=u/i;}else if(u!==i)throw new d(n);return r;},e.prototype.computeOutputShape=function(t){for(var e=!1,n=0;n<t.length;++n){if(this.isUnknown(t[n])){e=!0;break;}}return e?t.slice(0,1).concat(this.targetShape):t.slice(0,1).concat(this.fixUnknownDimension(t.slice(1),this.targetShape));},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){n.invokeCallHook(t,e);var r=ne(t),i=r.shape,o=i.slice(0,1).concat(n.fixUnknownDimension(i.slice(1),n.targetShape));return r.reshape(o);});},e.prototype.getConfig=function(){var e={targetShape:this.targetShape},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="Reshape",e;}(pe);r.serialization.registerClass(jr);var Br=function(t){function e(e){var n=t.call(this,e)||this;if(null==e.dims)throw new Error("Required configuration field `dims` is missing during Permute constructor call.");if(!Array.isArray(e.dims))throw new Error("Permute constructor requires `dims` to be an Array, but received "+e.dims+" instead.");var i=lt(1,e.dims.length+1);if(!r.util.arraysEqual(e.dims.slice().sort(),i))throw new Error("Invalid permutation `dims`: "+JSON.stringify(e.dims)+" `dims` must contain consecutive integers starting from 1.");return n.dims=e.dims,n.dimsIncludingBatch=[0].concat(n.dims),n.inputSpec=[new ce({ndim:n.dims.length+1})],n;}return o(e,t),e.prototype.computeOutputShape=function(t){var e=(t=re(t)).slice();return this.dims.forEach(function(n,r){e[r+1]=t[n];}),e;},e.prototype.call=function(t,e){return Object(r.transpose)(ne(t),this.dimsIncludingBatch);},e.prototype.getConfig=function(){var e={dims:this.dims},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="Permute",e;}(pe);r.serialization.registerClass(Br);var Pr=function(t){function e(e){var n=t.call(this,null==e?{}:e)||this;return n.supportsMasking=!0,n.maskValue=null!=e?null==e.maskValue?0:e.maskValue:0,n;}return o(e,t),e.prototype.computeOutputShape=function(t){return t;},e.prototype.getConfig=function(){var e=t.prototype.getConfig.call(this),n={maskValue:this.maskValue};return Object.assign(n,e),n;},e.prototype.computeMask=function(t,e){var n=ne(t);return Object(r.any)(Object(r.notEqual)(n,this.maskValue),-1);},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){n.invokeCallHook(t,e);var i=ne(t),o=Object(r.any)(Object(r.notEqual)(i,n.maskValue),-1,!0);return i.mul(o.asType(i.dtype));});},e.className="Masking",e;}(pe);r.serialization.registerClass(Pr);var Lr=function(t){function e(e){var n=t.call(this,e)||this;if(n.embeddings=null,n.DEFAULT_EMBEDDINGS_INITIALIZER="randomUniform",null==e.batchInputShape&&null==e.inputShape){var r=null;null!=e.batchSize&&(r=e.batchSize),null==e.inputLength?n.batchInputShape=[r,null]:n.batchInputShape=[r].concat(x(e.inputLength));}return n.inputDim=e.inputDim,T(n.inputDim,"inputDim"),n.outputDim=e.outputDim,T(n.outputDim,"outputDim"),n.embeddingsInitializer=Kt(e.embeddingsInitializer||n.DEFAULT_EMBEDDINGS_INITIALIZER),n.embeddingsRegularizer=sr(e.embeddingsRegularizer),n.activityRegularizer=sr(e.activityRegularizer),n.embeddingsConstraint=W(e.embeddingsConstraint),n.maskZero=e.maskZero,n.supportsMasking=e.maskZero,n.inputLength=e.inputLength,n;}return o(e,t),e.prototype.build=function(t){this.embeddings=this.addWeight("embeddings",[this.inputDim,this.outputDim],this.dtype,this.embeddingsInitializer,this.embeddingsRegularizer,!0,this.embeddingsConstraint),this.built=!0;},e.prototype.warnOnIncompatibleInputShape=function(t){},e.prototype.computeMask=function(t,e){var n=this;return Object(r.tidy)(function(){return n.maskZero?(t=ne(t),Object(r.notEqual)(t,Object(r.zerosLike)(t))):null;});},e.prototype.computeOutputShape=function(t){if(t=re(t),null==this.inputLength)return t.concat([this.outputDim]);var e=x(this.inputLength);if(e.length!==t.length-1)throw new d('"inputLength" is '+this.inputLength+", but received input shape has shape "+t);for(var n=0,r=0;r<e.length;++r){var i=e[r],o=t[r+1];if(null!=i&&null!=o&&i!==o)throw new d('"inputLength" is '+this.inputLength+", but received input shape has shape "+t);null==i&&(e[n]=o),n++;}return [t[0]].concat(e,[this.outputDim]);},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){n.invokeCallHook(t,e);var r=ne(t);return "int32"!==r.dtype&&(r=ft(r,"int32")),wt(n.embeddings.read(),r.as1D()).reshape(re(n.computeOutputShape(r.shape)));});},e.prototype.getConfig=function(){var e={inputDim:this.inputDim,outputDim:this.outputDim,embeddingsInitializer:Gt(this.embeddingsInitializer),embeddingsRegularizer:or(this.embeddingsRegularizer),activityRegularizer:or(this.activityRegularizer),embeddingsConstraint:z(this.embeddingsConstraint),maskZero:this.maskZero,inputLength:this.inputLength},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="Embedding",e;}(pe);r.serialization.registerClass(Lr);var zr=function(t){function e(e){var n=t.call(this,e||{})||this;return n.supportsMasking=!0,n;}return o(e,t),e.prototype.mergeFunction=function(t){throw new p();},e.prototype.computeElementwiseOpOutputShape=function(t,e){if(null==t||null==e)return null;if(t.length<e.length)return this.computeElementwiseOpOutputShape(e,t);if(0===e.length)return t;for(var n=t.slice(0,t.length-e.length),r=0;r<e.length;++r){var i=t[t.length-e.length+r],o=e[r];if(null==i||null==o||i<0||o<0)n.push(null);else if(1===i)n.push(o);else if(1===o)n.push(i);else {if(i!==o)throw new d("Operands could not be broadcast together with shapes "+JSON.stringify(t)+" "+JSON.stringify(e));n.push(i);}}return n;},e.prototype.build=function(t){if(Array.isArray(t)&&!Array.isArray(t[0])&&(t=[re(t)]),(t=t).length<2)throw new d("A merge layer should be called on an Array of at least 2 inputs. Got "+t.length+" input(s).");for(var e=[],n=0,r=t;n<r.length;n++){null!=(a=r[n])&&null!==a[0]&&e.push(a[0]);}if((e=_(e)).length>1)throw new d("Can not merge tensors with different batch sizes. Got tensors with shapes: "+JSON.stringify(t)+".");for(var i=null==t[0]?null:t[0].slice(1),o=1;o<t.length;++o){var a=null==t[o]?null:t[o].slice(1);i=this.computeElementwiseOpOutputShape(i,a);}var s=t.map(function(t){return t.length;});-1===t.indexOf(null)&&1===_(s).length?this.reshapeRequired=!1:this.reshapeRequired=!0;},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){if(t=t,n.reshapeRequired){var e=[],i=t.map(function(t){return t.rank;});if(-1===i.indexOf(null)){for(var o=ct(i),a=0,s=t;a<s.length;a++){for(var u=(d=s[a]).rank,c=0;c<o-u;++c){d=ht(d,1);}e.push(d);}return n.mergeFunction(e);}for(var l=!1,f=0,h=t;f<h.length;f++){var d;if(null==(u=(d=h[f]).rank)){var p=d.shape,m=p[0],g=p.slice(1).concat([m]),v=d.reshape([m].concat(at(p.slice(1))));v=(v=Object(r.transpose)(v,[1,0])).reshape(g),e.push(v),l=!0;}else if(u>1){var y=lt(1,u).concat([0]);e.push(Object(r.transpose)(d,y)),l=!0;}else e.push(d);}var b=n.mergeFunction(e),x=b.rank;if(l)if(null==x){var w=b.shape;g=[m=w[w.length-1]].concat(w.slice(0,w.length-1)),b=Object(r.transpose)(b.reshape([-1,m]),[1,0]).reshape(g);}else x>1&&(y=[x-1].concat(lt(0,x-1)),b=Object(r.transpose)(b,y));return b;}return n.mergeFunction(t);});},e.prototype.computeOutputShape=function(t){var e;e=null==(t=t)[0]?null:t[0].slice(1);for(var n=1;n<t.length;++n){var r=null==t[n]?null:t[n].slice(1);e=this.computeElementwiseOpOutputShape(e,r);}for(var i=[],o=0,a=t;o<a.length;o++){null!=(r=a[o])&&null!==r[0]&&i.push(r[0]);}return 1===(i=_(i)).length?i.concat(e):[null].concat(e);},e.prototype.computeMask=function(t,e){return Object(r.tidy)(function(){if(null==e)return null;if(!Array.isArray(e))throw new d("`mask` should be an Array");if(!Array.isArray(t))throw new d("`inputs` should be an Array");if(e.length!==t.length)throw new d("The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths ("+t.length+" vs "+e.length+")");if(e.every(function(t){return null==t;}))return null;for(var n=(e=e.map(function(t){return null==t?t:Object(r.expandDims)(t,0);}))[0],i=1;i<e.length-1;++i){n=Object(r.logicalAnd)(n,e[i]);}return n;});},e;}(pe),Ur=function(t){function e(e){return t.call(this,e)||this;}return o(e,t),e.prototype.mergeFunction=function(t){return Object(r.tidy)(function(){for(var e=t[0].clone(),n=1;n<t.length;++n){e=Object(r.add)(e,t[n]);}return e;});},e.className="Add",e;}(zr);r.serialization.registerClass(Ur);var Wr=function(t){function e(e){return t.call(this,e)||this;}return o(e,t),e.prototype.mergeFunction=function(t){return Object(r.tidy)(function(){for(var e=t[0].clone(),n=1;n<t.length;++n){e=Object(r.mul)(e,t[n]);}return e;});},e.className="Multiply",e;}(zr);r.serialization.registerClass(Wr);var Vr=function(t){function e(e){return t.call(this,e)||this;}return o(e,t),e.prototype.mergeFunction=function(t){return Object(r.tidy)(function(){for(var e=t[0].clone(),n=1;n<t.length;++n){e=Object(r.add)(e,t[n]);}return Object(r.mul)(1/t.length,e);});},e.className="Average",e;}(zr);r.serialization.registerClass(Vr);var qr=function(t){function e(e){return t.call(this,e)||this;}return o(e,t),e.prototype.mergeFunction=function(t){return Object(r.tidy)(function(){for(var e=t[0],n=1;n<t.length;++n){e=Object(r.maximum)(e,t[n]);}return e;});},e.className="Maximum",e;}(zr);r.serialization.registerClass(qr);var $r=function(t){function e(e){return t.call(this,e)||this;}return o(e,t),e.prototype.mergeFunction=function(t){return Object(r.tidy)(function(){for(var e=t[0],n=1;n<t.length;++n){e=Object(r.minimum)(e,t[n]);}return e;});},e.className="Minimum",e;}(zr);r.serialization.registerClass($r);var Hr=function(t){function e(e){var n=t.call(this,e)||this;return n.DEFAULT_AXIS=-1,null==e&&(e={}),n.axis=null==e.axis?n.DEFAULT_AXIS:e.axis,n.supportsMasking=!0,n.reshapeRequired=!1,n;}return o(e,t),e.prototype.build=function(t){if(!Array.isArray(t)||!Array.isArray(t[0])||1===t.length)throw new d("A `Concatenate` layer should be called on a list of at least 2 inputs");for(var e=!0,n=0,i=t=t;n<i.length;n++){if(null!=(f=i[n])){e=!1;break;}}if(!e){for(var o=[],a=0;a<t.length;++a){var s=t[a].slice();s.splice(this.axis,1);for(var u=!1,c=0,l=o;c<l.length;c++){var f=l[c];if(r.util.arraysEqual(f,s)){u=!0;break;}}u||o.push(s);}if(o.length>1)throw new d("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: "+JSON.stringify(t));}},e.prototype.mergeFunction=function(t){var e=this;return Object(r.tidy)(function(){return gt(t,e.axis);});},e.prototype.computeOutputShape=function(t){if(!Array.isArray(t)||!Array.isArray(t[0]))throw new d("A `Concatenate` layer should be called on a list of inputs.");for(var e=t,n=e[0].slice(),r=this.axis<0?n.length+this.axis:this.axis,i=0,o=e.slice(1);i<o.length;i++){var a=o[i];if(null==n[r]||null==a[r]){n[r]=null;break;}n[r]+=a[r];}return n;},e.prototype.computeMask=function(t,e){var n=this;if(null==e)return null;if(!Array.isArray(e))throw new d("`mask` should be an array for Concatenate");if(!Array.isArray(t))throw new d("`inputs` should be an array for Concatenate");if(e.length!==t.length)throw new d("Mismatch in the length of mask ("+e.length+") and the legnth of inputs ("+t.length+")");return Object(r.tidy)(function(){var i=!0;if(e.forEach(function(t){null==t||(i=!1);}),i)return null;for(var o=[],a=0;a<t.length;++a){null==e[a]?o.push(Object(r.onesLike)(t[a]).asType("bool")):e[a].rank<t[a].rank?o.push(Object(r.expandDims)(e[a],-1)):o.push(e[a]);}var s=Object(r.concat)(o,n.axis);return Object(r.all)(s,-1,!1);});},e.prototype.getConfig=function(){var e={axis:this.axis},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="Concatenate",e;}(zr);function Gr(t,e){for(;t<0;){t+=e;}return t;}r.serialization.registerClass(Hr);var Kr=function(t){function e(e){var n=t.call(this,e)||this;return n.axes=e.axes,n.normalize=null!=e.normalize&&e.normalize,n.supportsMasking=!0,n.reshapeRequired=!1,n;}return o(e,t),e.prototype.build=function(t){r.util.assert(Array.isArray(t)&&2===t.length&&Array.isArray(t[0])&&Array.isArray(t[1]),function(){return "A `Dot` layer should be called on a list of exactly 2 inputs.";});var e=t[0],n=t[1];if(e.length>3||n.length>3)throw new p("Dot layer does not support tensors of 4D or higher rank yet.");var i=this.interpretAxes(e,n);if(e[i[0]]!==n[i[1]])throw new d("Dimension incompatibility: "+e[i[0]]+" !== "+n[i[1]]);},e.prototype.mergeFunction=function(t){if(2!==t.length)throw new d("A `Dot` layer must be called on exactly 2 inputs, but received "+t.length+" input(s).");var e,n=t[0],i=t[1];return e=Array.isArray(this.axes)?this.axes.map(function(e,n){return Gr(e,t[n].shape.length);}):[Gr(this.axes,n.shape.length),Gr(this.axes,i.shape.length)],this.normalize&&(n=Fe(n,e[0]),i=Fe(i,e[1])),function(t,e,n){if(t.shape.length>3||e.shape.length>3)throw new p("batchDot is not implemented for tensors of 4D or higher rank yet");if(r.util.assert(t.shape.length>=2,function(){return "batchDot requires the rank of x to be >= 2, but got "+t.shape.length;}),r.util.assert(t.shape.length>=2,function(){return "batchDot requires the rank of y to be >= 2, but got "+e.shape.length;}),"number"==typeof n&&(n=[n,n]),"complex64"===t.dtype||"complex64"===e.dtype)throw new p("batchDot is not implemented for complex64-type Tensors yet.");var i=t.shape.length,o=e.shape.length;null==n&&(n=[i-1,o-2]);var a=n;return Object(r.tidy)(function(){var n,r;if(i>o){n=i-o;for(var s=[],u=0;u<n;++u){s.push(1);}e=e.reshape(e.shape.concat(s));}else if(o>i){for(n=o-i,s=[],u=0;u<n;++u){s.push(1);}t=t.reshape(t.shape.concat(s));}else n=0;if(2===t.shape.length&&2===e.shape.length)r=a[0]===a[1]?t.mulStrict(e).sum(a[0]):t.transpose([1,0]).mulStrict(e).sum(a[1]);else {var c=a[0]!==t.shape.length-1,l=a[1]===e.shape.length-1;r=t.matMul(e,c,l);}if(n>0){var f,h=[];for(u=f=i>o?i+o-3:i-1;u<f+n;++u){h.push(u);}r=r.squeeze(h);}return 1===r.shape.length&&(r=r.expandDims(1)),r;});}(n,i,e);},e.prototype.interpretAxes=function(t,e){return Array.isArray(this.axes)?this.axes:[Gr(this.axes,t.length),Gr(this.axes,e.length)];},e.prototype.computeOutputShape=function(t){r.util.assert(Array.isArray(t)&&2===t.length&&Array.isArray(t[0])&&Array.isArray(t[1]),function(){return "A `Dot` layer should be called on a list of exactly 2 inputs.";});var e=t[0].slice(),n=t[1].slice();if(e.length>3||n.length>3)throw new p("Dot layer does not support tensors of 4D or higher rank yet.");var i=this.interpretAxes(e,n);e.splice(i[0],1),n.splice(i[1],1),n.splice(0,1);var o=e.concat(n);return 1===o.length&&o.push(1),o;},e.prototype.computeMask=function(t,e){return null;},e.prototype.getConfig=function(){var e={axes:this.axes,normalize:this.normalize},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="Dot",e;}(zr);r.serialization.registerClass(Kr);var Xr=function(t){function e(e){var n=t.call(this,e)||this;return n.supportsMasking=!0,n.stddev=e.stddev,n;}return o(e,t),e.prototype.computeOutputShape=function(t){return t;},e.prototype.getConfig=function(){var e=t.prototype.getConfig.call(this),n={stddev:this.stddev};return Object.assign(n,e),n;},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){n.invokeCallHook(t,e);var r=ne(t);return Ot(function(){return bt(r.shape,0,n.stddev).add(r);},function(){return r;},e.training||!1);});},e.className="GaussianNoise",e;}(pe);r.serialization.registerClass(Xr);var Yr=function(t){function e(e){var n=t.call(this,e)||this;return n.supportsMasking=!0,n.rate=e.rate,n;}return o(e,t),e.prototype.computeOutputShape=function(t){return t;},e.prototype.getConfig=function(){var e=t.prototype.getConfig.call(this),n={rate:this.rate};return Object.assign(n,e),n;},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){n.invokeCallHook(t,e);var r=ne(t);return n.rate>0&&n.rate<1?Ot(function(){var t=Math.sqrt(n.rate/(1-n.rate));return r.mul(bt(r.shape,1,t));},function(){return r;},e.training||!1):r;});},e.className="GaussianDropout",e;}(pe);r.serialization.registerClass(Yr);var Jr=function(t){function e(e){var n=t.call(this,e)||this;return n.supportsMasking=!0,n.rate=e.rate,n.noiseShape=e.noiseShape,n;}return o(e,t),e.prototype._getNoiseShape=function(t){return this.noiseShape||ne(t).shape;},e.prototype.computeOutputShape=function(t){return t;},e.prototype.getConfig=function(){var e=t.prototype.getConfig.call(this),n={rate:this.rate};return Object.assign(n,e),n;},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){if(n.rate<1&&n.rate>0){var i=n._getNoiseShape(t);return Ot(function(){var e=ne(t),o=-1.7580993408473766,a=Object(r.greaterEqual)(Object(r.randomUniform)(i),n.rate);a=ft(a,"float32");var s=Math.pow((1-n.rate)*(1+n.rate*Math.pow(o,2)),-.5),u=-s*o*n.rate;return e.mul(a).add(a.add(-1).mul(o)).mul(s).add(u);},function(){return ne(t);},e.training||!1);}return t;});},e.className="AlphaDropout",e;}(pe);function Qr(t,e,n,i,o,a){var s;if(void 0===a&&(a=.001),2===t.rank)s=Object(r.batchNorm2d)(t,e,n,i,o,a);else if(3===t.rank)s=Object(r.batchNorm3d)(t,e,n,i,o,a);else {if(4!==t.rank)throw new p("batchNormalization is not implemented for array of rank "+t.rank+" yet");s=Object(r.batchNorm4d)(t,e,n,i,o,a);}return s;}function Zr(t,e,n,i,o){return void 0===o&&(o=.001),r.util.arraysEqual(i.slice().sort(),lt(0,t.rank-1))?function(t,e,n,i,o){return void 0===o&&(o=.001),Object(r.tidy)(function(){var a=Object(r.moments)(t,i),s=a.mean,u=a.variance;return [Qr(t,s,u,n,e,o),s,u];});}(t,e,n,i,o):function(t,e,n,i,o){return void 0===o&&(o=.001),Object(r.tidy)(function(){for(var a=Object(r.moments)(t,i),s=a.mean,u=a.variance,c=[],l=0,f=lt(0,t.rank);l<f.length;l++){var h=f[l];-1!==i.indexOf(h)?c.push(1):c.push(t.shape[h]);}var d=s.reshape(c),p=u.reshape(c),m=null==e?null:e.reshape(c),g=null==n?null:n.reshape(c);return [Qr(t,d,p,g,m,o),s,u];});}(t,e,n,i,o);}r.serialization.registerClass(Jr);var ti=function(t){function e(e){var n=this;return null==e&&(e={}),(n=t.call(this,e)||this).supportsMasking=!0,n.axis=null==e.axis?-1:e.axis,n.momentum=null==e.momentum?.99:e.momentum,n.epsilon=null==e.epsilon?.001:e.epsilon,n.center=null==e.center||e.center,n.scale=null==e.scale||e.scale,n.betaInitializer=Kt(e.betaInitializer||"zeros"),n.gammaInitializer=Kt(e.gammaInitializer||"ones"),n.movingMeanInitializer=Kt(e.movingMeanInitializer||"zeros"),n.movingVarianceInitializer=Kt(e.movingVarianceInitializer||"ones"),n.betaConstraint=W(e.betaConstraint),n.gammaConstraint=W(e.gammaConstraint),n.betaRegularizer=sr(e.betaRegularizer),n.gammaRegularizer=sr(e.gammaRegularizer),n;}return o(e,t),e.prototype.build=function(t){var e;t=re(t);var n=this.axis>=0?this.axis:this.axis+t.length,r=t[n];if(null==r)throw new d("Axis "+n+" of input tensor should have a defined dimension but the layer received an input with shape "+JSON.stringify(t)+".");this.inputSpec=[new ce({ndim:t.length,axes:(e={},e[n]=r,e)})];var i=[r];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;},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){var i=null!=e.training&&e.training,o=ne(t),a=o.shape,s=a.length,u=lt(0,s),c=n.axis>=0?n.axis:n.axis+s;u.splice(c,1);var l=g(1,s);l[c]=a[c];var f=u.slice();f.sort();var h=!r.util.arraysEqual(f,lt(0,s).slice(0,s-1));if(!i)return function(){if(h){var t=n.movingMean.read().reshape(l),e=n.movingVariance.read().reshape(l),r=n.center?n.beta.read().reshape(l):null,i=n.scale?n.gamma.read().reshape(l):null;return Qr(o,t,e,r,i,n.epsilon);}return Qr(o,n.movingMean.read(),n.movingVariance.read(),null==n.beta?null:n.beta.read(),null==n.gamma?null:n.gamma.read(),n.epsilon);}();var d=Zr(o,n.gamma.read(),n.beta.read(),u,n.epsilon),p=d[0],m=d[1],v=d[2],y=function y(t,e,n){Object(r.tidy)(function(){var r=1-n,i=t.read(),o=i.sub(e).mul(r);t.write(i.sub(o));});};return y(n.movingMean,m,n.momentum),y(n.movingVariance,v,n.momentum),p;});},e.prototype.getConfig=function(){var e={axis:this.axis,momentum:this.momentum,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Gt(this.betaInitializer),gammaInitializer:Gt(this.gammaInitializer),movingMeanInitializer:Gt(this.movingMeanInitializer),movingVarianceInitializer:Gt(this.movingVarianceInitializer),betaRegularizer:or(this.betaRegularizer),gammaRegularizer:or(this.gammaRegularizer),betaConstraint:z(this.betaConstraint),gammaConstraint:z(this.gammaConstraint)},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="BatchNormalization",e;}(pe);r.serialization.registerClass(ti);var ei=function(t){function e(e){var n=this;if(null==e&&(e={}),(n=t.call(this,e)||this).axis=null==e.axis?-1:e.axis,"number"==typeof n.axis){if(!Number.isInteger(n.axis))throw new Error("Expected axis to be an integer, but received "+n.axis);}else {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));for(var r=0,i=n.axis;r<i.length;r++){var o=i[r];if(!Number.isInteger(o))throw new Error("Expected axis to be an array of integers, but received "+JSON.stringify(n.axis));}}return n.epsilon=null==e.epsilon?.001:e.epsilon,n.center=null==e.center||e.center,n.scale=null==e.scale||e.scale,n.betaInitializer=Kt(e.betaInitializer||"zeros"),n.gammaInitializer=Kt(e.gammaInitializer||"ones"),n.betaRegularizer=sr(e.betaRegularizer),n.gammaRegularizer=sr(e.gammaRegularizer),n.supportsMasking=!0,n;}return o(e,t),e.prototype.build=function(t){var e=(t=re(t)).length;"number"==typeof this.axis&&(this.axis=[this.axis]);for(var n=0;n<this.axis.length;++n){this.axis[n]<0&&(this.axis[n]+=e);}for(var r=0,i=this.axis;r<i.length;r++){var o=i[r];if(o<0||o>=e)throw new Error("Invalid axis: "+o);}if(this.axis.length!==_(this.axis).length)throw new Error("Found duplicate axes in: "+this.axis);var a=this.axis.map(function(e){return t[e];});this.scale?this.gamma=this.addWeight("gamma",a,"float32",this.gammaInitializer,this.gammaRegularizer,!0):this.gamma=null,this.center?this.beta=this.addWeight("beta",a,"float32",this.betaInitializer,this.betaRegularizer,!0):this.beta=null,this.built=!0;},e.prototype.call=function(t,e){var n=this,i=ne(t),o=i.shape,a=o.length;return Object(r.tidy)(function(){for(var t=Object(r.moments)(i,n.axis,!0),e=t.mean,s=t.variance,u=g(1,a),c=0,l=n.axis;c<l.length;c++){var f=l[c];u[f]=o[f];}for(var h=function h(t){return null!=t&&t.shape.length!==a&&n.axis!==[a-1]?t.reshape(u):t;},d=h(n.gamma.read()),p=h(n.beta.read()),m=[],v=[],y=0;y<a;++y){-1!==n.axis.indexOf(y)?(m.push(o[y]),v.push(1)):(m.push(1),v.push(o[y]));}return e=e.tile(m),s=s.tile(m),d=d.tile(v),p=p.tile(v),Qr(i,e,s,p,d,n.epsilon);});},e.prototype.getConfig=function(){var e={axis:this.axis,epsilon:this.epsilon,center:this.center,scale:this.scale,betaInitializer:Gt(this.betaInitializer),gammaInitializer:Gt(this.gammaInitializer),betaRegularizer:or(this.betaRegularizer),gammaRegularizer:or(this.gammaRegularizer)},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="LayerNormalization",e;}(pe);r.serialization.registerClass(ei);var ni=function(t){function e(e){var n=this;if(null==e&&(e={}),(n=t.call(this,e)||this).dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,null==e.padding)n.padding=[[1,1],[1,1]];else if("number"==typeof e.padding)n.padding=[[e.padding,e.padding],[e.padding,e.padding]];else {if(e.padding=e.padding,2!==e.padding.length)throw new d("ZeroPadding2D expects padding to be a length-2 array, but received a length-"+e.padding.length+" array.");var r=void 0,i=void 0;if("number"==typeof e.padding[0])r=[e.padding[0],e.padding[0]],i=[e.padding[1],e.padding[1]];else {if(e.padding=e.padding,2!==e.padding[0].length)throw new d("ZeroPadding2D expects height padding to be a length-2 array, but received a length-"+e.padding[0].length+" array.");if(r=e.padding[0],2!==e.padding[1].length)throw new d("ZeroPadding2D expects width padding to be a length-2 array, but received a length-"+e.padding[1].length+" array.");i=e.padding[1];}n.padding=[r,i];}return n.inputSpec=[new ce({ndim:4})],n;}return o(e,t),e.prototype.computeOutputShape=function(t){var e,n;return t=re(t),"channelsFirst"===this.dataFormat?(e=null!=t[2]&&t[2]>=0?t[2]+this.padding[0][0]+this.padding[0][1]:null,n=null!=t[3]&&t[3]>=0?t[3]+this.padding[1][0]+this.padding[1][1]:null,[t[0],t[1],e,n]):(e=null!=t[1]&&t[1]>=0?t[1]+this.padding[0][0]+this.padding[0][1]:null,n=null!=t[2]&&t[2]>=0?t[2]+this.padding[1][0]+this.padding[1][1]:null,[t[0],e,n,t[3]]);},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){return function(t,e,n){return Object(r.tidy)(function(){if(4!==t.rank)throw new d("temporalPadding expects input tensor to be 4-D, but received a "+t.rank+"-D tensor.");if(null==e&&(e=[[1,1],[1,1]]),2!==e.length||2!==e[0].length||2!==e[1].length)throw new d("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");if(null==n&&(n="channelsLast"),"channelsLast"!==n&&"channelsFirst"!==n)throw new d("Unknown data format: "+n+". Supported data formats are 'channelsLast' and 'channelsFirst.");var i;return i="channelsFirst"===n?[[0,0],[0,0],e[0],e[1]]:[[0,0],e[0],e[1],[0,0]],Object(r.pad)(t,i);});}(ne(t),n.padding,n.dataFormat);});},e.prototype.getConfig=function(){var e={padding:this.padding,dataFormat:this.dataFormat},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="ZeroPadding2D",e;}(pe);function ri(t,e,n,i,o,a){return Object(r.tidy)(function(){var s;X(o),J(a),Y(i),null==n&&(n=[1,1]),null==i&&(i="valid"),null==o&&(o="channelsLast"),null==a&&(a="max"),t=vr(t,o);var u="same"===i?"same":"valid";return s="max"===a?Object(r.maxPool)(t,e,n,u):Object(r.avgPool)(t,e,n,u),"channelsFirst"===o&&(s=Object(r.transpose)(s,[0,3,1,2])),s;});}function ii(t,e,n,i,o,a){return Object(r.tidy)(function(){var s;X(o),J(a),Y(i),null==n&&(n=[1,1,1]),null==i&&(i="valid"),null==o&&(o="channelsLast"),null==a&&(a="max"),t=yr(t,o);var u="same"===i?"same":"valid";return s="max"===a?Object(r.maxPool3d)(t,e,n,u):Object(r.avgPool3d)(t,e,n,u),"channelsFirst"===o&&(s=Object(r.transpose)(s,[0,4,1,2,3])),s;});}r.serialization.registerClass(ni);var oi=function(t){function e(e){var n=this;if(null==e.poolSize&&(e.poolSize=2),n=t.call(this,e)||this,"number"==typeof e.poolSize)n.poolSize=[e.poolSize];else {if(!Array.isArray(e.poolSize)||1!==e.poolSize.length||"number"!=typeof e.poolSize[0])throw new d("poolSize for 1D convolutional layer must be a number or an Array of a single number, but received "+JSON.stringify(e.poolSize));n.poolSize=e.poolSize;}if(T(n.poolSize,"poolSize"),null==e.strides)n.strides=n.poolSize;else if("number"==typeof e.strides)n.strides=[e.strides];else {if(!Array.isArray(e.strides)||1!==e.strides.length||"number"!=typeof e.strides[0])throw new d("strides for 1D convolutional layer must be a number or an Array of a single number, but received "+JSON.stringify(e.strides));n.strides=e.strides;}return T(n.strides,"strides"),n.padding=null==e.padding?"valid":e.padding,Y(n.padding),n.inputSpec=[new ce({ndim:3})],n;}return o(e,t),e.prototype.computeOutputShape=function(t){var e=mr((t=re(t))[1],this.poolSize[0],this.padding,this.strides[0]);return [t[0],e,t[2]];},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){n.invokeCallHook(t,e),t=ht(ne(t),2);var i=n.poolingFunction(ne(t),[n.poolSize[0],1],[n.strides[0],1],n.padding,"channelsLast");return Object(r.squeeze)(i,[2]);});},e.prototype.getConfig=function(){var e={poolSize:this.poolSize,padding:this.padding,strides:this.strides},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e;}(pe),ai=function(t){function e(e){return t.call(this,e)||this;}return o(e,t),e.prototype.poolingFunction=function(t,e,n,r,i){return X(i),Y(r),ri(t,e,n,r,i,"max");},e.className="MaxPooling1D",e;}(oi);r.serialization.registerClass(ai);var si=function(t){function e(e){return t.call(this,e)||this;}return o(e,t),e.prototype.poolingFunction=function(t,e,n,r,i){return X(i),Y(r),ri(t,e,n,r,i,"avg");},e.className="AveragePooling1D",e;}(oi);r.serialization.registerClass(si);var ui=function(t){function e(e){var n=this;if(null==e.poolSize&&(e.poolSize=[2,2]),(n=t.call(this,e)||this).poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize],null==e.strides)n.strides=n.poolSize;else if(Array.isArray(e.strides)){if(2!==e.strides.length)throw new d("If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length "+e.strides.length+".");n.strides=e.strides;}else n.strides=[e.strides,e.strides];return T(n.poolSize,"poolSize"),T(n.strides,"strides"),n.padding=null==e.padding?"valid":e.padding,n.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,X(n.dataFormat),Y(n.padding),n.inputSpec=[new ce({ndim:4})],n;}return o(e,t),e.prototype.computeOutputShape=function(t){t=re(t);var e="channelsFirst"===this.dataFormat?t[2]:t[1],n="channelsFirst"===this.dataFormat?t[3]:t[2];return e=mr(e,this.poolSize[0],this.padding,this.strides[0]),n=mr(n,this.poolSize[1],this.padding,this.strides[1]),"channelsFirst"===this.dataFormat?[t[0],t[1],e,n]:[t[0],e,n,t[3]];},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){return n.invokeCallHook(t,e),n.poolingFunction(ne(t),n.poolSize,n.strides,n.padding,n.dataFormat);});},e.prototype.getConfig=function(){var e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e;}(pe),ci=function(t){function e(e){return t.call(this,e)||this;}return o(e,t),e.prototype.poolingFunction=function(t,e,n,r,i){return X(i),Y(r),ri(t,e,n,r,i,"max");},e.className="MaxPooling2D",e;}(ui);r.serialization.registerClass(ci);var li=function(t){function e(e){return t.call(this,e)||this;}return o(e,t),e.prototype.poolingFunction=function(t,e,n,r,i){return X(i),Y(r),ri(t,e,n,r,i,"avg");},e.className="AveragePooling2D",e;}(ui);r.serialization.registerClass(li);var fi=function(t){function e(e){var n=this;if(null==e.poolSize&&(e.poolSize=[2,2,2]),(n=t.call(this,e)||this).poolSize=Array.isArray(e.poolSize)?e.poolSize:[e.poolSize,e.poolSize,e.poolSize],null==e.strides)n.strides=n.poolSize;else if(Array.isArray(e.strides)){if(3!==e.strides.length)throw new d("If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length "+e.strides.length+".");n.strides=e.strides;}else n.strides=[e.strides,e.strides,e.strides];return T(n.poolSize,"poolSize"),T(n.strides,"strides"),n.padding=null==e.padding?"valid":e.padding,n.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,X(n.dataFormat),Y(n.padding),n.inputSpec=[new ce({ndim:5})],n;}return o(e,t),e.prototype.computeOutputShape=function(t){t=re(t);var e="channelsFirst"===this.dataFormat?t[2]:t[1],n="channelsFirst"===this.dataFormat?t[3]:t[2],r="channelsFirst"===this.dataFormat?t[4]:t[3];return e=mr(e,this.poolSize[0],this.padding,this.strides[0]),n=mr(n,this.poolSize[1],this.padding,this.strides[1]),r=mr(r,this.poolSize[2],this.padding,this.strides[2]),"channelsFirst"===this.dataFormat?[t[0],t[1],e,n,r]:[t[0],e,n,r,t[4]];},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){return n.invokeCallHook(t,e),n.poolingFunction(ne(t),n.poolSize,n.strides,n.padding,n.dataFormat);});},e.prototype.getConfig=function(){var e={poolSize:this.poolSize,padding:this.padding,strides:this.strides,dataFormat:this.dataFormat},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e;}(pe),hi=function(t){function e(e){return t.call(this,e)||this;}return o(e,t),e.prototype.poolingFunction=function(t,e,n,r,i){return X(i),Y(r),ii(t,e,n,r,i,"max");},e.className="MaxPooling3D",e;}(fi);r.serialization.registerClass(hi);var di=function(t){function e(e){return t.call(this,e)||this;}return o(e,t),e.prototype.poolingFunction=function(t,e,n,r,i){return X(i),Y(r),ii(t,e,n,r,i,"avg");},e.className="AveragePooling3D",e;}(fi);r.serialization.registerClass(di);var pi=function(t){function e(e){var n=t.call(this,e)||this;return n.inputSpec=[new ce({ndim:3})],n;}return o(e,t),e.prototype.computeOutputShape=function(t){return [t[0],t[2]];},e.prototype.call=function(t,e){throw new p();},e;}(pe),mi=function(t){function e(e){return t.call(this,e||{})||this;}return o(e,t),e.prototype.call=function(t,e){return Object(r.tidy)(function(){var e=ne(t);return Object(r.mean)(e,1);});},e.className="GlobalAveragePooling1D",e;}(pi);r.serialization.registerClass(mi);var gi=function(t){function e(e){return t.call(this,e||{})||this;}return o(e,t),e.prototype.call=function(t,e){return Object(r.tidy)(function(){var e=ne(t);return Object(r.max)(e,1);});},e.className="GlobalMaxPooling1D",e;}(pi);r.serialization.registerClass(gi);var vi=function(t){function e(e){var n=t.call(this,e)||this;return n.dataFormat=null==e.dataFormat?"channelsLast":e.dataFormat,X(n.dataFormat),n.inputSpec=[new ce({ndim:4})],n;}return o(e,t),e.prototype.computeOutputShape=function(t){return t=t,"channelsLast"===this.dataFormat?[t[0],t[3]]:[t[0],t[1]];},e.prototype.call=function(t,e){throw new p();},e.prototype.getConfig=function(){var e={dataFormat:this.dataFormat},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e;}(pe),yi=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){var e=ne(t);return "channelsLast"===n.dataFormat?Object(r.mean)(e,[1,2]):Object(r.mean)(e,[2,3]);});},e.className="GlobalAveragePooling2D",e;}(vi);r.serialization.registerClass(yi);var bi=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){var e=ne(t);return "channelsLast"===n.dataFormat?Object(r.max)(e,[1,2]):Object(r.max)(e,[2,3]);});},e.className="GlobalMaxPooling2D",e;}(vi);function xi(t,e,n,r){if(Array.isArray(t)){if(null!=e||null!=n)throw new d("When inputs is an array, neither initialState or constants should be provided");null!=r&&(n=t.slice(t.length-r,t.length),t=t.slice(0,t.length-r)),t.length>1&&(e=t.slice(1,t.length)),t=t[0];}function i(t){return null==t||Array.isArray(t)?t:[t];}return {inputs:t,initialState:e=i(e),constants:n=i(n)};}function wi(t,e,n,i,o,a,s,u){return void 0===i&&(i=!1),void 0===s&&(s=!1),void 0===u&&(u=!1),Object(r.tidy)(function(){var c=e.shape.length;if(c<3)throw new d("Input should be at least 3D, but is "+c+"D.");var l=[1,0].concat(lt(2,c));if(e=Object(r.transpose)(e,l),null!=a)throw new p("The rnn() functoin of the deeplearn.js backend does not support constants yet.");s&&console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."),null!=o&&((o=o.asType("bool").asType("float32")).rank===c-1&&(o=Object(r.expandDims)(o,-1)),o=Object(r.transpose)(o,l)),i&&(e=Object(r.reverse)(e,0),null!=o&&(o=Object(r.reverse)(o,0)));var f,h,m=[],g=n,v=e.shape[0],y=Object(r.unstack)(e);null!=o&&(h=Object(r.unstack)(o));for(var b,x=function x(e){var n=y[e],i=Object(r.tidy)(function(){return t(n,g);});if(null==o)f=i[0],g=i[1];else {var a=Object(r.tidy)(function(){var t=h[e],n=Object(r.onesLike)(t).sub(t);return {output:i[0].mul(t).addStrict(g[0].mul(n)),newStates:g.map(function(e,r){return i[1][r].mul(t).addStrict(e.mul(n));})};});f=a.output,g=a.newStates;}u&&m.push(f);},w=0;w<v;++w){x(w);}return u&&(b=Object(r.stack)(m,1)),[f,b,g];});}r.serialization.registerClass(bi);var ki=function(t){function e(e){var n,r=t.call(this,e)||this;if(null==e.cell)throw new d("cell property is missing for the constructor of RNN.");if(null==(n=Array.isArray(e.cell)?new Fi({cells:e.cell}):e.cell).stateSize)throw new d("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");return r.cell=n,r.returnSequences=null!=e.returnSequences&&e.returnSequences,r.returnState=null!=e.returnState&&e.returnState,r.goBackwards=null!=e.goBackwards&&e.goBackwards,r._stateful=null!=e.stateful&&e.stateful,r.unroll=null!=e.unroll&&e.unroll,r.supportsMasking=!0,r.inputSpec=[new ce({ndim:3})],r.stateSpec=null,r.states_=null,r.numConstants=null,r.keptStates=[],r;}return o(e,t),e.prototype.getStates=function(){return null==this.states_?lt(0,Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1).map(function(t){return null;}):this.states_;},e.prototype.setStates=function(t){this.states_=t;},e.prototype.computeOutputShape=function(t){te(t)&&(t=t[0]),t=t;var e=this.cell.stateSize;Array.isArray(e)||(e=[e]);var n,r=e[0];if(n=this.returnSequences?[t[0],t[1],r]:[t[0],r],this.returnState){for(var i=[],o=0,a=e;o<a.length;o++){var s=a[o];i.push([t[0],s]);}return [n].concat(i);}return n;},e.prototype.computeMask=function(t,e){var n=this;return Object(r.tidy)(function(){Array.isArray(e)&&(e=e[0]);var t=n.returnSequences?e:null;if(n.returnState){var r=n.states.map(function(t){return null;});return [t].concat(r);}return t;});},Object.defineProperty(e.prototype,"states",{get:function get(){if(null==this.states_){for(var t=Array.isArray(this.cell.stateSize)?this.cell.stateSize.length:1,e=[],n=0;n<t;++n){e.push(null);}return e;}return this.states_;},set:function set(t){this.states_=t;},enumerable:!0,configurable:!0}),e.prototype.build=function(t){if(null!=this.numConstants)throw new p("Constants support is not implemented in RNN yet.");te(t)&&(t=t[0]),t=t;var e=this.stateful?t[0]:null,n=t[t.length-1];this.inputSpec[0]=new ce({shape:[e,null,n]});var i,o=[t[0]].concat(t.slice(2));if(this.cell.build(o),i=Array.isArray(this.cell.stateSize)?this.cell.stateSize:[this.cell.stateSize],null!=this.stateSpec){if(!r.util.arraysEqual(this.stateSpec.map(function(t){return t.shape[t.shape.length-1];}),i))throw new d("An initialState was passed that is not compatible with cell.stateSize. Received stateSpec="+this.stateSpec+"; However cell.stateSize is "+this.cell.stateSize);}else this.stateSpec=i.map(function(t){return new ce({shape:[null,t]});});this.stateful&&this.resetStates();},e.prototype.resetStates=function(t,e){var n=this;void 0===e&&(e=!1),Object(r.tidy)(function(){if(!n.stateful)throw new f("Cannot call resetStates() on an RNN Layer that is not stateful.");var i=n.inputSpec[0].shape[0];if(null==i)throw new d("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");if(null==n.states_)Array.isArray(n.cell.stateSize)?n.states_=n.cell.stateSize.map(function(t){return Object(r.zeros)([i,t]);}):n.states_=[Object(r.zeros)([i,n.cell.stateSize])];else if(null==t)Object(r.dispose)(n.states_),null!=n.keptStates&&(Object(r.dispose)(n.keptStates),n.keptStates=[]),Array.isArray(n.cell.stateSize)?n.states_=n.cell.stateSize.map(function(t){return Object(r.zeros)([i,t]);}):n.states_[0]=Object(r.zeros)([i,n.cell.stateSize]);else {if(Array.isArray(t)||(t=[t]),t.length!==n.states_.length)throw new d("Layer "+n.name+" expects "+n.states_.length+" state(s), but it received "+t.length+" state value(s). Input received: "+t);!0===e?n.keptStates.push(n.states_.slice()):Object(r.dispose)(n.states_);for(var o=0;o<n.states_.length;++o){var a=t[o],s=Array.isArray(n.cell.stateSize)?n.cell.stateSize[o]:n.cell.stateSize,u=[i,s];if(!r.util.arraysEqual(a.shape,u))throw new d("State "+o+" is incompatible with layer "+n.name+": expected shape="+u+", received shape="+a.shape);n.states_[o]=a;}}n.states_=n.states_.map(function(t){return Object(r.keep)(t.clone());});});},e.prototype.apply=function(e,n){var r=null==n?null:n.initialState,i=null==n?null:n.constants;null==n&&(n={});var o=xi(e,r,i,this.numConstants);e=o.inputs,r=o.initialState,i=o.constants;var a=[],s=[];if(null!=r){n.initialState=r,a=a.concat(r),this.stateSpec=[];for(var u=0,c=r;u<c.length;u++){var l=c[u];this.stateSpec.push(new ce({shape:l.shape}));}s=s.concat(this.stateSpec);}if(null!=i&&(n.constants=i,a=a.concat(i),this.numConstants=i.length),a[0]instanceof le){var f=[e].concat(a),h=this.inputSpec.concat(s),d=this.inputSpec;this.inputSpec=h;var p=t.prototype.apply.call(this,f,n);return this.inputSpec=d,p;}return t.prototype.apply.call(this,e,n);},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){var r=null==e?null:e.mask,i=null==e?null:e.training,o=null==e?null:e.initialState;t=ne(t),null==o&&(o=n.stateful?n.states_:n.getInitialState(t));var a=Array.isArray(n.cell.stateSize)?n.cell.stateSize.length:1;if(o.length!==a)throw new d("RNN Layer has "+a+" state(s) but was passed "+o.length+" initial state(s).");n.unroll&&console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");var s={training:i},u=wi(function(t,e){var r=n.cell.call([t].concat(e),s);return [r[0],r.slice(1)];},t,o,n.goBackwards,r,null,n.unroll,n.returnSequences),c=u[0],l=u[1],f=u[2];n.stateful&&n.resetStates(f,i);var h=n.returnSequences?l:c;return n.returnState?[h].concat(f):h;});},e.prototype.getInitialState=function(t){var e=this;return Object(r.tidy)(function(){var n=Object(r.zeros)(t.shape);return n=ht(n=Object(r.sum)(n,[1,2])),Array.isArray(e.cell.stateSize)?e.cell.stateSize.map(function(t){return t>1?yt(n,[1,t]):n;}):e.cell.stateSize>1?[yt(n,[1,e.cell.stateSize])]:[n];});},Object.defineProperty(e.prototype,"trainableWeights",{get:function get(){return this.trainable?this.cell.trainableWeights:[];},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nonTrainableWeights",{get:function get(){return this.trainable?this.cell.nonTrainableWeights:this.cell.weights;},enumerable:!0,configurable:!0}),e.prototype.setFastWeightInitDuringBuild=function(e){t.prototype.setFastWeightInitDuringBuild.call(this,e),null!=this.cell&&this.cell.setFastWeightInitDuringBuild(e);},e.prototype.getConfig=function(){var e={returnSequences:this.returnSequences,returnState:this.returnState,goBackwards:this.goBackwards,stateful:this.stateful,unroll:this.unroll};null!=this.numConstants&&(e.numConstants=this.numConstants);var n=this.cell.getConfig();e.cell={className:this.cell.getClassName(),config:n};var r=t.prototype.getConfig.call(this);return Object.assign(e,r),e;},e.fromConfig=function(t,e,n){void 0===n&&(n={});var r=De(e.cell,n);return new t(Object.assign(e,{cell:r}));},e.className="RNN",e;}(pe);r.serialization.registerClass(ki);var Ei=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e;}(pe),Ci=function(t){function e(e){var n=t.call(this,e)||this;return n.DEFAULT_ACTIVATION="tanh",n.DEFAULT_KERNEL_INITIALIZER="glorotNormal",n.DEFAULT_RECURRENT_INITIALIZER="orthogonal",n.DEFAULT_BIAS_INITIALIZER="zeros",n.units=e.units,T(n.units,"units"),n.activation=tr(null==e.activation?n.DEFAULT_ACTIVATION:e.activation),n.useBias=null==e.useBias||e.useBias,n.kernelInitializer=Kt(e.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.recurrentInitializer=Kt(e.recurrentInitializer||n.DEFAULT_RECURRENT_INITIALIZER),n.biasInitializer=Kt(e.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.kernelRegularizer=sr(e.kernelRegularizer),n.recurrentRegularizer=sr(e.recurrentRegularizer),n.biasRegularizer=sr(e.biasRegularizer),n.kernelConstraint=W(e.kernelConstraint),n.recurrentConstraint=W(e.recurrentConstraint),n.biasConstraint=W(e.biasConstraint),n.dropout=ut([1,ct([0,null==e.dropout?0:e.dropout])]),n.recurrentDropout=ut([1,ct([0,null==e.recurrentDropout?0:e.recurrentDropout])]),n.stateSize=n.units,n.dropoutMask=null,n.recurrentDropoutMask=null,n;}return o(e,t),e.prototype.build=function(t){t=re(t),this.kernel=this.addWeight("kernel",[t[t.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;},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){if(2!==(t=t).length)throw new d("SimpleRNNCell expects 2 input Tensors, got "+t.length+".");var i=t[1];t=t[0];var o,a=null!=e.training&&e.training;0<n.dropout&&n.dropout<1&&null==n.dropoutMask&&(n.dropoutMask=Ti(function(){return Object(r.onesLike)(t);},n.dropout,a)),0<n.recurrentDropout&&n.recurrentDropout<1&&null==n.recurrentDropoutMask&&(n.recurrentDropoutMask=Ti(function(){return Object(r.onesLike)(i);},n.recurrentDropout,a));var s=n.dropoutMask,u=n.recurrentDropoutMask;o=xt(null!=s?Object(r.mul)(t,s):t,n.kernel.read()),null!=n.bias&&(o=Ct(o,n.bias.read())),null!=u&&(i=Object(r.mul)(i,u));var c=Object(r.add)(o,xt(i,n.recurrentKernel.read()));return null!=n.activation&&(c=n.activation.apply(c)),[c,c];});},e.prototype.getConfig=function(){var e={units:this.units,activation:Qn(this.activation),useBias:this.useBias,kernelInitializer:Gt(this.kernelInitializer),recurrentInitializer:Gt(this.recurrentInitializer),biasInitializer:Gt(this.biasInitializer),kernelRegularizer:or(this.kernelRegularizer),recurrentRegularizer:or(this.recurrentRegularizer),biasRegularizer:or(this.biasRegularizer),activityRegularizer:or(this.activityRegularizer),kernelConstraint:z(this.kernelConstraint),recurrentConstraint:z(this.recurrentConstraint),biasConstraint:z(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="SimpleRNNCell",e;}(Ei);r.serialization.registerClass(Ci);var Ai=function(t){function e(e){return e.cell=new Ci(e),t.call(this,e)||this;}return o(e,t),e.prototype.call=function(e,n){var i=this;return Object(r.tidy)(function(){null!=i.cell.dropoutMask&&(Object(r.dispose)(i.cell.dropoutMask),i.cell.dropoutMask=null),null!=i.cell.recurrentDropoutMask&&(Object(r.dispose)(i.cell.recurrentDropoutMask),i.cell.recurrentDropoutMask=null);var o=null==n?null:n.mask,a=null==n?null:n.training,s=null==n?null:n.initialState;return t.prototype.call.call(i,e,{mask:o,training:a,initialState:s});});},Object.defineProperty(e.prototype,"units",{get:function get(){return this.cell.units;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"activation",{get:function get(){return this.cell.activation;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useBias",{get:function get(){return this.cell.useBias;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"kernelInitializer",{get:function get(){return this.cell.kernelInitializer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"recurrentInitializer",{get:function get(){return this.cell.recurrentInitializer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"biasInitializer",{get:function get(){return this.cell.biasInitializer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"kernelRegularizer",{get:function get(){return this.cell.kernelRegularizer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"recurrentRegularizer",{get:function get(){return this.cell.recurrentRegularizer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"biasRegularizer",{get:function get(){return this.cell.biasRegularizer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"kernelConstraint",{get:function get(){return this.cell.kernelConstraint;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"recurrentConstraint",{get:function get(){return this.cell.recurrentConstraint;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"biasConstraint",{get:function get(){return this.cell.biasConstraint;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dropout",{get:function get(){return this.cell.dropout;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"recurrentDropout",{get:function get(){return this.cell.recurrentDropout;},enumerable:!0,configurable:!0}),e.prototype.getConfig=function(){var e={units:this.units,activation:Qn(this.activation),useBias:this.useBias,kernelInitializer:Gt(this.kernelInitializer),recurrentInitializer:Gt(this.recurrentInitializer),biasInitializer:Gt(this.biasInitializer),kernelRegularizer:or(this.kernelRegularizer),recurrentRegularizer:or(this.recurrentRegularizer),biasRegularizer:or(this.biasRegularizer),activityRegularizer:or(this.activityRegularizer),kernelConstraint:z(this.kernelConstraint),recurrentConstraint:z(this.recurrentConstraint),biasConstraint:z(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout},n=t.prototype.getConfig.call(this);return delete n.cell,Object.assign(e,n),e;},e.fromConfig=function(t,e){return new t(e);},e.className="SimpleRNN",e;}(ki);r.serialization.registerClass(Ai);var Oi=function(t){function e(e){var n=t.call(this,e)||this;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=e.units,T(n.units,"units"),n.activation=tr(void 0===e.activation?n.DEFAULT_ACTIVATION:e.activation),n.recurrentActivation=tr(void 0===e.recurrentActivation?n.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),n.useBias=null==e.useBias||e.useBias,n.kernelInitializer=Kt(e.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.recurrentInitializer=Kt(e.recurrentInitializer||n.DEFAULT_RECURRENT_INITIALIZER),n.biasInitializer=Kt(e.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.kernelRegularizer=sr(e.kernelRegularizer),n.recurrentRegularizer=sr(e.recurrentRegularizer),n.biasRegularizer=sr(e.biasRegularizer),n.kernelConstraint=W(e.kernelConstraint),n.recurrentConstraint=W(e.recurrentConstraint),n.biasConstraint=W(e.biasConstraint),n.dropout=ut([1,ct([0,null==e.dropout?0:e.dropout])]),n.recurrentDropout=ut([1,ct([0,null==e.recurrentDropout?0:e.recurrentDropout])]),n.implementation=e.implementation,n.stateSize=n.units,n.dropoutMask=null,n.recurrentDropoutMask=null,n;}return o(e,t),e.prototype.build=function(t){var e=(t=re(t))[t.length-1];this.kernel=this.addWeight("kernel",[e,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;},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){if(2!==(t=t).length)throw new d("GRUCell expects 2 input Tensors (inputs, h, c), got "+t.length+".");var i=null!=e.training&&e.training,o=t[1];t=t[0],0<n.dropout&&n.dropout<1&&null==n.dropoutMask&&(n.dropoutMask=Ti(function(){return Object(r.onesLike)(t);},n.dropout,i,3)),0<n.recurrentDropout&&n.recurrentDropout<1&&null==n.recurrentDropoutMask&&(n.recurrentDropoutMask=Ti(function(){return Object(r.onesLike)(o);},n.recurrentDropout,i,3));var a,s,u,c=n.dropoutMask,l=n.recurrentDropoutMask;0<n.dropout&&n.dropout<1&&(t=Object(r.mul)(t,c[0]));var f=xt(t,n.kernel.read());n.useBias&&(f=Ct(f,n.bias.read())),0<n.recurrentDropout&&n.recurrentDropout<1&&(o=Object(r.mul)(o,l[0]));var h=n.recurrentKernel.read(),p=Object(r.split)(h,[2*n.units,n.units],h.rank-1),m=p[0],g=p[1],v=xt(o,m),y=Object(r.split)(f,3,f.rank-1),b=y[0],x=y[1],w=y[2],k=Object(r.split)(v,2,v.rank-1),E=k[0],C=k[1];a=n.recurrentActivation.apply(Object(r.add)(b,E)),s=n.recurrentActivation.apply(Object(r.add)(x,C));var A=xt(Object(r.mul)(s,o),g);u=n.activation.apply(Object(r.add)(w,A));var O=Object(r.add)(Object(r.mul)(a,o),Object(r.mul)(Object(r.add)(1,Object(r.neg)(a)),u));return [O,O];});},e.prototype.getConfig=function(){var e={units:this.units,activation:Qn(this.activation),recurrentActivation:Qn(this.recurrentActivation),useBias:this.useBias,kernelInitializer:Gt(this.kernelInitializer),recurrentInitializer:Gt(this.recurrentInitializer),biasInitializer:Gt(this.biasInitializer),kernelRegularizer:or(this.kernelRegularizer),recurrentRegularizer:or(this.recurrentRegularizer),biasRegularizer:or(this.biasRegularizer),activityRegularizer:or(this.activityRegularizer),kernelConstraint:z(this.kernelConstraint),recurrentConstraint:z(this.recurrentConstraint),biasConstraint:z(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="GRUCell",e;}(Ei);r.serialization.registerClass(Oi);var _i=function(t){function e(e){return 0===e.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),e.cell=new Oi(e),t.call(this,e)||this;}return o(e,t),e.prototype.call=function(e,n){var i=this;return Object(r.tidy)(function(){null!=i.cell.dropoutMask&&(Object(r.dispose)(i.cell.dropoutMask),i.cell.dropoutMask=null),null!=i.cell.recurrentDropoutMask&&(Object(r.dispose)(i.cell.recurrentDropoutMask),i.cell.recurrentDropoutMask=null);var o=null==n?null:n.mask,a=null==n?null:n.training,s=null==n?null:n.initialState;return t.prototype.call.call(i,e,{mask:o,training:a,initialState:s});});},Object.defineProperty(e.prototype,"units",{get:function get(){return this.cell.units;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"activation",{get:function get(){return this.cell.activation;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"recurrentActivation",{get:function get(){return this.cell.recurrentActivation;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useBias",{get:function get(){return this.cell.useBias;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"kernelInitializer",{get:function get(){return this.cell.kernelInitializer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"recurrentInitializer",{get:function get(){return this.cell.recurrentInitializer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"biasInitializer",{get:function get(){return this.cell.biasInitializer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"kernelRegularizer",{get:function get(){return this.cell.kernelRegularizer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"recurrentRegularizer",{get:function get(){return this.cell.recurrentRegularizer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"biasRegularizer",{get:function get(){return this.cell.biasRegularizer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"kernelConstraint",{get:function get(){return this.cell.kernelConstraint;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"recurrentConstraint",{get:function get(){return this.cell.recurrentConstraint;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"biasConstraint",{get:function get(){return this.cell.biasConstraint;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dropout",{get:function get(){return this.cell.dropout;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"recurrentDropout",{get:function get(){return this.cell.recurrentDropout;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"implementation",{get:function get(){return this.cell.implementation;},enumerable:!0,configurable:!0}),e.prototype.getConfig=function(){var e={units:this.units,activation:Qn(this.activation),recurrentActivation:Qn(this.recurrentActivation),useBias:this.useBias,kernelInitializer:Gt(this.kernelInitializer),recurrentInitializer:Gt(this.recurrentInitializer),biasInitializer:Gt(this.biasInitializer),kernelRegularizer:or(this.kernelRegularizer),recurrentRegularizer:or(this.recurrentRegularizer),biasRegularizer:or(this.biasRegularizer),activityRegularizer:or(this.activityRegularizer),kernelConstraint:z(this.kernelConstraint),recurrentConstraint:z(this.recurrentConstraint),biasConstraint:z(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation},n=t.prototype.getConfig.call(this);return delete n.cell,Object.assign(e,n),e;},e.fromConfig=function(t,e){return 0===e.implmentation&&(e.implementation=1),new t(e);},e.className="GRU",e;}(ki);r.serialization.registerClass(_i);var Si=function(t){function e(e){var n=t.call(this,e)||this;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=e.units,T(n.units,"units"),n.activation=tr(void 0===e.activation?n.DEFAULT_ACTIVATION:e.activation),n.recurrentActivation=tr(void 0===e.recurrentActivation?n.DEFAULT_RECURRENT_ACTIVATION:e.recurrentActivation),n.useBias=null==e.useBias||e.useBias,n.kernelInitializer=Kt(e.kernelInitializer||n.DEFAULT_KERNEL_INITIALIZER),n.recurrentInitializer=Kt(e.recurrentInitializer||n.DEFAULT_RECURRENT_INITIALIZER),n.biasInitializer=Kt(e.biasInitializer||n.DEFAULT_BIAS_INITIALIZER),n.unitForgetBias=e.unitForgetBias,n.kernelRegularizer=sr(e.kernelRegularizer),n.recurrentRegularizer=sr(e.recurrentRegularizer),n.biasRegularizer=sr(e.biasRegularizer),n.kernelConstraint=W(e.kernelConstraint),n.recurrentConstraint=W(e.recurrentConstraint),n.biasConstraint=W(e.biasConstraint),n.dropout=ut([1,ct([0,null==e.dropout?0:e.dropout])]),n.recurrentDropout=ut([1,ct([0,null==e.recurrentDropout?0:e.recurrentDropout])]),n.implementation=e.implementation,n.stateSize=[n.units,n.units],n.dropoutMask=null,n.recurrentDropoutMask=null,n;}return o(e,t),e.prototype.build=function(t){var e,n,r=(t=re(t))[t.length-1];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){if(this.unitForgetBias){var i=this.biasInitializer,a=this.units;n=new((e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return o(e,t),e.prototype.apply=function(t,e){var n=i.apply([a]),r=new Tt().apply([a]),o=i.apply([2*a]);return vt(vt(n,r),o);},e;}(Dt)).className="CustomInit",e)();}else n=this.biasInitializer;this.bias=this.addWeight("bias",[4*this.units],null,n,this.biasRegularizer,!0,this.biasConstraint);}else this.bias=null;this.built=!0;},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){var i=null!=e.training&&e.training;if(3!==(t=t).length)throw new d("LSTMCell expects 3 input Tensors (inputs, h, c), got "+t.length+".");var o=t[1],a=t[2];t=t[0],0<n.dropout&&n.dropout<1&&null==n.dropoutMask&&(n.dropoutMask=Ti(function(){return Object(r.onesLike)(t);},n.dropout,i,4)),0<n.recurrentDropout&&n.recurrentDropout<1&&null==n.recurrentDropoutMask&&(n.recurrentDropoutMask=Ti(function(){return Object(r.onesLike)(o);},n.recurrentDropout,i,4));var s,u,c,l,f=n.dropoutMask,h=n.recurrentDropoutMask;0<n.dropout&&n.dropout<1&&(t=Object(r.mul)(t,f[0]));var p=xt(t,n.kernel.read());0<n.recurrentDropout&&n.recurrentDropout<1&&(o=Object(r.mul)(o,h[0])),p=Object(r.add)(p,xt(o,n.recurrentKernel.read())),n.useBias&&(p=Ct(p,n.bias.read()));var m=Object(r.split)(p,4,p.rank-1),g=m[0],v=m[1],y=m[2],b=m[3];s=n.recurrentActivation.apply(g),u=n.recurrentActivation.apply(v),c=Object(r.add)(Object(r.mul)(u,a),Object(r.mul)(s,n.activation.apply(y))),l=n.recurrentActivation.apply(b);var x=Object(r.mul)(l,n.activation.apply(c));return [x,x,c];});},e.prototype.getConfig=function(){var e={units:this.units,activation:Qn(this.activation),recurrentActivation:Qn(this.recurrentActivation),useBias:this.useBias,kernelInitializer:Gt(this.kernelInitializer),recurrentInitializer:Gt(this.recurrentInitializer),biasInitializer:Gt(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:or(this.kernelRegularizer),recurrentRegularizer:or(this.recurrentRegularizer),biasRegularizer:or(this.biasRegularizer),activityRegularizer:or(this.activityRegularizer),kernelConstraint:z(this.kernelConstraint),recurrentConstraint:z(this.recurrentConstraint),biasConstraint:z(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.className="LSTMCell",e;}(Ei);r.serialization.registerClass(Si);var Di=function(t){function e(e){return 0===e.implementation&&console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."),e.cell=new Si(e),t.call(this,e)||this;}return o(e,t),e.prototype.call=function(e,n){var i=this;return Object(r.tidy)(function(){null!=i.cell.dropoutMask&&(Object(r.dispose)(i.cell.dropoutMask),i.cell.dropoutMask=null),null!=i.cell.recurrentDropoutMask&&(Object(r.dispose)(i.cell.recurrentDropoutMask),i.cell.recurrentDropoutMask=null);var o=null==n?null:n.mask,a=null==n?null:n.training,s=null==n?null:n.initialState;return t.prototype.call.call(i,e,{mask:o,training:a,initialState:s});});},Object.defineProperty(e.prototype,"units",{get:function get(){return this.cell.units;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"activation",{get:function get(){return this.cell.activation;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"recurrentActivation",{get:function get(){return this.cell.recurrentActivation;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useBias",{get:function get(){return this.cell.useBias;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"kernelInitializer",{get:function get(){return this.cell.kernelInitializer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"recurrentInitializer",{get:function get(){return this.cell.recurrentInitializer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"biasInitializer",{get:function get(){return this.cell.biasInitializer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"unitForgetBias",{get:function get(){return this.cell.unitForgetBias;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"kernelRegularizer",{get:function get(){return this.cell.kernelRegularizer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"recurrentRegularizer",{get:function get(){return this.cell.recurrentRegularizer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"biasRegularizer",{get:function get(){return this.cell.biasRegularizer;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"kernelConstraint",{get:function get(){return this.cell.kernelConstraint;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"recurrentConstraint",{get:function get(){return this.cell.recurrentConstraint;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"biasConstraint",{get:function get(){return this.cell.biasConstraint;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dropout",{get:function get(){return this.cell.dropout;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"recurrentDropout",{get:function get(){return this.cell.recurrentDropout;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"implementation",{get:function get(){return this.cell.implementation;},enumerable:!0,configurable:!0}),e.prototype.getConfig=function(){var e={units:this.units,activation:Qn(this.activation),recurrentActivation:Qn(this.recurrentActivation),useBias:this.useBias,kernelInitializer:Gt(this.kernelInitializer),recurrentInitializer:Gt(this.recurrentInitializer),biasInitializer:Gt(this.biasInitializer),unitForgetBias:this.unitForgetBias,kernelRegularizer:or(this.kernelRegularizer),recurrentRegularizer:or(this.recurrentRegularizer),biasRegularizer:or(this.biasRegularizer),activityRegularizer:or(this.activityRegularizer),kernelConstraint:z(this.kernelConstraint),recurrentConstraint:z(this.recurrentConstraint),biasConstraint:z(this.biasConstraint),dropout:this.dropout,recurrentDropout:this.recurrentDropout,implementation:this.implementation},n=t.prototype.getConfig.call(this);return delete n.cell,Object.assign(e,n),e;},e.fromConfig=function(t,e){return 0===e.implmentation&&(e.implementation=1),new t(e);},e.className="LSTM",e;}(ki);r.serialization.registerClass(Di);var Fi=function(t){function e(e){var n=t.call(this,e)||this;return n.cells=e.cells,n;}return o(e,t),Object.defineProperty(e.prototype,"stateSize",{get:function get(){for(var t=[],e=0,n=this.cells.slice().reverse();e<n.length;e++){var r=n[e];Array.isArray(r.stateSize)?t.push.apply(t,r.stateSize):t.push(r.stateSize);}return t;},enumerable:!0,configurable:!0}),e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){for(var r=(t=t).slice(1),i=[],o=0,a=n.cells.slice().reverse();o<a.length;o++){var s=a[o];Array.isArray(s.stateSize)?i.push(r.splice(0,s.stateSize.length)):i.push(r.splice(0,1));}i.reverse();for(var u,c=[],l=0;l<n.cells.length;++l){s=n.cells[l],r=i[l],u=0===l?[t[0]].concat(r):[u[0]].concat(r),u=s.call(u,e),c.push(u.slice(1));}r=[];for(var f=0,h=c.slice().reverse();f<h.length;f++){var d=h[f];r.push.apply(r,d);}return [u[0]].concat(r);});},e.prototype.build=function(t){var e;te(t)&&(t=t[0]),t=t,this.cells.forEach(function(n,r){tt("RNNCell_"+r,function(){n.build(t),e=Array.isArray(n.stateSize)?n.stateSize[0]:n.stateSize,t=[t[0],e];});}),this.built=!0;},e.prototype.getConfig=function(){for(var e=[],n=0,r=this.cells;n<r.length;n++){var i=r[n];e.push({className:i.getClassName(),config:i.getConfig()});}var o={cells:e},a=t.prototype.getConfig.call(this);return Object.assign(o,a),o;},e.fromConfig=function(t,e,n){void 0===n&&(n={});for(var r=[],i=0,o=e.cells;i<o.length;i++){var a=o[i];r.push(De(a,n));}return new t({cells:r});},Object.defineProperty(e.prototype,"trainableWeights",{get:function get(){if(!this.trainable)return [];for(var t=[],e=0,n=this.cells;e<n.length;e++){var r=n[e];t.push.apply(t,r.trainableWeights);}return t;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nonTrainableWeights",{get:function get(){for(var t=[],e=0,n=this.cells;e<n.length;e++){var r=n[e];t.push.apply(t,r.nonTrainableWeights);}if(!this.trainable){for(var i=[],o=0,a=this.cells;o<a.length;o++){r=a[o],i.push.apply(i,r.trainableWeights);}return i.concat(t);}return t;},enumerable:!0,configurable:!0}),e.prototype.getWeights=function(){for(var t=[],e=0,n=this.cells;e<n.length;e++){var r=n[e];t.push.apply(t,r.weights);}return se(t);},e.prototype.setWeights=function(t){for(var e=[],n=0,r=this.cells;n<r.length;n++){for(var i=r[n],o=i.weights.length,a=t.splice(o),s=0;s<i.weights.length;++s){e.push([i.weights[s],a[s]]);}}ue(e);},e.className="StackedRNNCells",e;}(Ei);function Ti(t,e,n,i){function o(){return At(t(),e);}if(void 0===n&&(n=null),void 0===i&&(i=1),i>1){for(var a=[],s=0;s<i;s++){a.push(Ot(o,t,n));}return a.map(function(t){return Object(r.keep)(t.clone());});}return Object(r.keep)(Ot(o,t,n).clone());}r.serialization.registerClass(Fi);var Ni=function(t){function e(e){var n=t.call(this,e)||this;return n.layer=e.layer,n;}return o(e,t),e.prototype.build=function(t){this.built=!0;},Object.defineProperty(e.prototype,"trainable",{get:function get(){return null!=this.layer&&this.layer.trainable;},set:function set(t){null!=this.layer&&(this.layer.trainable=t);},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"trainableWeights",{get:function get(){return this.layer.trainableWeights;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nonTrainableWeights",{get:function get(){return this.layer.nonTrainableWeights;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updates",{get:function get(){return this.layer._updates;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"losses",{get:function get(){return this.layer.losses;},enumerable:!0,configurable:!0}),e.prototype.getWeights=function(){return this.layer.getWeights();},e.prototype.setWeights=function(t){this.layer.setWeights(t);},e.prototype.getConfig=function(){var e={layer:{className:this.layer.getClassName(),config:this.layer.getConfig()}},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.prototype.setFastWeightInitDuringBuild=function(e){t.prototype.setFastWeightInitDuringBuild.call(this,e),null!=this.layer&&this.layer.setFastWeightInitDuringBuild(e);},e.fromConfig=function(t,e,n){void 0===n&&(n={});var r=De(e.layer,n);delete e.layer;var i={layer:r};return Object.assign(i,e),new t(i);},e;}(pe),Ii=function(t){function e(e){var n=t.call(this,e)||this;return n.supportsMasking=!0,n;}return o(e,t),e.prototype.build=function(e){if((e=re(e)).length<3)throw new d("TimeDistributed layer expects an input shape >= 3D, but received input shape "+JSON.stringify(e));this.inputSpec=[{shape:e}];var n=[e[0]].concat(e.slice(2));this.layer.built||(this.layer.build(n),this.layer.built=!0),t.prototype.build.call(this,e);},e.prototype.computeOutputShape=function(t){var e=[(t=re(t))[0]].concat(t.slice(2)),n=this.layer.computeOutputShape(e),r=t[1];return [n[0],r].concat(n.slice(1));},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){return wi(function(t,r){return [ne(n.layer.call(t,e)),[]];},t=ne(t),[],!1,null,null,!1,!0)[1];});},e.className="TimeDistributed",e;}(Ni);r.serialization.registerClass(Ii);var Ri="concat",Mi=function(t){function e(e){var n=t.call(this,e)||this,r=e.layer.getConfig(),i={};i.className=e.layer.getClassName(),i.config=r,n.forwardLayer=De(i),r.goBackwards=!0!==r.goBackwards;var o={};if(o.className=e.layer.getClassName(),o.config=r,n.backwardLayer=De(o),n.forwardLayer.name="forward_"+n.forwardLayer.name,n.backwardLayer.name="backward_"+n.backwardLayer.name,n.mergeMode=void 0===e.mergeMode?Ri:e.mergeMode,function(t){D(G,"BidirectionalMergeMode",t);}(n.mergeMode),e.weights)throw new p("weights support is not implemented for Bidirectional layer yet.");return n._stateful=e.layer.stateful,n.returnSequences=e.layer.returnSequences,n.returnState=e.layer.returnState,n.supportsMasking=!0,n._trainable=!0,n.inputSpec=e.layer.inputSpec,n.numConstants=null,n;}return o(e,t),Object.defineProperty(e.prototype,"trainable",{get:function get(){return this._trainable;},set:function set(t){this._trainable=t,null!=this.forwardLayer&&(this.forwardLayer.trainable=t),null!=this.backwardLayer&&(this.backwardLayer.trainable=t);},enumerable:!0,configurable:!0}),e.prototype.getWeights=function(){return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights());},e.prototype.setWeights=function(t){var e=t.length,n=Math.floor(e/2);this.forwardLayer.setWeights(t.slice(0,n)),this.backwardLayer.setWeights(t.slice(n));},e.prototype.computeOutputShape=function(t){var e,n,r,i=this.forwardLayer.computeOutputShape(t);return Array.isArray(i)&&Array.isArray(i[0])||(i=[i]),i=i,this.returnState?(r=i.slice(1),e=i[0]):e=i[0],e=e,"concat"===this.mergeMode?(e[e.length-1]*=2,n=[e]):n=null==this.mergeMode?[e,e.slice()]:[e],this.returnState?null==this.mergeMode?n.concat(r).concat(r.slice()):[e].concat(r).concat(r.slice()):b(n);},e.prototype.apply=function(e,n){var r=null==n?null:n.initialState,i=null==n?null:n.constants;null==n&&(n={});var o=xi(e,r,i,this.numConstants);if(e=o.inputs,r=o.initialState,i=o.constants,Array.isArray(e)&&(r=e.slice(1),e=e[0]),(null==r||0===r.length)&&null==i)return t.prototype.apply.call(this,e,n);var a=[],s=[];if(null!=r){var u=r.length;if(u%2>0)throw new d("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");n.initialState=r,a.push.apply(a,r);var c=r.map(function(t){return new ce({shape:t.shape});});this.forwardLayer.stateSpec=c.slice(0,u/2),this.backwardLayer.stateSpec=c.slice(u/2),s.push.apply(s,c);}if(null!=i)throw new p("Support for constants in Bidirectional layers is not implemented yet.");for(var l=a[0]instanceof le,f=0,h=a;f<h.length;f++){if(h[f]instanceof le!==l)throw new d("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");}if(l){var m=[e].concat(a),g=this.inputSpec.concat(s),v=this.inputSpec;this.inputSpec=g;var y=t.prototype.apply.call(this,m,n);return this.inputSpec=v,y;}return t.prototype.apply.call(this,e,n);},e.prototype.call=function(t,e){var n=this;return Object(r.tidy)(function(){var i,o,a,s,u=e.initialState;if(null==u)i=n.forwardLayer.call(t,e),o=n.backwardLayer.call(t,e);else {var c=u.slice(0,u.length/2),l=u.slice(u.length/2);i=n.forwardLayer.call(t,Object.assign(e,{initialState:c})),o=n.backwardLayer.call(t,Object.assign(e,{initialState:l}));}return n.returnState&&(Array.isArray(i)&&(a=i.slice(1).concat(o.slice(1))),i=i[0],o=o[0]),n.returnSequences&&(o=Object(r.reverse)(o,1)),"concat"===n.mergeMode?s=gt([i,o]):"sum"===n.mergeMode?s=Object(r.add)(i,o):"ave"===n.mergeMode?s=Object(r.mul)(.5,Object(r.add)(i,o)):"mul"===n.mergeMode?s=Object(r.mul)(i,o):null==n.mergeMode&&(s=[i,o]),n.returnState?null==n.mergeMode?s.concat(a):[s].concat(a):s;});},e.prototype.resetStates=function(t){this.forwardLayer.resetStates(),this.backwardLayer.resetStates();},e.prototype.build=function(t){var e=this;tt(this.forwardLayer.name,function(){e.forwardLayer.build(t);}),tt(this.backwardLayer.name,function(){e.backwardLayer.build(t);}),this.built=!0;},e.prototype.computeMask=function(t,e){var n;if(Array.isArray(e)&&(e=e[0]),n=this.returnSequences?null==this.mergeMode?[e,e]:e:null==this.mergeMode?[null,null]:null,this.returnState){var r=this.forwardLayer.states.map(function(t){return null;});return Array.isArray(n)?n.concat(r).concat(r):[n].concat(r).concat(r);}return n;},Object.defineProperty(e.prototype,"trainableWeights",{get:function get(){return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights);},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nonTrainableWeights",{get:function get(){return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights);},enumerable:!0,configurable:!0}),e.prototype.setFastWeightInitDuringBuild=function(e){t.prototype.setFastWeightInitDuringBuild.call(this,e),null!=this.forwardLayer&&this.forwardLayer.setFastWeightInitDuringBuild(e),null!=this.backwardLayer&&this.backwardLayer.setFastWeightInitDuringBuild(e);},e.prototype.getConfig=function(){var e={mergeMode:this.mergeMode},n=t.prototype.getConfig.call(this);return Object.assign(e,n),e;},e.fromConfig=function(t,e){var n=De(e.layer);if(delete e.layer,null!=e.numConstants)throw new p("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");var r=e;return r.layer=n,new t(r);},e.className="Bidirectional",e;}(Ni);function ji(t){return new si(t);}function Bi(t){return new li(t);}function Pi(t){return new di(t);}function Li(t){return new gi(t);}function zi(t){return new bi(t);}function Ui(t){return new ai(t);}function Wi(t){return new ci(t);}r.serialization.registerClass(Mi);var Vi=Li,qi=zi,$i=Ui,Hi=Wi;var Gi=Object.freeze({inputLayer:function inputLayer(t){return new ge(t);},elu:function elu(t){return new fr(t);},reLU:function reLU(t){return new ur(t);},leakyReLU:function leakyReLU(t){return new cr(t);},prelu:function prelu(t){return new lr(t);},softmax:function softmax(t){return new dr(t);},thresholdedReLU:function thresholdedReLU(t){return new hr(t);},conv1d:function conv1d(t){return new Or(t);},conv2d:function conv2d(t){return new kr(t);},conv2dTranspose:function conv2dTranspose(t){return new Cr(t);},conv3d:function conv3d(t){return new Er(t);},separableConv2d:function separableConv2d(t){return new Ar(t);},cropping2D:function cropping2D(t){return new _r(t);},upSampling2d:function upSampling2d(t){return new Sr(t);},depthwiseConv2d:function depthwiseConv2d(t){return new Dr(t);},activation:function activation(t){return new Rr(t);},dense:function dense(t){return new Nr(t);},dropout:function dropout(t){return new Fr(t);},spatialDropout1d:function spatialDropout1d(t){return new Tr(t);},flatten:function flatten(t){return new Ir(t);},repeatVector:function repeatVector(t){return new Mr(t);},reshape:function reshape(t){return new jr(t);},permute:function permute(t){return new Br(t);},embedding:function embedding(t){return new Lr(t);},add:function add(t){return new Ur(t);},average:function average(t){return new Vr(t);},concatenate:function concatenate(t){return new Hr(t);},maximum:function maximum(t){return new qr(t);},minimum:function minimum(t){return new $r(t);},multiply:function multiply(t){return new Wr(t);},dot:function dot(t){return new Kr(t);},batchNormalization:function batchNormalization(t){return new ti(t);},layerNormalization:function layerNormalization(t){return new ei(t);},zeroPadding2d:function zeroPadding2d(t){return new ni(t);},averagePooling1d:ji,avgPool1d:function avgPool1d(t){return ji(t);},avgPooling1d:function avgPooling1d(t){return ji(t);},averagePooling2d:Bi,avgPool2d:function avgPool2d(t){return Bi(t);},avgPooling2d:function avgPooling2d(t){return Bi(t);},averagePooling3d:Pi,avgPool3d:function avgPool3d(t){return Pi(t);},avgPooling3d:function avgPooling3d(t){return Pi(t);},globalAveragePooling1d:function globalAveragePooling1d(t){return new mi(t);},globalAveragePooling2d:function globalAveragePooling2d(t){return new yi(t);},globalMaxPooling1d:Li,globalMaxPooling2d:zi,maxPooling1d:Ui,maxPooling2d:Wi,maxPooling3d:function maxPooling3d(t){return new hi(t);},gru:function gru(t){return new _i(t);},gruCell:function gruCell(t){return new Oi(t);},lstm:function lstm(t){return new Di(t);},lstmCell:function lstmCell(t){return new Si(t);},simpleRNN:function simpleRNN(t){return new Ai(t);},simpleRNNCell:function simpleRNNCell(t){return new Ci(t);},rnn:function rnn(t){return new ki(t);},stackedRNNCells:function stackedRNNCells(t){return new Fi(t);},bidirectional:function bidirectional(t){return new Mi(t);},timeDistributed:function timeDistributed(t){return new Ii(t);},globalMaxPool1d:Vi,globalMaxPool2d:qi,maxPool1d:$i,maxPool2d:Hi,Layer:pe,RNN:ki,RNNCell:Ei,input:Bn,gaussianNoise:function gaussianNoise(t){return new Xr(t);},gaussianDropout:function gaussianDropout(t){return new Yr(t);},alphaDropout:function alphaDropout(t){return new Jr(t);},masking:function masking(t){return new Pr(t);}});var Ki=Object.freeze({binaryAccuracy:function binaryAccuracy(t,e){return ze(t,e);},binaryCrossentropy:function binaryCrossentropy(t,e){return $e(t,e);},sparseCategoricalAccuracy:function sparseCategoricalAccuracy(t,e){return He(t,e);},categoricalAccuracy:function categoricalAccuracy(t,e){return Ue(t,e);},categoricalCrossentropy:function categoricalCrossentropy(t,e){return Ge(t,e);},precision:function precision(t,e){return Ve(t,e);},recall:function recall(t,e){return qe(t,e);},cosineProximity:function cosineProximity(t,e){return Be(t,e);},meanAbsoluteError:function meanAbsoluteError(t,e){return Ne(t,e);},meanAbsolutePercentageError:function meanAbsolutePercentageError(t,e){return Ie(t,e);},MAPE:function MAPE(t,e){return Ie(t,e);},mape:function mape(t,e){return Ie(t,e);},meanSquaredError:function meanSquaredError(t,e){return Te(t,e);},MSE:function MSE(t,e){return Te(t,e);},mse:function mse(t,e){return Te(t,e);}}),Xi=Object.freeze({modelFromJSON:function modelFromJSON(t,e){return u(this,void 0,void 0,function(){var n,i,o,a,s,u,l,f;return c(this,function(c){switch(c.label){case 0:return "modelTopology"in t||(t={modelTopology:t}),null!=(n=(t=t).modelTopology).model_config&&(n=n.model_config),i=on(n),o=De(i,e),null==t.weightsManifest?[3,2]:[4,r.io.loadWeights(t.weightsManifest,t.pathPrefix,o.weights.map(function(t){return t.originalName;}))];case 1:for(a=c.sent(),s={},u=0,l=o.weights;u<l.length;u++){f=l[u],s[f.originalName]=a[f.originalName];}o.loadWeights(s),Object(r.dispose)(a),c.label=2;case 2:return [2,o];}});});}});var Yi=Object.freeze({l1l2:function l1l2(t){return new rr(t);},l1:function l1(t){return function(t){return er(t),new rr({l1:null!=t?t.l1:null,l2:0});}(t);},l2:function l2(t){return function(t){return er(t),new rr({l2:null!=t?t.l2:null,l1:0});}(t);}}),Ji=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.model=null,e;}return o(e,t),e.prototype.setModel=function(t){if(!(t instanceof Tn))throw new Error("model must be a LayersModel, not some other Container");this.model=t;},e;}(we);function Qi(t,e){return t<e;}function Zi(t,e){return t>e;}var to=function(t){function e(e){var n=t.call(this)||this;if(null==e&&(e={}),e.restoreBestWeights)throw new p("restoreBestWeights = True is not implemented in EarlyStopping yet.");return n.monitor=e.monitor||"val_loss",n.minDelta=Math.abs(e.minDelta||0),n.patience=e.patience||0,n.verbose=e.verbose||0,n.mode=e.mode||"auto",n.baseline=e.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=Qi:"max"===n.mode?n.monitorFunc=Zi:-1!==n.monitor.indexOf("acc")?n.monitorFunc=Zi:n.monitorFunc=Qi,n.monitorFunc===Qi&&(n.minDelta*=-1),n;}return o(e,t),e.prototype.onTrainBegin=function(t){return u(this,void 0,void 0,function(){return c(this,function(t){return this.wait=0,this.stoppedEpoch=0,null!=this.baseline?this.best=this.baseline:this.best=this.monitorFunc===Qi?1/0:-1/0,[2];});});},e.prototype.onEpochEnd=function(t,e){return u(this,void 0,void 0,function(){var n;return c(this,function(r){switch(r.label){case 0:return [4,ye(e)];case 1:return r.sent(),null==(n=this.getMonitorValue(e))?[2]:(this.monitorFunc(n-this.minDelta,this.best)?(this.best=n,this.wait=0):(this.wait++,this.wait>=this.patience&&(this.stoppedEpoch=t,this.model.stopTraining=!0)),[2]);}});});},e.prototype.onTrainEnd=function(t){return u(this,void 0,void 0,function(){return c(this,function(t){return this.stoppedEpoch>0&&this.verbose&&console.log("Epoch "+this.stoppedEpoch+": early stopping."),[2];});});},e.prototype.getMonitorValue=function(t){null==t&&(t={});var e=t[this.monitor];return null==e&&console.warn("Metric for EarlyStopping "+this.monitor+" is not available. Available metrics are: "+Object.keys(t)),e;},e;}(Ji);var eo={earlyStopping:function earlyStopping(t){return new to(t);}},no=n(20),ro=n(130);n.d(e,"version",function(){return io;}),n.d(e,"AdadeltaOptimizer",function(){return r.AdadeltaOptimizer;}),n.d(e,"AdagradOptimizer",function(){return r.AdagradOptimizer;}),n.d(e,"AdamOptimizer",function(){return r.AdamOptimizer;}),n.d(e,"AdamaxOptimizer",function(){return r.AdamaxOptimizer;}),n.d(e,"Add",function(){return r.Add;}),n.d(e,"AddN",function(){return r.AddN;}),n.d(e,"BroadcastTo",function(){return r.BroadcastTo;}),n.d(e,"DataStorage",function(){return r.DataStorage;}),n.d(e,"Div",function(){return r.Div;}),n.d(e,"ENV",function(){return r.ENV;}),n.d(e,"Environment",function(){return r.Environment;}),n.d(e,"FromPixels",function(){return r.FromPixels;}),n.d(e,"FusedBatchNorm",function(){return r.FusedBatchNorm;}),n.d(e,"Identity",function(){return r.Identity;}),n.d(e,"KernelBackend",function(){return r.KernelBackend;}),n.d(e,"MaxPoolWithArgmax",function(){return r.MaxPoolWithArgmax;}),n.d(e,"MomentumOptimizer",function(){return r.MomentumOptimizer;}),n.d(e,"NonMaxSuppressionV5",function(){return r.NonMaxSuppressionV5;}),n.d(e,"OneHot",function(){return r.OneHot;}),n.d(e,"Optimizer",function(){return r.Optimizer;}),n.d(e,"PadV2",function(){return r.PadV2;}),n.d(e,"RMSPropOptimizer",function(){return r.RMSPropOptimizer;}),n.d(e,"Rank",function(){return r.Rank;}),n.d(e,"Reduction",function(){return r.Reduction;}),n.d(e,"SGDOptimizer",function(){return r.SGDOptimizer;}),n.d(e,"Square",function(){return r.Square;}),n.d(e,"SquaredDifference",function(){return r.SquaredDifference;}),n.d(e,"Tensor",function(){return r.Tensor;}),n.d(e,"TensorBuffer",function(){return r.TensorBuffer;}),n.d(e,"Tile",function(){return r.Tile;}),n.d(e,"Transpose",function(){return r.Transpose;}),n.d(e,"Variable",function(){return r.Variable;}),n.d(e,"abs",function(){return r.abs;}),n.d(e,"acos",function(){return r.acos;}),n.d(e,"acosh",function(){return r.acosh;}),n.d(e,"add",function(){return r.add;}),n.d(e,"addN",function(){return r.addN;}),n.d(e,"addStrict",function(){return r.addStrict;}),n.d(e,"all",function(){return r.all;}),n.d(e,"any",function(){return r.any;}),n.d(e,"argMax",function(){return r.argMax;}),n.d(e,"argMin",function(){return r.argMin;}),n.d(e,"asin",function(){return r.asin;}),n.d(e,"asinh",function(){return r.asinh;}),n.d(e,"atan",function(){return r.atan;}),n.d(e,"atan2",function(){return r.atan2;}),n.d(e,"atanh",function(){return r.atanh;}),n.d(e,"avgPool",function(){return r.avgPool;}),n.d(e,"avgPool3d",function(){return r.avgPool3d;}),n.d(e,"backend",function(){return r.backend;}),n.d(e,"backend_util",function(){return r.backend_util;}),n.d(e,"basicLSTMCell",function(){return r.basicLSTMCell;}),n.d(e,"batchNorm",function(){return r.batchNorm;}),n.d(e,"batchNorm2d",function(){return r.batchNorm2d;}),n.d(e,"batchNorm3d",function(){return r.batchNorm3d;}),n.d(e,"batchNorm4d",function(){return r.batchNorm4d;}),n.d(e,"batchNormalization",function(){return r.batchNormalization;}),n.d(e,"batchNormalization2d",function(){return r.batchNormalization2d;}),n.d(e,"batchNormalization3d",function(){return r.batchNormalization3d;}),n.d(e,"batchNormalization4d",function(){return r.batchNormalization4d;}),n.d(e,"batchToSpaceND",function(){return r.batchToSpaceND;}),n.d(e,"booleanMaskAsync",function(){return r.booleanMaskAsync;}),n.d(e,"broadcastTo",function(){return r.broadcastTo;}),n.d(e,"browser",function(){return r.browser;}),n.d(e,"buffer",function(){return r.buffer;}),n.d(e,"cast",function(){return r.cast;}),n.d(e,"ceil",function(){return r.ceil;}),n.d(e,"clipByValue",function(){return r.clipByValue;}),n.d(e,"clone",function(){return r.clone;}),n.d(e,"complex",function(){return r.complex;}),n.d(e,"concat",function(){return r.concat;}),n.d(e,"concat1d",function(){return r.concat1d;}),n.d(e,"concat2d",function(){return r.concat2d;}),n.d(e,"concat3d",function(){return r.concat3d;}),n.d(e,"concat4d",function(){return r.concat4d;}),n.d(e,"conv1d",function(){return r.conv1d;}),n.d(e,"conv2d",function(){return r.conv2d;}),n.d(e,"conv2dTranspose",function(){return r.conv2dTranspose;}),n.d(e,"conv3d",function(){return r.conv3d;}),n.d(e,"conv3dTranspose",function(){return r.conv3dTranspose;}),n.d(e,"cos",function(){return r.cos;}),n.d(e,"cosh",function(){return r.cosh;}),n.d(e,"cumsum",function(){return r.cumsum;}),n.d(e,"customGrad",function(){return r.customGrad;}),n.d(e,"deprecationWarn",function(){return r.deprecationWarn;}),n.d(e,"depthToSpace",function(){return r.depthToSpace;}),n.d(e,"depthwiseConv2d",function(){return r.depthwiseConv2d;}),n.d(e,"diag",function(){return r.diag;}),n.d(e,"disableDeprecationWarnings",function(){return r.disableDeprecationWarnings;}),n.d(e,"dispose",function(){return r.dispose;}),n.d(e,"disposeVariables",function(){return r.disposeVariables;}),n.d(e,"div",function(){return r.div;}),n.d(e,"divNoNan",function(){return r.divNoNan;}),n.d(e,"divStrict",function(){return r.divStrict;}),n.d(e,"dot",function(){return r.dot;}),n.d(e,"dropout",function(){return r.dropout;}),n.d(e,"elu",function(){return r.elu;}),n.d(e,"enableDebugMode",function(){return r.enableDebugMode;}),n.d(e,"enableProdMode",function(){return r.enableProdMode;}),n.d(e,"engine",function(){return r.engine;}),n.d(e,"env",function(){return r.env;}),n.d(e,"equal",function(){return r.equal;}),n.d(e,"equalStrict",function(){return r.equalStrict;}),n.d(e,"erf",function(){return r.erf;}),n.d(e,"exp",function(){return r.exp;}),n.d(e,"expandDims",function(){return r.expandDims;}),n.d(e,"expm1",function(){return r.expm1;}),n.d(e,"eye",function(){return r.eye;}),n.d(e,"fft",function(){return r.fft;}),n.d(e,"fill",function(){return r.fill;}),n.d(e,"findBackend",function(){return r.findBackend;}),n.d(e,"findBackendFactory",function(){return r.findBackendFactory;}),n.d(e,"floor",function(){return r.floor;}),n.d(e,"floorDiv",function(){return r.floorDiv;}),n.d(e,"frame",function(){return r.frame;}),n.d(e,"fused",function(){return r.fused;}),n.d(e,"gather",function(){return r.gather;}),n.d(e,"gatherND",function(){return r.gatherND;}),n.d(e,"gather_util",function(){return r.gather_util;}),n.d(e,"getBackend",function(){return r.getBackend;}),n.d(e,"getGradient",function(){return r.getGradient;}),n.d(e,"getKernel",function(){return r.getKernel;}),n.d(e,"getKernelsForBackend",function(){return r.getKernelsForBackend;}),n.d(e,"grad",function(){return r.grad;}),n.d(e,"grads",function(){return r.grads;}),n.d(e,"greater",function(){return r.greater;}),n.d(e,"greaterEqual",function(){return r.greaterEqual;}),n.d(e,"greaterEqualStrict",function(){return r.greaterEqualStrict;}),n.d(e,"greaterStrict",function(){return r.greaterStrict;}),n.d(e,"hammingWindow",function(){return r.hammingWindow;}),n.d(e,"hannWindow",function(){return r.hannWindow;}),n.d(e,"ifft",function(){return r.ifft;}),n.d(e,"imag",function(){return r.imag;}),n.d(e,"image",function(){return r.image;}),n.d(e,"inTopKAsync",function(){return r.inTopKAsync;}),n.d(e,"io",function(){return r.io;}),n.d(e,"irfft",function(){return r.irfft;}),n.d(e,"isFinite",function(){return r.isFinite;}),n.d(e,"isInf",function(){return r.isInf;}),n.d(e,"isNaN",function(){return r.isNaN;}),n.d(e,"keep",function(){return r.keep;}),n.d(e,"leakyRelu",function(){return r.leakyRelu;}),n.d(e,"less",function(){return r.less;}),n.d(e,"lessEqual",function(){return r.lessEqual;}),n.d(e,"lessEqualStrict",function(){return r.lessEqualStrict;}),n.d(e,"lessStrict",function(){return r.lessStrict;}),n.d(e,"linalg",function(){return r.linalg;}),n.d(e,"linspace",function(){return r.linspace;}),n.d(e,"localResponseNormalization",function(){return r.localResponseNormalization;}),n.d(e,"log",function(){return r.log;}),n.d(e,"log1p",function(){return r.log1p;}),n.d(e,"logSigmoid",function(){return r.logSigmoid;}),n.d(e,"logSoftmax",function(){return r.logSoftmax;}),n.d(e,"logSumExp",function(){return r.logSumExp;}),n.d(e,"logicalAnd",function(){return r.logicalAnd;}),n.d(e,"logicalNot",function(){return r.logicalNot;}),n.d(e,"logicalOr",function(){return r.logicalOr;}),n.d(e,"logicalXor",function(){return r.logicalXor;}),n.d(e,"losses",function(){return r.losses;}),n.d(e,"matMul",function(){return r.matMul;}),n.d(e,"math",function(){return r.math;}),n.d(e,"max",function(){return r.max;}),n.d(e,"maxPool",function(){return r.maxPool;}),n.d(e,"maxPool3d",function(){return r.maxPool3d;}),n.d(e,"maxPoolWithArgmax",function(){return r.maxPoolWithArgmax;}),n.d(e,"maximum",function(){return r.maximum;}),n.d(e,"maximumStrict",function(){return r.maximumStrict;}),n.d(e,"mean",function(){return r.mean;}),n.d(e,"memory",function(){return r.memory;}),n.d(e,"min",function(){return r.min;}),n.d(e,"minimum",function(){return r.minimum;}),n.d(e,"minimumStrict",function(){return r.minimumStrict;}),n.d(e,"mod",function(){return r.mod;}),n.d(e,"modStrict",function(){return r.modStrict;}),n.d(e,"moments",function(){return r.moments;}),n.d(e,"movingAverage",function(){return r.movingAverage;}),n.d(e,"mul",function(){return r.mul;}),n.d(e,"mulStrict",function(){return r.mulStrict;}),n.d(e,"multiRNNCell",function(){return r.multiRNNCell;}),n.d(e,"multinomial",function(){return r.multinomial;}),n.d(e,"neg",function(){return r.neg;}),n.d(e,"nextFrame",function(){return r.nextFrame;}),n.d(e,"norm",function(){return r.norm;}),n.d(e,"notEqual",function(){return r.notEqual;}),n.d(e,"notEqualStrict",function(){return r.notEqualStrict;}),n.d(e,"oneHot",function(){return r.oneHot;}),n.d(e,"ones",function(){return r.ones;}),n.d(e,"onesLike",function(){return r.onesLike;}),n.d(e,"op",function(){return r.op;}),n.d(e,"outerProduct",function(){return r.outerProduct;}),n.d(e,"pad",function(){return r.pad;}),n.d(e,"pad1d",function(){return r.pad1d;}),n.d(e,"pad2d",function(){return r.pad2d;}),n.d(e,"pad3d",function(){return r.pad3d;}),n.d(e,"pad4d",function(){return r.pad4d;}),n.d(e,"pool",function(){return r.pool;}),n.d(e,"pow",function(){return r.pow;}),n.d(e,"powStrict",function(){return r.powStrict;}),n.d(e,"prelu",function(){return r.prelu;}),n.d(e,"print",function(){return r.print;}),n.d(e,"prod",function(){return r.prod;}),n.d(e,"profile",function(){return r.profile;}),n.d(e,"rand",function(){return r.rand;}),n.d(e,"randomGamma",function(){return r.randomGamma;}),n.d(e,"randomNormal",function(){return r.randomNormal;}),n.d(e,"randomUniform",function(){return r.randomUniform;}),n.d(e,"range",function(){return r.range;}),n.d(e,"ready",function(){return r.ready;}),n.d(e,"real",function(){return r.real;}),n.d(e,"reciprocal",function(){return r.reciprocal;}),n.d(e,"registerBackend",function(){return r.registerBackend;}),n.d(e,"registerGradient",function(){return r.registerGradient;}),n.d(e,"registerKernel",function(){return r.registerKernel;}),n.d(e,"relu",function(){return r.relu;}),n.d(e,"relu6",function(){return r.relu6;}),n.d(e,"removeBackend",function(){return r.removeBackend;}),n.d(e,"reshape",function(){return r.reshape;}),n.d(e,"reverse",function(){return r.reverse;}),n.d(e,"reverse1d",function(){return r.reverse1d;}),n.d(e,"reverse2d",function(){return r.reverse2d;}),n.d(e,"reverse3d",function(){return r.reverse3d;}),n.d(e,"reverse4d",function(){return r.reverse4d;}),n.d(e,"rfft",function(){return r.rfft;}),n.d(e,"round",function(){return r.round;}),n.d(e,"rsqrt",function(){return r.rsqrt;}),n.d(e,"scalar",function(){return r.scalar;}),n.d(e,"scatterND",function(){return r.scatterND;}),n.d(e,"scatter_util",function(){return r.scatter_util;}),n.d(e,"selu",function(){return r.selu;}),n.d(e,"separableConv2d",function(){return r.separableConv2d;}),n.d(e,"serialization",function(){return r.serialization;}),n.d(e,"setBackend",function(){return r.setBackend;}),n.d(e,"setPlatform",function(){return r.setPlatform;}),n.d(e,"setdiff1dAsync",function(){return r.setdiff1dAsync;}),n.d(e,"sigmoid",function(){return r.sigmoid;}),n.d(e,"sign",function(){return r.sign;}),n.d(e,"signal",function(){return r.signal;}),n.d(e,"sin",function(){return r.sin;}),n.d(e,"sinh",function(){return r.sinh;}),n.d(e,"slice",function(){return r.slice;}),n.d(e,"slice1d",function(){return r.slice1d;}),n.d(e,"slice2d",function(){return r.slice2d;}),n.d(e,"slice3d",function(){return r.slice3d;}),n.d(e,"slice4d",function(){return r.slice4d;}),n.d(e,"slice_util",function(){return r.slice_util;}),n.d(e,"softmax",function(){return r.softmax;}),n.d(e,"softplus",function(){return r.softplus;}),n.d(e,"spaceToBatchND",function(){return r.spaceToBatchND;}),n.d(e,"sparseToDense",function(){return r.sparseToDense;}),n.d(e,"spectral",function(){return r.spectral;}),n.d(e,"split",function(){return r.split;}),n.d(e,"sqrt",function(){return r.sqrt;}),n.d(e,"square",function(){return r.square;}),n.d(e,"squaredDifference",function(){return r.squaredDifference;}),n.d(e,"squaredDifferenceStrict",function(){return r.squaredDifferenceStrict;}),n.d(e,"squeeze",function(){return r.squeeze;}),n.d(e,"stack",function(){return r.stack;}),n.d(e,"step",function(){return r.step;}),n.d(e,"stft",function(){return r.stft;}),n.d(e,"stridedSlice",function(){return r.stridedSlice;}),n.d(e,"sub",function(){return r.sub;}),n.d(e,"subStrict",function(){return r.subStrict;}),n.d(e,"sum",function(){return r.sum;}),n.d(e,"sumOutType",function(){return r.sumOutType;}),n.d(e,"tan",function(){return r.tan;}),n.d(e,"tanh",function(){return r.tanh;}),n.d(e,"tensor",function(){return r.tensor;}),n.d(e,"tensor1d",function(){return r.tensor1d;}),n.d(e,"tensor2d",function(){return r.tensor2d;}),n.d(e,"tensor3d",function(){return r.tensor3d;}),n.d(e,"tensor4d",function(){return r.tensor4d;}),n.d(e,"tensor5d",function(){return r.tensor5d;}),n.d(e,"tensor6d",function(){return r.tensor6d;}),n.d(e,"tensor_util",function(){return r.tensor_util;}),n.d(e,"test_util",function(){return r.test_util;}),n.d(e,"tidy",function(){return r.tidy;}),n.d(e,"tile",function(){return r.tile;}),n.d(e,"time",function(){return r.time;}),n.d(e,"topk",function(){return r.topk;}),n.d(e,"train",function(){return r.train;}),n.d(e,"transpose",function(){return r.transpose;}),n.d(e,"truncatedNormal",function(){return r.truncatedNormal;}),n.d(e,"unregisterGradient",function(){return r.unregisterGradient;}),n.d(e,"unregisterKernel",function(){return r.unregisterKernel;}),n.d(e,"unsortedSegmentSum",function(){return r.unsortedSegmentSum;}),n.d(e,"unstack",function(){return r.unstack;}),n.d(e,"util",function(){return r.util;}),n.d(e,"valueAndGrad",function(){return r.valueAndGrad;}),n.d(e,"valueAndGrads",function(){return r.valueAndGrads;}),n.d(e,"variable",function(){return r.variable;}),n.d(e,"variableGrads",function(){return r.variableGrads;}),n.d(e,"version_core",function(){return r.version_core;}),n.d(e,"webgl",function(){return r.webgl;}),n.d(e,"where",function(){return r.where;}),n.d(e,"whereAsync",function(){return r.whereAsync;}),n.d(e,"zeros",function(){return r.zeros;}),n.d(e,"zerosLike",function(){return r.zerosLike;}),n.d(e,"constraints",function(){return V;}),n.d(e,"initializers",function(){return Xt;}),n.d(e,"layers",function(){return Gi;}),n.d(e,"metrics",function(){return Ki;}),n.d(e,"models",function(){return Xi;}),n.d(e,"regularizers",function(){return Yi;}),n.d(e,"CallbackList",function(){return ke;}),n.d(e,"CustomCallback",function(){return Ae;}),n.d(e,"History",function(){return Ce;}),n.d(e,"Callback",function(){return Ji;}),n.d(e,"callbacks",function(){return eo;}),n.d(e,"EarlyStopping",function(){return to;}),n.d(e,"InputSpec",function(){return ce;}),n.d(e,"SymbolicTensor",function(){return le;}),n.d(e,"LayersModel",function(){return Tn;}),n.d(e,"input",function(){return Bn;}),n.d(e,"loadLayersModel",function(){return jn;}),n.d(e,"model",function(){return Rn;}),n.d(e,"registerCallbackConstructor",function(){return Pn;}),n.d(e,"sequential",function(){return Mn;}),n.d(e,"RNN",function(){return ki;}),n.d(e,"Sequential",function(){return In;}),n.d(e,"LayerVariable",function(){return ae;}),n.d(e,"version_layers",function(){return "1.7.4";}),n.d(e,"GraphModel",function(){return no.GraphModel;}),n.d(e,"loadGraphModel",function(){return no.loadGraphModel;}),n.d(e,"deregisterOp",function(){return no.deregisterOp;}),n.d(e,"registerOp",function(){return no.registerOp;}),n.d(e,"version_converter",function(){return no.version_converter;}),n.d(e,"data",function(){return ro;});var io={"tfjs-core":r.version_core,"tfjs-data":ro.version_data,"tfjs-layers":"1.7.4","tfjs-converter":no.version_converter,tfjs:"1.7.4"};},function(t,e,n){n.r(e),function(t,r,i,o){n.d(e,"AdadeltaOptimizer",function(){return nh;}),n.d(e,"AdagradOptimizer",function(){return rh;}),n.d(e,"AdamOptimizer",function(){return ih;}),n.d(e,"AdamaxOptimizer",function(){return oh;}),n.d(e,"DataStorage",function(){return ki;}),n.d(e,"ENV",function(){return h;}),n.d(e,"Environment",function(){return l;}),n.d(e,"KernelBackend",function(){return Ei;}),n.d(e,"MomentumOptimizer",function(){return sh;}),n.d(e,"Optimizer",function(){return eh;}),n.d(e,"RMSPropOptimizer",function(){return uh;}),n.d(e,"Rank",function(){return Ot;}),n.d(e,"Reduction",function(){return Hc;}),n.d(e,"SGDOptimizer",function(){return ah;}),n.d(e,"Tensor",function(){return At;}),n.d(e,"TensorBuffer",function(){return wt;}),n.d(e,"Variable",function(){return Tt;}),n.d(e,"abs",function(){return $a;}),n.d(e,"acos",function(){return Ha;}),n.d(e,"acosh",function(){return Ga;}),n.d(e,"add",function(){return $s;}),n.d(e,"addN",function(){return Hs;}),n.d(e,"addStrict",function(){return Gs;}),n.d(e,"all",function(){return lc;}),n.d(e,"any",function(){return fc;}),n.d(e,"argMax",function(){return hc;}),n.d(e,"argMin",function(){return dc;}),n.d(e,"asin",function(){return Ka;}),n.d(e,"asinh",function(){return Xa;}),n.d(e,"atan",function(){return Ya;}),n.d(e,"atan2",function(){return Ks;}),n.d(e,"atanh",function(){return Ja;}),n.d(e,"avgPool",function(){return tc;}),n.d(e,"avgPool3d",function(){return rc;}),n.d(e,"backend",function(){return mn;}),n.d(e,"backend_util",function(){return Vi;}),n.d(e,"basicLSTMCell",function(){return Fc;}),n.d(e,"batchNorm",function(){return Ms;}),n.d(e,"batchNorm2d",function(){return js;}),n.d(e,"batchNorm3d",function(){return Bs;}),n.d(e,"batchNorm4d",function(){return Ps;}),n.d(e,"batchNormalization",function(){return Rs;}),n.d(e,"batchNormalization2d",function(){return Ts;}),n.d(e,"batchNormalization3d",function(){return Ns;}),n.d(e,"batchNormalization4d",function(){return Is;}),n.d(e,"batchToSpaceND",function(){return br;}),n.d(e,"booleanMaskAsync",function(){return Su;}),n.d(e,"broadcastTo",function(){return xr;}),n.d(e,"browser",function(){return Wf;}),n.d(e,"buffer",function(){return vr;}),n.d(e,"cast",function(){return wr;}),n.d(e,"ceil",function(){return Qa;}),n.d(e,"clipByValue",function(){return Za;}),n.d(e,"clone",function(){return kr;}),n.d(e,"complex",function(){return In;}),n.d(e,"concat",function(){return Zn;}),n.d(e,"concat1d",function(){return tr;}),n.d(e,"concat2d",function(){return er;}),n.d(e,"concat3d",function(){return nr;}),n.d(e,"concat4d",function(){return rr;}),n.d(e,"conv1d",function(){return Nu;}),n.d(e,"conv2d",function(){return Iu;}),n.d(e,"conv2dTranspose",function(){return Uu;}),n.d(e,"conv3d",function(){return Ru;}),n.d(e,"conv3dTranspose",function(){return Wu;}),n.d(e,"cos",function(){return ts;}),n.d(e,"cosh",function(){return es;}),n.d(e,"cumsum",function(){return Er;}),n.d(e,"customGrad",function(){return yi;}),n.d(e,"deprecationWarn",function(){return Qe;}),n.d(e,"depthToSpace",function(){return Cr;}),n.d(e,"depthwiseConv2d",function(){return Bu;}),n.d(e,"diag",function(){return Vc;}),n.d(e,"disableDeprecationWarnings",function(){return Je;}),n.d(e,"dispose",function(){return on;}),n.d(e,"disposeVariables",function(){return Ze;}),n.d(e,"div",function(){return Xs;}),n.d(e,"divNoNan",function(){return Ys;}),n.d(e,"divStrict",function(){return Js;}),n.d(e,"dot",function(){return qu;}),n.d(e,"dropout",function(){return qc;}),n.d(e,"elu",function(){return wc;}),n.d(e,"enableDebugMode",function(){return Ye;}),n.d(e,"enableProdMode",function(){return Xe;}),n.d(e,"engine",function(){return tn;}),n.d(e,"env",function(){return f;}),n.d(e,"equal",function(){return hu;}),n.d(e,"equalStrict",function(){return du;}),n.d(e,"erf",function(){return ns;}),n.d(e,"exp",function(){return rs;}),n.d(e,"expandDims",function(){return Ar;}),n.d(e,"expm1",function(){return is;}),n.d(e,"eye",function(){return Or;}),n.d(e,"fft",function(){return jc;}),n.d(e,"fill",function(){return Kn;}),n.d(e,"findBackend",function(){return hn;}),n.d(e,"findBackendFactory",function(){return dn;}),n.d(e,"floor",function(){return os;}),n.d(e,"floorDiv",function(){return Qs;}),n.d(e,"frame",function(){return Xc;}),n.d(e,"fused",function(){return Sl;}),n.d(e,"gather",function(){return Ou;}),n.d(e,"gatherND",function(){return Wc;}),n.d(e,"gather_util",function(){return Qr;}),n.d(e,"getBackend",function(){return ln;}),n.d(e,"getGradient",function(){return g;}),n.d(e,"getKernel",function(){return m;}),n.d(e,"getKernelsForBackend",function(){return v;}),n.d(e,"grad",function(){return di;}),n.d(e,"grads",function(){return pi;}),n.d(e,"greater",function(){return pu;}),n.d(e,"greaterEqual",function(){return mu;}),n.d(e,"greaterEqualStrict",function(){return gu;}),n.d(e,"greaterStrict",function(){return vu;}),n.d(e,"hammingWindow",function(){return Kc;}),n.d(e,"hannWindow",function(){return Gc;}),n.d(e,"ifft",function(){return Bc;}),n.d(e,"imag",function(){return Mn;}),n.d(e,"image",function(){return xl;}),n.d(e,"inTopKAsync",function(){return Qc;}),n.d(e,"io",function(){return Pf;}),n.d(e,"irfft",function(){return Lc;}),n.d(e,"isFinite",function(){return vs;}),n.d(e,"isInf",function(){return gs;}),n.d(e,"isNaN",function(){return ms;}),n.d(e,"keep",function(){return an;}),n.d(e,"leakyRelu",function(){return kc;}),n.d(e,"less",function(){return yu;}),n.d(e,"lessEqual",function(){return bu;}),n.d(e,"lessEqualStrict",function(){return xu;}),n.d(e,"lessStrict",function(){return wu;}),n.d(e,"linalg",function(){return dl;}),n.d(e,"linspace",function(){return Xn;}),n.d(e,"localResponseNormalization",function(){return Sc;}),n.d(e,"log",function(){return as;}),n.d(e,"log1p",function(){return ss;}),n.d(e,"logSigmoid",function(){return us;}),n.d(e,"logSoftmax",function(){return wi;}),n.d(e,"logSumExp",function(){return pc;}),n.d(e,"logicalAnd",function(){return Ls;}),n.d(e,"logicalNot",function(){return zs;}),n.d(e,"logicalOr",function(){return Us;}),n.d(e,"logicalXor",function(){return Ws;}),n.d(e,"losses",function(){return ul;}),n.d(e,"matMul",function(){return Vu;}),n.d(e,"math",function(){return zf;}),n.d(e,"max",function(){return mc;}),n.d(e,"maxPool",function(){return Zu;}),n.d(e,"maxPool3d",function(){return nc;}),n.d(e,"maximum",function(){return Zs;}),n.d(e,"maximumStrict",function(){return tu;}),n.d(e,"mean",function(){return gc;}),n.d(e,"memory",function(){return en;}),n.d(e,"min",function(){return vc;}),n.d(e,"minimum",function(){return eu;}),n.d(e,"minimumStrict",function(){return nu;}),n.d(e,"mod",function(){return ru;}),n.d(e,"modStrict",function(){return iu;}),n.d(e,"moments",function(){return yc;}),n.d(e,"movingAverage",function(){return Nc;}),n.d(e,"mul",function(){return ou;}),n.d(e,"mulStrict",function(){return au;}),n.d(e,"multiRNNCell",function(){return Tc;}),n.d(e,"multinomial",function(){return _r;}),n.d(e,"neg",function(){return cs;}),n.d(e,"nextFrame",function(){return hh;}),n.d(e,"norm",function(){return Dc;}),n.d(e,"notEqual",function(){return ku;}),n.d(e,"notEqualStrict",function(){return Eu;}),n.d(e,"oneHot",function(){return Sr;}),n.d(e,"ones",function(){return Hn;}),n.d(e,"onesLike",function(){return Jn;}),n.d(e,"op",function(){return Nn;}),n.d(e,"outerProduct",function(){return $u;}),n.d(e,"pad",function(){return Dr;}),n.d(e,"pad1d",function(){return Fr;}),n.d(e,"pad2d",function(){return Tr;}),n.d(e,"pad3d",function(){return Nr;}),n.d(e,"pad4d",function(){return Ir;}),n.d(e,"pool",function(){return ec;}),n.d(e,"pow",function(){return su;}),n.d(e,"powStrict",function(){return uu;}),n.d(e,"prelu",function(){return Ec;}),n.d(e,"print",function(){return yr;}),n.d(e,"prod",function(){return xc;}),n.d(e,"profile",function(){return nn;}),n.d(e,"rand",function(){return Rr;}),n.d(e,"randomGamma",function(){return jr;}),n.d(e,"randomNormal",function(){return Mr;}),n.d(e,"randomUniform",function(){return Br;}),n.d(e,"range",function(){return Yn;}),n.d(e,"ready",function(){return cn;}),n.d(e,"real",function(){return Rn;}),n.d(e,"reciprocal",function(){return ls;}),n.d(e,"registerBackend",function(){return pn;}),n.d(e,"registerGradient",function(){return b;}),n.d(e,"registerKernel",function(){return y;}),n.d(e,"relu",function(){return Cc;}),n.d(e,"relu6",function(){return Ac;}),n.d(e,"removeBackend",function(){return fn;}),n.d(e,"reshape",function(){return Pr;}),n.d(e,"reverse",function(){return Hu;}),n.d(e,"reverse1d",function(){return Gu;}),n.d(e,"reverse2d",function(){return Ku;}),n.d(e,"reverse3d",function(){return Xu;}),n.d(e,"reverse4d",function(){return Yu;}),n.d(e,"rfft",function(){return Pc;}),n.d(e,"round",function(){return fs;}),n.d(e,"rsqrt",function(){return hs;}),n.d(e,"scalar",function(){return Pn;}),n.d(e,"scatterND",function(){return Mc;}),n.d(e,"scatter_util",function(){return ii;}),n.d(e,"selu",function(){return Oc;}),n.d(e,"separableConv2d",function(){return zu;}),n.d(e,"serialization",function(){return Hf;}),n.d(e,"setBackend",function(){return un;}),n.d(e,"setPlatform",function(){return gn;}),n.d(e,"setdiff1dAsync",function(){return $r;}),n.d(e,"sigmoid",function(){return ds;}),n.d(e,"sign",function(){return ps;}),n.d(e,"signal",function(){return Jc;}),n.d(e,"sin",function(){return ys;}),n.d(e,"sinh",function(){return bs;}),n.d(e,"slice",function(){return ic;}),n.d(e,"slice1d",function(){return oc;}),n.d(e,"slice2d",function(){return ac;}),n.d(e,"slice3d",function(){return sc;}),n.d(e,"slice4d",function(){return uc;}),n.d(e,"slice_util",function(){return hi;}),n.d(e,"softmax",function(){return xi;}),n.d(e,"softplus",function(){return xs;}),n.d(e,"spaceToBatchND",function(){return Lr;}),n.d(e,"sparseToDense",function(){return Uc;}),n.d(e,"spectral",function(){return zc;}),n.d(e,"split",function(){return ir;}),n.d(e,"sqrt",function(){return ws;}),n.d(e,"square",function(){return Wa;}),n.d(e,"squaredDifference",function(){return qa;}),n.d(e,"squaredDifferenceStrict",function(){return cu;}),n.d(e,"squeeze",function(){return zr;}),n.d(e,"stack",function(){return Ur;}),n.d(e,"step",function(){return ks;}),n.d(e,"stft",function(){return Yc;}),n.d(e,"stridedSlice",function(){return Ic;}),n.d(e,"sub",function(){return lu;}),n.d(e,"subStrict",function(){return fu;}),n.d(e,"sum",function(){return bc;}),n.d(e,"sumOutType",function(){return Rt;}),n.d(e,"tan",function(){return Es;}),n.d(e,"tanh",function(){return Cs;}),n.d(e,"tensor",function(){return jn;}),n.d(e,"tensor1d",function(){return Ln;}),n.d(e,"tensor2d",function(){return zn;}),n.d(e,"tensor3d",function(){return Un;}),n.d(e,"tensor4d",function(){return Wn;}),n.d(e,"tensor5d",function(){return Vn;}),n.d(e,"tensor6d",function(){return qn;}),n.d(e,"tensor_util",function(){return Lt;}),n.d(e,"test_util",function(){return Qf;}),n.d(e,"tidy",function(){return rn;}),n.d(e,"tile",function(){return Wr;}),n.d(e,"time",function(){return sn;}),n.d(e,"topk",function(){return Rc;}),n.d(e,"train",function(){return lh;}),n.d(e,"transpose",function(){return _c;}),n.d(e,"truncatedNormal",function(){return Vr;}),n.d(e,"unregisterGradient",function(){return w;}),n.d(e,"unregisterKernel",function(){return x;}),n.d(e,"unsortedSegmentSum",function(){return _u;}),n.d(e,"unstack",function(){return qr;}),n.d(e,"util",function(){return ht;}),n.d(e,"valueAndGrad",function(){return mi;}),n.d(e,"valueAndGrads",function(){return gi;}),n.d(e,"variable",function(){return $n;}),n.d(e,"variableGrads",function(){return vi;}),n.d(e,"version_core",function(){return Zf;}),n.d(e,"webgl",function(){return th;}),n.d(e,"where",function(){return Vs;}),n.d(e,"whereAsync",function(){return qs;}),n.d(e,"zeros",function(){return Gn;}),n.d(e,"zerosLike",function(){return Qn;});/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var _a5=function a(t,e){return (_a5=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e;}||function(t,e){for(var n in e){e.hasOwnProperty(n)&&(t[n]=e[n]);}})(t,e);};function s(t,e){function n(){this.constructor=t;}_a5(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n());}function u(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});}function c(t,e){var n,r,i,o,a={label:0,sent:function sent(){if(1&i[0])throw i[1];return i[1];},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this;}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;){try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue;}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break;}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break;}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break;}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(t,a);}catch(t){o=[6,t],r=0;}finally{n=i=0;}}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:!0};}([o,s]);};}}var l=function(){function t(t){this.global=t,this.flags={},this.flagRegistry={},this.urlFlags={},this.populateURLFlags();}return t.prototype.setPlatform=function(t,e){null!=this.platform&&console.warn("Platform "+this.platformName+" has already been set. Overwriting the platform with "+e+"."),this.platformName=t,this.platform=e;},t.prototype.registerFlag=function(t,e,n){if(this.flagRegistry[t]={evaluationFn:e,setHook:n},null!=this.urlFlags[t]){var r=this.urlFlags[t];console.warn("Setting feature override from URL "+t+": "+r+"."),this.set(t,r);}},t.prototype.get=function(t){return t in this.flags?this.flags[t]:(this.flags[t]=this.evaluateFlag(t),this.flags[t]);},t.prototype.getNumber=function(t){return this.get(t);},t.prototype.getBool=function(t){return this.get(t);},t.prototype.getFlags=function(){return this.flags;},Object.defineProperty(t.prototype,"features",{get:function get(){return this.flags;},enumerable:!0,configurable:!0}),t.prototype.set=function(t,e){if(null==this.flagRegistry[t])throw new Error("Cannot set flag "+t+" as it has not been registered.");this.flags[t]=e,null!=this.flagRegistry[t].setHook&&this.flagRegistry[t].setHook(e);},t.prototype.evaluateFlag=function(t){if(null==this.flagRegistry[t])throw new Error("Cannot evaluate flag '"+t+"': no evaluation function found.");return this.flagRegistry[t].evaluationFn();},t.prototype.setFlags=function(t){this.flags=Object.assign({},t);},t.prototype.reset=function(){this.flags={},this.urlFlags={},this.populateURLFlags();},t.prototype.populateURLFlags=function(){var t=this;if(void 0!==this.global&&void 0!==this.global.location&&void 0!==this.global.location.search){var e,n,r=(e=this.global.location.search,n={},e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,function(t){for(var e=[],r=1;r<arguments.length;r++){e[r-1]=arguments[r];}return function(t,e,n){t[decodeURIComponent(e)]=decodeURIComponent(n||"");}(n,e[0],e[1]),e.join("=");}),n);"tfjsflags"in r&&r.tfjsflags.split(",").forEach(function(e){var n=e.split(":"),r=n[0],i=n[1];t.urlFlags[r]=function(t,e){if("true"===(e=e.toLowerCase())||"false"===e)return "true"===e;if(""+ +e===e)return +e;throw new Error("Could not parse value flag value "+e+" for flag "+t+".");}(r,i);});}},t;}();function f(){return h;}var h=null,d=new Map(),p=new Map();function m(t,e){var n=k(t,e);return d.get(n);}function g(t){return p.get(t);}function v(t){for(var e=d.entries(),n=[];;){var r=e.next(),i=r.done,o=r.value;if(i)break;var a=o[0],s=o[1];a.split("_")[0]===t&&n.push(s);}return n;}function y(t){var e=t.kernelName,n=t.backendName,r=k(e,n);if(d.has(r))throw new Error("The kernel '"+e+"' for backend '"+n+"' is already registered");d.set(r,t);}function b(t){var e=t.kernelName;p.has(e)&&console.warn("Overriding the gradient for '"+e+"'"),p.set(e,t);}function x(t,e){var n=k(t,e);if(!d.has(n))throw new Error("The kernel '"+t+"' for backend '"+e+"' is not registered");d.delete(n);}function w(t){if(!p.has(t))throw new Error("The gradient '"+t+"' for backend is not registered");p.delete(t);}function k(t,e){return e+"_"+t;}function E(t){for(var e=t.length,n=0,r=0;e>0;){r=Math.random()*e|0,n=t[--e],t[e]=t[r],t[r]=n;}}function C(t,e,n){return Math.max(t,Math.min(e,n));}function A(t){return t%2==0?t:t+1;}function O(t){for(var e=0,n=0;n<t.length;n++){e+=t[n];}return e;}function _(t,e){if(!t)throw new Error("string"==typeof e?e:e());}function S(t,e,n){void 0===n&&(n=""),_(N(t,e),function(){return n+" Shapes "+t+" and "+e+" must match";});}function D(t){_(null!=t,function(){return "The input to the tensor constructor must be a non-null value.";});}function F(t,e,n){if(void 0===e&&(e=[]),void 0===n&&(n=!1),null==e&&(e=[]),Array.isArray(t)||H(t)&&!n)for(var r=0;r<t.length;++r){F(t[r],e,n);}else e.push(t);return e;}function T(t){if(0===t.length)return 1;for(var e=t[0],n=1;n<t.length;n++){e*=t[n];}return e;}function N(t,e){if(t===e)return !0;if(null==t||null==e)return !1;if(t.length!==e.length)return !1;for(var n=0;n<t.length;n++){if(t[n]!==e[n])return !1;}return !0;}function I(t){return t%1==0;}function R(t){if(null!=Math.tanh)return Math.tanh(t);if(t===1/0)return 1;if(t===-1/0)return -1;var e=Math.exp(2*t);return (e-1)/(e+1);}function M(t){var e=Math.ceil(Math.sqrt(t));return [e,Math.ceil(t/e)];}function j(t,e){return e<=t.length?t:t+" ".repeat(e-t.length);}function B(t,e,n){return void 0===e&&(e=function e(t){return 0;}),new Promise(function(r,i){var o=0,a=function a(){if(t())r();else {var s=e(++o);null!=n&&o>=n?i():setTimeout(a,s);}};a();});}function P(t,e){for(var n=1,r=-1,i=0;i<t.length;++i){if(t[i]>=0)n*=t[i];else if(-1===t[i]){if(-1!==r)throw Error("Shapes can only have 1 implicit size. Found -1 at dim "+r+" and dim "+i);r=i;}else if(t[i]<0)throw Error("Shapes can not be < 0. Found "+t[i]+" at dim "+i);}if(-1===r){if(e>0&&e!==n)throw Error("Size("+e+") must match the product of shape "+t);return t;}if(0===n)throw Error("Cannot infer the missing size in ["+t+"] when there are 0 elements");if(e%n!=0)throw Error("The implicit shape can't be a fractional number. Got "+e+" / "+n);var o=t.slice();return o[r]=e/n,o;}function L(t,e){var n=e.length;return _((t=null==t?e.map(function(t,e){return e;}):[].concat(t)).every(function(t){return t>=-n&&t<n;}),function(){return "All values in axis param must be in range [-"+n+", "+n+") but got axis "+t;}),_(t.every(function(t){return I(t);}),function(){return "All values in axis param must be integers but got axis "+t;}),t.map(function(t){return t<0?n+t:t;});}function z(t,e){for(var n=[],r=[],i=null!=e&&Array.isArray(e)&&0===e.length,o=null==e||i?null:L(e,t).sort(),a=0,s=0;s<t.length;++s){if(null!=o){if(o[a]===s&&1!==t[s])throw new Error("Can't squeeze axis "+s+" since its dim '"+t[s]+"' is not 1");(null==o[a]||o[a]>s)&&1===t[s]&&(n.push(t[s]),r.push(s)),o[a]<=s&&a++;}1!==t[s]&&(n.push(t[s]),r.push(s));}return {newShape:n,keptDims:r};}function U(t,e){var n=null;if(null==t||"float32"===t)n=new Float32Array(e);else if("int32"===t)n=new Int32Array(e);else {if("bool"!==t)throw new Error("Unknown data type "+t);n=new Uint8Array(e);}return n;}function W(t,e){var n=null;if(null==t||"float32"===t)n=new Float32Array(e);else if("int32"===t)n=new Int32Array(e);else if("bool"===t)n=new Uint8Array(e);else {if("string"!==t)throw new Error("Unknown data type "+t);n=new Array(e);}return n;}function V(t,e){for(var n=0;n<t.length;n++){var r=t[n];if(isNaN(r)||!isFinite(r))throw Error("A tensor of type "+e+" being uploaded contains "+r+".");}}function q(t){return "bool"===t||"complex64"===t||"float32"===t||"int32"===t||"string"===t;}function $(t,e){return !("complex64"===e||"float32"===e&&"complex64"!==t||"int32"===e&&"float32"!==t&&"complex64"!==t||"bool"===e&&"bool"===t);}function H(t){return t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array;}function G(t){if("float32"===t||"int32"===t)return 4;if("complex64"===t)return 8;if("bool"===t)return 1;throw new Error("Unknown dtype "+t);}function K(t){if(null==t)return 0;var e=0;return t.forEach(function(t){return e+=t.length;}),e;}function X(t){return "string"==typeof t||t instanceof String;}function Y(t){return "boolean"==typeof t;}function J(t){return "number"==typeof t;}function Q(t){return Array.isArray(t)?Q(t[0]):t instanceof Float32Array?"float32":t instanceof Int32Array||t instanceof Uint8Array?"int32":J(t)?"float32":X(t)?"string":Y(t)?"bool":"float32";}function Z(t){return !!(t&&t.constructor&&t.call&&t.apply);}function tt(t,e){for(var n=e;n<t;++n){if(t%n==0)return n;}return t;}function et(t){var e=t.length;if(e<2)return [];var n=new Array(e-1);n[e-2]=t[e-1];for(var r=e-3;r>=0;--r){n[r]=n[r+1]*t[r+1];}return n;}function nt(t,e,n){if("string"===e)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(t)&&(t=F(t)),n&&V(t,e),function(t,e){return t instanceof Float32Array&&"float32"===e||t instanceof Int32Array&&"int32"===e||t instanceof Uint8Array&&"bool"===e;}(t,e))return t;if(null==e||"float32"===e||"complex64"===e)return new Float32Array(t);if("int32"===e)return new Int32Array(t);if("bool"===e){for(var r=new Uint8Array(t.length),i=0;i<r.length;++i){0!==Math.round(t[i])&&(r[i]=1);}return r;}throw new Error("Unknown data type "+e);}function rt(t,e){if(0===t.length)return e[0];var n=t.reduce(function(t,e){return t*e;});if(0===n)return [];if(n!==e.length)throw new Error("["+t+"] does not match the input size.");return function t(e,n,r){var i=new Array();if(1===n.length)for(var o=n[0],a=0;a<o;a++){i[a]=r[e+a];}else {o=n[0];var s=n.slice(1),u=s.reduce(function(t,e){return t*e;});for(a=0;a<o;a++){i[a]=t(e+a*u,s,r);}}return i;}(0,t,e);}function it(t,e){for(var n=ot(t,e),r=0;r<n.length;r++){n[r]=1;}return n;}function ot(t,e){if(null==e||"float32"===e||"complex64"===e)return new Float32Array(t);if("int32"===e)return new Int32Array(t);if("bool"===e)return new Uint8Array(t);throw new Error("Unknown data type "+e);}function at(){return f().platform.now();}function st(t){t.forEach(function(e){_(Number.isInteger(e)&&e>=0,function(){return "Tensor must have a shape comprised of positive integers but got shape ["+t+"].";});});}function ut(t,e){return void 0===e&&(e="utf-8"),e=e||"utf-8",f().platform.encode(t,e);}function ct(t,e){return void 0===e&&(e="utf-8"),e=e||"utf-8",f().platform.decode(t,e);}function lt(t,e,n){if(0===e)return 0;if(1===e)return t[0];for(var r=t[t.length-1],i=0;i<t.length-1;++i){r+=n[i]*t[i];}return r;}function ft(t,e,n){if(0===e)return [];if(1===e)return [t];for(var r=new Array(e),i=0;i<r.length-1;++i){r[i]=Math.floor(t/n[i]),t-=r[i]*n[i];}return r[r.length-1]=t,r;}var ht=Object.freeze({shuffle:E,clamp:C,nearestLargerEven:A,sum:O,randUniform:function randUniform(t,e){var n=Math.random();return e*n+(1-n)*t;},distSquared:function distSquared(t,e){for(var n=0,r=0;r<t.length;r++){var i=Number(t[r])-Number(e[r]);n+=i*i;}return n;},assert:_,assertShapesMatch:S,assertNonNull:D,flatten:F,sizeFromShape:T,isScalarShape:function isScalarShape(t){return 0===t.length;},arraysEqual:N,isInt:I,tanh:R,sizeToSquarishShape:M,createShuffledIndices:function createShuffledIndices(t){for(var e=new Uint32Array(t),n=0;n<t;++n){e[n]=n;}return E(e),e;},rightPad:j,repeatedTry:B,inferFromImplicitShape:P,parseAxisParam:L,squeezeShape:z,getTypedArrayFromDType:U,getArrayFromDType:W,checkConversionForErrors:V,isValidDtype:q,hasEncodingLoss:$,isTypedArray:H,bytesPerElement:G,bytesFromStringArray:K,isString:X,isBoolean:Y,isNumber:J,inferDtype:Q,isFunction:Z,nearestDivisor:tt,computeStrides:et,toTypedArray:nt,toNestedArray:rt,makeOnesTypedArray:it,makeZerosTypedArray:ot,now:at,assertNonNegativeIntegerDimensions:st,fetch:function fetch(t,e){return f().platform.fetch(t,e);},encodeString:ut,decodeString:ct,locToIndex:lt,indexToLoc:ft}),dt=function(){function t(t,e){this.backendTimer=t,this.logger=e,null==e&&(this.logger=new pt());}return t.prototype.profileKernel=function(t,e,n){var r,i=this,o=this.backendTimer.time(function(){r=n();});return r.forEach(function(n){n.data().then(function(r){!function(t,e,n){if("float32"!==e)return !1;for(var r=0;r<t.length;r++){var i=t[r];if(isNaN(i)||!isFinite(i))return console.warn("Found "+i+" in the result of '"+n+"'"),!0;}}(r,n.dtype,t),o.then(function(o){var a="";null!=o.getExtraProfileInfo&&(a=o.getExtraProfileInfo()),i.logger.logKernelProfile(t,n,r,o.kernelMs,e,a);});});}),r;},t;}(),pt=function(){function t(){}return t.prototype.logKernelProfile=function(t,e,n,r,i,o){var a="number"==typeof r?j(r+"ms",9):r.error,s=j(t,25),u=e.rank,c=e.size,l=j(e.shape.toString(),14),f="";for(var h in i){var d=i[h].shape||e.shape,p=d.length;f+=h+": "+p+"D "+(p>0?d:"")+" ";}console.log("%c"+s+"\t%c"+a+"\t%c"+u+"D "+l+"\t%c"+c+"\t%c"+f+"\t%c"+o,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue");},t;}(),mt=20,gt=3,vt=7;function yt(t,e,n){return j(Array.isArray(t)?parseFloat(t[0].toFixed(vt))+" + "+parseFloat(t[1].toFixed(vt))+"j":X(t)?"'"+t+"'":"bool"===n?bt(t):parseFloat(t.toFixed(vt)).toString(),e);}function bt(t){return 0===t?"false":"true";}function xt(t){for(var e=[],n=0;n<t.length;n+=2){e.push([t[n],t[n+1]]);}return e;}var wt=function(){function t(t,e,n){var r=this;if(this.dtype=e,this.shape=t.slice(),this.size=T(t),null!=n){var i=n.length;_(i===this.size,function(){return "Length of values '"+i+"' does not match the size inferred by the shape '"+r.size+"'.";});}if("complex64"===e)throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||W(e,this.size),this.strides=et(t);}return t.prototype.set=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++){n[r-1]=arguments[r];}0===n.length&&(n=[0]),_(n.length===this.rank,function(){return "The number of provided coordinates ("+n.length+") must match the rank ("+e.rank+")";});var i=this.locToIndex(n);this.values[i]=t;},t.prototype.get=function(){for(var t=[],e=0;e<arguments.length;e++){t[e]=arguments[e];}0===t.length&&(t=[0]);for(var n=0,r=0,i=t;r<i.length;r++){var o=i[r];if(o<0||o>=this.shape[n]){var a="Requested out of range element at "+t+".   Buffer shape="+this.shape;throw new Error(a);}n++;}for(var s=t[t.length-1],u=0;u<t.length-1;++u){s+=this.strides[u]*t[u];}return this.values[s];},t.prototype.locToIndex=function(t){if(0===this.rank)return 0;if(1===this.rank)return t[0];for(var e=t[t.length-1],n=0;n<t.length-1;++n){e+=this.strides[n]*t[n];}return e;},t.prototype.indexToLoc=function(t){if(0===this.rank)return [];if(1===this.rank)return [t];for(var e=new Array(this.shape.length),n=0;n<e.length-1;++n){e[n]=Math.floor(t/this.strides[n]),t-=e[n]*this.strides[n];}return e[e.length-1]=t,e;},Object.defineProperty(t.prototype,"rank",{get:function get(){return this.shape.length;},enumerable:!0,configurable:!0}),t.prototype.toTensor=function(){return kt().makeTensor(this.values,this.shape,this.dtype);},t;}(),kt=null,Et=null,Ct=null,At=function(){function t(t,e,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=t.slice(),this.dtype=e||"float32",this.size=T(t),this.strides=et(t),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher";}return t.prototype.flatten=function(){return this.throwIfDisposed(),this.as1D();},t.prototype.asScalar=function(){return this.throwIfDisposed(),_(1===this.size,function(){return "The array must have only 1 element.";}),this.reshape([]);},t.prototype.as1D=function(){return this.throwIfDisposed(),this.reshape([this.size]);},t.prototype.as2D=function(t,e){return this.throwIfDisposed(),this.reshape([t,e]);},t.prototype.as3D=function(t,e,n){return this.throwIfDisposed(),this.reshape([t,e,n]);},t.prototype.as4D=function(t,e,n,r){return this.throwIfDisposed(),this.reshape([t,e,n,r]);},t.prototype.as5D=function(t,e,n,r,i){return this.throwIfDisposed(),this.reshape([t,e,n,r,i]);},t.prototype.asType=function(t){return this.throwIfDisposed(),Et.cast(this,t);},Object.defineProperty(t.prototype,"rank",{get:function get(){return this.shape.length;},enumerable:!0,configurable:!0}),t.prototype.buffer=function(){return u(this,void 0,void 0,function(){var t;return c(this,function(e){switch(e.label){case 0:return [4,this.data()];case 1:return t=e.sent(),[2,Et.buffer(this.shape,this.dtype,t)];}});});},t.prototype.bufferSync=function(){return Et.buffer(this.shape,this.dtype,this.dataSync());},t.prototype.array=function(){return u(this,void 0,void 0,function(){var t;return c(this,function(e){switch(e.label){case 0:return [4,this.data()];case 1:return t=e.sent(),[2,rt(this.shape,t)];}});});},t.prototype.arraySync=function(){return rt(this.shape,this.dataSync());},t.prototype.data=function(){return u(this,void 0,void 0,function(){var t,e;return c(this,function(n){switch(n.label){case 0:return this.throwIfDisposed(),t=kt().read(this.dataId),"string"!==this.dtype?[3,2]:[4,t];case 1:e=n.sent();try{return [2,e.map(function(t){return ct(t);})];}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().");}n.label=2;case 2:return [2,t];}});});},t.prototype.dataSync=function(){this.throwIfDisposed();var t=kt().readSync(this.dataId);if("string"===this.dtype)try{return t.map(function(t){return ct(t);});}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().");}return t;},t.prototype.bytes=function(){return u(this,void 0,void 0,function(){var t;return c(this,function(e){switch(e.label){case 0:return this.throwIfDisposed(),[4,kt().read(this.dataId)];case 1:return t=e.sent(),"string"===this.dtype?[2,t]:[2,new Uint8Array(t.buffer)];}});});},t.prototype.dispose=function(){this.isDisposed||(kt().disposeTensor(this),this.isDisposedInternal=!0);},Object.defineProperty(t.prototype,"isDisposed",{get:function get(){return this.isDisposedInternal;},enumerable:!0,configurable:!0}),t.prototype.throwIfDisposed=function(){if(this.isDisposed)throw new Error("Tensor is disposed.");},t.prototype.toFloat=function(){return this.asType("float32");},t.prototype.toInt=function(){return this.asType("int32");},t.prototype.toBool=function(){return this.asType("bool");},t.prototype.print=function(t){return void 0===t&&(t=!1),Et.print(this,t);},t.prototype.reshape=function(t){return this.throwIfDisposed(),Et.reshape(this,t);},t.prototype.reshapeAs=function(t){return this.throwIfDisposed(),this.reshape(t.shape);},t.prototype.expandDims=function(t){return void 0===t&&(t=0),Et.expandDims(this,t);},t.prototype.cumsum=function(t,e,n){return void 0===t&&(t=0),void 0===e&&(e=!1),void 0===n&&(n=!1),Et.cumsum(this,t,e,n);},t.prototype.squeeze=function(t){return this.throwIfDisposed(),Et.squeeze(this,t);},t.prototype.clone=function(){return this.throwIfDisposed(),Et.clone(this);},t.prototype.oneHot=function(t,e,n){return this.throwIfDisposed(),Et.oneHot(this,t,e,n);},t.prototype.toString=function(t){return void 0===t&&(t=!1),function(t,e,n,r){var i=et(e),o=function(t,e,n,r){var i=T(e),o=r[r.length-1],a=new Array(o).fill(0),s=e.length,u="complex64"===n?xt(t):t;if(s>1)for(var c=0;c<i/o;c++){for(var l=c*o,f=0;f<o;f++){a[f]=Math.max(a[f],yt(u[l+f],0,n).length);}}return a;}(t,e,n,i),a=e.length,s=function t(e,n,r,i,o,a){void 0===a&&(a=!0);var s="complex64"===r?2:1,u=n[0],c=n.length;if(0===c)return "complex64"===r?[yt(xt(e)[0],0,r)]:"bool"===r?[bt(e[0])]:[e[0].toString()];if(1===c){if(u>mt){var l=gt*s,f=Array.from(e.slice(0,l)),h=Array.from(e.slice((u-gt)*s,u*s));return "complex64"===r&&(f=xt(f),h=xt(h)),["["+f.map(function(t,e){return yt(t,o[e],r);}).join(", ")+", ..., "+h.map(function(t,e){return yt(t,o[u-gt+e],r);}).join(", ")+"]"];}return ["["+("complex64"===r?xt(e):Array.from(e)).map(function(t,e){return yt(t,o[e],r);}).join(", ")+"]"];}var d=n.slice(1),p=i.slice(1),m=i[0]*s,g=[];if(u>mt){for(var v=0;v<gt;v++){var y=(b=v*m)+m;g.push.apply(g,t(e.slice(b,y),d,r,p,o,!1));}for(g.push("..."),v=u-gt;v<u;v++){y=(b=v*m)+m,g.push.apply(g,t(e.slice(b,y),d,r,p,o,v===u-1));}}else for(v=0;v<u;v++){var b;y=(b=v*m)+m,g.push.apply(g,t(e.slice(b,y),d,r,p,o,v===u-1));}var x=2===c?",":"";for(g[0]="["+g[0]+x,v=1;v<g.length-1;v++){g[v]=" "+g[v]+x;}var w=",\n";for(v=2;v<c;v++){w+="\n";}return g[g.length-1]=" "+g[g.length-1]+"]"+(a?"":w),g;}(t,e,n,i,o),u=["Tensor"];return r&&(u.push("  dtype: "+n),u.push("  rank: "+a),u.push("  shape: ["+e+"]"),u.push("  values:")),u.push(s.map(function(t){return "    "+t;}).join("\n")),u.join("\n");}(this.dataSync(),this.shape,this.dtype,t);},t.prototype.tile=function(t){return this.throwIfDisposed(),Et.tile(this,t);},t.prototype.gather=function(t,e){return void 0===e&&(e=0),this.throwIfDisposed(),Et.gather(this,t,e);},t.prototype.matMul=function(t,e,n){return void 0===e&&(e=!1),void 0===n&&(n=!1),this.throwIfDisposed(),Et.matMul(this,t,e,n);},t.prototype.dot=function(t){return this.throwIfDisposed(),Et.dot(this,t);},t.prototype.norm=function(t,e,n){return void 0===t&&(t="euclidean"),void 0===e&&(e=null),void 0===n&&(n=!1),this.throwIfDisposed(),Et.norm(this,t,e,n);},t.prototype.slice=function(t,e){return this.throwIfDisposed(),Et.slice(this,t,e);},t.prototype.reverse=function(t){return this.throwIfDisposed(),Et.reverse(this,t);},t.prototype.concat=function(e,n){return void 0===n&&(n=0),this.throwIfDisposed(),e instanceof t&&(e=[e]),Et.concat([this].concat(e),n);},t.prototype.split=function(t,e){return void 0===e&&(e=0),this.throwIfDisposed(),Et.split(this,t,e);},t.prototype.stack=function(t,e){return void 0===e&&(e=0),Et.stack([this,t],e);},t.prototype.unstack=function(t){return void 0===t&&(t=0),Et.unstack(this,t);},t.prototype.pad=function(t,e){return void 0===e&&(e=0),Et.pad(this,t,e);},t.prototype.batchNormalization=function(t,e,n,r,i){return void 0===n&&(n=.001),Ct("tf.batchNormalization() is going away. Use tf.batchNorm() instead, and note the positional argument change of scale, offset, and varianceEpsilon"),this.batchNorm(t,e,i,r,n);},t.prototype.batchNorm=function(t,e,n,r,i){return void 0===i&&(i=.001),this.throwIfDisposed(),Et.batchNorm(this,t,e,n,r,i);},t.prototype.all=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),Et.all(this,t,e);},t.prototype.any=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),Et.any(this,t,e);},t.prototype.logSumExp=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),Et.logSumExp(this,t,e);},t.prototype.sum=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),Et.sum(this,t,e);},t.prototype.prod=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),Et.prod(this,t,e);},t.prototype.mean=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),Et.mean(this,t,e);},t.prototype.min=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),Et.min(this,t,e);},t.prototype.max=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),Et.max(this,t,e);},t.prototype.argMin=function(t){return void 0===t&&(t=null),this.throwIfDisposed(),Et.argMin(this,t);},t.prototype.argMax=function(t){return void 0===t&&(t=null),this.throwIfDisposed(),Et.argMax(this,t);},t.prototype.cast=function(t){return this.throwIfDisposed(),Et.cast(this,t);},t.prototype.add=function(t){return this.throwIfDisposed(),Et.add(this,t);},t.prototype.addStrict=function(t){return this.throwIfDisposed(),Et.addStrict(this,t);},t.prototype.atan2=function(t){return this.throwIfDisposed(),Et.atan2(this,t);},t.prototype.sub=function(t){return this.throwIfDisposed(),Et.sub(this,t);},t.prototype.subStrict=function(t){return this.throwIfDisposed(),Et.subStrict(this,t);},t.prototype.pow=function(t){return this.throwIfDisposed(),Et.pow(this,t);},t.prototype.powStrict=function(t){return this.throwIfDisposed(),Et.powStrict(this,t);},t.prototype.mul=function(t){return this.throwIfDisposed(),Et.mul(this,t);},t.prototype.mulStrict=function(t){return this.throwIfDisposed(),Et.mulStrict(this,t);},t.prototype.div=function(t){return this.throwIfDisposed(),Et.div(this,t);},t.prototype.divNoNan=function(t){return this.throwIfDisposed(),Et.divNoNan(this,t);},t.prototype.floorDiv=function(t){return this.throwIfDisposed(),Et.floorDiv(this,t);},t.prototype.divStrict=function(t){return this.throwIfDisposed(),Et.divStrict(this,t);},t.prototype.minimum=function(t){return this.throwIfDisposed(),Et.minimum(this,t);},t.prototype.minimumStrict=function(t){return this.throwIfDisposed(),Et.minimumStrict(this,t);},t.prototype.maximum=function(t){return this.throwIfDisposed(),Et.maximum(this,t);},t.prototype.maximumStrict=function(t){return this.throwIfDisposed(),Et.maximumStrict(this,t);},t.prototype.mod=function(t){return this.throwIfDisposed(),Et.mod(this,t);},t.prototype.modStrict=function(t){return this.throwIfDisposed(),Et.modStrict(this,t);},t.prototype.squaredDifferenceStrict=function(t){return this.throwIfDisposed(),Et.squaredDifferenceStrict(this,t);},t.prototype.transpose=function(t){return this.throwIfDisposed(),Et.transpose(this,t);},t.prototype.notEqual=function(t){return this.throwIfDisposed(),Et.notEqual(this,t);},t.prototype.notEqualStrict=function(t){return this.throwIfDisposed(),Et.notEqualStrict(this,t);},t.prototype.less=function(t){return this.throwIfDisposed(),Et.less(this,t);},t.prototype.lessStrict=function(t){return this.throwIfDisposed(),Et.lessStrict(this,t);},t.prototype.equal=function(t){return this.throwIfDisposed(),Et.equal(this,t);},t.prototype.equalStrict=function(t){return this.throwIfDisposed(),Et.equalStrict(this,t);},t.prototype.lessEqual=function(t){return this.throwIfDisposed(),Et.lessEqual(this,t);},t.prototype.lessEqualStrict=function(t){return this.throwIfDisposed(),Et.lessEqualStrict(this,t);},t.prototype.greater=function(t){return this.throwIfDisposed(),Et.greater(this,t);},t.prototype.greaterStrict=function(t){return this.throwIfDisposed(),Et.greaterStrict(this,t);},t.prototype.greaterEqual=function(t){return this.throwIfDisposed(),Et.greaterEqual(this,t);},t.prototype.greaterEqualStrict=function(t){return this.throwIfDisposed(),Et.greaterEqualStrict(this,t);},t.prototype.logicalAnd=function(t){return this.throwIfDisposed(),Et.logicalAnd(this,t);},t.prototype.logicalOr=function(t){return this.throwIfDisposed(),Et.logicalOr(this,t);},t.prototype.logicalNot=function(){return this.throwIfDisposed(),Et.logicalNot(this);},t.prototype.logicalXor=function(t){return this.throwIfDisposed(),Et.logicalXor(this,t);},t.prototype.where=function(t,e){return this.throwIfDisposed(),Et.where(t,this,e);},t.prototype.neg=function(){return this.throwIfDisposed(),Et.neg(this);},t.prototype.ceil=function(){return this.throwIfDisposed(),Et.ceil(this);},t.prototype.floor=function(){return this.throwIfDisposed(),Et.floor(this);},t.prototype.sign=function(){return this.throwIfDisposed(),Et.sign(this);},t.prototype.isNaN=function(){return this.throwIfDisposed(),Et.isNaN(this);},t.prototype.isInf=function(){return this.throwIfDisposed(),Et.isInf(this);},t.prototype.isFinite=function(){return this.throwIfDisposed(),Et.isFinite(this);},t.prototype.exp=function(){return this.throwIfDisposed(),Et.exp(this);},t.prototype.expm1=function(){return this.throwIfDisposed(),Et.expm1(this);},t.prototype.log=function(){return this.throwIfDisposed(),Et.log(this);},t.prototype.log1p=function(){return this.throwIfDisposed(),Et.log1p(this);},t.prototype.sqrt=function(){return this.throwIfDisposed(),Et.sqrt(this);},t.prototype.rsqrt=function(){return this.throwIfDisposed(),Et.rsqrt(this);},t.prototype.square=function(){return this.throwIfDisposed(),Et.square(this);},t.prototype.reciprocal=function(){return this.throwIfDisposed(),Et.reciprocal(this);},t.prototype.abs=function(){return this.throwIfDisposed(),Et.abs(this);},t.prototype.clipByValue=function(t,e){return this.throwIfDisposed(),Et.clipByValue(this,t,e);},t.prototype.relu=function(){return this.throwIfDisposed(),Et.relu(this);},t.prototype.relu6=function(){return this.throwIfDisposed(),Et.relu6(this);},t.prototype.elu=function(){return this.throwIfDisposed(),Et.elu(this);},t.prototype.selu=function(){return this.throwIfDisposed(),Et.selu(this);},t.prototype.leakyRelu=function(t){return void 0===t&&(t=.2),this.throwIfDisposed(),Et.leakyRelu(this,t);},t.prototype.prelu=function(t){return this.throwIfDisposed(),Et.prelu(this,t);},t.prototype.sigmoid=function(){return this.throwIfDisposed(),Et.sigmoid(this);},t.prototype.logSigmoid=function(){return this.throwIfDisposed(),Et.logSigmoid(this);},t.prototype.softplus=function(){return this.throwIfDisposed(),Et.softplus(this);},t.prototype.zerosLike=function(){return this.throwIfDisposed(),Et.zerosLike(this);},t.prototype.onesLike=function(){return this.throwIfDisposed(),Et.onesLike(this);},t.prototype.sin=function(){return this.throwIfDisposed(),Et.sin(this);},t.prototype.cos=function(){return this.throwIfDisposed(),Et.cos(this);},t.prototype.tan=function(){return this.throwIfDisposed(),Et.tan(this);},t.prototype.asin=function(){return this.throwIfDisposed(),Et.asin(this);},t.prototype.acos=function(){return this.throwIfDisposed(),Et.acos(this);},t.prototype.atan=function(){return this.throwIfDisposed(),Et.atan(this);},t.prototype.sinh=function(){return this.throwIfDisposed(),Et.sinh(this);},t.prototype.cosh=function(){return this.throwIfDisposed(),Et.cosh(this);},t.prototype.tanh=function(){return this.throwIfDisposed(),Et.tanh(this);},t.prototype.asinh=function(){return this.throwIfDisposed(),Et.asinh(this);},t.prototype.acosh=function(){return this.throwIfDisposed(),Et.acosh(this);},t.prototype.atanh=function(){return this.throwIfDisposed(),Et.atanh(this);},t.prototype.erf=function(){return this.throwIfDisposed(),Et.erf(this);},t.prototype.round=function(){return this.throwIfDisposed(),Et.round(this);},t.prototype.step=function(t){return void 0===t&&(t=0),this.throwIfDisposed(),Et.step(this,t);},t.prototype.softmax=function(t){return void 0===t&&(t=-1),this.throwIfDisposed(),Et.softmax(this,t);},t.prototype.logSoftmax=function(t){return void 0===t&&(t=-1),this.throwIfDisposed(),Et.logSoftmax(this,t);},t.prototype.resizeBilinear=function(t,e){return void 0===e&&(e=!1),this.throwIfDisposed(),Et.image.resizeBilinear(this,t,e);},t.prototype.resizeNearestNeighbor=function(t,e){return void 0===e&&(e=!1),this.throwIfDisposed(),Et.image.resizeNearestNeighbor(this,t,e);},t.prototype.conv1d=function(t,e,n,r,i,o){return void 0===r&&(r="NWC"),void 0===i&&(i=1),this.throwIfDisposed(),Et.conv1d(this,t,e,n,r,i,o);},t.prototype.conv2d=function(t,e,n,r,i,o){return void 0===r&&(r="NHWC"),void 0===i&&(i=[1,1]),this.throwIfDisposed(),Et.conv2d(this,t,e,n,r,i,o);},t.prototype.conv2dTranspose=function(t,e,n,r,i){return this.throwIfDisposed(),Et.conv2dTranspose(this,t,e,n,r,i);},t.prototype.depthwiseConv2D=function(t,e,n,r,i,o){return void 0===r&&(r="NHWC"),void 0===i&&(i=[1,1]),this.throwIfDisposed(),Et.depthwiseConv2d(this,t,e,n,r,i,o);},t.prototype.separableConv2d=function(t,e,n,r,i,o){return void 0===i&&(i=[1,1]),void 0===o&&(o="NHWC"),this.throwIfDisposed(),Et.separableConv2d(this,t,e,n,r,i,o);},t.prototype.avgPool=function(t,e,n,r){return this.throwIfDisposed(),Et.avgPool(this,t,e,n,r);},t.prototype.maxPool=function(t,e,n,r){return this.throwIfDisposed(),Et.maxPool(this,t,e,n,r);},t.prototype.localResponseNormalization=function(t,e,n,r){return void 0===t&&(t=5),void 0===e&&(e=1),void 0===n&&(n=1),void 0===r&&(r=.5),Et.localResponseNormalization(this,t,e,n,r);},t.prototype.pool=function(t,e,n,r,i){return this.throwIfDisposed(),Et.pool(this,t,e,n,r,i);},t.prototype.variable=function(t,e,n){return void 0===t&&(t=!0),this.throwIfDisposed(),kt().makeVariable(this,t,e,n);},t.prototype.unsortedSegmentSum=function(t,e){return this.throwIfDisposed(),Et.unsortedSegmentSum(this,t,e);},t.prototype.batchToSpaceND=function(t,e){return this.throwIfDisposed(),Et.batchToSpaceND(this,t,e);},t.prototype.spaceToBatchND=function(t,e){return this.throwIfDisposed(),Et.spaceToBatchND(this,t,e);},t.prototype.topk=function(t,e){return void 0===t&&(t=1),void 0===e&&(e=!0),this.throwIfDisposed(),Et.topk(this,t,e);},t.prototype.stridedSlice=function(t,e,n,r,i,o,a,s){return void 0===r&&(r=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===a&&(a=0),void 0===s&&(s=0),this.throwIfDisposed(),Et.stridedSlice(this,t,e,n,r,i,o,a,s);},t.prototype.depthToSpace=function(t,e){return this.throwIfDisposed(),Et.depthToSpace(this,t,e);},t.prototype.fft=function(){return this.throwIfDisposed(),Et.spectral.fft(this);},t.prototype.ifft=function(){return this.throwIfDisposed(),Et.spectral.ifft(this);},t.prototype.rfft=function(){return this.throwIfDisposed(),Et.spectral.rfft(this);},t.prototype.irfft=function(){return this.throwIfDisposed(),Et.spectral.irfft(this);},t;}();Object.defineProperty(At,Symbol.hasInstance,{value:function value(t){return !!t&&null!=t.dataId&&null!=t.shape&&null!=t.dtype;}});var Ot,_t,St,Dt,Ft,Tt=function(t){function e(e,n,r,i){var o=t.call(this,e.shape,e.dtype,e.dataId,i)||this;return o.trainable=n,o.name=r,o;}return s(e,t),e.prototype.assign=function(t){if(t.dtype!==this.dtype)throw new Error("dtype of the new value ("+t.dtype+") and previous value ("+this.dtype+") must match");if(!N(t.shape,this.shape))throw new Error("shape of the new value ("+t.shape+") and previous value ("+this.shape+") must match");kt().disposeTensor(this),this.dataId=t.dataId,kt().incRef(this,null);},e.prototype.dispose=function(){kt().disposeVariable(this),this.isDisposedInternal=!0;},e;}(At);Object.defineProperty(Tt,Symbol.hasInstance,{value:function value(t){return t instanceof At&&null!=t.assign&&t.assign instanceof Function;}}),function(t){t.R0="R0",t.R1="R1",t.R2="R2",t.R3="R3",t.R4="R4",t.R5="R5",t.R6="R6";}(Ot||(Ot={})),function(t){t.float32="float32",t.int32="int32",t.bool="int32",t.complex64="complex64";}(_t||(_t={})),function(t){t.float32="float32",t.int32="int32",t.bool="bool",t.complex64="complex64";}(St||(St={})),function(t){t.float32="float32",t.int32="float32",t.bool="float32",t.complex64="complex64";}(Dt||(Dt={})),function(t){t.float32="complex64",t.int32="complex64",t.bool="complex64",t.complex64="complex64";}(Ft||(Ft={}));var Nt={float32:Dt,int32:_t,bool:St,complex64:Ft};function It(t,e){if("string"===t||"string"===e){if("string"===t&&"string"===e)return "string";throw new Error("Can not upcast "+t+" with "+e);}return Nt[t][e];}function Rt(t){return It(t,"int32");}function Mt(t,e){if(t.dtype===e.dtype)return [t,e];var n=It(t.dtype,e.dtype);return [t.cast(n),e.cast(n)];}function jt(t,e){_(t.dtype===e.dtype,function(){return "The dtypes of the first("+t.dtype+") and second("+e.dtype+") input must match";});}function Bt(t){var e=[];return function t(e,n,r){if(null!=e)if(e instanceof At)n.push(e);else if(i=e,Array.isArray(i)||"object"==_typeof$1(i)){var i,o=e;for(var a in o){var s=o[a];r.has(s)||(r.add(s),t(s,n,r));}}}(t,e,new Set()),e;}var Pt,Lt=Object.freeze({makeTypesMatch:Mt,assertTypesMatch:jt,isTensorInList:function isTensorInList(t,e){return e.some(function(e){return e.id===t.id;});},getTensorsInContainer:Bt}),zt=function(){function t(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap(),this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null};}return t.prototype.dispose=function(){for(var t in this.registeredVariables){this.registeredVariables[t].dispose();}},t;}(),Ut=function(){function t(t){this.ENV=t,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new zt();}return t.prototype.ready=function(){return u(this,void 0,void 0,function(){var t,e,n;return c(this,function(r){switch(r.label){case 0:if(null!=this.pendingBackendInit)return [2,this.pendingBackendInit.then(function(){})];if(null!=this.backendInstance)return [2];t=this.getSortedBackends(),e=0,r.label=1;case 1:return e<t.length?(n=t[e],[4,this.initializeBackend(n).success]):[3,5];case 2:return r.sent()?[4,this.setBackend(n)]:[3,4];case 3:return r.sent(),[2];case 4:return e++,[3,1];case 5:throw new Error("Could not initialize any backends, all backend initializations failed.");}});});},Object.defineProperty(t.prototype,"backend",{get:function get(){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");if(null==this.backendInstance){var t=this.initializeBackendsAndReturnBest(),e=t.name;if(t.asyncInit)throw new Error("The highest priority backend '"+e+"' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods");this.setBackend(e);}return this.backendInstance;},enumerable:!0,configurable:!0}),t.prototype.backendNames=function(){return Object.keys(this.registryFactory);},t.prototype.findBackend=function(t){if(!(t in this.registry)){if(!(t in this.registryFactory))return null;if(this.initializeBackend(t).asyncInit)return null;}return this.registry[t];},t.prototype.findBackendFactory=function(t){return t in this.registryFactory?this.registryFactory[t].factory:null;},t.prototype.registerBackend=function(t,e,n){return void 0===n&&(n=1),t in this.registryFactory?(console.warn(t+" backend was already registered. Reusing existing backend factory."),!1):(this.registryFactory[t]={factory:e,priority:n},!0);},t.prototype.setBackend=function(t){return u(this,void 0,void 0,function(){var e,n,r;return c(this,function(i){switch(i.label){case 0:if(null==this.registryFactory[t])throw new Error("Backend name '"+t+"' not found in registry");return this.backendName=t,null!=this.registry[t]?[3,4]:(this.backendInstance=null,e=this.initializeBackend(t),n=e.success,e.asyncInit?[4,n]:[3,2]);case 1:return r=i.sent(),[3,3];case 2:r=n,i.label=3;case 3:if(!r)return [2,!1];i.label=4;case 4:return this.backendInstance=this.registry[t],this.setupRegisteredKernels(),this.profiler=new dt(this.backendInstance),[2,!0];}});});},t.prototype.setupRegisteredKernels=function(){var t=this;v(this.backendName).forEach(function(e){null!=e.setupFunc&&e.setupFunc(t.backendInstance);});},t.prototype.disposeRegisteredKernels=function(t){var e=this;v(t).forEach(function(n){null!=n.disposeFunc&&n.disposeFunc(e.registry[t]);});},t.prototype.initializeBackend=function(t){var e=this,n=this.registryFactory[t];if(null==n)throw new Error("Cannot initialize backend "+t+", no registration found.");try{var r=n.factory();if(Promise.resolve(r)===r){var i=++this.pendingBackendInitId,o=r.then(function(n){return !(i<e.pendingBackendInitId||(e.registry[t]=n,e.pendingBackendInit=null,0));}).catch(function(n){return !(i<e.pendingBackendInitId||(e.pendingBackendInit=null,console.warn("Initialization of backend "+t+" failed"),console.warn(n.stack||n.message),1));});return this.pendingBackendInit=o,{success:o,asyncInit:!0};}return this.registry[t]=r,{success:!0,asyncInit:!1};}catch(e){return console.warn("Initialization of backend "+t+" failed"),console.warn(e.stack||e.message),{success:!1,asyncInit:!1};}},t.prototype.removeBackend=function(t){if(!(t in this.registryFactory))throw new Error(t+" backend not found in registry");this.backendName===t&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,t in this.registry&&(this.disposeRegisteredKernels(t),this.registry[t].dispose(),delete this.registry[t]),delete this.registryFactory[t],this.backendName===t&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null);},t.prototype.getSortedBackends=function(){var t=this;if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort(function(e,n){return t.registryFactory[n].priority-t.registryFactory[e].priority;});},t.prototype.initializeBackendsAndReturnBest=function(){for(var t=this.getSortedBackends(),e=0;e<t.length;e++){var n=t[e],r=this.initializeBackend(n),i=r.success,o=r.asyncInit;if(o||i)return {name:n,asyncInit:o};}throw new Error("Could not initialize any backends, all backend initializations failed.");},t.prototype.moveData=function(t,e){var n=this.state.tensorInfo.get(e),r=n.backend,i=this.readSync(e);r.disposeData(e),n.backend=t,t.move(e,i,n.shape,n.dtype),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++;},t.prototype.tidy=function(t,e){var n,r=this,i=null;if(null==e){if("function"!=typeof t)throw new Error("Please provide a function to tidy()");e=t;}else {if("string"!=typeof t&&!(t instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof e)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");i=t;}return this.scopedRun(function(){return r.startScope(i);},function(){return r.endScope(n);},function(){return (n=e())instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n;});},t.prototype.scopedRun=function(t,e,n){t();try{var r=n();return e(),r;}catch(t){throw e(),t;}},t.prototype.nextTensorId=function(){return t.nextTensorId++;},t.prototype.nextVariableId=function(){return t.nextVariableId++;},t.prototype.clone=function(t){var e=this.makeTensorFromDataId(t.dataId,t.shape,t.dtype),n={x:t};return this.addTapeNode(this.state.activeScope.name,n,[e],function(t){return {x:function x(){return t.toFloat();}};},[]),e;},t.prototype.runKernel=function(t,e,n,r,i){return this.runKernelFunc(null,e,null,t,n,r,i);},t.prototype.shouldCheckForMemLeaks=function(){return this.ENV.getBool("IS_TEST");},t.prototype.checkKernelForMemLeak=function(t,e,n){var r=this.backend.numDataIds(),i=0;n.forEach(function(t){i+="complex64"===t.dtype?3:1;});var o=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],a=r-e-i-o;if(a>0)throw new Error("Backend '"+this.backendName+"' has an internal memory leak ("+a+" data ids) after running '"+t+"'");},t.prototype.runKernelFunc=function(t,e,n,r,i,o,a){var s,u=this;void 0===o&&(o=[]),void 0===a&&(a=[]);var c=[],l=this.isTapeOn();null==r&&(r=null!=this.state.activeScope?this.state.activeScope.name:"");var f,h=function h(t){l&&(c=t.map(function(t){return u.keep(u.clone(t));}));},d=this.state.numBytes,p=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);var g,v=m(r,this.backendName);return f=null!=v?function(){var t=u.backend.numDataIds();g=v.kernelFunc({inputs:e,attrs:i,backend:u.backend});var n=Array.isArray(g)?g:[g];u.shouldCheckForMemLeaks()&&u.checkKernelForMemLeak(r,t,n);var s=n.map(function(t){var e=t.dataId,n=t.shape,r=t.dtype;return u.makeTensorFromDataId(e,n,r);}),c=s.filter(function(t,e){return a[e];});return h((o||[]).slice().concat(c)),s;}:function(){var e=u.backend.numDataIds();g=u.tidy(function(){return t(u.backend,h);});var n=Array.isArray(g)?g:[g];return u.shouldCheckForMemLeaks()&&u.checkKernelForMemLeak(r,e,n),n;},this.scopedRun(function(){return u.state.kernelDepth++;},function(){return u.state.kernelDepth--;},function(){s=u.ENV.getBool("DEBUG")?u.profiler.profileKernel(r,e,function(){return f();}):f();}),l&&this.addTapeNode(r,e,s,n,c),this.state.profiling&&this.state.activeProfile.kernels.push({name:r,bytesAdded:this.state.numBytes-d,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-p,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(e).map(function(t){return e[t].shape;}),outputShapes:s.map(function(t){return t.shape;})}),Array.isArray(g)?s:s[0];},t.prototype.makeTensor=function(t,e,n,r){if(null==t)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;var i=t;"string"===n&&X(t[0])&&(i=t.map(function(t){return ut(t);}));var o=r.write(i,e,n),a=new At(e,n,o,this.nextTensorId());if(this.incRef(a,r),"string"===n){var s=this.state.tensorInfo.get(o),u=K(i);this.state.numBytes+=u-s.bytes,s.bytes=u;}return a;},t.prototype.makeTensorFromDataId=function(t,e,n,r){var i=new At(e,n=n||"float32",t,this.nextTensorId());return this.incRef(i,r),i;},t.prototype.makeVariable=function(t,e,n,r){void 0===e&&(e=!0),n=n||this.nextVariableId().toString(),null!=r&&r!==t.dtype&&(t=t.asType(r));var i=new Tt(t,e,n,this.nextTensorId());if(null!=this.state.registeredVariables[i.name])throw new Error("Variable with name "+i.name+" was already registered");return this.state.registeredVariables[i.name]=i,this.incRef(i,this.backend),i;},t.prototype.incRef=function(t,e){var n=this.state.tensorInfo.has(t.dataId)?this.state.tensorInfo.get(t.dataId).refCount:0;if(this.state.numTensors++,"string"===t.dtype&&this.state.numStringTensors++,0===n){this.state.numDataBuffers++;var r=0;"complex64"!==t.dtype&&"string"!==t.dtype&&(r=t.size*G(t.dtype)),this.state.tensorInfo.set(t.dataId,{backend:e||this.backend,dtype:t.dtype,shape:t.shape,bytes:r,refCount:0}),this.state.numBytes+=r;}this.state.tensorInfo.get(t.dataId).refCount++,t instanceof Tt||this.track(t);},t.prototype.disposeTensor=function(t){if(this.state.tensorInfo.has(t.dataId)){this.state.numTensors--,"string"===t.dtype&&this.state.numStringTensors--;var e=this.state.tensorInfo.get(t.dataId);e.refCount<=1?("complex64"!==t.dtype&&(this.state.numBytes-=e.bytes),this.state.numDataBuffers--,e.backend.disposeData(t.dataId),this.state.tensorInfo.delete(t.dataId)):this.state.tensorInfo.get(t.dataId).refCount--;}},t.prototype.disposeVariables=function(){for(var t in this.state.registeredVariables){var e=this.state.registeredVariables[t];this.disposeVariable(e);}},t.prototype.disposeVariable=function(t){this.disposeTensor(t),null!=this.state.registeredVariables[t.name]&&delete this.state.registeredVariables[t.name];},t.prototype.memory=function(){var t=this.backend.memory();return t.numTensors=this.state.numTensors,t.numDataBuffers=this.state.numDataBuffers,t.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(t.unreliable=!0,null==t.reasons&&(t.reasons=[]),t.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),t;},t.prototype.profile=function(t){return u(this,void 0,void 0,function(){var e,n;return c(this,function(r){return this.state.profiling=!0,e=this.state.numBytes,n=this.state.numTensors,this.state.activeProfile.kernels=[],this.state.activeProfile.result=t(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max.apply(Math,this.state.activeProfile.kernels.map(function(t){return t.totalBytesSnapshot;})),this.state.activeProfile.newBytes=this.state.numBytes-e,this.state.activeProfile.newTensors=this.state.numTensors-n,[2,this.state.activeProfile];});});},t.prototype.isTapeOn=function(){return this.state.gradientDepth>0&&0===this.state.kernelDepth;},t.prototype.addTapeNode=function(t,e,n,r,i){var o=this,a={id:this.state.nextTapeNodeId++,kernelName:t,inputs:e,outputs:n,saved:i},s=g(t);null!=s&&(r=s.gradFunc),null!=r&&(a.gradient=function(t){return t=t.map(function(t,e){if(null==t){var r=n[e],i=ot(r.size,r.dtype);return o.makeTensor(i,r.shape,r.dtype);}return t;}),r(t.length>1?t:t[0],i);}),this.state.activeTape.push(a);},t.prototype.keep=function(t){return t.kept=!0,t;},t.prototype.startTape=function(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++;},t.prototype.endTape=function(){this.state.gradientDepth--;},t.prototype.startScope=function(t){var e={track:[],name:"unnamed scope",id:this.state.nextScopeId++};t&&(e.name=t),this.state.scopeStack.push(e),this.state.activeScope=e;},t.prototype.endScope=function(t){for(var e=this,n=Bt(t),r=new Set(n.map(function(t){return t.id;})),i=0;i<this.state.activeScope.track.length;i++){var o=this.state.activeScope.track[i];o.kept||r.has(o.id)||o.dispose();}var a=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],n.forEach(function(t){t.kept||t.scopeId!==a.id||e.track(t);});},t.prototype.gradients=function(t,e,n,r){var i=this;if(void 0===r&&(r=!1),_(e.length>0,function(){return "gradients() received an empty list of xs.";}),null!=n&&"float32"!==n.dtype)throw new Error("dy must have 'float32' dtype, but has '"+n.dtype+"'");var o=this.scopedRun(function(){return i.startTape();},function(){return i.endTape();},function(){return i.tidy("forward",t);});_(o instanceof At,function(){return "The result y returned by f() must be a tensor.";});var a=function(t,e,n){for(var r={},i={},o=0;o<e.length;o++){r[e[o].id]=!0;}for(o=0;o<t.length;o++){var a=(p=t[o]).inputs;for(var s in a){for(var u=a[s],c=!1,l=0;l<e.length;l++){if(r[u.id]){p.outputs.forEach(function(t){return r[t.id]=!0;}),c=!0,i[p.id]=!0;break;}}if(c)break;}}var f={};f[n.id]=!0;var h={};for(o=t.length-1;o>=0;o--){for(a=(p=t[o]).inputs,l=0;l<p.outputs.length;l++){if(f[p.outputs[l].id]){for(var s in a){f[a[s].id]=!0,h[p.id]=!0;}break;}}}var d=[];for(o=0;o<t.length;o++){var p;if(i[(p=t[o]).id]&&h[p.id]){var m={};for(var s in p.inputs){var g=p.inputs[s];r[g.id]&&(m[s]=g);}var v=Object.assign({},p);v.inputs=m,v.outputs=p.outputs,d.push(v);}}return d;}(this.state.activeTape,e,o);if(!r&&0===a.length&&e.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",function(){var t,r,s={};s[o.id]=null==n?(r=it(T(t=o.shape),"float32"),Wt.makeTensor(r,t,"float32")):n,function(t,e,n){for(var r=function r(_r10){var i=e[_r10],o=[];if(i.outputs.forEach(function(e){var n=t[e.id];null!=n?o.push(n):o.push(null);}),null==i.gradient)throw new Error("Cannot compute gradient: gradient function not found for "+i.kernelName+".");var a=i.gradient(o),s=function s(e){if(!(e in a))throw new Error("Cannot backprop through input "+e+". Available gradients found: "+Object.keys(a)+".");var r=n(function(){return a[e]();});if("float32"!==r.dtype)throw new Error("Error in gradient for op "+i.kernelName+". The gradient of input "+e+" must have 'float32' dtype, but has '"+r.dtype+"'");var o=i.inputs[e];if(!N(r.shape,o.shape))throw new Error("Error in gradient for op "+i.kernelName+". The gradient of input '"+e+"' has shape '"+r.shape+"', which does not match the shape of the input '"+o.shape+"'");if(null==t[o.id])t[o.id]=r;else {var s=t[o.id];t[o.id]=s.add(r),s.dispose();}};for(var u in i.inputs){s(u);}},i=e.length-1;i>=0;i--){r(i);}}(s,a,function(t){return i.tidy(t);});var u=e.map(function(t){return s[t.id];});return 0===i.state.gradientDepth&&(i.state.activeTape.forEach(function(t){for(var e=0,n=t.saved;e<n.length;e++){n[e].dispose();}}),i.state.activeTape=null),{value:o,grads:u};});},t.prototype.customGrad=function(t){var e=this;return _(Z(t),function(){return "The f passed in customGrad(f) must be a function.";}),function(){for(var n,r=[],i=0;i<arguments.length;i++){r[i]=arguments[i];}_(r.every(function(t){return t instanceof At;}),function(){return "The args passed in customGrad(f)(x1, x2,...) must all be tensors";});var o={};return r.forEach(function(t,e){o[e]=t;}),e.runKernelFunc(function(e,i){return _((n=t.apply(void 0,r.concat([i]))).value instanceof At,function(){return "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor";}),_(Z(n.gradFunc),function(){return "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.";}),n.value;},o,function(t,e){var i=n.gradFunc(t,e),o=Array.isArray(i)?i:[i];_(o.length===r.length,function(){return "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...).";}),_(o.every(function(t){return t instanceof At;}),function(){return "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.";});var a={};return o.forEach(function(t,e){a[e]=function(){return t;};}),a;});};},t.prototype.readSync=function(t){return this.state.tensorInfo.get(t).backend.readSync(t);},t.prototype.read=function(t){return this.state.tensorInfo.get(t).backend.read(t);},t.prototype.time=function(t){return u(this,void 0,void 0,function(){var e,n;return c(this,function(r){switch(r.label){case 0:return e=at(),[4,this.backend.time(t)];case 1:return (n=r.sent()).wallMs=at()-e,[2,n];}});});},t.prototype.track=function(t){return null!=this.state.activeScope&&(t.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(t)),t;},Object.defineProperty(t.prototype,"registeredVariables",{get:function get(){return this.state.registeredVariables;},enumerable:!0,configurable:!0}),t.prototype.reset=function(){for(var t in this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new zt(),this.registry){this.disposeRegisteredKernels(t),this.registry[t].dispose(),delete this.registry[t];}this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null;},t.nextTensorId=0,t.nextVariableId=0,t;}(),Wt=function(){var e=function(){if(null==Pt){var e=void 0;if("undefined"!=typeof window)e=window;else if(void 0!==t)e=t;else if(void 0!==r)e=r;else {if("undefined"==typeof self)throw new Error("Could not find a global object");e=self;}Pt=e;}return Pt;}();if(null==e._tfengine){var n=new l(e);e._tfengine=new Ut(n);}return function(t){h=t;}(e._tfengine.ENV),kt=function kt(){return e._tfengine;},e._tfengine;}();function Vt(){return "undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope;}var qt=f();qt.registerFlag("DEBUG",function(){return !1;},function(t){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.");}),qt.registerFlag("IS_BROWSER",function(){return Vt();}),qt.registerFlag("IS_NODE",function(){return void 0!==r&&void 0!==r.versions&&void 0!==r.versions.node;}),qt.registerFlag("IS_CHROME",function(){return "undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor);}),qt.registerFlag("PROD",function(){return !1;}),qt.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",function(){return qt.getBool("DEBUG");}),qt.registerFlag("DEPRECATION_WARNINGS_ENABLED",function(){return !0;}),qt.registerFlag("IS_TEST",function(){return !1;});var $t,Ht,Gt,Kt={},Xt={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function Yt(t,e){Kt[t]=e;}function Jt(t){t in Kt||(Kt[t]=function(t){if(1!==t&&2!==t)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");var e=function(t){if("undefined"!=typeof OffscreenCanvas&&2===t)return new OffscreenCanvas(300,150);if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context");}(t);return e.addEventListener("webglcontextlost",function(e){e.preventDefault(),delete Kt[t];},!1),1===t?e.getContext("webgl",Xt)||e.getContext("experimental-webgl",Xt):e.getContext("webgl2",Xt);}(t));var e=Kt[t];return e.isContextLost()?(delete Kt[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),Kt[t]);}function Qt(t,e){return [e,t];}function Zt(t){var e=T(t);return M(Math.ceil(e/4));}function te(t,e){return [Math.max(1,Math.ceil(e/2)),Math.max(1,Math.ceil(t/2))];}function ee(t,e){var n,r,i,o,a,s,u,c,l,h=t;return 2===f().getNumber("WEBGL_VERSION")?(n=h.R32F,r=h.R16F,i=h.RGBA16F,o=h.RGBA32F,a=h.RED,s=4,u=1,c=h.HALF_FLOAT,l=h.FLOAT):(n=t.RGBA,r=t.RGBA,i=t.RGBA,o=h.RGBA,a=t.RGBA,s=4,u=4,c=null!=e?e.HALF_FLOAT_OES:null,l=t.FLOAT),{internalFormatFloat:n,internalFormatHalfFloat:r,internalFormatPackedHalfFloat:i,internalFormatPackedFloat:o,textureFormatFloat:a,downloadTextureFormat:t.RGBA,downloadUnpackNumChannels:s,defaultNumChannels:u,textureTypeHalfFloat:c,textureTypeFloat:l};}function ne(t,e,n){var r=n();return e&&function(t){var e=t.getError();if(e!==t.NO_ERROR)throw new Error("WebGL Error: "+ae(t,e));}(t),r;}!function(t){t[t.DENSE=0]="DENSE",t[t.SHARED_BATCH=1]="SHARED_BATCH";}($t||($t={})),function(t){t[t.RENDER=0]="RENDER",t[t.UPLOAD=1]="UPLOAD",t[t.PIXELS=2]="PIXELS",t[t.DOWNLOAD=3]="DOWNLOAD";}(Ht||(Ht={})),function(t){t[t.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",t[t.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",t[t.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",t[t.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",t[t.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16";}(Gt||(Gt={}));var re=5.96e-8,ie=65504;function oe(t){return !!(f().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===t||re<Math.abs(t)&&Math.abs(t)<ie);}function ae(t,e){switch(e){case t.NO_ERROR:return "NO_ERROR";case t.INVALID_ENUM:return "INVALID_ENUM";case t.INVALID_VALUE:return "INVALID_VALUE";case t.INVALID_OPERATION:return "INVALID_OPERATION";case t.INVALID_FRAMEBUFFER_OPERATION:return "INVALID_FRAMEBUFFER_OPERATION";case t.OUT_OF_MEMORY:return "OUT_OF_MEMORY";case t.CONTEXT_LOST_WEBGL:return "CONTEXT_LOST_WEBGL";default:return "Unknown error code "+e;}}function se(t,e,n){return Fe(t,e,function(){return t.getExtension(n);},'Extension "'+n+'" not supported on this browser.');}function ue(t,e,n){var r=Fe(t,e,function(){return t.createShader(t.VERTEX_SHADER);},"Unable to create vertex WebGLShader.");if(ne(t,e,function(){return t.shaderSource(r,n);}),ne(t,e,function(){return t.compileShader(r);}),!1===t.getShaderParameter(r,t.COMPILE_STATUS))throw console.log(t.getShaderInfoLog(r)),new Error("Failed to compile vertex shader.");return r;}function ce(t,e,n){var r=Fe(t,e,function(){return t.createShader(t.FRAGMENT_SHADER);},"Unable to create fragment WebGLShader.");if(ne(t,e,function(){return t.shaderSource(r,n);}),ne(t,e,function(){return t.compileShader(r);}),!1===t.getShaderParameter(r,t.COMPILE_STATUS))throw function(t,e){var n=he.exec(e);if(null==n)return console.log("Couldn't parse line number in error: "+e),void console.log(t);for(var r=+n[1],i=t.split("\n"),o=i.length.toString().length+2,a=i.map(function(t,e){return j((e+1).toString(),o)+t;}),s=0,u=0;u<a.length;u++){s=Math.max(a[u].length,s);}var c=a.slice(0,r-1),l=a.slice(r-1,r),f=a.slice(r);console.log(c.join("\n")),console.log(e.split("\n")[0]),console.log("%c "+j(l[0],s),"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(f.join("\n"));}(n,t.getShaderInfoLog(r)),new Error("Failed to compile fragment shader.");return r;}var le,fe,he=/ERROR: [0-9]+:([0-9]+):/g;function de(t,e){return Fe(t,e,function(){return t.createProgram();},"Unable to create WebGLProgram.");}function pe(t,e,n){if(ne(t,e,function(){return t.linkProgram(n);}),!1===t.getProgramParameter(n,t.LINK_STATUS))throw console.log(t.getProgramInfoLog(n)),new Error("Failed to link vertex and fragment shaders.");}function me(t,e,n){if(ne(t,e,function(){return t.validateProgram(n);}),!1===t.getProgramParameter(n,t.VALIDATE_STATUS))throw console.log(t.getProgramInfoLog(n)),new Error("Shader program validation failed.");}function ge(t,e,n){var r=Fe(t,e,function(){return t.createBuffer();},"Unable to create WebGLBuffer");return ne(t,e,function(){return t.bindBuffer(t.ARRAY_BUFFER,r);}),ne(t,e,function(){return t.bufferData(t.ARRAY_BUFFER,n,t.STATIC_DRAW);}),r;}function ve(t,e,n){var r=Fe(t,e,function(){return t.createBuffer();},"Unable to create WebGLBuffer");return ne(t,e,function(){return t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,r);}),ne(t,e,function(){return t.bufferData(t.ELEMENT_ARRAY_BUFFER,n,t.STATIC_DRAW);}),r;}function ye(t,e){return Fe(t,e,function(){return t.createTexture();},"Unable to create WebGLTexture.");}function be(t,e){var n=f().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(t<=0||e<=0){var r="["+t+"x"+e+"]";throw new Error("Requested texture size "+r+" is invalid.");}if(t>n||e>n)throw r="["+t+"x"+e+"]",new Error("Requested texture size "+r+" greater than WebGL maximum on this browser / GPU ["+n+"x"+n+"].");}function xe(t,e){return Fe(t,e,function(){return t.createFramebuffer();},"Unable to create WebGLFramebuffer.");}function we(t,e,n,r,i,o,a,s){var u=t.getAttribLocation(n,r);return -1!==u&&(ne(t,e,function(){return t.bindBuffer(t.ARRAY_BUFFER,i);}),ne(t,e,function(){return t.vertexAttribPointer(u,o,t.FLOAT,!1,a,s);}),ne(t,e,function(){return t.enableVertexAttribArray(u);}),!0);}function ke(t,e,n,r){Te(t,r),ne(t,e,function(){return t.activeTexture(t.TEXTURE0+r);}),ne(t,e,function(){return t.bindTexture(t.TEXTURE_2D,n);});}function Ee(t,e,n,r){return Fe(t,e,function(){return t.getUniformLocation(n,r);},'uniform "'+r+'" not present in program.');}function Ce(t,e,n){return t.getUniformLocation(e,n);}function Ae(t,e,n,r,i,o){ne(t,e,function(){return ke(t,e,r,o);}),ne(t,e,function(){return t.uniform1i(i,o);});}function Oe(t,e,n,r){ne(t,e,function(){return t.bindFramebuffer(t.FRAMEBUFFER,r);}),ne(t,e,function(){return t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0);});}function _e(t,e,n){ne(t,e,function(){return t.bindFramebuffer(t.FRAMEBUFFER,n);}),ne(t,e,function(){return t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,null,0);});}function Se(t){var e=t.checkFramebufferStatus(t.FRAMEBUFFER);if(e!==t.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+De(t,e));}function De(t,e){switch(e){case t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return "FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return "FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case t.FRAMEBUFFER_UNSUPPORTED:return "FRAMEBUFFER_UNSUPPORTED";default:return "unknown error "+e;}}function Fe(t,e,n,r){var i=ne(t,e,function(){return n();});if(null==i)throw new Error(r);return i;}function Te(t,e){var n=t.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=e+t.TEXTURE0;if(r<t.TEXTURE0||r>n)throw new Error("textureUnit must be in [gl.TEXTURE0, gl.TEXTURE"+n+"].");}function Ne(t,e){return void 0===e&&(e=2),T(t.slice(0,t.length-e));}function Ie(t){if(0===t.length)throw Error("Cannot get rows and columns of an empty shape array.");return [t.length>1?t[t.length-2]:1,t[t.length-1]];}function Re(t){var e=[1,1,1];return 0===t.length||1===t.length&&1===t[0]||(e=[Ne(t)].concat(Ie(t))),e;}function Me(t,e){var n;void 0===e&&(e=!1);var r=f().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e&&(r*=2,1===(t=t.map(function(e,n){return n>=t.length-2?A(t[n]):t[n];})).length&&(t=[2,t[0]])),2!==t.length){var i=z(t);t=i.newShape;}var o=T(t);if(t.length<=1&&o<=r)return [1,o];if(2===t.length&&t[0]<=r&&t[1]<=r)return t;if(3===t.length&&t[0]*t[1]<=r&&t[2]<=r)return [t[0]*t[1],t[2]];if(3===t.length&&t[0]<=r&&t[1]*t[2]<=r)return [t[0],t[1]*t[2]];if(4===t.length&&t[0]*t[1]*t[2]<=r&&t[3]<=r)return [t[0]*t[1]*t[2],t[3]];if(4===t.length&&t[0]<=r&&t[1]*t[2]*t[3]<=r)return [t[0],t[1]*t[2]*t[3]];if(e){var a=Ne(t),s=2,u=2;return t.length&&(s=(n=Ie(t))[0],u=n[1]),M(o=a*(s/2)*(u/2)).map(function(t){return 2*t;});}return M(o);}function je(t){return t%2==0;}function Be(t,e){if(N(t=t.slice(-2),e=e.slice(-2)))return !0;if(!t.length||!e.length)return !0;if(0===t[0]||0===t[1]||0===e[0]||0===e[1])return !0;if(t.length!==e.length){var n=t.slice(-1)[0],r=e.slice(-1)[0];if(n===r)return !0;if(je(n)&&je(r)&&(1===t[0]||1===e[0]))return !0;}return t[1]===e[1]&&je(t[0])&&je(e[0]);}function Pe(t){if(null==le){var e=Jt(t);le=e.getParameter(e.MAX_TEXTURE_SIZE);}return le;}function Le(t){if(null==fe){var e=Jt(t);fe=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);}return Math.min(16,fe);}function ze(t){if(0===t)return 0;var e=Jt(t);return Ue(e,"EXT_disjoint_timer_query_webgl2")&&2===t?2:Ue(e,"EXT_disjoint_timer_query")?1:0;}function Ue(t,e){return null!=t.getExtension(e);}function We(t){try{if(null!=Jt(t))return !0;}catch(t){return !1;}return !1;}function Ve(t){if(0===t)return !1;var e=Jt(t);if(1===t){if(!Ue(e,"OES_texture_float"))return !1;}else if(!Ue(e,"EXT_color_buffer_float"))return !1;return $e(e);}function qe(t){if(0===t)return !1;var e=Jt(t);return 1!==t?Ue(e,"EXT_color_buffer_float")?$e(e):!!Ue(e,"EXT_color_buffer_half_float")&&function(t,e){var n=ee(t,e),r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r),t.texImage2D(t.TEXTURE_2D,0,n.internalFormatHalfFloat,1,1,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);var i=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,i),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0);var o=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(r),t.deleteFramebuffer(i),o;}(e,e.getExtension("EXT_color_buffer_half_float")):!!Ue(e,"OES_texture_float")&&!!Ue(e,"WEBGL_color_buffer_float")&&$e(e);}function $e(t){var e=ee(t),n=t.createTexture();t.bindTexture(t.TEXTURE_2D,n),t.texImage2D(t.TEXTURE_2D,0,e.internalFormatFloat,1,1,0,e.textureFormatFloat,e.textureTypeFloat,null);var r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0);var i=t.checkFramebufferStatus(t.FRAMEBUFFER)===t.FRAMEBUFFER_COMPLETE;return t.bindTexture(t.TEXTURE_2D,null),t.bindFramebuffer(t.FRAMEBUFFER,null),t.deleteTexture(n),t.deleteFramebuffer(r),i;}function He(t){return 2===t&&null!=Jt(t).fenceSync;}var Ge=Object.freeze({callAndCheck:ne,canBeRepresented:oe,getWebGLErrorMessage:ae,getExtensionOrThrow:se,createVertexShader:ue,createFragmentShader:ce,createProgram:de,linkProgram:pe,validateProgram:me,createStaticVertexBuffer:ge,createStaticIndexBuffer:ve,getNumChannels:function getNumChannels(){return 2===f().getNumber("WEBGL_VERSION")?1:4;},createTexture:ye,validateTextureSize:be,createFramebuffer:xe,bindVertexBufferToProgramAttribute:we,bindTextureUnit:ke,unbindTextureUnit:function unbindTextureUnit(t,e,n){Te(t,n),ne(t,e,function(){return t.activeTexture(t.TEXTURE0+n);}),ne(t,e,function(){return t.bindTexture(t.TEXTURE_2D,null);});},getProgramUniformLocationOrThrow:Ee,getProgramUniformLocation:Ce,bindTextureToProgramUniformSampler:Ae,bindCanvasToFramebuffer:function bindCanvasToFramebuffer(t,e){ne(t,e,function(){return t.bindFramebuffer(t.FRAMEBUFFER,null);}),ne(t,e,function(){return t.viewport(0,0,t.canvas.width,t.canvas.height);}),ne(t,e,function(){return t.scissor(0,0,t.canvas.width,t.canvas.height);});},bindColorTextureToFramebuffer:Oe,unbindColorTextureFromFramebuffer:_e,validateFramebuffer:Se,getFramebufferErrorMessage:De,getBatchDim:Ne,getRowsCols:Ie,getShapeAs3D:Re,getTextureShapeFromLogicalShape:Me,isReshapeFree:Be,getWebGLMaxTextureSize:Pe,resetMaxTextureSize:function resetMaxTextureSize(){le=null;},resetMaxTexturesInShader:function resetMaxTexturesInShader(){fe=null;},getMaxTexturesInShader:Le,getWebGLDisjointQueryTimerVersion:ze,hasExtension:Ue,isWebGLVersionEnabled:We,isCapableOfRenderingToFloatTexture:Ve,isDownloadFloatTextureEnabled:qe,isWebGLFenceEnabled:He}),Ke=f();function Xe(){f().set("PROD",!0);}function Ye(){f().set("DEBUG",!0);}function Je(){f().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.");}function Qe(t){f().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(t+" You can disable deprecation warnings with tf.disableDeprecationWarnings().");}function Ze(){Wt.disposeVariables();}function tn(){return Wt;}function en(){return Wt.memory();}function nn(t){return Wt.profile(t);}function rn(t,e){return Wt.tidy(t,e);}function on(t){Bt(t).forEach(function(t){return t.dispose();});}function an(t){return Wt.keep(t);}function sn(t){return Wt.time(t);}function un(t){return Wt.setBackend(t);}function cn(){return Wt.ready();}function ln(){return Wt.backendName;}function fn(t){Wt.removeBackend(t);}function hn(t){return Wt.findBackend(t);}function dn(t){return Wt.findBackendFactory(t);}function pn(t,e,n){return void 0===n&&(n=1),Wt.registerBackend(t,e,n);}function mn(){return Wt.backend;}function gn(t,e){f().setPlatform(t,e);}function vn(){for(var t=[],e=0;e<arguments.length;e++){t[e]=arguments[e];}f().getBool("IS_TEST")||console.warn.apply(console,t);}function yn(t,e){var n=t;if(H(t))return "string"===e?[]:[t.length];if(!Array.isArray(t))return [];for(var r=[];Array.isArray(n)||H(n)&&"string"!==e;){r.push(n.length),n=n[0];}return Array.isArray(t)&&f().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&function t(e,n,r){if(r=r||[],Array.isArray(e)||H(e)){_(n.length>0,function(){return "Element arr["+r.join("][")+"] should be a primitive, but is an array of "+e.length+" elements";}),_(e.length===n[0],function(){return "Element arr["+r.join("][")+"] should have "+n[0]+" elements, but has "+e.length+" elements";});for(var i=n.slice(1),o=0;o<e.length;++o){t(e[o],i,r.concat(o));}}else _(0===n.length,function(){return "Element arr["+r.join("][")+"] is a primitive, but should be an array/TypedArray of "+n[0]+" elements";});}(t,r,[]),r;}function bn(t,e,n,r){if(null!=t&&("numeric"!==t&&t!==e||"numeric"===t&&"string"===e))throw new Error("Argument '"+n+"' passed to '"+r+"' must be "+t+" tensor, but got "+e+" tensor");}function xn(t,e,n,r){if(void 0===r&&(r="numeric"),t instanceof At)return bn(r,t.dtype,e,n),t;var i=Q(t);if("string"!==i&&["bool","int32","float32"].indexOf(r)>=0&&(i=r),bn(r,i,e,n),null==t||!H(t)&&!Array.isArray(t)&&"number"!=typeof t&&"boolean"!=typeof t&&"string"!=typeof t){var o=null==t?"null":t.constructor.name;throw new Error("Argument '"+e+"' passed to '"+n+"' must be a Tensor or TensorLike, but got '"+o+"'");}var a=yn(t,i);H(t)||Array.isArray(t)||(t=[t]);var s="string"!==i?nt(t,i,f().getBool("DEBUG")):F(t,[],!0);return Wt.makeTensor(s,a,i);}function wn(t,e,n,r){if(void 0===r&&(r="numeric"),!Array.isArray(t))throw new Error("Argument "+e+" passed to "+n+" must be a `Tensor[]` or `TensorLike[]`");return t.map(function(t,r){return xn(t,e+"["+r+"]",n);},r);}function kn(t,e){for(var n=0;n<t.length;++n){if(t[t.length-n-1]!==e-1-n)return !1;}return !0;}function En(t,e,n){for(var r=t.length+e.length,i=[],o=0,a=0,s=0;s<r;s++){-1===n.indexOf(s)?i.push(t[o++]):i.push(e[a++]);}return i;}function Cn(t,e){for(var n=[],r=t.length,i=0;i<r;i++){-1===e.indexOf(i)&&n.push(t[i]);}return [n,e.map(function(e){return t[e];})];}function An(t,e){return En(t,e.map(function(t){return 1;}),e);}function On(t,e,n){_(kn(e,n),function(){return t+" supports only inner-most axes for now. Got axes "+e+" and rank-"+n+" input.";});}function _n(t,e){if(kn(t,e))return null;for(var n=[],r=0;r<e;++r){-1===t.indexOf(r)&&n.push(r);}return t.forEach(function(t){return n.push(t);}),n;}function Sn(t){return t.map(function(t,e){return [e,t];}).sort(function(t,e){return t[1]-e[1];}).map(function(t){return t[0];});}function Dn(t,e){for(var n=[],r=e-t;r<e;++r){n.push(r);}return n;}function Fn(t,e){var n=t[0].length;t.forEach(function(t,e){_(t.length===n,function(){return "Error in concat"+n+"D: rank of tensors["+e+"] must be the same as the rank of the rest ("+n+")";});}),_(e>=0&&e<n,function(){return "Error in concat"+n+"D: axis must be between 0 and "+(n-1)+".";});var r=t[0];t.forEach(function(t,i){for(var o=0;o<n;o++){_(o===e||t[o]===r[o],function(){return "Error in concat"+n+"D: Shape of tensors["+i+"] ("+t+") does not match the shape of the rest ("+r+") along the non-concatenated axis "+i+".";});}});}function Tn(t,e){for(var n=t[0].slice(),r=1;r<t.length;r++){n[e]+=t[r][e];}return n;}function Nn(t){var e=Object.keys(t);if(1!==e.length)throw new Error("Please provide an object with a single key (operation name) mapping to a function. Got an object with "+e.length+" keys.");var n=e[0],r=t[n];n.endsWith("_")&&(n=n.substring(0,n.length-1));var i=function i(){for(var t=[],e=0;e<arguments.length;e++){t[e]=arguments[e];}Wt.startScope(n);try{var i=r.apply(void 0,t);return i instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),Wt.endScope(i),i;}catch(t){throw Wt.endScope(null),t;}};return Object.defineProperty(i,"name",{value:n,configurable:!0}),i;}Ke.registerFlag("HAS_WEBGL",function(){return Ke.getNumber("WEBGL_VERSION")>0;}),Ke.registerFlag("WEBGL_VERSION",function(){return We(2)?2:We(1)?1:0;}),Ke.registerFlag("WEBGL_BUFFER_SUPPORTED",function(){return 2===Ke.get("WEBGL_VERSION");}),Ke.registerFlag("WEBGL_CPU_FORWARD",function(){return !0;}),Ke.registerFlag("WEBGL_FORCE_F16_TEXTURES",function(){return !1;}),Ke.registerFlag("WEBGL_PACK",function(){return Ke.getBool("HAS_WEBGL");}),Ke.registerFlag("WEBGL_PACK_NORMALIZATION",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_PACK_CLIP",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_PACK_DEPTHWISECONV",function(){return !1;}),Ke.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_PACK_REDUCE",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_LAZILY_UNPACK",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_CONV_IM2COL",function(){return Ke.getBool("WEBGL_PACK");}),Ke.registerFlag("WEBGL_MAX_TEXTURE_SIZE",function(){return Pe(Ke.getNumber("WEBGL_VERSION"));}),Ke.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",function(){return Le(Ke.getNumber("WEBGL_VERSION"));}),Ke.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",function(){var t=Ke.getNumber("WEBGL_VERSION");return 0===t?0:ze(t);}),Ke.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",function(){return Ke.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&(t=navigator.userAgent||navigator.vendor||window.opera,!(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4))));var t;}),Ke.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",function(){return Ve(Ke.getNumber("WEBGL_VERSION"));}),Ke.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",function(){return !Ke.getBool("WEBGL_FORCE_F16_TEXTURES")&&Ke.getBool("WEBGL_RENDER_FLOAT32_CAPABLE");}),Ke.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",function(){return qe(Ke.getNumber("WEBGL_VERSION"));}),Ke.registerFlag("WEBGL_FENCE_API_ENABLED",function(){return He(Ke.getNumber("WEBGL_VERSION"));}),Ke.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",function(){return Ke.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0;}),Ct=Qe;var In=Nn({complex_:function complex_(t,e){var n=xn(t,"real","complex"),r=xn(e,"imag","complex");return S(n.shape,r.shape,"real and imag shapes, "+n.shape+" and "+r.shape+", must match in call to tf.complex()."),Wt.runKernelFunc(function(t){return t.complex(n,r);},{$real:n,$imag:r});}}),Rn=Nn({real_:function real_(t){var e=xn(t,"input","real");return Wt.runKernelFunc(function(t){return t.real(e);},{$input:e});}}),Mn=Nn({imag_:function imag_(t){var e=xn(t,"input","imag");return Wt.runKernelFunc(function(t){return t.imag(e);},{$input:e});}});function jn(t,e,n){return Bn(t,e,yn(t,n),n);}function Bn(t,e,n,r){if(null==r&&(r=Q(t)),"complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!H(t)&&!Array.isArray(t)&&"number"!=typeof t&&"boolean"!=typeof t&&"string"!=typeof t)throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(null!=e){st(e);var i=T(e),o=T(n);_(i===o,function(){return "Based on the provided shape, ["+e+"], the tensor should have "+i+" values but has "+o;});for(var a=0;a<n.length;++a){var s=n[a],u=a!==n.length-1||s!==T(e.slice(a));_(n[a]===e[a]||!u,function(){return "Error creating a new Tensor. Inferred shape ("+n+") does not match the provided shape ("+e+"). ";});}}return H(t)||Array.isArray(t)||(t=[t]),e=e||n,t="string"!==r?nt(t,r,f().getBool("DEBUG")):F(t,[],!0),Wt.makeTensor(t,e,r);}function Pn(t,e){if((H(t)&&"string"!==e||Array.isArray(t))&&"complex64"!==e)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===e&&H(t)&&!(t instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return Bn(t,[],[],e);}function Ln(t,e){D(t);var n=yn(t,e);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return Bn(t,null,n,e);}function zn(t,e,n){if(D(t),null!=e&&2!==e.length)throw new Error("tensor2d() requires shape to have two numbers");var r=yn(t,n);if(2!==r.length&&1!==r.length)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return Bn(t,e,r,n);}function Un(t,e,n){if(D(t),null!=e&&3!==e.length)throw new Error("tensor3d() requires shape to have three numbers");var r=yn(t,n);if(3!==r.length&&1!==r.length)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return Bn(t,e,r,n);}function Wn(t,e,n){if(D(t),null!=e&&4!==e.length)throw new Error("tensor4d() requires shape to have four numbers");var r=yn(t,n);if(4!==r.length&&1!==r.length)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return Bn(t,e,r,n);}function Vn(t,e,n){if(D(t),null!=e&&5!==e.length)throw new Error("tensor5d() requires shape to have five numbers");var r=yn(t,n);if(5!==r.length&&1!==r.length)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return Bn(t,e,r,n);}function qn(t,e,n){if(D(t),null!=e&&6!==e.length)throw new Error("tensor6d() requires shape to have six numbers");var r=yn(t,n);if(6!==r.length&&1!==r.length)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return Bn(t,e=e||r,r,n);}function $n(t,e,n,r){return void 0===e&&(e=!0),Wt.makeVariable(t,e,n,r);}function Hn(t,e){if(void 0===e&&(e="float32"),"complex64"===e){var n=Hn(t,"float32"),r=Gn(t,"float32");return In(n,r);}var i=it(T(t),e);return Wt.makeTensor(i,t,e);}function Gn(t,e){if(void 0===e&&(e="float32"),"complex64"===e){var n=Gn(t,"float32"),r=Gn(t,"float32");return In(n,r);}var i=ot(T(t),e);return Wt.makeTensor(i,t,e);}function Kn(t,e,n){return Wt.runKernelFunc(function(r){return r.fill(t,e,n);},{});}function Xn(t,e,n){if(n<=0)throw new Error("The number of values should be positive.");return Wt.runKernelFunc(function(r){return r.linspace(t,e,n);},{});}function Yn(t,e,n,r){if(void 0===n&&(n=1),void 0===r&&(r="float32"),0===n)throw new Error("Cannot have a step of zero");if(t===e||t<e&&n<0||e<t&&n>1)return Gn([0],r);var i=ot(Math.abs(Math.ceil((e-t)/n)),r);e<t&&1===n&&(n=-1),i[0]=t;for(var o=1;o<i.length;o++){i[o]=i[o-1]+n;}return Ln(i,r);}var Jn=Nn({onesLike_:function onesLike_(t){var e=xn(t,"x","onesLike");if("complex64"===e.dtype){var n=Jn(Rn(e)),r=Qn(Mn(e));return In(n,r);}return Wt.runKernelFunc(function(t){return t.onesLike(e);},{$x:e},function(t,e){return {$x:function $x(){return Qn(t);}};});}}),Qn=Nn({zerosLike_:function zerosLike_(t){var e=xn(t,"x","zerosLike");return Wt.runKernelFunc(function(t){return t.zerosLike(e);},{$x:e},function(t,e){return {$x:function $x(){return Qn(t);}};});}}),Zn=Nn({concat_:function concat_(t,e){void 0===e&&(e=0),_(t.length>=1,function(){return "Pass at least one tensor to concat";});var n=wn(t,"tensors","concat");"complex64"===n[0].dtype&&n.forEach(function(t){if("complex64"!==t.dtype)throw new Error("Cannot concatenate complex64 tensors with a tensor\n          with dtype "+t.dtype+". ");}),e=L(e,n[0].shape)[0];var r=Tn(n.map(function(t){return t.shape;}),e);if(0===T(r))return jn([],r);if(1===(n=n.filter(function(t){return t.size>0;})).length)return n[0];var i=n.map(function(t){return t.shape;});Fn(i,e);var o=n,a={axis:e};return Wt.runKernelFunc(function(t){return t.concat(n,e);},o,function(t){var n=i.map(function(t){return t[e];});return ir(t,n,e).map(function(t){return function(){return t;};});},"Concat",a);}}),tr=Nn({concat1d_:function concat1d_(t){return Zn(t,0);}}),er=Nn({concat2d_:function concat2d_(t,e){return Zn(t,e);}}),nr=Nn({concat3d_:function concat3d_(t,e){return Zn(t,e);}}),rr=Nn({concat4d_:function concat4d_(t,e){return Zn(t,e);}}),ir=Nn({split_:function split_(t,e,n){void 0===n&&(n=0);var r,i=xn(t,"x","split");return n=L(n,i.shape)[0],"number"==typeof e?(_(i.shape[n]%e==0,function(){return "Number of splits must evenly divide the axis.";}),r=new Array(e).fill(i.shape[n]/e)):(_(i.shape[n]===e.reduce(function(t,e){return t+e;}),function(){return "The sum of sizes must match the size of the axis dimension.";}),r=e),Wt.runKernelFunc(function(t){return t.split(i,r,n);},{$x:i},function(t){return {$x:function $x(){return Zn(t,n);}};});}});function or(t,e){return t(e={exports:{}},e.exports),e.exports;}var ar=or(function(t){!function(t,e,n){function r(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e;}function i(t,e){var n=new function(t){var e,n=this,r=(e=4022871197,function(t){t=t.toString();for(var n=0;n<t.length;n++){var r=.02519603282416938*(e+=t.charCodeAt(n));r-=e=r>>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e);}return 2.3283064365386963e-10*(e>>>0);});n.next=function(){var t=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=t-(n.c=0|t);},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(t),n.s0<0&&(n.s0+=1),n.s1-=r(t),n.s1<0&&(n.s1+=1),n.s2-=r(t),n.s2<0&&(n.s2+=1),r=null;}(t),i=e&&e.state,o=n.next;return o.int32=function(){return 4294967296*n.next()|0;},o.double=function(){return o()+1.1102230246251565e-16*(2097152*o()|0);},o.quick=o,i&&("object"==_typeof$1(i)&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.alea=i;}(0,t);}),sr=or(function(t){!function(t,e,n){function r(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e;}function i(t,e){var n=new function(t){var e=this,n="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8;},t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++){e.x^=0|n.charCodeAt(r),e.next();}}(t),i=e&&e.state,o=function o(){return (n.next()>>>0)/4294967296;};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);}while(0===t);return t;},o.int32=n.next,o.quick=o,i&&("object"==_typeof$1(i)&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.xor128=i;}(0,t);}),ur=or(function(t){!function(t,e,n){function r(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e;}function i(t,e){var n=new function(t){var e=this,n="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0;},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++){e.x^=0|n.charCodeAt(r),r==n.length&&(e.d=e.x<<10^e.x>>>4),e.next();}}(t),i=e&&e.state,o=function o(){return (n.next()>>>0)/4294967296;};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);}while(0===t);return t;},o.int32=n.next,o.quick=o,i&&("object"==_typeof$1(i)&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.xorwow=i;}(0,t);}),cr=or(function(t){!function(t,e,n){function r(t,e){return e.x=t.x.slice(),e.i=t.i,e;}function i(t,e){null==t&&(t=+new Date());var n=new function(t){var e=this;e.next=function(){var t,n,r=e.x,i=e.i;return t=r[i],n=(t^=t>>>7)^t<<24,n^=(t=r[i+1&7])^t>>>10,n^=(t=r[i+3&7])^t>>>3,n^=(t=r[i+4&7])^t<<7,t=r[i+7&7],n^=(t^=t<<13)^t<<9,r[i]=n,e.i=i+1&7,n;},function(t,e){var n,r=[];if(e===(0|e))r[0]=e;else for(e=""+e,n=0;n<e.length;++n){r[7&n]=r[7&n]<<15^e.charCodeAt(n)+r[n+1&7]<<13;}for(;r.length<8;){r.push(0);}for(n=0;n<8&&0===r[n];++n){}for(8==n?r[7]=-1:r[n],t.x=r,t.i=0,n=256;n>0;--n){t.next();}}(e,t);}(t),i=e&&e.state,o=function o(){return (n.next()>>>0)/4294967296;};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);}while(0===t);return t;},o.int32=n.next,o.quick=o,i&&(i.x&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.xorshift7=i;}(0,t);}),lr=or(function(t){!function(t,e,n){function r(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e;}function i(t,e){null==t&&(t=+new Date());var n=new function(t){var e=this;e.next=function(){var t,n,r=e.w,i=e.X,o=e.i;return e.w=r=r+1640531527|0,n=i[o+34&127],t=i[o=o+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,n=i[o]=n^t,e.i=o,n+(r^r>>>16)|0;},function(t,e){var n,r,i,o,a,s=[],u=128;for(e===(0|e)?(r=e,e=null):(e+="\0",r=0,u=Math.max(u,e.length)),i=0,o=-32;o<u;++o){e&&(r^=e.charCodeAt((o+32)%e.length)),0===o&&(a=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,o>=0&&(a=a+1640531527|0,i=0==(n=s[127&o]^=r+a)?i+1:0);}for(i>=128&&(s[127&(e&&e.length||0)]=-1),i=127,o=512;o>0;--o){r=s[i+34&127],n=s[i=i+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,s[i]=r^n;}t.w=a,t.X=s,t.i=i;}(e,t);}(t),i=e&&e.state,o=function o(){return (n.next()>>>0)/4294967296;};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);}while(0===t);return t;},o.int32=n.next,o.quick=o,i&&(i.X&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.xor4096=i;}(0,t);}),fr=or(function(t){!function(t,e,n){function r(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e;}function i(t,e){var n=new function(t){var e=this,n="";e.next=function(){var t=e.b,n=e.c,r=e.d,i=e.a;return t=t<<25^t>>>7^n,n=n-r|0,r=r<<24^r>>>8^i,i=i-t|0,e.b=t=t<<20^t>>>12^n,e.c=n=n-r|0,e.d=r<<16^n>>>16^i,e.a=i-t|0;},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):n+=t;for(var r=0;r<n.length+20;r++){e.b^=0|n.charCodeAt(r),e.next();}}(t),i=e&&e.state,o=function o(){return (n.next()>>>0)/4294967296;};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);}while(0===t);return t;},o.int32=n.next,o.quick=o,i&&("object"==_typeof$1(i)&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.tychei=i;}(0,t);}),hr=or(function(t){!function(e,r){var i,o=this,a=256,s=6,u="random",c=r.pow(a,s),l=r.pow(2,52),f=2*l,h=a-1;function d(t,n,h){var d=[],y=g(function t(e,n){var r,i=[],o=_typeof$1(e);if(n&&"object"==o)for(r in e){try{i.push(t(e[r],n-1));}catch(t){}}return i.length?i:"string"==o?e:e+"\0";}((n=1==n?{entropy:!0}:n||{}).entropy?[t,v(e)]:null==t?function(){try{var t;return i&&(t=i.randomBytes)?t=t(a):(t=new Uint8Array(a),(o.crypto||o.msCrypto).getRandomValues(t)),v(t);}catch(t){var n=o.navigator,r=n&&n.plugins;return [+new Date(),o,r,o.screen,v(e)];}}():t,3),d),b=new p(d),x=function x(){for(var t=b.g(s),e=c,n=0;t<l;){t=(t+n)*a,e*=a,n=b.g(1);}for(;t>=f;){t/=2,e/=2,n>>>=1;}return (t+n)/e;};return x.int32=function(){return 0|b.g(4);},x.quick=function(){return b.g(4)/4294967296;},x.double=x,g(v(b.S),e),(n.pass||h||function(t,e,n,i){return i&&(i.S&&m(i,b),t.state=function(){return m(b,{});}),n?(r[u]=t,e):t;})(x,y,"global"in n?n.global:this==r,n.state);}function p(t){var e,n=t.length,r=this,i=0,o=r.i=r.j=0,s=r.S=[];for(n||(t=[n++]);i<a;){s[i]=i++;}for(i=0;i<a;i++){s[i]=s[o=h&o+t[i%n]+(e=s[i])],s[o]=e;}(r.g=function(t){for(var e,n=0,i=r.i,o=r.j,s=r.S;t--;){e=s[i=h&i+1],n=n*a+s[h&(s[i]=s[o=h&o+e])+(s[o]=e)];}return r.i=i,r.j=o,n;})(a);}function m(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e;}function g(t,e){for(var n,r=t+"",i=0;i<r.length;){e[h&i]=h&(n^=19*e[h&i])+r.charCodeAt(i++);}return v(e);}function v(t){return String.fromCharCode.apply(0,t);}if(r["seed"+u]=d,g(r.random(),e),t.exports){t.exports=d;try{i=n(251);}catch(t){}}}([],Math);});hr.alea=ar,hr.xor128=sr,hr.xorwow=ur,hr.xorshift7=cr,hr.xor4096=lr,hr.tychei=fr;var dr=hr.alea,pr=function(){function t(t,e,n,r,i){this.mean=t,this.stdDev=e,this.dtype=n,this.nextVal=NaN,this.truncated=r,this.truncated&&(this.upper=this.mean+2*this.stdDev,this.lower=this.mean-2*this.stdDev);var o=i||Math.random();this.random=dr(o.toString());}return t.prototype.nextValue=function(){if(!isNaN(this.nextVal)){var t=this.nextVal;return this.nextVal=NaN,t;}for(var e,n,r=!1;!r;){var i=void 0,o=void 0,a=void 0;do{a=(i=2*this.random()-1)*i+(o=2*this.random()-1)*o;}while(a>=1||0===a);var s=Math.sqrt(-2*Math.log(a)/a);e=this.mean+this.stdDev*i*s,n=this.mean+this.stdDev*o*s,this.truncated&&!this.isValidTruncated(e)||(r=!0);}return this.truncated&&!this.isValidTruncated(n)||(this.nextVal=this.convertValue(n)),this.convertValue(e);},t.prototype.convertValue=function(t){return null==this.dtype||"float32"===this.dtype?t:Math.round(t);},t.prototype.isValidTruncated=function(t){return t<=this.upper&&t>=this.lower;},t;}(),mr=function(){function t(t,e,n,r){this.alpha=t,this.beta=1/e,this.dtype=n;var i=r||Math.random();this.randu=dr(i.toString()),this.randn=new pr(0,1,n,!1,this.randu()),this.d=t<1?t+2/3:t-1/3,this.c=1/Math.sqrt(9*this.d);}return t.prototype.nextValue=function(){for(var t,e,n,r,i,o;;){do{r=this.randn.nextValue(),o=1+this.c*r;}while(o<=0);if(o*=o*o,e=1-.331*(t=r*r)*t,n=.5*t+this.d*(1-o+Math.log(o)),(i=this.randu())<e||Math.log(i)<n)break;}return o=1/this.beta*this.d*o,this.alpha<1&&(o*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(o);},t.prototype.convertValue=function(t){return "float32"===this.dtype?t:Math.round(t);},t;}(),gr=function(){function t(t,e,n,r){var i=this;if(void 0===t&&(t=0),void 0===e&&(e=1),this.canReturnFloat=function(){return null==i.dtype||"float32"===i.dtype;},this.min=t,this.range=e-t,this.dtype=n,null==r&&(r=Math.random()),"number"==typeof r&&(r=r.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error("The difference between "+t+" - "+e+" <= 1 and dtype is not float");this.random=dr(r);}return t.prototype.convertValue=function(t){return this.canReturnFloat()?t:Math.round(t);},t.prototype.nextValue=function(){return this.convertValue(this.min+this.range*this.random());},t;}();function vr(t,e,n){return void 0===e&&(e="float32"),e=e||"float32",st(t),new wt(t,e,n);}function yr(t,e){void 0===e&&(e=!1),console.log(t.toString(e));}var br=Nn({batchToSpaceND_:function batchToSpaceND_(t,e,n){var r=xn(t,"x","batchToSpaceND"),i=e.reduce(function(t,e){return t*e;});return _(r.rank>=1+e.length,function(){return "input rank is "+r.rank+" but should be > than blockShape.length "+e.length;}),_(n.length===e.length,function(){return "crops.length is "+n.length+" but should be equal to blockShape.length  "+e.length;}),_(r.shape[0]%i==0,function(){return "input tensor batch is "+r.shape[0]+" but is not divisible by the product of the elements of blockShape "+e.join(" * ")+" === "+i;}),Wt.runKernelFunc(function(t){return t.batchToSpaceND(r,e,n);},{$x:r},function(t){return {$x:function $x(){return t.spaceToBatchND(e,n);}};});}}),xr=Nn({broadcastTo_:function broadcastTo_(t,e){var n=xn(t,"broadcastTo","x"),r=n.shape;if(e.some(function(t){return !(t>0)||t%1!=0;}))throw new Error("broadcastTo(): Invalid broadcast shape ["+e+"].");if(e.length<n.rank)throw new Error("broadcastTo(): shape.length="+e.length+" < input.rank="+n.rank+".");if(e.length>n.rank){for(var i=n.shape.slice();i.length<e.length;){i.unshift(1);}n=n.reshape(i);}for(var o=Array.from(e),a=e.length-1;a>=0;a--){if(n.shape[a]===e[a])o[a]=1;else if(1!==n.shape[a])throw new Error("broadcastTo(): ["+r+"] cannot be broadcast to ["+e+"].");}var s=o.map(function(t,e){return t>1?e:-1;}).filter(function(t){return t>=0;});return 0===s.length?n.clone():Wt.runKernelFunc(function(t){return t.tile(n,o);},{input:n},function(t){return {input:function input(){return t.sum(s,!0);}};});}}),wr=Nn({cast_:function cast_(t,e){var n=xn(t,"x","cast");if(!q(e))throw new Error("Failed to cast to unknown dtype "+e);if("string"===e&&"string"!==n.dtype||"string"!==e&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");var r={dtype:e};return Wt.runKernelFunc(function(t){return t.cast(n,e);},{x:n},function(t){return {x:function x(){return t.clone();}};},"Cast",r);}}),kr=Nn({clone_:function clone_(t){var e=xn(t,"x","clone",null);return Wt.runKernelFunc(function(){return Wt.makeTensorFromDataId(e.dataId,e.shape,e.dtype);},{$x:e},function(t){return {$x:function $x(){return t.toFloat();}};});}}),Er=Nn({cumsum_:function cumsum_(t,e,n,r){void 0===e&&(e=0),void 0===n&&(n=!1),void 0===r&&(r=!1);var i=xn(t,"x","cumsum"),o=_n([e|=0],i.rank),a=i;null!=o&&(a=i.transpose(o));var s=Dn(1,i.rank)[0],u=Wt.runKernelFunc(function(t){return t.cumsum(a,s,n,r);},{permutedX:a},function(t){return {permutedX:function permutedX(){return t.cumsum(e,n,!r);}};});return null!=o&&(u=u.transpose(o)),u;}}),Cr=Nn({depthToSpace_:function depthToSpace_(t,e,n){void 0===n&&(n="NHWC");var r=xn(t,"x","depthToSpace"),i="NHWC"===n?r.shape[1]:r.shape[2],o="NHWC"===n?r.shape[2]:r.shape[3],a="NHWC"===n?r.shape[3]:r.shape[1];return _(i*e>=0,function(){return "Negative dimension size caused by overflow when multiplying\n      "+i+" and "+e+"  for depthToSpace with input shape\n      "+r.shape;}),_(o*e>=0,function(){return "Negative dimension size caused by overflow when multiplying\n      "+o+" and "+e+" for depthToSpace with input shape\n          "+r.shape;}),_(a%(e*e)==0,function(){return "Dimension size must be evenly divisible by "+e*e+" but is "+a+" for depthToSpace with input shape "+r.shape;}),Wt.runKernelFunc(function(t){return t.depthToSpace(r,e,n);},{$x:r});}}),Ar=Nn({expandDims_:function expandDims_(t,e){void 0===e&&(e=0);var n=xn(t,"x","expandDims",null);_(e<=n.rank,function(){return "Axis must be <= rank of the tensor";});var r=n.shape.slice();return e<0&&(_(-(n.rank+1)<=e,function(){return "Axis must be in the interval ["+-(n.rank+1)+", "+n.rank+"]";}),e=n.rank+e+1),r.splice(e,0,1),Pr(n,r);}}),Or=Nn({eye_:function eye_(t,e,n,r){void 0===r&&(r="float32"),null==e&&(e=t);for(var i=vr([t,e],r),o=t<=e?t:e,a=0;a<o;++a){i.set(1,a,a);}var s=i.toTensor().as2D(t,e);if(null==n)return s;if(1===n.length)return Wr(Ar(s,0),[n[0],1,1]);if(2===n.length)return Wr(Ar(Ar(s,0),0),[n[0],n[1],1,1]);if(3===n.length)return Wr(Ar(Ar(Ar(s,0),0),0),[n[0],n[1],n[2],1,1]);throw new Error("eye() currently supports only 1D and 2D batchShapes, but received "+n.length+"D.");}}),_r=Nn({multinomial_:function multinomial_(t,e,n,r){void 0===r&&(r=!1);var i=xn(t,"logits","multinomial"),o=i.size,a=i.rank;if(o<2)throw new Error("Error in multinomial: you need at least 2 outcomes, but got "+o+".");if(a>2)throw new Error("Rank of probabilities must be 1 or 2, but is "+a);n=n||Math.random();var s=1===a?i.as2D(1,-1):i,u=Wt.runKernelFunc(function(t){return t.multinomial(s,r,e,n);},{logits2D:s});return 1===a?u.as1D():u;}}),Sr=Nn({oneHot_:function oneHot_(t,e,n,r){if(void 0===n&&(n=1),void 0===r&&(r=0),e<2)throw new Error("Error in oneHot: depth must be >=2, but it is "+e);var i=xn(t,"indices","oneHot","int32"),o=i.shape.concat([e]);return i=i.flatten(),Wt.runKernelFunc(function(t){return t.oneHot(i,e,n,r);},{$indices:i},function(t){return {$indices:function $indices(){return Gn(i.shape,"float32");}};}).reshape(o);}}),Dr=Nn({pad_:function pad_(t,e,n){void 0===n&&(n=0);var r=xn(t,"x","pad");if(0===r.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");var i={paddings:e,constantValue:n};return Wt.runKernelFunc(function(t){return t.pad(r,e,n);},{x:r},function(t){var n=e.map(function(t){return t[0];});return {x:function x(){return t.slice(n,r.shape);}};},"PadV2",i);}}),Fr=Nn({pad1d_:function pad1d_(t,e,n){return void 0===n&&(n=0),_(2===e.length,function(){return "Invalid number of paddings. Must be length of 2.";}),Dr(t,[e],n);}}),Tr=Nn({pad2d_:function pad2d_(t,e,n){return void 0===n&&(n=0),_(2===e.length&&2===e[0].length&&2===e[1].length,function(){return "Invalid number of paddings. Must be length of 2 each.";}),Dr(t,e,n);}}),Nr=Nn({pad3d_:function pad3d_(t,e,n){return void 0===n&&(n=0),_(3===e.length&&2===e[0].length&&2===e[1].length&&2===e[2].length,function(){return "Invalid number of paddings. Must be length of 2 each.";}),Dr(t,e,n);}}),Ir=Nn({pad4d_:function pad4d_(t,e,n){return void 0===n&&(n=0),_(4===e.length&&2===e[0].length&&2===e[1].length&&2===e[2].length&&2===e[3].length,function(){return "Invalid number of paddings. Must be length of 2 each.";}),Dr(t,e,n);}}),Rr=Nn({rand_:function rand_(t,e,n){var r=T(t),i=null;if(null==n||"float32"===n)i=new Float32Array(r);else if("int32"===n)i=new Int32Array(r);else {if("bool"!==n)throw new Error("Unknown data type "+n);i=new Uint8Array(r);}for(var o=0;o<r;o++){i[o]=e();}return Wt.makeTensor(i,t,n);}}),Mr=Nn({randomNormal_:function randomNormal_(t,e,n,r,i){if(void 0===e&&(e=0),void 0===n&&(n=1),null!=r&&"bool"===r)throw new Error("Unsupported data type "+r);for(var o=new pr(e,n,r,!1,i),a=vr(t,r),s=0;s<a.values.length;s++){a.values[s]=o.nextValue();}return a.toTensor();}}),jr=Nn({randomGamma_:function randomGamma_(t,e,n,r,i){if(void 0===n&&(n=1),void 0===r&&(r="float32"),null==n&&(n=1),null==r&&(r="float32"),"float32"!==r&&"int32"!==r)throw new Error("Unsupported data type "+r);for(var o=new mr(e,n,r,i),a=vr(t,r),s=0;s<a.values.length;s++){a.values[s]=o.nextValue();}return a.toTensor();}}),Br=Nn({randomUniform_:function randomUniform_(t,e,n,r,i){void 0===e&&(e=0),void 0===n&&(n=1),void 0===r&&(r="float32");for(var o=vr(t,r),a=new gr(e,n,null,i),s=0;s<o.values.length;s++){o.values[s]=a.nextValue();}return o.toTensor();}}),Pr=Nn({reshape_:function reshape_(t,e){var n=xn(t,"x","reshape",null);e=P(e,n.size),_(n.size===T(e),function(){return "new shape and old shape must have the same number of elements.";});var r={shape:e};return Wt.runKernelFunc(function(t){return t.reshape(n,e);},{x:n},function(t){return {x:function x(){return t.reshape(n.shape);}};},"Reshape",r);}}),Lr=Nn({spaceToBatchND_:function spaceToBatchND_(t,e,n){var r=xn(t,"x","spaceToBatchND");return _(r.rank>=1+e.length,function(){return "input rank "+r.rank+" should be > than [blockShape] "+e.length;}),_(n.length===e.length,function(){return "paddings.shape[0] "+n.length+" must be equal to [blockShape] "+e.length;}),_(r.shape.reduce(function(t,r,i){return i>0&&i<=e.length?t&&(r+n[i-1][0]+n[i-1][1])%e[i-1]==0:t;},!0),function(){return "input spatial dimensions "+r.shape.slice(1)+" with paddings "+n.toString()+" must be divisible by blockShapes "+e.toString();}),Wt.runKernelFunc(function(t){return t.spaceToBatchND(r,e,n);},{$x:r},function(t){return {$x:function $x(){return t.batchToSpaceND(e,n);}};});}}),zr=Nn({squeeze_:function squeeze_(t,e){var n=xn(t,"x","squeeze");return Pr(n,z(n.shape,e).newShape);}}),Ur=Nn({stack_:function stack_(t,e){void 0===e&&(e=0);var n=wn(t,"tensors","stack");if(_(n.length>=1,function(){return "Pass at least one tensor to tf.stack";}),1===n.length)return n[0].expandDims(e);var r=n[0].rank,i=n[0].shape,o=n[0].dtype;_(e<=r,function(){return "Axis must be <= rank of the tensor";}),n.forEach(function(t){S(i,t.shape,"All tensors passed to stack must have matching shapes");}),n.forEach(function(t){_(o===t.dtype,function(){return "All tensors passed to stack must have matching dtypes";});});var a=n.map(function(t){return t.expandDims(e);});return Zn(a,e);}}),Wr=Nn({tile_:function tile_(t,e){var n=xn(t,"x","tile",null);_(n.rank===e.length,function(){return "Error in transpose: rank of input "+n.rank+" must match length of reps "+e+".";});var r=[n],i={reps:e};return Wt.runKernelFunc(function(t,r){var i=t.tile(n,e);return r([n]),i;},{x:n},function(t,n){var r=n[0];return {x:function x(){var n=Qn(r);if(1===r.rank)for(var i=0;i<e[0];++i){n=n.add(t.slice([i*r.shape[0]],[r.shape[0]]));}else if(2===r.rank)for(i=0;i<e[0];++i){for(var o=0;o<e[1];++o){n=n.add(t.slice([i*r.shape[0],o*r.shape[1]],[r.shape[0],r.shape[1]]));}}else if(3===r.rank)for(i=0;i<e[0];++i){for(o=0;o<e[1];++o){for(var a=0;a<e[2];++a){n=n.add(t.slice([i*r.shape[0],o*r.shape[1],a*r.shape[2]],[r.shape[0],r.shape[1],r.shape[2]]));}}}else {if(4!==r.rank)throw new Error("Gradient for tile operation is not implemented for rank-"+r.rank+" tensors yet.");for(i=0;i<e[0];++i){for(o=0;o<e[1];++o){for(a=0;a<e[2];++a){for(var s=0;s<e[3];++s){n=n.add(t.slice([i*r.shape[0],o*r.shape[1],a*r.shape[2],s*r.shape[3]],[r.shape[0],r.shape[1],r.shape[2],r.shape[3]]));}}}}}return n;}};},"Tile",i,r);}}),Vr=Nn({truncatedNormal_:function truncatedNormal_(t,e,n,r,i){if(void 0===e&&(e=0),void 0===n&&(n=1),null!=r&&"bool"===r)throw new Error("Unsupported data type "+r);for(var o=new pr(e,n,r,!0,i),a=vr(t,r),s=0;s<a.values.length;s++){a.values[s]=o.nextValue();}return a.toTensor();}}),qr=Nn({unstack_:function unstack_(t,e){void 0===e&&(e=0),e=e||0;var n=xn(t,"x","unstack");_(e>=-n.shape.length&&e<n.shape.length,function(){return "Axis = "+e+" is not in [-"+n.shape.length+", "+n.shape.length+")";}),e<0&&(e+=n.shape.length);var r={axis:e};return Wt.runKernelFunc(function(t){return t.unstack(n,e);},{x:n},function(t){return {x:function x(){return Ur(t,e);}};},"Unpack",r);}}),$r=function $r(t,e){return u(this,void 0,void 0,function(){var n,r,i,o,a,s,u,l,f,h;return c(this,function(c){switch(c.label){case 0:return n=xn(t,"x","setdiff1d"),r=xn(e,"y","setdiff1d"),_(n.dtype===r.dtype,function(){return "x and y should have the same dtype, but got x ("+n.dtype+") and y ("+r.dtype+").";}),_(1===n.rank,function(){return "x should be 1D tensor, but got x ("+n.shape+").";}),_(1===r.rank,function(){return "y should be 1D tensor, but got y ("+r.shape+").";}),[4,n.data()];case 1:return i=c.sent(),[4,r.data()];case 2:for(o=c.sent(),a=new Set(o),s=0,f=0;f<i.length;f++){a.has(i[f])||s++;}for(u=new wt([s],n.dtype),l=new wt([s],"int32"),f=0,h=0;f<i.length;f++){a.has(i[f])||(u.values[h]=i[f],l.values[h]=f,h++);}return [2,[u.toTensor(),l.toTensor()]];}});});};function Hr(t,e,n,r){void 0===r&&(r=!0);var i=[];if(r)(i=i.concat(e.slice(0))).push(t[0]/n),i=i.concat(t.slice(1));else {i=i.concat(t[0]);for(var o=e.length,a=0;a<o;++a){i=i.concat([t[a+1]/e[a],e[a]]);}i=i.concat(t.slice(o+1));}return i;}function Gr(t,e,n){void 0===n&&(n=!0);var r=[];if(n){r.push(e);for(var i=e+1;i<t;++i){i<=2*e?(r.push(i),r.push(i-(e+1))):r.push(i);}}else {var o=[],a=[];for(i=1;i<t;++i){i>=2*e+1||i%2==1?a.push(i):o.push(i);}r.push.apply(r,o),r.push(0),r.push.apply(r,a);}return r;}function Kr(t,e,n,r){void 0===r&&(r=!0);var i=[];r?i.push(t[0]/n):i.push(t[0]*n);for(var o=1;o<t.length;++o){o<=e.length?r?i.push(e[o-1]*t[o]):i.push(t[o]/e[o-1]):i.push(t[o]);}return i;}function Xr(t,e){for(var n=[0],r=0;r<e;++r){n.push(t[r][0]);}return n;}function Yr(t,e,n){for(var r=t.slice(0,1),i=0;i<n;++i){r.push(t[i+1]-e[i][0]-e[i][1]);}return r;}function Jr(t,e){if(t.rank<1)throw new Error("tf.gatherND() expects the input to be rank 1 or higher, but the rank was "+t.rank+".");if(e.rank<1)throw new Error("tf.gatherND() expects the indices to be rank 1 or higher, but the rank was "+e.rank+".");if("int32"!==e.dtype)throw new Error("tf.gatherND() expects the indices to be int32 type, but the dtype was "+e.dtype+".");if(e.shape[e.rank-1]>t.rank)throw new Error("index innermost dimension length must be <= tensor rank; saw: "+e.shape[e.rank-1]+" vs. "+t.rank);if(0===t.size)throw new Error("Requested more than 0 entries, but input is empty. Input shape: "+t.shape+".");for(var n=e.shape,r=n[n.length-1],i=1,o=0;o<n.length-1;++o){i*=n[o];}var a=t.shape,s=n.slice();s.pop();var u=1;for(o=r;o<t.rank;++o){u*=a[o],s.push(a[o]);}var c=et(t.shape).map(function(t){return t/u;}).concat([1]).slice(0,r);return [s,i,u,c];}var Qr=Object.freeze({prepareAndValidate:Jr}),Zr=30;function ti(t){return t<=Zr?t:tt(t,Math.floor(Math.sqrt(t)));}function ei(t,e,n){var r=e.rank>1?e.shape[e.rank-1]:1,i=e.rank>1?e.rank-1:1,o="Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: "+n.shape+", indices.shape: "+e.shape+", shape: "+t+", sliceDim: "+r+", and batchDim: "+i+".";if(n.rank<i)throw new Error(o+" update.rank < "+i+". ");if(t.length<r+(n.rank-i))throw new Error(o+" Output shape length < "+(r+(n.rank-i)));if(n.rank!==i+t.length-r)throw new Error(o+" update.rank != "+(i+t.length-r));for(var a=0;a<i;++a){if(n.shape[a]!==e.shape[a])throw new Error(o+" updates.shape["+a+"] ("+n.shape[a]+") != indices.shape["+a+"] ("+e.shape[a]+").");}for(a=0;a<n.rank-i;++a){if(n.shape[a+i]!==t[a+r])throw new Error(o+" updates.shape["+(a+i)+"] ("+n.shape[a+i]+") != shape["+(a+i)+"] ("+t[a+i]+")");}}function ni(t,e,n){if(e.rank<1)throw new Error("tf.scatterND() expects the indices to be rank 1 or higher, but the rank was "+e.rank+".");if(t.rank<1)throw new Error("tf.scatterND() expects the updates to be rank 1 or higher, but the rank was "+t.rank+".");if("int32"!==e.dtype)throw new Error("The dtype of 'indices' should be int32, but got dtype: "+e.dtype);if(n.length<1)throw new Error("Output rank must be greater or equal to 1, but got shape: "+n);if(0===n.length){if(0===e.size)throw new Error("Indices specified for empty output. indices shape: "+e.shape);if(0===t.size)throw new Error("Updates specified for empty output. updates shape: "+t.shape);}ei(n,e,t);}function ri(t,e,n){for(var r=e.shape.length,i=r>1?e.shape[r-1]:1,o=n.length,a=1,s=i;s<o;++s){a*=n[s];}var u=i<1?1:i;return {sliceRank:i,numUpdates:T(e.shape)/u,sliceSize:a,strides:et(n.slice(0,i)).concat([1]),outputSize:T(n)};}var ii=Object.freeze({validateUpdateShape:ei,validateInput:ni,calculateShapes:ri});function oi(t,e,n){_(t.rank===e.length,function(){return "Error in slice"+t.rank+"D: Length of begin "+e+" must match the rank of the array ("+t.rank+").";}),_(t.rank===n.length,function(){return "Error in slice"+t.rank+"D: Length of size "+n+" must match the rank of the array ("+t.rank+").";});for(var r=function r(_r11){_(e[_r11]+n[_r11]<=t.shape[_r11],function(){return "Error in slice"+t.rank+"D: begin["+_r11+"] + size["+_r11+"] ("+(e[_r11]+n[_r11])+") would overflow input.shape["+_r11+"] ("+t.shape[_r11]+")";});},i=0;i<t.rank;++i){r(i);}}function ai(t){for(var e=[],n=0;t>0;){1&t&&e.push(n),t/=2,n++;}return e;}function si(t,e,n){for(var r=[],i=0;i<t.length;i++){r[i]=Math.ceil((e[i]-t[i])/n[i]);}return r;}function ui(t,e,n,r,i){var o=e[i],a=n[i]||1;(t&1<<i||null==o)&&(o=a>0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);var s=r[i];return o<0&&(o+=s),C(0,o,s-1);}function ci(t,e,n,r,i){var o=e[i],a=n[i]||1;(t&1<<i||null==o)&&(o=a>0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);var s=r[i];return o<0&&(o+=s),a>0?C(0,o,s):C(-1,o,s-1);}function li(t,e,n){for(var r=n.length,i=0;i<n.length;i++){if(n[i]>1){r=i;break;}}for(i=r+1;i<n.length;i++){if(e[i]>0||n[i]!==t[i])return !1;}return !0;}function fi(t,e){for(var n=t.length>0?t[t.length-1]:1,r=0;r<t.length-1;r++){n+=t[r]*e[r];}return n;}var hi=Object.freeze({assertParamsValid:oi,maskToAxes:ai,computeOutShape:si,startForAxis:ui,stopForAxis:ci,isSliceContinous:li,computeFlatOffset:fi});function di(t){return _(Z(t),function(){return "The f passed in grad(f) must be a function";}),function(e,n){var r=xn(e,"x","tf.grad",null),i=null!=n?xn(n,"dy","tf.grad"):null;return Wt.tidy(function(){var e=Wt.gradients(function(){return t(r);},[r],i),n=e.value,o=e.grads;return null!=i&&S(n.shape,i.shape,"The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"),bi(o),o[0];});};}function pi(t){return _(Z(t),function(){return "The f passed in grads(f) must be a function";}),function(e,n){_(Array.isArray(e),function(){return "The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s";});var r=wn(e,"args","tf.grads",null),i=null!=n?xn(n,"dy","tf.grads"):null;return Wt.tidy(function(){var e=Wt.gradients(function(){return t.apply(void 0,r);},r,i),n=e.value,o=e.grads;return null!=i&&S(n.shape,i.shape,"The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),bi(o),o;});};}function mi(t){return _(Z(t),function(){return "The f passed in valueAndGrad(f) must be a function";}),function(e,n){_(e instanceof At,function(){return "The x passed in valueAndGrad(f)(x) must be a tensor";}),_(null==n||n instanceof At,function(){return "The dy passed in valueAndGrad(f)(x, dy) must be a tensor";});var r=Wt.gradients(function(){return t(e);},[e],n),i=r.grads,o=r.value;return bi(i),{grad:i[0],value:o};};}function gi(t){return _(Z(t),function(){return "The f passed in valueAndGrads(f) must be a function";}),function(e,n){_(Array.isArray(e)&&e.every(function(t){return t instanceof At;}),function(){return "The args passed in valueAndGrads(f)(args) must be array of tensors";}),_(null==n||n instanceof At,function(){return "The dy passed in valueAndGrads(f)(args, dy) must be a tensor";});var r=Wt.gradients(function(){return t.apply(void 0,e);},e,n);return null!=n&&S(r.value.shape,n.shape,"The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"),bi(r.grads),r;};}function vi(t,e){_(Z(t),function(){return "The f passed in variableGrads(f) must be a function";}),_(null==e||Array.isArray(e)&&e.every(function(t){return t instanceof Tt;}),function(){return "The varList passed in variableGrads(f, varList) must be an array of variables";});var n=null!=e;if(!n)for(var r in e=[],Wt.registeredVariables){e.push(Wt.registeredVariables[r]);}var i=n?e.filter(function(t){return !t.trainable;}):null,o=e.length;_((e=e.filter(function(t){return t.trainable;})).length>0,function(){return "variableGrads() expects at least one of the input variables to be trainable, but none of the "+o+" variables is trainable.";});var a=Wt.gradients(t,e,null,!0),s=a.value,u=a.grads;_(u.some(function(t){return null!=t;}),function(){return "Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize().";}),_(0===s.rank,function(){return "The f passed in variableGrads(f) must return a scalar, but it returned a rank-"+s.rank+" tensor";});var c={};return e.forEach(function(t,e){null!=u[e]&&(c[t.name]=u[e]);}),null!=i&&i.forEach(function(t){return c[t.name]=null;}),{value:s,grads:c};}function yi(t){return Wt.customGrad(t);}function bi(t){if(t.filter(function(t){return null==t;}).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.");}var xi=Nn({softmax_:function softmax_(t,e){void 0===e&&(e=-1);var n=xn(t,"logits","softmax","float32");if(-1===e&&(e=n.rank-1),e!==n.rank-1)throw Error("Softmax along a non-last dimension is not yet supported. Logits was rank "+n.rank+" and dim was "+e);return Wt.runKernelFunc(function(t,r){var i=t.softmax(n,e);return r([i]),i;},{logits:n},function(t,n){var r=n[0],i=t.mul(r);return {logits:function logits(){return i.sub(i.sum([e],!0).mul(r));}};},"Softmax",{dim:e},[],[!0]);}}),wi=Nn({logSoftmax_:function logSoftmax_(t,e){void 0===e&&(e=-1);var n=xn(t,"logits","logSoftmax");if(-1===e&&(e=n.rank-1),e!==n.rank-1)throw Error("Log Softmax along a non-last dimension is not yet supported. Logits was rank "+n.rank+" and axis was "+e);return yi(function(t,n){var r=t.max(e,!0),i=t.sub(r),o=i.toFloat().sub(i.exp().sum(e,!0).log());return n([o]),{value:o,gradFunc:function gradFunc(t,n){var r=n[0].exp();return t.sub(t.sum(e,!0).mul(r));}};})(n);}}),ki=function(){function t(t,e){this.backend=t,this.dataMover=e,this.data=new WeakMap(),this.dataIdsCount=0;}return t.prototype.get=function(t){return this.data.has(t)||this.dataMover.moveData(this.backend,t),this.data.get(t);},t.prototype.set=function(t,e){this.dataIdsCount++,this.data.set(t,e);},t.prototype.has=function(t){return this.data.has(t);},t.prototype.delete=function(t){return this.dataIdsCount--,this.data.delete(t);},t.prototype.numDataIds=function(){return this.dataIdsCount;},t;}(),Ei=function(){function t(){}return t.prototype.time=function(t){return Ci("time");},t.prototype.read=function(t){return Ci("read");},t.prototype.readSync=function(t){return Ci("readSync");},t.prototype.numDataIds=function(){return Ci("numDataIds");},t.prototype.disposeData=function(t){return Ci("disposeData");},t.prototype.write=function(t,e,n){return Ci("write");},t.prototype.move=function(t,e,n,r){return Ci("move");},t.prototype.memory=function(){return Ci("memory");},t.prototype.floatPrecision=function(){return Ci("floatPrecision");},t.prototype.epsilon=function(){return 32===this.floatPrecision()?1e-7:1e-4;},t.prototype.batchMatMul=function(t,e,n,r){return Ci("batchMatMul");},t.prototype.fusedBatchMatMul=function(t){return t.a,t.b,t.transposeA,t.transposeB,t.bias,t.activation,t.preluActivationWeights,Ci("fusedBatchMatMul");},t.prototype.slice=function(t,e,n){return Ci("slice");},t.prototype.stridedSlice=function(t,e,n,r){return Ci("stridedSlice");},t.prototype.unstack=function(t,e){return Ci("unstack");},t.prototype.reverse=function(t,e){return Ci("reverse");},t.prototype.concat=function(t,e){return Ci("concat");},t.prototype.neg=function(t){return Ci("neg");},t.prototype.add=function(t,e){return Ci("add");},t.prototype.addN=function(t){return Ci("addN");},t.prototype.subtract=function(t,e){return Ci("subtract");},t.prototype.multiply=function(t,e){return Ci("multiply");},t.prototype.realDivide=function(t,e){return Ci("realDivide");},t.prototype.floorDiv=function(t,e){return Ci("floorDiv");},t.prototype.sum=function(t,e){return Ci("sum");},t.prototype.prod=function(t,e){return Ci("prod");},t.prototype.unsortedSegmentSum=function(t,e,n){return Ci("unsortedSegmentSum");},t.prototype.argMin=function(t,e){return Ci("argMin");},t.prototype.argMax=function(t,e){return Ci("argMax");},t.prototype.equal=function(t,e){return Ci("equal");},t.prototype.notEqual=function(t,e){return Ci("notEqual");},t.prototype.less=function(t,e){return Ci("less");},t.prototype.lessEqual=function(t,e){return Ci("lessEqual");},t.prototype.greater=function(t,e){return Ci("greater");},t.prototype.greaterEqual=function(t,e){return Ci("greaterEqual");},t.prototype.logicalNot=function(t){return Ci("logicalNot");},t.prototype.logicalAnd=function(t,e){return Ci("logicalAnd");},t.prototype.logicalOr=function(t,e){return Ci("logicalOr");},t.prototype.where=function(t){return Ci("where");},t.prototype.select=function(t,e,n){return Ci("select");},t.prototype.topk=function(t,e,n){return Ci("topk");},t.prototype.min=function(t,e){return Ci("min");},t.prototype.minimum=function(t,e){return Ci("minimum");},t.prototype.mod=function(t,e){return Ci("mod");},t.prototype.max=function(t,e){return Ci("max");},t.prototype.maximum=function(t,e){return Ci("maximum");},t.prototype.all=function(t,e){return Ci("all");},t.prototype.any=function(t,e){return Ci("any");},t.prototype.squaredDifference=function(t,e){return Ci("squaredDifference");},t.prototype.ceil=function(t){return Ci("ceil");},t.prototype.floor=function(t){return Ci("floor");},t.prototype.round=function(t){return Ci("round");},t.prototype.sign=function(t){return Ci("sign");},t.prototype.isNaN=function(t){return Ci("isNaN");},t.prototype.isInf=function(t){return Ci("isInf");},t.prototype.isFinite=function(t){return Ci("isFinite");},t.prototype.pow=function(t,e){return Ci("pow");},t.prototype.exp=function(t){return Ci("exp");},t.prototype.expm1=function(t){return Ci("expm1");},t.prototype.softmax=function(t,e){return Ci("softmax");},t.prototype.log=function(t){return Ci("log");},t.prototype.log1p=function(t){return Ci("log1p");},t.prototype.sqrt=function(t){return Ci("sqrt");},t.prototype.rsqrt=function(t){return Ci("rsqrt");},t.prototype.square=function(t){return Ci("square");},t.prototype.reciprocal=function(t){return Ci("reciprocal");},t.prototype.relu=function(t){return Ci("relu");},t.prototype.relu6=function(t){return Ci("relu6");},t.prototype.prelu=function(t,e){return Ci("prelu");},t.prototype.elu=function(t){return Ci("elu");},t.prototype.eluDer=function(t,e){return Ci("eluDer");},t.prototype.selu=function(t){return Ci("selu");},t.prototype.int=function(t){return Ci("int");},t.prototype.clip=function(t,e,n){return Ci("clip");},t.prototype.abs=function(t){return Ci("abs");},t.prototype.complexAbs=function(t){return Ci("complexAbs");},t.prototype.sigmoid=function(t){return Ci("sigmoid");},t.prototype.softplus=function(t){return Ci("softplus");},t.prototype.sin=function(t){return Ci("sin");},t.prototype.cos=function(t){return Ci("cos");},t.prototype.tan=function(t){return Ci("tan");},t.prototype.asin=function(t){return Ci("asin");},t.prototype.acos=function(t){return Ci("acos");},t.prototype.atan=function(t){return Ci("atan");},t.prototype.atan2=function(t,e){return Ci("atan2");},t.prototype.sinh=function(t){return Ci("sinh");},t.prototype.cosh=function(t){return Ci("cosh");},t.prototype.tanh=function(t){return Ci("tanh");},t.prototype.asinh=function(t){return Ci("asinh");},t.prototype.acosh=function(t){return Ci("acosh");},t.prototype.atanh=function(t){return Ci("atanh");},t.prototype.erf=function(t){return Ci("erf");},t.prototype.step=function(t,e){return Ci("step");},t.prototype.fusedConv2d=function(t){return t.input,t.filter,t.convInfo,t.bias,t.activation,t.preluActivationWeights,Ci("fusedConv2d");},t.prototype.conv2d=function(t,e,n){return Ci("conv2d");},t.prototype.conv2dDerInput=function(t,e,n){return Ci("conv2dDerInput");},t.prototype.conv2dDerFilter=function(t,e,n){return Ci("conv2dDerFilter");},t.prototype.fusedDepthwiseConv2D=function(t){return t.input,t.filter,t.convInfo,t.bias,t.activation,t.preluActivationWeights,Ci("fusedDepthwiseConv2D");},t.prototype.depthwiseConv2D=function(t,e,n){return Ci("depthwiseConv2D");},t.prototype.depthwiseConv2DDerInput=function(t,e,n){return Ci("depthwiseConv2DDerInput");},t.prototype.depthwiseConv2DDerFilter=function(t,e,n){return Ci("depthwiseConv2DDerFilter");},t.prototype.conv3d=function(t,e,n){return Ci("conv3d");},t.prototype.conv3dDerInput=function(t,e,n){return Ci("conv3dDerInput");},t.prototype.conv3dDerFilter=function(t,e,n){return Ci("conv3dDerFilter");},t.prototype.maxPool=function(t,e){return Ci("maxPool");},t.prototype.maxPoolBackprop=function(t,e,n,r){return Ci("maxPoolBackprop");},t.prototype.avgPool=function(t,e){return Ci("avgPool");},t.prototype.avgPoolBackprop=function(t,e,n){return Ci("avgPoolBackprop");},t.prototype.avgPool3d=function(t,e){return Ci("avgPool3d");},t.prototype.avgPool3dBackprop=function(t,e,n){return Ci("avgPool3dBackprop");},t.prototype.maxPool3d=function(t,e){return Ci("maxPool3d");},t.prototype.maxPool3dBackprop=function(t,e,n,r){return Ci("maxPool3dBackprop");},t.prototype.reshape=function(t,e){return Ci("reshape");},t.prototype.cast=function(t,e){return Ci("cast");},t.prototype.tile=function(t,e){return Ci("tile");},t.prototype.pad=function(t,e,n){return Ci("pad");},t.prototype.transpose=function(t,e){return Ci("transpose");},t.prototype.gather=function(t,e,n){return Ci("gather");},t.prototype.gatherND=function(t,e){return Ci("gatherND");},t.prototype.scatterND=function(t,e,n){return Ci("scatterND");},t.prototype.batchToSpaceND=function(t,e,n){return Ci("batchToSpaceND");},t.prototype.spaceToBatchND=function(t,e,n){return Ci("spaceToBatchND");},t.prototype.resizeBilinear=function(t,e,n,r){return Ci("resizeBilinear");},t.prototype.resizeBilinearBackprop=function(t,e,n){return Ci("resizeBilinearBackprop");},t.prototype.resizeNearestNeighbor=function(t,e,n,r){return Ci("resizeNearestNeighbor");},t.prototype.resizeNearestNeighborBackprop=function(t,e,n){return Ci("resizeNearestNeighborBackprop");},t.prototype.batchNormalization=function(t,e,n,r,i,o){return Ci("batchNormalization");},t.prototype.localResponseNormalization4D=function(t,e,n,r,i){return Ci("localResponseNormalization4D");},t.prototype.LRNGrad=function(t,e,n,r,i,o,a){return Ci("LRNGrad");},t.prototype.multinomial=function(t,e,n,r){return Ci("multinomial");},t.prototype.oneHot=function(t,e,n,r){return Ci("oneHot");},t.prototype.cumsum=function(t,e,n,r){return Ci("cumsum");},t.prototype.nonMaxSuppression=function(t,e,n,r,i){return Ci("nonMaxSuppression");},t.prototype.fft=function(t){return Ci("fft");},t.prototype.ifft=function(t){return Ci("ifft");},t.prototype.complex=function(t,e){return Ci("complex");},t.prototype.real=function(t){return Ci("real");},t.prototype.imag=function(t){return Ci("imag");},t.prototype.cropAndResize=function(t,e,n,r,i,o){return Ci("cropAndResize");},t.prototype.depthToSpace=function(t,e,n){return Ci("depthToSpace");},t.prototype.split=function(t,e,n){return Ci("split");},t.prototype.sparseToDense=function(t,e,n,r){return Ci("sparseToDense");},t.prototype.diag=function(t){return Ci("diag");},t.prototype.fill=function(t,e,n){return Ci("fill");},t.prototype.onesLike=function(t){return Ci("onesLike");},t.prototype.zerosLike=function(t){return Ci("zerosLike");},t.prototype.linspace=function(t,e,n){return Ci("linspace");},t.prototype.dispose=function(){return Ci("dispose");},t;}();function Ci(t){throw new Error("'"+t+"' not yet implemented or not found in the registry. Did you forget to import the kernel?");}function Ai(t,e){for(var n=t.length,r=[],i=0;i<n;i++){var o=n-1-i,a=t[o]||1;(e[e.length-1-i]||1)>1&&1===a&&r.unshift(o);}return r;}function Oi(t,e){for(var n=[],r=0;r<e.length;r++){var i=t[t.length-r-1],o=e.length-r-1,a=e[o];(null==i||1===i&&a>1)&&n.unshift(o);}return n;}function _i(t,e){for(var n=[],r=Math.max(t.length,e.length),i=0;i<r;i++){var o=t[t.length-i-1];null==o&&(o=1);var a=e[e.length-i-1];if(null==a&&(a=1),1===o)n.unshift(a);else if(1===a)n.unshift(o);else {if(o!==a)throw Error("Operands could not be broadcast together with shapes "+t+" and "+e+".");n.unshift(o);}}return n;}function Si(t,e,n,r,i,o,a){void 0===a&&(a="channelsLast");var s,u=Ii(e),c=u[0],l=u[1];if("channelsLast"===a)s=[c,l,t[3],t[3]];else {if("channelsFirst"!==a)throw new Error("Unknown dataFormat "+a);s=[c,l,t[1],t[1]];}return Fi(t,s,n,r,i,o,!1,a);}function Di(t,e,n,r,i,o,a){void 0===a&&(a="NDHWC");var s,u,c=Ri(e),l=c[0],f=c[1],h=c[2];if("NDHWC"===a)u="channelsLast",s=[l,f,h,t[4],t[4]];else {if("NCDHW"!==a)throw new Error("Unknown dataFormat "+a);u="channelsFirst",s=[l,f,h,t[1],t[1]];}return Ti(t,s,n,r,i,!1,u,o);}function Fi(t,e,n,r,i,o,a,s){void 0===a&&(a=!1),void 0===s&&(s="channelsLast");var u=[-1,-1,-1,-1],c=u[0],l=u[1],f=u[2],h=u[3];if("channelsLast"===s)c=t[0],l=t[1],f=t[2],h=t[3];else {if("channelsFirst"!==s)throw new Error("Unknown dataFormat "+s);c=t[0],h=t[1],l=t[2],f=t[3];}var d,p=e[0],m=e[1],g=e[3],v=Ii(n),y=v[0],b=v[1],x=Ii(r),w=x[0],k=x[1],E=Mi(p,w),C=Mi(m,k),A=function(t,e,n,r,i,o,a,s){var u,c,l;if("number"==typeof t){u={top:t,bottom:t,left:t,right:t,type:0===t?"VALID":"NUMBER"};var f=function(t,e,n,r,i){null==r&&(r=Ni(t,e,n));var o=t[1],a=ji((t[0]-e+2*r)/n+1,i);_(I(a),function(){return "The output # of rows ("+a+") must be an integer. Change the stride and/or zero pad parameters";});var s=ji((o-e+2*r)/n+1,i);return _(I(s),function(){return "The output # of columns ("+s+") must be an integer. Change the stride and/or zero pad parameters";}),[a,s];}([e,n],o,r,t,s);c=f[0],l=f[1];}else if("same"===t){c=Math.ceil(e/r),l=Math.ceil(n/i);var h=Math.max(0,(c-1)*r+o-e),d=Math.max(0,(l-1)*i+a-n),p=Math.floor(h/2),m=h-p,g=Math.floor(d/2);u={top:p,bottom:m,left:g,right:d-g,type:"SAME"};}else {if("valid"!==t)throw Error("Unknown padding parameter: "+t);u={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((e-o+1)/r),l=Math.ceil((n-a+1)/i);}return {padInfo:u,outHeight:c,outWidth:l};}(i,l,f,y,b,E,C,o),O=A.padInfo,S=A.outHeight,D=A.outWidth,F=a?g*h:g;return "channelsFirst"===s?d=[c,F,S,D]:"channelsLast"===s&&(d=[c,S,D,F]),{batchSize:c,dataFormat:s,inHeight:l,inWidth:f,inChannels:h,outHeight:S,outWidth:D,outChannels:F,padInfo:O,strideHeight:y,strideWidth:b,filterHeight:p,filterWidth:m,effectiveFilterHeight:E,effectiveFilterWidth:C,dilationHeight:w,dilationWidth:k,inShape:t,outShape:d,filterShape:e};}function Ti(t,e,n,r,i,o,a,s){void 0===o&&(o=!1),void 0===a&&(a="channelsLast");var u=[-1,-1,-1,-1,-1],c=u[0],l=u[1],f=u[2],h=u[3],d=u[4];if("channelsLast"===a)c=t[0],l=t[1],f=t[2],h=t[3],d=t[4];else {if("channelsFirst"!==a)throw new Error("Unknown dataFormat "+a);c=t[0],d=t[1],l=t[2],f=t[3],h=t[4];}var p,m=e[0],g=e[1],v=e[2],y=e[4],b=Ri(n),x=b[0],w=b[1],k=b[2],E=Ri(r),C=E[0],A=E[1],O=E[2],S=Mi(m,C),D=Mi(g,A),F=Mi(v,O),T=function(t,e,n,r,i,o,a,s,u,c,l){var f,h,d,p;if("number"==typeof t){f={top:t,bottom:t,left:t,right:t,front:t,back:t,type:0===t?"VALID":"NUMBER"};var m=function(t,e,n,r,i,o){null==i&&(i=Ni(t,e,r));var a=t[1],s=t[2],u=ji((t[0]-e+2*i)/r+1,o);_(I(u),function(){return "The output # of depths ("+u+") must be an integer. Change the stride and/or zero pad parameters";});var c=ji((a-e+2*i)/r+1,o);_(I(c),function(){return "The output # of rows ("+c+") must be an integer. Change the stride and/or zero pad parameters";});var l=ji((s-e+2*i)/r+1,o);return _(I(l),function(){return "The output # of columns ("+l+") must be an integer. Change the stride and/or zero pad parameters";}),[u,c,l,1];}([e,n,r,1],s,0,i,t,l);h=m[0],d=m[1],p=m[2];}else if("same"===t){var g=((h=Math.ceil(e/i))-1)*i+s-e,v=((d=Math.ceil(n/o))-1)*o+u-n,y=((p=Math.ceil(r/a))-1)*a+c-r,b=Math.floor(g/2),x=g-b,w=Math.floor(v/2),k=v-w,E=Math.floor(y/2);f={top:w,bottom:k,left:E,right:y-E,front:b,back:x,type:"SAME"};}else {if("valid"!==t)throw Error("Unknown padding parameter: "+t);f={top:0,bottom:0,left:0,right:0,front:0,back:0,type:"VALID"},h=Math.ceil((e-s+1)/i),d=Math.ceil((n-u+1)/o),p=Math.ceil((r-c+1)/a);}return {padInfo:f,outDepth:h,outHeight:d,outWidth:p};}(i,l,f,h,x,w,k,S,D,F,s),N=T.padInfo,R=T.outDepth,M=T.outHeight,j=T.outWidth,B=o?y*d:y;return "channelsFirst"===a?p=[c,B,R,M,j]:"channelsLast"===a&&(p=[c,R,M,j,B]),{batchSize:c,dataFormat:a,inDepth:l,inHeight:f,inWidth:h,inChannels:d,outDepth:R,outHeight:M,outWidth:j,outChannels:B,padInfo:N,strideDepth:x,strideHeight:w,strideWidth:k,filterDepth:m,filterHeight:g,filterWidth:v,effectiveFilterDepth:S,effectiveFilterHeight:D,effectiveFilterWidth:F,dilationDepth:C,dilationHeight:A,dilationWidth:O,inShape:t,outShape:p,filterShape:e};}function Ni(t,e,n,r){void 0===r&&(r=1);var i=Mi(e,r);return Math.floor((t[0]*(n-1)-n+i)/2);}function Ii(t){return "number"==typeof t?[t,t,t]:2===t.length?[t[0],t[1],1]:t;}function Ri(t){return "number"==typeof t?[t,t,t]:t;}function Mi(t,e){return e<=1?t:t+(t-1)*(e-1);}function ji(t,e){if(!e)return t;switch(e){case"round":return Math.round(t);case"ceil":return Math.ceil(t);case"floor":return Math.floor(t);default:throw new Error("Unknown roundingMode "+e);}}function Bi(t){var e=Ii(t),n=e[0],r=e[1],i=e[2];return 1===n&&1===r&&1===i;}function Pi(t,e){return Bi(t)||Bi(e);}function Li(t){if("NHWC"===t)return "channelsLast";if("NCHW"===t)return "channelsFirst";throw new Error("Unknown dataFormat "+t);}function zi(t,e,n){if("complex64"===e){if("complex64"===t.dtype)return t.clone();var r=Gn(t.shape),i=t.toFloat(),o=n.complex(i,r);return r.dispose(),i.dispose(),o;}if(!$(t.dtype,e))return Wt.makeTensorFromDataId(t.dataId,t.shape,e);if("complex64"===t.dtype){var a=n.real(t);return o=a.cast(e),a.dispose(),o;}if("int32"===e)return n.int(t);if("bool"===e){var s=Pn(0,t.dtype);return o=n.notEqual(t,s),s.dispose(),o;}throw new Error("Error in Cast: failed to cast "+t.dtype+" to "+e);}function Ui(t,e){return Wt.makeTensorFromDataId(t.dataId,e,t.dtype);}function Wi(t,e,n){var r=(e-t)/(n-1),i=ot(n,"float32");i[0]=t;for(var o=1;o<i.length;o++){i[o]=i[o-1]+r;}return Ln(i,"float32");}var Vi=Object.freeze({castTensor:zi,reshapeTensor:Ui,linspaceImpl:Wi,upcastType:It,axesAreInnerMostDims:kn,combineLocations:En,computeOutAndReduceShapes:Cn,expandShapeToKeepDim:An,assertAxesAreInnerMostDims:On,getAxesPermutation:_n,getUndoAxesPermutation:Sn,getInnerMostAxes:Dn,getBroadcastDims:Ai,getReductionAxes:Oi,assertAndGetBroadcastShape:_i,assertParamsConsistent:Fn,computeOutShape:Tn,computePool2DInfo:Si,computePool3DInfo:Di,computeConv2DInfo:Fi,computeConv3DInfo:Ti,computeDefaultPad:Ni,tupleValuesAreOne:Bi,eitherStridesOrDilationsAreOne:Pi,convertConv2DDataFormat:Li,PARALLELIZE_THRESHOLD:Zr,computeOptimalWindowSize:ti});function qi(t,e){if(t.length!==e.length)throw new Error("Cannot merge real and imag arrays of different lengths. real:"+t.length+", imag: "+e.length+".");for(var n=new Float32Array(2*t.length),r=0;r<n.length;r+=2){n[r]=t[r/2],n[r+1]=e[r/2];}return n;}function $i(t,e){return {real:t[2*e],imag:t[2*e+1]};}function Hi(t,e,n,r){t[2*r]=e,t[2*r+1]=n;}function Gi(t,e,n){var r=(n?2:-2)*Math.PI*(t/e);return {real:Math.cos(r),imag:Math.sin(r)};}function Ki(t,e,n){var r=function(t,e,n){return function(t,e,n){for(var r=0,i=t.length,o=0,a=!1;r<i;){var s=n(e,t[o=r+(i-r>>>1)]);s>0?r=o+1:(i=o,a=!s);}return a?r:-r-1;}(t,e,n||Xi);}(t,e,n),i=r<0?-(r+1):r;t.splice(i,0,e);}function Xi(t,e){return t>e?1:t<e?-1:0;}function Yi(t,e,n,r,i){return Qi(t,e,n,r,i,0).selectedIndices;}function Ji(t,e,n,r,i,o){var a=Qi(t,e,n,r,i,o);return a.numValidOutputs.dispose(),{selectedIndices:a.selectedIndices,selectedScores:a.selectedScores};}function Qi(t,e,n,r,i,o,a,s){void 0===s&&(s=!1);for(var u=Array.from(e).map(function(t,e){return {score:t,boxIndex:e,suppressBeginIndex:0};}).filter(function(t){return t.score>i;}).sort(eo),c=o>0?-.5/o:0,l=[],f=[];l.length<n&&u.length>0;){var h=u.pop(),d=h.score,p=h.boxIndex,m=h.suppressBeginIndex;if(d<i)break;for(var g=!1,v=l.length-1;v>=m;--v){var y=Zi(t,p,l[v]);if(y>=r){g=!0;break;}if(h.score=h.score*to(r,c,y),h.score<=i)break;}h.suppressBeginIndex=l.length,g||(h.score===d?(l.push(p),f.push(h.score)):h.score>i&&Ki(u,h,eo));}var b=l.length;return s&&(l.fill(0,b),f.fill(0,b)),{selectedIndices:Ln(l,"int32"),selectedScores:Ln(f,"float32"),numValidOutputs:Pn(b,"int32")};}function Zi(t,e,n){var r=t.subarray(4*e,4*e+4),i=t.subarray(4*n,4*n+4),o=Math.min(r[0],r[2]),a=Math.min(r[1],r[3]),s=Math.max(r[0],r[2]),u=Math.max(r[1],r[3]),c=Math.min(i[0],i[2]),l=Math.min(i[1],i[3]),f=Math.max(i[0],i[2]),h=Math.max(i[1],i[3]),d=(s-o)*(u-a),p=(f-c)*(h-l);if(d<=0||p<=0)return 0;var m=Math.max(o,c),g=Math.max(a,l),v=Math.min(s,f),y=Math.min(u,h),b=Math.max(v-m,0)*Math.max(y-g,0);return b/(d+p-b);}function to(t,e,n){var r=Math.exp(e*n*n);return n<=t?r:0;}function eo(t,e){return t.score-e.score||t.score===e.score&&e.boxIndex-t.boxIndex;}function no(t,e,n){var r=new Array(t.rank).fill(0),i=t.shape.slice();return e.map(function(e){i[n]=e;var o=t.slice(r,i);return r[n]+=e,o;});}function ro(t,e){for(var n=new Array(t.rank),r=0;r<n.length;r++){n[r]=t.shape[r]*e[r];}var i=vr(n,t.dtype);for(r=0;r<i.values.length;++r){for(var o=i.indexToLoc(r),a=new Array(t.rank),s=0;s<a.length;s++){a[s]=o[s]%t.shape[s];}var u=t.locToIndex(a);i.values[r]=t.values[u];}return i.toTensor();}function io(t,e,n,r,i){for(var o=e[e.length-1],a=[t.length/o,o],s=a[0],u=a[1],c=U(n,s*r),l=U("int32",s*r),f=0;f<s;f++){for(var h=f*u,d=t.subarray(h,h+u),p=[],m=0;m<d.length;m++){p.push({value:d[m],index:m});}p.sort(function(t,e){return e.value-t.value;});var g=f*r,v=c.subarray(g,g+r),y=l.subarray(g,g+r);for(m=0;m<r;m++){v[m]=p[m].value,y[m]=p[m].index;}}var b=e.slice();return b[b.length-1]=r,[jn(c,b,n),jn(l,b,"int32")];}function oo(t,e){for(var n=[],r=0;r<e.length;r++){e[r]&&n.push(r);}var i=vr(t,"int32"),o=vr([n.length,t.length],"int32");for(r=0;r<n.length;r++){var a=i.indexToLoc(n[r]),s=r*t.length;o.values.set(a,s);}return o.toTensor();}function ao(t,e){return ["x","y","z","w","u","v"].slice(0,e).map(function(e){return t+"."+e;});}function so(t,e){return 1===e?[t]:ao(t,e);}function uo(){var t,e,n,r,i,o,a,s,u,c;return 2===f().getNumber("WEBGL_VERSION")?(t="#version 300 es",e="in",n="out",r="in",i="texture",o="outputColor",a="out vec4 outputColor;",s="\n      bool isnan_custom(float val) {\n        return (val > 0.0 || val < 0.0) ? false : val != 0.0;\n      }\n\n      bvec4 isnan_custom(vec4 val) {\n        return bvec4(isnan_custom(val.x),\n          isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n      }\n\n      #define isnan(value) isnan_custom(value)\n    ",u="",c="\n      #define round(value) newRound(value)\n      int newRound(float value) {\n        return int(floor(value + 0.5));\n      }\n\n      ivec4 newRound(vec4 value) {\n        return ivec4(floor(value + vec4(0.5)));\n      }\n    "):(t="",e="attribute",n="varying",r="varying",i="texture2D",o="gl_FragColor",a="",s="\n      #define isnan(value) isnan_custom(value)\n      bool isnan_custom(float val) {\n        return (val > 0. || val < 1. || val == 0.) ? false : true;\n      }\n      bvec4 isnan_custom(vec4 val) {\n        return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n      }\n    ",u="\n      uniform float INFINITY;\n\n      bool isinf(float val) {\n        return abs(val) == INFINITY;\n      }\n      bvec4 isinf(vec4 val) {\n        return equal(abs(val), vec4(INFINITY));\n      }\n    ",c="\n      int round(float value) {\n        return int(floor(value + 0.5));\n      }\n\n      ivec4 round(vec4 value) {\n        return ivec4(floor(value + vec4(0.5)));\n      }\n    "),{version:t,attribute:e,varyingVs:n,varyingFs:r,texture2D:i,output:o,defineOutput:a,defineSpecialNaN:s,defineSpecialInf:u,defineRound:c};}function co(t,e,n){void 0===n&&(n="index");var r=et(e);return r.map(function(e,i){return "int "+t[i]+" = "+n+" / "+e+"; "+(i===r.length-1?"int "+t[i+1]+" = "+n+" - "+t[i]+" * "+e:"index -= "+t[i]+" * "+e)+";";}).join("");}function lo(t){var e=et(t).map(function(t){return t.toString();});return "\n  int getFlatIndex(ivec3 coords) {\n    return coords.x * "+e[0]+" + coords.y * "+e[1]+" + coords.z;\n  }\n";}var fo="\n  const float FLOAT_MAX = 1.70141184e38;\n  const float FLOAT_MIN = 1.17549435e-38;\n\n  lowp vec4 encode_float(highp float v) {\n    if (isnan(v)) {\n      return vec4(255, 255, 255, 255);\n    }\n\n    highp float av = abs(v);\n\n    if(av < FLOAT_MIN) {\n      return vec4(0.0, 0.0, 0.0, 0.0);\n    } else if(v > FLOAT_MAX) {\n      return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n    } else if(v < -FLOAT_MAX) {\n      return vec4(0.0, 0.0,  128.0, 255.0) / 255.0;\n    }\n\n    highp vec4 c = vec4(0,0,0,0);\n\n    highp float e = floor(log2(av));\n    highp float m = exp2(fract(log2(av))) - 1.0;\n\n    c[2] = floor(128.0 * m);\n    m -= c[2] / 128.0;\n    c[1] = floor(32768.0 * m);\n    m -= c[1] / 32768.0;\n    c[0] = floor(8388608.0 * m);\n\n    highp float ebias = e + 127.0;\n    c[3] = floor(ebias / 2.0);\n    ebias -= c[3] * 2.0;\n    c[2] += floor(ebias) * 128.0;\n\n    c[3] += 128.0 * step(0.0, -v);\n\n    return c / 255.0;\n  }\n";function ho(t,e,n,r){var i=[];t.forEach(function(t){var e=T(t.shapeInfo.logicalShape);t.shapeInfo.isUniform?i.push("uniform float "+t.name+(e>1?"["+e+"]":"")+";"):(i.push("uniform sampler2D "+t.name+";"),i.push("uniform int offset"+t.name+";"));});var o,a,s=i.join("\n"),u=t.map(function(t){return function(t,e,n){void 0===n&&(n=!1);var r="";r+=n?function t(e){var n,r,i;switch(e.shapeInfo.logicalShape.length){case 0:return n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),i=uo(),"\n    vec4 "+r+"() {\n      return "+i.texture2D+"("+n+", halfCR);\n    }\n  ";case 1:return function(t){var e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1),r=t.shapeInfo.texShape,i=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)],o=uo();return "\n    vec4 "+n+"(int index) {\n      vec2 uv = packedUVfrom1D(\n        "+i[0]+", "+i[1]+", index);\n      return "+o.texture2D+"("+e+", uv);\n    }\n  ";}(e);case 2:return function(t){var e=t.shapeInfo.logicalShape,n=t.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),i=t.shapeInfo.texShape,o=i[0],a=i[1],s=uo();if(null!=i&&N(e,i))return "\n      vec4 "+r+"(int row, int col) {\n        vec2 uv = (vec2(col, row) + halfCR) / vec2("+a+".0, "+o+".0);\n\n        return "+s.texture2D+"("+n+", uv);\n      }\n    ";var u=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)],c=Math.ceil(e[1]/2);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  ";}(e);case 3:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,i="get"+r.charAt(0).toUpperCase()+r.slice(1),o=e.shapeInfo.texShape,a=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)];if(1===n[0]){var s=n.slice(1),u=wo(e,s);return "\n        "+t(u)+"\n        vec4 "+i+"(int b, int row, int col) {\n          return "+i+"("+ko(["b","row","col"],[1,2])+");\n        }\n      ";}var c=a[0],l=a[1],f=Math.ceil(n[2]/2),h=f*Math.ceil(n[1]/2),d=uo();return "\n    vec4 "+i+"(int b, int row, int col) {\n      vec2 uv = packedUVfrom3D(\n        "+c+", "+l+", "+h+", "+f+", b, row, col);\n      return "+d.texture2D+"("+r+", uv);\n    }\n  ";}(e);default:return function(t){for(var e=t.shapeInfo.logicalShape,n=e.length,r=t.name,i="get"+r.charAt(0).toUpperCase()+r.slice(1),o=t.shapeInfo.texShape,a=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)],s=a[0],u=a[1],c=Math.ceil(e[n-1]/2),l=c*Math.ceil(e[n-2]/2),f="int b, int row, int col",h="b * "+l+" + (row / 2) * "+c+" + (col / 2)",d=2;d<n-1;d++){f="int b"+d+", "+f,l*=e[n-d-1],h="b"+d+" * "+l+" + "+h;}var p=uo();return "\n    vec4 "+i+"("+f+") {\n      int index = "+h+";\n      int texR = index / "+u+";\n      int texC = index - texR * "+u+";\n      vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+u+", "+s+");\n      return "+p.texture2D+"("+r+", uv);\n    }\n  ";}(e);}}(t):function t(e){var n=e.shapeInfo.logicalShape;switch(n.length){case 0:return function(t){var e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1);if(t.shapeInfo.isUniform)return "float "+n+"() {return "+e+";}";var r=t.shapeInfo.texShape,i=r[0],o=r[1];if(1===i&&1===o)return "\n      float "+n+"() {\n        return sampleTexture("+e+", halfCR);\n      }\n    ";var a=t.shapeInfo.texShape,s=a[0],u=a[1],c=yo(e);return "\n    float "+n+"() {\n      vec2 uv = uvFromFlat("+s+", "+u+", "+c+");\n      return sampleTexture("+e+", uv);\n    }\n  ";}(e);case 1:return function(t){var e=t.name,n="get"+e.charAt(0).toUpperCase()+e.slice(1);if(t.shapeInfo.isUniform)return "\n      float "+n+"(int index) {\n        "+bo(t)+"\n      }\n    ";var r=t.shapeInfo.texShape,i=r[0],o=r[1];if(1===o&&1===i)return "\n      float "+n+"(int index) {\n        return sampleTexture("+e+", halfCR);\n      }\n    ";var a=yo(e);return 1===o?"\n      float "+n+"(int index) {\n        vec2 uv = vec2(0.5, (float(index + "+a+") + 0.5) / "+i+".0);\n        return sampleTexture("+e+", uv);\n      }\n    ":1===i?"\n      float "+n+"(int index) {\n        vec2 uv = vec2((float(index + "+a+") + 0.5) / "+o+".0, 0.5);\n        return sampleTexture("+e+", uv);\n      }\n    ":"\n    float "+n+"(int index) {\n      vec2 uv = uvFromFlat("+i+", "+o+", index + "+a+");\n      return sampleTexture("+e+", uv);\n    }\n  ";}(e);case 2:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,i="get"+r.charAt(0).toUpperCase()+r.slice(1),o=e.shapeInfo.texShape;if(null!=o&&N(n,o)){var a=o[0],s=o[1];return "\n    float "+i+"(int row, int col) {\n      vec2 uv = (vec2(col, row) + halfCR) / vec2("+s+".0, "+a+".0);\n      return sampleTexture("+r+", uv);\n    }\n  ";}var u=z(n),c=u.newShape,l=u.keptDims,f=c;if(f.length<n.length){var h=wo(e,f);return "\n      "+t(h)+"\n      float "+i+"(int row, int col) {\n        return "+i+"("+ko(["row","col"],l)+");\n      }\n    ";}if(e.shapeInfo.isUniform)return "\n      float "+i+"(int row, int col) {\n        int index = round(dot(vec2(row, col), vec2("+n[1]+", 1)));\n        "+bo(e)+"\n      }\n    ";var d=o[0],p=o[1],m=yo(r);return 1===p?"\n    float "+i+"(int row, int col) {\n      float index = dot(vec3(row, col, "+m+"), vec3("+n[1]+", 1, 1));\n      vec2 uv = vec2(0.5, (index + 0.5) / "+d+".0);\n      return sampleTexture("+r+", uv);\n    }\n  ":1===d?"\n    float "+i+"(int row, int col) {\n      float index = dot(vec3(row, col, "+m+"), vec3("+n[1]+", 1, 1));\n      vec2 uv = vec2((index + 0.5) / "+p+".0, 0.5);\n      return sampleTexture("+r+", uv);\n    }\n  ":"\n  float "+i+"(int row, int col) {\n    // Explicitly use integer operations as dot() only works on floats.\n    int index = row * "+n[1]+" + col + "+m+";\n    vec2 uv = uvFromFlat("+d+", "+p+", index);\n    return sampleTexture("+r+", uv);\n  }\n";}(e);case 3:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,i="get"+r.charAt(0).toUpperCase()+r.slice(1),o=n[1]*n[2],a=n[2],s=z(n),u=s.newShape,c=s.keptDims,l=u;if(l.length<n.length){var f=wo(e,l);return "\n        "+t(f)+"\n        float "+i+"(int row, int col, int depth) {\n          return "+i+"("+ko(["row","col","depth"],c)+");\n        }\n      ";}if(e.shapeInfo.isUniform)return "\n      float "+i+"(int row, int col, int depth) {\n        int index = round(dot(vec3(row, col, depth),\n                          vec3("+o+", "+a+", 1)));\n        "+bo(e)+"\n      }\n    ";var h=e.shapeInfo.texShape,d=h[0],p=h[1],m=e.shapeInfo.flatOffset;if(p===o&&null==m)return "\n        float "+i+"(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("+p+".0, "+d+".0);\n          return sampleTexture("+r+", uv);\n        }\n      ";if(p===a&&null==m)return "\n    float "+i+"(int row, int col, int depth) {\n      float texR = dot(vec2(row, col), vec2("+n[1]+", 1));\n      float texC = float(depth);\n      vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+p+".0, "+d+".0);\n      return sampleTexture("+r+", uv);\n    }\n  ";var g=yo(r);return "\n      float "+i+"(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 + "+g+";\n        vec2 uv = uvFromFlat("+d+", "+p+", index);\n        return sampleTexture("+r+", uv);\n      }\n  ";}(e);case 4:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,i="get"+r.charAt(0).toUpperCase()+r.slice(1),o=n[3],a=n[2]*o,s=n[1]*a,u=z(n),c=u.newShape,l=u.keptDims;if(c.length<n.length){var f=wo(e,c);return "\n      "+t(f)+"\n      float "+i+"(int row, int col, int depth, int depth2) {\n        return "+i+"("+ko(["row","col","depth","depth2"],l)+");\n      }\n    ";}if(e.shapeInfo.isUniform)return "\n      float "+i+"(int row, int col, int depth, int depth2) {\n        int index = round(dot(vec4(row, col, depth, depth2),\n                          vec4("+s+", "+a+", "+o+", 1)));\n        "+bo(e)+"\n      }\n    ";var h=e.shapeInfo.flatOffset,d=e.shapeInfo.texShape,p=d[0],m=d[1];if(m===s&&null==h)return "\n      float "+i+"(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("+m+".0, "+p+".0);\n        return sampleTexture("+r+", uv);\n      }\n    ";if(m===o&&null==h)return "\n      float "+i+"(int row, int col, int depth, int depth2) {\n        float texR = dot(vec3(row, col, depth),\n                         vec3("+n[1]*n[2]+", "+n[2]+", 1));\n        float texC = float(depth2);\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2("+m+".0, "+p+".0);\n        return sampleTexture("+r+", uv);\n      }\n    ";var g=yo(r);return "\n    float "+i+"(int row, int col, int depth, int depth2) {\n      // Explicitly use integer operations as dot() only works on floats.\n      int index = row * "+s+" + col * "+a+" +\n          depth * "+o+" + depth2;\n      vec2 uv = uvFromFlat("+p+", "+m+", index + "+g+");\n      return sampleTexture("+r+", uv);\n    }\n  ";}(e);case 5:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,i="get"+r.charAt(0).toUpperCase()+r.slice(1),o=n[4],a=n[3]*o,s=n[2]*a,u=n[1]*s,c=z(n),l=c.newShape,f=c.keptDims;if(l.length<n.length){var h=wo(e,l);return "\n      "+t(h)+"\n      float "+i+"(int row, int col, int depth, int depth2, int depth3) {\n        return "+i+"("+ko(["row","col","depth","depth2","depth3"],f)+");\n      }\n    ";}if(e.shapeInfo.isUniform)return "\n      float "+i+"(int row, int col, int depth, int depth2, int depth3) {\n        float index = dot(\n          vec4(row, col, depth, depth2),\n          vec4("+u+", "+s+", "+a+", "+o+")) +\n          depth3;\n        "+bo(e)+"\n      }\n    ";var d=e.shapeInfo.flatOffset,p=e.shapeInfo.texShape,m=p[0],g=p[1];if(g===u&&null==d)return "\n      float "+i+"(int row, int col, int depth, int depth2, int depth3) {\n        int texR = row;\n        float texC = dot(vec4(col, depth, depth2, depth3),\n                         vec4("+s+", "+a+", "+o+", 1));\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                   vec2("+g+".0, "+m+".0);\n        return sampleTexture("+r+", uv);\n      }\n    ";if(g===o&&null==d)return "\n      float "+i+"(int row, int col, int depth, int depth2, int depth3) {\n        float texR = dot(\n          vec4(row, col, depth, depth2),\n          vec4("+n[1]*n[2]*n[3]+",\n               "+n[2]*n[3]+", "+n[3]+", 1));\n        int texC = depth3;\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2("+g+".0, "+m+".0);\n        return sampleTexture("+r+", uv);\n      }\n    ";var v=yo(r);return "\n    float "+i+"(int row, int col, int depth, int depth2, int depth3) {\n      // Explicitly use integer operations as dot() only works on floats.\n      int index = row * "+u+" + col * "+s+" + depth * "+a+" +\n          depth2 * "+o+" + depth3 + "+v+";\n      vec2 uv = uvFromFlat("+m+", "+g+", index);\n      return sampleTexture("+r+", uv);\n    }\n  ";}(e);case 6:return function(e){var n=e.shapeInfo.logicalShape,r=e.name,i="get"+r.charAt(0).toUpperCase()+r.slice(1),o=z(n),a=o.newShape,s=o.keptDims;if(a.length<n.length){var u=wo(e,a);return "\n      "+t(u)+"\n      float "+i+"(int row, int col, int depth,\n                    int depth2, int depth3, int depth4) {\n        return "+i+"("+ko(["row","col","depth","depth2","depth3","depth4"],s)+");\n      }\n    ";}var c=n[5],l=n[4]*c,f=n[3]*l,h=n[2]*f,d=n[1]*h;if(e.shapeInfo.isUniform)return "\n      float "+i+"(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("+d+", "+h+", "+f+", "+l+")) +\n          dot(\n            vec2(depth3, depth4),\n            vec2("+c+", 1)));\n        "+bo(e)+"\n      }\n    ";var p=e.shapeInfo.flatOffset,m=e.shapeInfo.texShape,g=m[0],v=m[1];if(v===d&&null==p)return "\n      float "+i+"(int row, int col, int depth,\n                    int depth2, int depth3, int depth4) {\n        int texR = row;\n        float texC = dot(vec4(col, depth, depth2, depth3),\n          vec4("+h+", "+f+", "+l+", "+c+")) +\n               float(depth4);\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                   vec2("+v+".0, "+g+".0);\n        return sampleTexture("+r+", uv);\n      }\n    ";if(v===c&&null==p)return "\n      float "+i+"(int row, int col, int depth,\n                    int depth2, int depth3, int depth4) {\n        float texR = dot(vec4(row, col, depth, depth2),\n          vec4("+n[1]*n[2]*n[3]*n[4]+",\n               "+n[2]*n[3]*n[4]+",\n               "+n[3]*n[4]+",\n               "+n[4]+")) + float(depth3);\n        int texC = depth4;\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2("+v+".0, "+g+".0);\n        return sampleTexture("+r+", uv);\n      }\n    ";var y=yo(r);return "\n    float "+i+"(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 * "+d+" + col * "+h+" + depth * "+f+" +\n          depth2 * "+l+" + depth3 * "+c+" + depth4 + "+y+";\n      vec2 uv = uvFromFlat("+g+", "+v+", index);\n      return sampleTexture("+r+", uv);\n    }\n  ";}(e);default:throw new Error(n.length+"-D input sampling is not yet supported");}}(t);var i=t.shapeInfo.logicalShape,o=e.logicalShape;return i.length<=o.length&&(r+=n?function(t,e){var n,r=t.name,i=r.charAt(0).toUpperCase()+r.slice(1),o="get"+i+"AtOutCoords",a=t.shapeInfo.logicalShape.length,s=e.logicalShape.length,u=Ai(t.shapeInfo.logicalShape,e.logicalShape),c=xo(s),l=s-a,f=["x","y","z","w","u","v"];n=0===a?"":s<2&&u.length>=1?"coords = 0;":u.map(function(t){return "coords."+f[t+l]+" = 0;";}).join("\n");var h;h=s<2&&a>0?"coords":t.shapeInfo.logicalShape.map(function(t,e){return "coords."+f[e+l];}).join(", ");var d="return outputValue;",p=1===T(t.shapeInfo.logicalShape),m=1===T(e.logicalShape);if(1!==a||p||m){if(p&&!m)d=1===s?"\n        return vec4(outputValue.x, outputValue.x, 0., 0.);\n      ":"\n        return vec4(outputValue.x);\n      ";else if(u.length){var g=a-2,v=a-1;u.indexOf(g)>-1&&u.indexOf(v)>-1?d="return vec4(outputValue.x);":u.indexOf(g)>-1?d="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":u.indexOf(v)>-1&&(d="return vec4(outputValue.xx, outputValue.zz);");}}else d="\n      return vec4(outputValue.xy, outputValue.xy);\n    ";return "\n    vec4 "+o+"() {\n      "+c+" coords = getOutputCoords();\n      "+n+"\n      vec4 outputValue = get"+i+"("+h+");\n      "+d+"\n    }\n  ";}(t,e):function(t,e){var n=t.name,r=n.charAt(0).toUpperCase()+n.slice(1),i="get"+r+"AtOutCoords",o=e.texShape,a=t.shapeInfo.texShape,s=t.shapeInfo.logicalShape.length,u=e.logicalShape.length;if(!t.shapeInfo.isUniform&&s===u&&null==t.shapeInfo.flatOffset&&N(a,o))return "\n      float "+i+"() {\n        return sampleTexture("+n+", resultUV);\n      }\n    ";var c=xo(u),l=Ai(t.shapeInfo.logicalShape,e.logicalShape),f=u-s,h=["x","y","z","w","u","v"];return "\n    float "+i+"() {\n      "+c+" coords = getOutputCoords();\n      "+(0===s?"":u<2&&l.length>=1?"coords = 0;":l.map(function(t){return "coords."+h[t+f]+" = 0;";}).join("\n"))+"\n      return get"+r+"("+(u<2&&s>0?"coords":t.shapeInfo.logicalShape.map(function(t,e){return "coords."+h[e+f];}).join(", "))+");\n    }\n  ";}(t,e)),r;}(t,e,r);}).join("\n"),c=e.texShape,l=uo(),f="\n    float sampleTexture(sampler2D textureSampler, vec2 uv) {\n      return "+l.texture2D+"(textureSampler, uv).r;\n    }\n  ",h=function(t){return t.version+"\n    precision highp float;\n    precision highp int;\n    precision highp sampler2D;\n    "+t.varyingFs+" vec2 resultUV;\n    "+t.defineOutput+"\n    const vec2 halfCR = vec2(0.5, 0.5);\n\n    struct ivec5\n    {\n      int x;\n      int y;\n      int z;\n      int w;\n      int u;\n    };\n\n    struct ivec6\n    {\n      int x;\n      int y;\n      int z;\n      int w;\n      int u;\n      int v;\n    };\n\n    uniform float NAN;\n    "+t.defineSpecialNaN+"\n    "+t.defineSpecialInf+"\n    "+t.defineRound+"\n\n    int imod(int x, int y) {\n      return x - y * (x / y);\n    }\n\n    int idiv(int a, int b, float sign) {\n      int res = a / b;\n      int mod = imod(a, b);\n      if (sign < 0. && mod != 0) {\n        res -= 1;\n      }\n      return res;\n    }\n\n    //Based on the work of Dave Hoskins\n    //https://www.shadertoy.com/view/4djSRW\n    #define HASHSCALE1 443.8975\n    float random(float seed){\n      vec2 p = resultUV * seed;\n      vec3 p3  = fract(vec3(p.xyx) * HASHSCALE1);\n      p3 += dot(p3, p3.yzx + 19.19);\n      return fract((p3.x + p3.y) * p3.z);\n    }\n\n    "+po+"\n    "+mo+"\n    "+go+"\n  ";}(l);return e.isPacked?(o=function(t,e){switch(t.length){case 0:return "\n    int getOutputCoords() {\n      return 0;\n    }\n  ";case 1:return function(t,e){var n=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];return 1===n[0]?"\n      int getOutputCoords() {\n        return 2 * int(resultUV.x * "+n[1]+".0);\n      }\n    ":1===n[1]?"\n      int getOutputCoords() {\n        return 2 * int(resultUV.y * "+n[0]+".0);\n      }\n    ":"\n    int getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+n[0]+", "+n[1]+"));\n      return 2 * (resTexRC.x * "+n[1]+" + resTexRC.y);\n    }\n  ";}(0,e);case 2:return function(t,e){var n=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)];if(N(t,e))return "\n      ivec2 getOutputCoords() {\n        return 2 * ivec2(resultUV.yx * vec2("+n[0]+", "+n[1]+"));\n      }\n    ";var r=Math.ceil(t[1]/2);return "\n    ivec2 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+n[0]+", "+n[1]+"));\n\n      int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n      int r = 2 * (index / "+r+");\n      int c = imod(index, "+r+") * 2;\n\n      return ivec2(r, c);\n    }\n  ";}(t,e);case 3:return n=t,r=e,i=[Math.ceil(r[0]/2),Math.ceil(r[1]/2)],a=(o=Math.ceil(n[2]/2))*Math.ceil(n[1]/2),"\n    ivec3 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+i[0]+", "+i[1]+"));\n      int index = resTexRC.x * "+i[1]+" + resTexRC.y;\n\n      int b = index / "+a+";\n      index -= b * "+a+";\n\n      int r = 2 * (index / "+o+");\n      int c = imod(index, "+o+") * 2;\n\n      return ivec3(b, r, c);\n    }\n  ";default:return function(t,e){for(var n=[Math.ceil(e[0]/2),Math.ceil(e[1]/2)],r=Math.ceil(t[t.length-1]/2),i=r*Math.ceil(t[t.length-2]/2),o=i,a="",s="b, r, c",u=2;u<t.length-1;u++){a="\n      int b"+u+" = index / "+(o*=t[t.length-u-1])+";\n      index -= b"+u+" * "+o+";\n    "+a,s="b"+u+", "+s;}return "\n    ivec"+t.length+" getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+n[0]+", "+n[1]+"));\n      int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n\n      "+a+"\n\n      int b = index / "+i+";\n      index -= b * "+i+";\n\n      int r = 2 * (index / "+r+");\n      int c = imod(index, "+r+") * 2;\n\n      return ivec"+t.length+"("+s+");\n    }\n  ";}(t,e);}var n,r,i,o,a;}(e.logicalShape,c),a="\n    void setOutput(vec4 val) {\n      "+l.output+" = val;\n    }\n  "):(o=function(t,e){switch(t.length){case 0:return "\n    int getOutputCoords() {\n      return 0;\n    }\n  ";case 1:return function(t,e){return 1===e[0]?"\n      int getOutputCoords() {\n        return int(resultUV.x * "+e[1]+".0);\n      }\n    ":1===e[1]?"\n      int getOutputCoords() {\n        return int(resultUV.y * "+e[0]+".0);\n      }\n    ":"\n    int getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+e[0]+", "+e[1]+"));\n      return resTexRC.x * "+e[1]+" + resTexRC.y;\n    }\n  ";}(0,e);case 2:return function(t,e){return N(t,e)?"\n      ivec2 getOutputCoords() {\n        return ivec2(resultUV.yx * vec2("+e[0]+", "+e[1]+"));\n      }\n    ":1===t[1]?"\n      ivec2 getOutputCoords() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n                               vec2("+e[0]+", "+e[1]+"));\n        int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n        return ivec2(index, 0);\n      }\n    ":1===t[0]?"\n      ivec2 getOutputCoords() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n                               vec2("+e[0]+", "+e[1]+"));\n        int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n        return ivec2(0, index);\n      }\n    ":"\n    ivec2 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+e[0]+", "+e[1]+"));\n      int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n      int r = index / "+t[1]+";\n      int c = index - r * "+t[1]+";\n      return ivec2(r, c);\n    }\n  ";}(t,e);case 3:return n=e,r=co(["r","c","d"],t),"\n    ivec3 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2("+n[0]+", "+n[1]+"));\n      int index = resTexRC.x * "+n[1]+" + resTexRC.y;\n      "+r+"\n      return ivec3(r, c, d);\n    }\n  ";case 4:return function(t,e){var n=co(["r","c","d","d2"],t);return "\n    ivec4 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n        vec2("+e[0]+", "+e[1]+"));\n      int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n      "+n+"\n      return ivec4(r, c, d, d2);\n    }\n  ";}(t,e);case 5:return function(t,e){var n=co(["r","c","d","d2","d3"],t);return "\n    ivec5 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx * vec2("+e[0]+",\n                             "+e[1]+"));\n\n      int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n\n      "+n+"\n\n      ivec5 outShape = ivec5(r, c, d, d2, d3);\n      return outShape;\n    }\n  ";}(t,e);case 6:return function(t,e){var n=co(["r","c","d","d2","d3","d4"],t);return "\n    ivec6 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n        vec2("+e[0]+", "+e[1]+"));\n      int index = resTexRC.x * "+e[1]+" + resTexRC.y;\n\n      "+n+"\n\n      ivec6 result = ivec6(r, c, d, d2, d3, d4);\n      return result;\n    }\n  ";}(t,e);default:throw new Error(t.length+"-D output sampling is not yet supported");}var n,r;}(e.logicalShape,c),a="\n    void setOutput(float val) {\n      "+l.output+" = vec4(val, 0, 0, 0);\n    }\n  "),r&&(h+=vo),[h,f,a,s,o,u,n].join("\n");}var po="\nvec2 uvFromFlat(int texNumR, int texNumC, int index) {\n  int texR = index / texNumC;\n  int texC = index - texR * texNumC;\n  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\nvec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n  int texelIndex = index / 2;\n  int texR = texelIndex / texNumC;\n  int texC = texelIndex - texR * texNumC;\n  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",mo="\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",go="\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",vo="\n  float getChannel(vec4 frag, vec2 innerDims) {\n    vec2 modCoord = mod(innerDims, 2.);\n    return modCoord.x == 0. ?\n      (modCoord.y == 0. ? frag.r : frag.g) :\n      (modCoord.y == 0. ? frag.b : frag.a);\n  }\n  float getChannel(vec4 frag, int dim) {\n    float modCoord = mod(float(dim), 2.);\n    return modCoord == 0. ? frag.r : frag.g;\n  }\n";function yo(t){return "offset"+t;}function bo(t){var e=t.name,n=T(t.shapeInfo.logicalShape);return n<2?"return "+e+";":"\n    for (int i = 0; i < "+n+"; i++) {\n      if (i == index) {\n        return "+e+"[i];\n      }\n    }\n  ";}function xo(t){if(t<=1)return "int";if(2===t)return "ivec2";if(3===t)return "ivec3";if(4===t)return "ivec4";if(5===t)return "ivec5";if(6===t)return "ivec6";throw Error("GPU for rank "+t+" is not yet supported");}function wo(t,e){var n=JSON.parse(JSON.stringify(t));return n.shapeInfo.logicalShape=e,n;}function ko(t,e){return e.map(function(e){return t[e];}).join(", ");}var Eo=function Eo(t,e,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=_i(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    ";},Co="return a + b;",Ao="return a - b;",Oo="return a * b;",_o="return (a < 0.) ? b * a : a;",So=function So(t,e,n){this.variableNames=["A","B"],this.outputShape=_i(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    ";},Do="\n  vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n  return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n",Fo=function Fo(t,e,n,r){void 0===r&&(r=!1),this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=_i(e,n);var i=this.outputShape.length,o="";if(r)if(0===i||1===T(this.outputShape))o="\n          result.y = 0.;\n          result.z = 0.;\n          result.w = 0.;\n        ";else if(o="\n          "+xo(i)+" coords = getOutputCoords();\n        ",1===i)o+="\n            result.y = (coords + 1) >= "+this.outputShape[0]+" ? 0. : result.y;\n            result.z = 0.;\n            result.w = 0.;\n          ";else {var a=so("coords",i);o+="\n            bool nextRowOutOfBounds =\n              ("+a[i-2]+" + 1) >= "+this.outputShape[i-2]+";\n            bool nextColOutOfBounds =\n              ("+a[i-1]+" + 1) >= "+this.outputShape[i-1]+";\n            result.y = nextColOutOfBounds ? 0. : result.y;\n            result.z = nextRowOutOfBounds ? 0. : result.z;\n            result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n          ";}this.userCode="\n      vec4 binaryOperation(vec4 a, vec4 b) {\n        "+t+"\n      }\n\n      void main() {\n        vec4 a = getAAtOutCoords();\n        vec4 b = getBAtOutCoords();\n\n        vec4 result = binaryOperation(a, b);\n        "+o+"\n\n        setOutput(result);\n      }\n    ";},To=function(){function t(t){this.variableNames=["A"],this.outputShape=t,this.userCode="\n      uniform float minVal;\n      uniform float maxVal;\n\n      void main() {\n        float value = getAAtOutCoords();\n        if (isnan(value)) {\n          setOutput(value);\n          return;\n        }\n\n        setOutput(clamp(value, minVal, maxVal));\n      }\n    ";}return t.prototype.getCustomSetupFunc=function(t,e){var n=this;return function(r,i){null==n.minLoc&&(n.minLoc=r.getUniformLocationNoThrow(i,"minVal"),n.maxLoc=r.getUniformLocationNoThrow(i,"maxVal")),r.gl.uniform1f(n.minLoc,t),r.gl.uniform1f(n.maxLoc,e);};},t;}(),No=function(){function t(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.userCode="\n      uniform float minVal;\n      uniform float maxVal;\n\n      void main() {\n        vec4 value = getAAtOutCoords();\n\n        if (any(isnan(value))) {\n          setOutput(value);\n          return;\n        }\n\n        setOutput(clamp(value, vec4(minVal), vec4(maxVal)));\n      }\n    ";}return t.prototype.getCustomSetupFunc=function(t,e){var n=this;return function(r,i){null==n.minLoc&&(n.minLoc=r.getUniformLocationNoThrow(i,"minVal"),n.maxLoc=r.getUniformLocationNoThrow(i,"maxVal")),r.gl.uniform1f(n.minLoc,t),r.gl.uniform1f(n.maxLoc,e);};},t;}();function Io(t,e,n){var r=t.indexOf(e);return t.map(function(t,e){return e===r?t+" - "+n:t;}).join();}var Ro=function Ro(t,e,n,r){void 0===e&&(e=!1),void 0===n&&(n=null),void 0===r&&(r=!1),this.variableNames=["x","W"],this.outputShape=t.outShape;var i=t.padInfo.top,o=t.padInfo.left,a=t.strideHeight,s=t.strideWidth,u=t.dilationHeight,c=t.dilationWidth,l=t.filterHeight,f=t.filterWidth,h=4*Math.floor(t.inChannels/4),d=t.inChannels%4,p="channelsLast"===t.dataFormat,m=p?1:2,g=p?2:3,v=p?3:1,y="",b="";n&&(y=r?"float activation(float a) {\n          float b = getPreluActivationWeightsAtOutCoords();\n          "+n+"\n        }":"\n          float activation(float x) {\n            "+n+"\n          }\n        ",b="result = activation(result);");var x=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode="\n      "+y+"\n\n      const ivec2 strides = ivec2("+a+", "+s+");\n      const ivec2 pads = ivec2("+i+", "+o+");\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords[0];\n        int d2 = coords["+v+"];\n\n        ivec2 xRCCorner =\n            ivec2(coords["+m+"], coords["+g+"]) * strides - pads;\n        int xRCorner = xRCCorner.x;\n        int xCCorner = xRCCorner.y;\n\n        // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < "+l+"; wR++) {\n          int xR = xRCorner + wR * "+u+";\n\n          if (xR < 0 || xR >= "+t.inHeight+") {\n            continue;\n          }\n\n          for (int wC = 0; wC < "+f+"; wC++) {\n            int xC = xCCorner + wC * "+c+";\n\n            if (xC < 0 || xC >= "+t.inWidth+") {\n              continue;\n            }\n\n            for (int d1 = 0; d1 < "+h+"; d1 += 4) {\n              vec4 wValues = vec4(\n                getW(wR, wC, d1, d2),\n                getW(wR, wC, d1 + 1, d2),\n                getW(wR, wC, d1 + 2, d2),\n                getW(wR, wC, d1 + 3, d2)\n              );\n\n              if ("+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, "+h+") *\n                    getW(wR, wC, "+h+", d2);\n              } else {\n                dotProd +=\n                    getX(batch, "+h+", xR, xC) *\n                    getW(wR, wC, "+h+", d2);\n              }\n\n            } else if ("+(2===d)+") {\n              vec2 wValues = vec2(\n                getW(wR, wC, "+h+", d2),\n                getW(wR, wC, "+h+" + 1, d2)\n              );\n\n              if ("+p+") {\n                vec2 xValues = vec2(\n                  getX(batch, xR, xC, "+h+"),\n                  getX(batch, xR, xC, "+h+" + 1)\n                );\n                dotProd += dot(xValues, wValues);\n              } else {\n                vec2 xValues = vec2(\n                  getX(batch, "+h+", xR, xC),\n                  getX(batch, "+h+" + 1, xR, xC)\n                );\n                dotProd += dot(xValues, wValues);\n              }\n\n            } else if ("+(3===d)+") {\n              vec3 wValues = vec3(\n                getW(wR, wC, "+h+", d2),\n                getW(wR, wC, "+h+" + 1, d2),\n                getW(wR, wC, "+h+" + 2, d2)\n              );\n\n              if ("+p+") {\n                vec3 xValues = vec3(\n                  getX(batch, xR, xC, "+h+"),\n                  getX(batch, xR, xC, "+h+" + 1),\n                  getX(batch, xR, xC, "+h+" + 2)\n                );\n                dotProd += dot(xValues, wValues);\n              } else {\n                vec3 xValues = vec3(\n                  getX(batch, "+h+", xR, xC),\n                  getX(batch, "+h+" + 1, xR, xC),\n                  getX(batch, "+h+" + 2, xR, xC)\n                );\n                dotProd += dot(xValues, wValues);\n              }\n\n            }\n          }\n        }\n\n        float result = dotProd;\n        "+x+"\n        "+b+"\n        setOutput(result);\n      }\n    ";},Mo=function Mo(t,e,n,r){void 0===e&&(e=!1),void 0===n&&(n=null),void 0===r&&(r=!1),this.variableNames=["x","W"],this.outputShape=t.outShape;var i=t.inHeight,o=t.inWidth,a=t.padInfo.top,s=t.padInfo.left,u=t.strideHeight,c=t.strideWidth,l=t.dilationHeight,f=t.dilationWidth,h=t.filterHeight,d=t.filterWidth,p=t.outChannels/t.inChannels,m="",g="";n&&(m=r?"float activation(float a) {\n          float b = getPreluActivationWeightsAtOutCoords();\n          "+n+"\n        }":"\n          float activation(float x) {\n            "+n+"\n          }\n        ",g="result = activation(result);");var v=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode="\n      "+m+"\n\n      const ivec2 strides = ivec2("+u+", "+c+");\n      const ivec2 pads = ivec2("+a+", "+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 < "+h+"; wR++) {\n          int xR = xRCorner + wR * "+l+";\n\n          if (xR < 0 || xR >= "+i+") {\n            continue;\n          }\n\n          for (int wC = 0; wC < "+d+"; wC++) {\n            int xC = xCCorner + wC * "+f+";\n\n            if (xC < 0 || xC >= "+o+") {\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        "+v+"\n        "+g+"\n        setOutput(result);\n      }\n    ";},jo=function jo(t,e,n,r){void 0===e&&(e=!1),void 0===n&&(n=null),void 0===r&&(r=!1),this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t.outShape;for(var i=t.inHeight,o=t.inWidth,a=t.padInfo.top,s=t.padInfo.left,u=t.strideHeight,c=t.strideWidth,l=t.dilationHeight,f=t.dilationWidth,h=t.filterHeight,d=t.filterWidth,p=d,m="int xR; int xC; int xCOffset;",g=0;g<h;g++){for(var v=0;v<d;v++){m+="\n          vec4 xTexelR"+g+"C"+2*v+" = vec4(0.);\n          vec4 wR"+g+"C"+v+" = vec4(0.);\n          vec4 xR"+g+"C"+v+" = vec4(0.);";}}for(g=0;g<h;g++){for(var y=0;y<p;y++){if(m+="\n          xR = xRCorner + "+g*l+";\n          xC = xCCorner + "+(v=2*y)*f+";\n        ",1===c){if(v<d&&(m+=s%2==1?"\n                xCOffset = xC + 1;\n                if(xR >= 0 && xR < "+i+" && xCOffset >= 0 && xCOffset < "+o+") {\n                  xTexelR"+g+"C"+v+" = 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 >= "+o+") {\n                    xTexelR"+g+"C"+v+".zw = vec2(0.);\n                  }\n                } else {\n                  xTexelR"+g+"C"+v+" = vec4(0.);\n                }\n\n                xCOffset = xC + 1 - 2;\n                if(xR >= 0 && xR < "+i+" && xCOffset >= 0 && xCOffset < "+o+") {\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 >= "+o+") {\n                    previous.zw = vec2(0.);\n                  }\n\n                  xR"+g+"C"+v+" = vec4(previous.zw, xTexelR"+g+"C"+v+".xy);\n                } else {\n                  xR"+g+"C"+v+" = vec4(0, 0, xTexelR"+g+"C"+v+".xy);\n                }\n              ":"\n                if(xR >= 0 && xR < "+i+" && xC >= 0 && xC < "+o+") {\n                  xTexelR"+g+"C"+v+" = getX(batch, xR, xC, d1);\n                } else {\n                  xTexelR"+g+"C"+v+" = vec4(0.);\n                }\n\n                xR"+g+"C"+v+" = xTexelR"+g+"C"+v+";\n              ",v+1<d)){var b=s%2==0?A(f):f;f%2==0&&s%2==1||f%2!=0&&s%2!=1?(m+="\n                  xCOffset = xC + "+s%2+" + "+b+";\n\n                  if(xR >= 0 && xR < "+i+" &&\n                    xCOffset >= 0 && xCOffset < "+o+") {\n                    xTexelR"+g+"C"+(v+2)+" = getX(batch, xR, xCOffset, d1);\n                  }\n                ",f>1&&(m+="\n                    xCOffset -= 2;\n                    if(xR >= 0 && xR < "+i+" &&\n                      xCOffset >= 0 && xCOffset < "+o+") {\n                      xTexelR"+g+"C"+v+" = getX(batch, xR, xCOffset, d1);\n                    } else {\n                      xTexelR"+g+"C"+v+" = vec4(0.);\n                    }\n                  "),m+="\n                  xR"+g+"C"+(v+1)+" = vec4(\n                    xTexelR"+g+"C"+v+".zw, xTexelR"+g+"C"+(v+2)+".xy);\n                "):m+="\n                  xCOffset = xC + "+b+";\n\n                  if(xR >= 0 && xR < "+i+" &&\n                    xCOffset >= 0 && xCOffset < "+o+") {\n                    xTexelR"+g+"C"+(v+2)+" = getX(batch, xR, xCOffset, d1);\n                  }\n\n                  xR"+g+"C"+(v+1)+" = xTexelR"+g+"C"+(v+2)+";\n                ";}}else v<d&&(m+="\n              if(xR >= 0 && xR < "+i+") {\n            ",s%2==1?(m+="\n                xCOffset = xC + 1 - "+c+";\n                if(xCOffset >= 0 && xCOffset < "+o+") {\n                  xTexelR"+g+"C"+v+" = getX(batch, xR, xCOffset, d1);\n                } else {\n                  xTexelR"+g+"C"+v+" = vec4(0.);\n                }\n\n                if(xC + 1 >= 0 && xC + 1 < "+o+") {\n                  xTexelR"+g+"C"+(v+2)+" = getX(batch, xR, xC + 1, d1);\n                } else {\n                  xTexelR"+g+"C"+(v+2)+" = vec4(0.);\n                }\n\n                xR"+g+"C"+v+" = vec4(\n                  xTexelR"+g+"C"+v+".zw, xTexelR"+g+"C"+(v+2)+".zw);\n              ",v+1<d&&(m+="\n                  vec4 final = vec4(0.);\n                  xCOffset = xC + 1 + "+c+";\n                  if(xCOffset >= 0 && xCOffset < "+o+") {\n                    final = getX(batch, xR, xCOffset, d1);\n                  }\n                  xR"+g+"C"+(v+1)+" = vec4(xTexelR"+g+"C"+(v+2)+".xy, final.xy);\n                ")):(m+="\n                if(xC >= 0 && xC < "+o+") {\n                  xTexelR"+g+"C"+v+" = getX(batch, xR, xC, d1);\n                } else {\n                  xTexelR"+g+"C"+v+" = vec4(0.);\n                }\n\n                xCOffset = xC + "+c+";\n                if(xCOffset >= 0 && xCOffset < "+o+") {\n                  xTexelR"+g+"C"+(v+2)+" = getX(batch, xR, xCOffset, d1);\n                } else {\n                  xTexelR"+g+"C"+(v+2)+" = vec4(0.);\n                }\n\n                xR"+g+"C"+v+" = vec4(\n                  xTexelR"+g+"C"+v+".xy, xTexelR"+g+"C"+(v+2)+".xy);\n              ",v+1<d&&(m+="\n                  xR"+g+"C"+(v+1)+" = vec4(\n                    xTexelR"+g+"C"+v+".zw, xTexelR"+g+"C"+(v+2)+".zw);\n                ")),m+="}");v<d&&(m+="\n            vec4 wTexelR"+g+"C"+v+" = getW("+g+", "+v+", d1, q);\n            wR"+g+"C"+v+" = vec4(wTexelR"+g+"C"+v+".xz, wTexelR"+g+"C"+v+".xz);\n          ",v+1<d&&(m+="\n              vec4 wTexelR"+g+"C"+(v+1)+" = getW("+g+", "+(v+1)+", d1, q);\n              wR"+g+"C"+(v+1)+" =\n                vec4(wTexelR"+g+"C"+(v+1)+".xz, wTexelR"+g+"C"+(v+1)+".xz);"));}}for(g=0;g<h;g++){for(v=0;v<d;v++){m+="dotProd += xR"+g+"C"+v+" * wR"+g+"C"+v+";";}}var x="",w="";n&&(x=r?"vec4 activation(vec4 a) {\n          vec4 b = getPreluActivationWeightsAtOutCoords();\n          "+n+"\n        }":"vec4 activation(vec4 x) {\n          "+n+"\n        }",w="result = activation(result);");var k=e?"result += getBiasAtOutCoords();":"";e&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),this.userCode="\n      "+x+"\n\n      const ivec2 strides = ivec2("+u+", "+c+");\n      const ivec2 pads = ivec2("+a+", "+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        "+m+"\n\n        vec4 result = dotProd;\n        "+k+"\n        "+w+"\n        setOutput(result);\n      }\n    ";};function Bo(t,e){if(1===t)return ""+e;if(2===t)return e+".y";if(3===t)return e+".z";if(4===t)return e+".w";throw Error("Cumulative sum for rank "+t+" is not yet supported");}var Po=function(){function t(t,e,n){this.variableNames=["x"],this.outputShape=[],this.outputShape=t,this.blockSize=e,this.dataFormat=n,this.userCode="\n    void main() {\n      ivec4 coords = getOutputCoords();\n      int b = coords[0];\n      int h = "+this.getHeightCoordString()+";\n      int w = "+this.getWidthCoordString()+";\n      int d = "+this.getDepthCoordString()+";\n\n      int in_h = h / "+e+";\n      int offset_h = imod(h, "+e+");\n      int in_w = w / "+e+";\n      int offset_w = imod(w, "+e+");\n      int offset_d = (offset_h * "+e+" + offset_w) *\n        "+this.getOutputDepthSize()+";\n      int in_d = d + offset_d;\n\n      float result = "+this.getInputSamplingString()+";\n      setOutput(result);\n    }\n  ";}return t.prototype.getHeightCoordString=function(){return "NHWC"===this.dataFormat?"coords[1]":"coords[2]";},t.prototype.getWidthCoordString=function(){return "NHWC"===this.dataFormat?"coords[2]":"coords[3]";},t.prototype.getDepthCoordString=function(){return "NHWC"===this.dataFormat?"coords[3]":"coords[1]";},t.prototype.getOutputDepthSize=function(){return "NHWC"===this.dataFormat?this.outputShape[3]:this.outputShape[1];},t.prototype.getInputSamplingString=function(){return "NHWC"===this.dataFormat?"getX(b, in_h, in_w, in_d)":"getX(b, in_d, in_h, in_w)";},t;}(),Lo=function Lo(t,e,n){this.variableNames=["real","imag"];var r=e[1];this.outputShape=e;var i=n?"2.0 * "+Math.PI:"-2.0 * "+Math.PI,o=n?r+".0":"1.0";this.userCode="\n      const float exponentMultiplier = "+i+";\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) / "+o+";\n        }\n\n        return result;\n      }\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        setOutput(mulMatDFT(coords[0], coords[1]));\n      }\n    ";},zo=function(){function t(t,e){this.outputShape=[],this.variableNames=["x"],this.outputShape=t,this.userCode="\n      uniform float value;\n      void main() {\n        // Input can be obtained from uniform value.\n        setOutput(value);\n      }\n    ";}return t.prototype.getCustomSetupFunc=function(t){var e=this;return function(n,r){null==e.valueLoc&&(e.valueLoc=n.getUniformLocationNoThrow(r,"value")),n.gl.uniform1f(e.valueLoc,t);};},t;}();function Uo(t,e){var n=uo();return ue(t,e,n.version+"\n    precision highp float;\n    "+n.attribute+" vec3 clipSpacePos;\n    "+n.attribute+" vec2 uv;\n    "+n.varyingVs+" vec2 resultUV;\n\n    void main() {\n      gl_Position = vec4(clipSpacePos, 1);\n      resultUV = uv;\n    }");}function Wo(t,e){return ge(t,e,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]));}function Vo(t,e){return ve(t,e,new Uint16Array([0,1,2,2,1,3]));}function qo(t,e,n,r,i,o,a){be(n,r);var s=ye(t,e),u=t.TEXTURE_2D;return ne(t,e,function(){return t.bindTexture(u,s);}),ne(t,e,function(){return t.texParameteri(u,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE);}),ne(t,e,function(){return t.texParameteri(u,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE);}),ne(t,e,function(){return t.texParameteri(u,t.TEXTURE_MIN_FILTER,t.NEAREST);}),ne(t,e,function(){return t.texParameteri(u,t.TEXTURE_MAG_FILTER,t.NEAREST);}),ne(t,e,function(){return t.texImage2D(u,0,i,n,r,0,o,a,null);}),ne(t,e,function(){return t.bindTexture(t.TEXTURE_2D,null);}),s;}function $o(t,e,n,r,i){var o=Qt(n,r);return qo(t,e,o[0],o[1],i.internalFormatFloat,i.textureFormatFloat,t.FLOAT);}function Ho(t,e,n,r,i){var o=Qt(n,r);return qo(t,e,o[0],o[1],i.internalFormatHalfFloat,i.textureFormatFloat,i.textureTypeHalfFloat);}function Go(t,e,n,r,i){var o=Qt(n,r);return qo(t,e,o[0],o[1],t.RGBA,t.RGBA,t.UNSIGNED_BYTE);}function Ko(t,e,n,r,i){var o=te(n,r);return qo(t,e,o[0],o[1],i.internalFormatPackedFloat,t.RGBA,t.FLOAT);}function Xo(t,e,n,r,i){var o=te(n,r);return qo(t,e,o[0],o[1],i.internalFormatPackedHalfFloat,t.RGBA,i.textureTypeHalfFloat);}function Yo(t,e,n,r){return ne(t,e,function(){return t.bindBuffer(t.ARRAY_BUFFER,r);}),we(t,e,n,"clipSpacePos",r,3,20,0)&&we(t,e,n,"uv",r,2,20,12);}function Jo(t,e,n,r,i,o,a){var s,u,c;ne(t,e,function(){return t.bindTexture(t.TEXTURE_2D,n);}),o instanceof Uint8Array?(s=new Uint8Array(r*i*4),u=t.UNSIGNED_BYTE,c=t.RGBA):(s=new Float32Array(r*i*4),u=t.FLOAT,c=a.internalFormatPackedFloat),s.set(o),ne(t,e,function(){return t.texImage2D(t.TEXTURE_2D,0,c,r,i,0,t.RGBA,u,s);}),ne(t,e,function(){return t.bindTexture(t.TEXTURE_2D,null);});}function Qo(t,e,n,r){ne(t,e,function(){return t.bindTexture(t.TEXTURE_2D,n);}),r.data instanceof Uint8Array?ne(t,e,function(){return t.texImage2D(t.TEXTURE_2D,0,t.RGBA,r.width,r.height,0,t.RGBA,t.UNSIGNED_BYTE,r.data);}):ne(t,e,function(){return t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,r);}),ne(t,e,function(){return t.bindTexture(t.TEXTURE_2D,null);});}function Zo(t,e,n,r,i){var o=t.createBuffer();ne(t,e,function(){return t.bindBuffer(t.PIXEL_PACK_BUFFER,o);});var a=16*n*r;return ne(t,e,function(){return t.bufferData(t.PIXEL_PACK_BUFFER,a,t.STREAM_READ);}),ne(t,e,function(){return t.readPixels(0,0,r,n,t.RGBA,t.FLOAT,0);}),ne(t,e,function(){return t.bindBuffer(t.PIXEL_PACK_BUFFER,null);}),o;}function ta(t,e,n){var r=t,i=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,e),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,i),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),i;}function ea(t,e,n,r,i){var o=Qt(n,r),a=o[0],s=o[1],u=new Uint8Array(n*r*4);return ne(t,e,function(){return t.readPixels(0,0,a,s,i.downloadTextureFormat,t.UNSIGNED_BYTE,u);}),new Float32Array(u.buffer);}function na(t,e,n,r,i,o,a,s){var u=t,c=new Float32Array(function(t,e){var n=te(o,a);return n[0]*n[1]*4;}());return u.bindBuffer(u.PIXEL_PACK_BUFFER,e),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,c),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),c;}function ra(t,e,n,r){var i=new Float32Array(n*r*4);return ne(t,e,function(){return t.readPixels(0,0,r,n,t.RGBA,t.FLOAT,i);}),i;}var ia=Object.freeze({createVertexShader:Uo,createVertexBuffer:Wo,createIndexBuffer:Vo,createFloat32MatrixTexture:$o,createFloat16MatrixTexture:Ho,createUnsignedBytesMatrixTexture:Go,createPackedMatrixTexture:Ko,createFloat16PackedMatrixTexture:Xo,bindVertexProgramAttributeStreams:Yo,uploadDenseMatrixToTexture:Jo,uploadPixelDataToTexture:Qo,createBufferFromOutputTexture:Zo,downloadFloat32MatrixFromBuffer:ta,downloadByteEncodedFloatMatrixFromOutputTexture:ea,downloadPackedMatrixFromBuffer:na,downloadMatrixFromPackedOutputTexture:ra}),oa=function(){function t(t){this.outputTexture=null,this.program=null,this.disposed=!1,this.vertexAttrsAreBound=!1,this.itemsToPoll=[];var e=f().getNumber("WEBGL_VERSION");null!=t?(this.gl=t,Yt(e,t)):this.gl=Jt(e);var n="WEBGL_color_buffer_float";if(1===f().getNumber("WEBGL_VERSION")){if(this.textureFloatExtension=se(this.gl,this.debug,"OES_texture_float"),Ue(this.gl,"OES_texture_half_float"))this.textureHalfFloatExtension=se(this.gl,this.debug,"OES_texture_half_float");else if(f().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(n),Ue(this.gl,"EXT_color_buffer_half_float"))this.colorBufferHalfFloatExtension=se(this.gl,this.debug,"EXT_color_buffer_half_float");else if(f().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");}else if(n="EXT_color_buffer_float",Ue(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else {if(!Ue(this.gl,"EXT_color_buffer_half_float"))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension("EXT_color_buffer_half_float");}this.vertexBuffer=Wo(this.gl,this.debug),this.indexBuffer=Vo(this.gl,this.debug),this.framebuffer=xe(this.gl,this.debug),this.textureConfig=ee(this.gl,this.textureHalfFloatExtension);}return Object.defineProperty(t.prototype,"debug",{get:function get(){return f().getBool("DEBUG");},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){var t=this;if(!this.disposed){null!=this.program&&console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."),null!=this.outputTexture&&console.warn("Disposing a GPGPUContext that still has a bound output matrix texture.  This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");var e=this.gl;ne(e,this.debug,function(){return e.finish();}),ne(e,this.debug,function(){return e.bindFramebuffer(e.FRAMEBUFFER,null);}),ne(e,this.debug,function(){return e.deleteFramebuffer(t.framebuffer);}),ne(e,this.debug,function(){return e.bindBuffer(e.ARRAY_BUFFER,null);}),ne(e,this.debug,function(){return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null);}),ne(e,this.debug,function(){return e.deleteBuffer(t.indexBuffer);}),this.disposed=!0;}},t.prototype.createFloat32MatrixTexture=function(t,e){return this.throwIfDisposed(),$o(this.gl,this.debug,t,e,this.textureConfig);},t.prototype.createFloat16MatrixTexture=function(t,e){return this.throwIfDisposed(),Ho(this.gl,this.debug,t,e,this.textureConfig);},t.prototype.createUnsignedBytesMatrixTexture=function(t,e){return this.throwIfDisposed(),Go(this.gl,this.debug,t,e,this.textureConfig);},t.prototype.uploadPixelDataToTexture=function(t,e){this.throwIfDisposed(),Qo(this.gl,this.debug,t,e);},t.prototype.uploadDenseMatrixToTexture=function(t,e,n,r){this.throwIfDisposed(),Jo(this.gl,this.debug,t,e,n,r,this.textureConfig);},t.prototype.createFloat16PackedMatrixTexture=function(t,e){return this.throwIfDisposed(),Xo(this.gl,this.debug,t,e,this.textureConfig);},t.prototype.createPackedMatrixTexture=function(t,e){return this.throwIfDisposed(),Ko(this.gl,this.debug,t,e,this.textureConfig);},t.prototype.deleteMatrixTexture=function(t){var e=this;this.throwIfDisposed(),this.outputTexture===t&&(_e(this.gl,this.debug,this.framebuffer),this.outputTexture=null),ne(this.gl,this.debug,function(){return e.gl.deleteTexture(t);});},t.prototype.downloadByteEncodedFloatMatrixFromOutputTexture=function(t,e,n){var r=this;return this.downloadMatrixDriver(t,function(){return ea(r.gl,r.debug,e,n,r.textureConfig);});},t.prototype.downloadPackedMatrixFromBuffer=function(t,e,n,r,i,o){return na(this.gl,t,0,0,0,i,o,this.textureConfig);},t.prototype.downloadFloat32MatrixFromBuffer=function(t,e){return ta(this.gl,t,e);},t.prototype.createBufferFromTexture=function(t,e,n){this.bindTextureToFrameBuffer(t);var r=Zo(this.gl,this.debug,e,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r;},t.prototype.createAndWaitForFence=function(){var t=this.createFence(this.gl);return this.pollFence(t);},t.prototype.createFence=function(t){var e,n,r=this;if(f().getBool("WEBGL_FENCE_API_ENABLED")){var i=t,o=i.fenceSync(i.SYNC_GPU_COMMANDS_COMPLETE,0);t.flush(),n=function n(){var t=i.clientWaitSync(o,0,0);return t===i.ALREADY_SIGNALED||t===i.CONDITION_SATISFIED;},e=o;}else f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(e=this.beginQuery(),this.endQuery(),n=function n(){return r.isQueryAvailable(e,f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"));}):n=function n(){return !0;};return {query:e,isFencePassed:n};},t.prototype.downloadMatrixFromPackedTexture=function(t,e,n){var r=this;return this.downloadMatrixDriver(t,function(){return ra(r.gl,r.debug,e,n);});},t.prototype.createProgram=function(t){this.throwIfDisposed();var e=this.gl,n=ce(e,this.debug,t),r=Uo(e,this.debug),i=de(e,this.debug);return ne(e,this.debug,function(){return e.attachShader(i,r);}),ne(e,this.debug,function(){return e.attachShader(i,n);}),pe(e,this.debug,i),this.debug&&me(e,this.debug,i),this.vertexAttrsAreBound||(this.setProgram(i),this.vertexAttrsAreBound=Yo(e,this.debug,this.program,this.vertexBuffer)),i;},t.prototype.deleteProgram=function(t){var e=this;this.throwIfDisposed(),t===this.program&&(this.program=null),null!=t&&ne(this.gl,this.debug,function(){return e.gl.deleteProgram(t);});},t.prototype.setProgram=function(t){var e=this;this.throwIfDisposed(),this.program=t,null!=this.program&&this.debug&&me(this.gl,this.debug,this.program),ne(this.gl,this.debug,function(){return e.gl.useProgram(t);});},t.prototype.getUniformLocation=function(t,e,n){return void 0===n&&(n=!0),this.throwIfDisposed(),n?Ee(this.gl,this.debug,t,e):Ce(this.gl,t,e);},t.prototype.getAttributeLocation=function(t,e){var n=this;return this.throwIfDisposed(),ne(this.gl,this.debug,function(){return n.gl.getAttribLocation(t,e);});},t.prototype.getUniformLocationNoThrow=function(t,e){return this.throwIfDisposed(),this.gl.getUniformLocation(t,e);},t.prototype.setInputMatrixTexture=function(t,e,n){this.throwIfDisposed(),this.throwIfNoProgram(),Ae(this.gl,this.debug,this.program,t,e,n);},t.prototype.setOutputMatrixTexture=function(t,e,n){this.setOutputMatrixTextureDriver(t,n,e);},t.prototype.setOutputPackedMatrixTexture=function(t,e,n){this.throwIfDisposed();var r=te(e,n),i=r[0],o=r[1];this.setOutputMatrixTextureDriver(t,i,o);},t.prototype.setOutputMatrixWriteRegion=function(t,e,n,r){this.setOutputMatrixWriteRegionDriver(n,t,r,e);},t.prototype.setOutputPackedMatrixWriteRegion=function(t,e,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.");},t.prototype.debugValidate=function(){null!=this.program&&me(this.gl,this.debug,this.program),Se(this.gl);},t.prototype.executeProgram=function(){this.throwIfDisposed(),this.throwIfNoProgram();var t=this.gl;this.debug&&this.debugValidate(),ne(t,this.debug,function(){return t.drawElements(t.TRIANGLES,6,t.UNSIGNED_SHORT,0);});},t.prototype.blockUntilAllProgramsCompleted=function(){var t=this;this.throwIfDisposed(),ne(this.gl,this.debug,function(){return t.gl.finish();});},t.prototype.getQueryTimerExtension=function(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=se(this.gl,this.debug,2===f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension;},t.prototype.getQueryTimerExtensionWebGL2=function(){return this.getQueryTimerExtension();},t.prototype.getQueryTimerExtensionWebGL1=function(){return this.getQueryTimerExtension();},t.prototype.beginQuery=function(){if(2===f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){var t=this.gl,e=this.getQueryTimerExtensionWebGL2(),n=t.createQuery();return t.beginQuery(e.TIME_ELAPSED_EXT,n),n;}var r=this.getQueryTimerExtensionWebGL1(),i=r.createQueryEXT();return r.beginQueryEXT(r.TIME_ELAPSED_EXT,i),i;},t.prototype.endQuery=function(){if(2!==f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){var t=this.getQueryTimerExtensionWebGL1();t.endQueryEXT(t.TIME_ELAPSED_EXT);}else {var e=this.gl,n=this.getQueryTimerExtensionWebGL2();e.endQuery(n.TIME_ELAPSED_EXT);}},t.prototype.waitForQueryAndGetTime=function(t){return u(this,void 0,void 0,function(){var e=this;return c(this,function(n){switch(n.label){case 0:return [4,B(function(){return e.disposed||e.isQueryAvailable(t,f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"));})];case 1:return n.sent(),[2,this.getQueryTime(t,f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))];}});});},t.prototype.getQueryTime=function(t,e){if(0===e)return null;if(2===e){var n=this.gl;return n.getQueryParameter(t,n.QUERY_RESULT)/1e6;}var r=this.getQueryTimerExtensionWebGL1();return r.getQueryObjectEXT(t,r.QUERY_RESULT_EXT)/1e6;},t.prototype.isQueryAvailable=function(t,e){if(0===e)return !0;if(2===e){var n=this.gl,r=this.getQueryTimerExtensionWebGL2(),i=n.getQueryParameter(t,n.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),i&&!this.disjoint;}return i=(r=this.getQueryTimerExtensionWebGL1()).getQueryObjectEXT(t,r.QUERY_RESULT_AVAILABLE_EXT),null==this.disjoint&&(this.disjoint=this.gl.getParameter(r.GPU_DISJOINT_EXT)),i&&!this.disjoint;},t.prototype.pollFence=function(t){var e=this;return new Promise(function(n){e.addItemToPoll(function(){return t.isFencePassed();},function(){return n();});});},t.prototype.pollItems=function(){for(var t=function(t){for(var e=0;e<t.length&&t[e]();++e){}return e-1;}(this.itemsToPoll.map(function(t){return t.isDoneFn;})),e=0;e<=t;++e){(0, this.itemsToPoll[e].resolveFn)();}this.itemsToPoll=this.itemsToPoll.slice(t+1);},t.prototype.addItemToPoll=function(t,e){var n=this;this.itemsToPoll.push({isDoneFn:t,resolveFn:e}),this.itemsToPoll.length>1||B(function(){return n.pollItems(),0===n.itemsToPoll.length;});},t.prototype.bindTextureToFrameBuffer=function(t){this.throwIfDisposed(),Oe(this.gl,this.debug,t,this.framebuffer),this.debug&&Se(this.gl);},t.prototype.unbindTextureToFrameBuffer=function(){null!=this.outputTexture?(Oe(this.gl,this.debug,this.outputTexture,this.framebuffer),this.debug&&Se(this.gl)):_e(this.gl,this.debug,this.framebuffer);},t.prototype.downloadMatrixDriver=function(t,e){this.bindTextureToFrameBuffer(t);var n=e();return this.unbindTextureToFrameBuffer(),n;},t.prototype.setOutputMatrixTextureDriver=function(t,e,n){this.throwIfDisposed();var r=this.gl;Oe(r,this.debug,t,this.framebuffer),this.debug&&Se(r),this.outputTexture=t,ne(r,this.debug,function(){return r.viewport(0,0,e,n);}),ne(r,this.debug,function(){return r.scissor(0,0,e,n);});},t.prototype.setOutputMatrixWriteRegionDriver=function(t,e,n,r){var i=this;this.throwIfDisposed(),ne(this.gl,this.debug,function(){return i.gl.scissor(t,e,n,r);});},t.prototype.throwIfDisposed=function(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.");},t.prototype.throwIfNoProgram=function(){if(null==this.program)throw new Error("No GPU program is currently set.");},t;}();function aa(t,e){if(t.length!==e.length)throw Error("Binary was compiled with "+t.length+" inputs, but was executed with "+e.length+" inputs");t.forEach(function(t,n){var r=t.logicalShape,i=e[n],o=i.shape;if(!N(r,o))throw Error("Binary was compiled with different shapes than the current args. Shapes "+r+" and "+o+" must match");if(!t.isUniform||!i.isUniform){var a=t.texShape,s=i.isUniform?null:i.texData.texShape;if(!N(a,s))throw Error("Binary was compiled with different texture shapes than the current args. Shape "+a+" and "+s+" must match");}});}var sa=function sa(t,e,n,r,i,o,a){void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===i&&(i=!1),void 0===o&&(o=null),void 0===a&&(a=!1),this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e;var s=n?t[1]:t[2],u=Math.ceil(s/2),c=n?"i * 2, rc.y":"rc.y, i * 2",l=r?"rc.z, i * 2":"i * 2, rc.z",f=n?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],h=r?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"],d="",p="";o&&(d=a?"vec4 activation(vec4 a) {\n          vec4 b = getPreluActivationWeightsAtOutCoords();\n          "+o+"\n        }":"vec4 activation(vec4 x) {\n          "+o+"\n        }",p="result = activation(result);");var m=i?"result += getBiasAtOutCoords();":"";i&&this.variableNames.push("bias"),a&&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 += ("+f[0]+" * "+h[0]+");\n          result += ("+f[1]+" * "+h[1]+");\n        }\n        return result;\n      }\n\n      void main() {\n        ivec3 rc = getOutputCoords();\n        vec4 result = dot2x2ARowBCol(rc);\n\n        "+m+"\n\n        "+p+"\n\n        setOutput(result);\n      }\n    ";},ua=function(){function t(t,e,n){this.variableNames=["probs"],this.outputShape=[t,n],this.userCode="\n      uniform float seed;\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n\n        float r = random(seed);\n        float cdf = 0.0;\n\n        for (int i = 0; i < "+(e-1)+"; i++) {\n          cdf += getProbs(batch, i);\n\n          if (r < cdf) {\n            setOutput(float(i));\n            return;\n          }\n        }\n\n        // If no other event happened, last event happened.\n        setOutput(float("+(e-1)+"));\n      }\n    ";}return t.prototype.getCustomSetupFunc=function(t){var e=this;return function(n,r){null==e.seedLoc&&(e.seedLoc=n.getUniformLocation(r,"seed")),n.gl.uniform1f(e.seedLoc,t);};},t;}(),ca=function ca(t,e,n){if(this.variableNames=["x"],"avg"===e&&n)throw new Error("Cannot compute positions for average pool.");var r=t.filterWidth,i=t.strideHeight,o=t.strideWidth,a=t.dilationHeight,s=t.dilationWidth,u=t.effectiveFilterHeight,c=t.effectiveFilterWidth,l=t.padInfo.top,f=t.padInfo.left;this.outputShape=t.outShape;var h="avg"===e,d="0.0";if(h||(d="-1.0 / 1e-20"),n)this.userCode="\n        const ivec2 strides = ivec2("+i+", "+o+");\n        const ivec2 pads = ivec2("+l+", "+f+");\n\n        void main() {\n          ivec4 coords = getOutputCoords();\n          int batch = coords[0];\n          int d = coords[3];\n\n          ivec2 xRCCorner = coords.yz * strides - pads;\n          int xRCorner = xRCCorner.x;\n          int xCCorner = xRCCorner.y;\n\n          // max/min x(?, ?, d) to get y(yR, yC, d).\n          // ? = to be determined\n          float minMaxValue = 0.0;\n          float minMaxValueFound = 0.0;\n          int minMaxPosition = 0;\n          float avgValue = 0.0;\n\n          for (int wR = 0; wR < "+u+";\n              wR += "+a+") {\n            int xR = xRCorner + wR;\n\n            if (xR < 0 || xR >= "+t.inHeight+") {\n              continue;\n            }\n\n            for (int wC = 0; wC < "+c+";\n                wC += "+s+") {\n              int xC = xCCorner + wC;\n\n              if (xC < 0 || xC >= "+t.inWidth+") {\n                continue;\n              }\n\n              float value = getX(batch, xR, xC, d);\n\n              // If a min / max value has already been found, use it. If not,\n              // use the current value.\n              float currMinMaxValue = mix(\n                  value, minMaxValue, minMaxValueFound);\n              if (value >= currMinMaxValue) {\n                minMaxValue = value;\n                minMaxValueFound = 1.0;\n                minMaxPosition = wR * "+c+" + wC;\n              }\n            }\n          }\n          setOutput(float(minMaxPosition));\n        }\n      ";else {var p=e+"("+e+"("+e+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"avg"===e&&(p="avgValue / count");var m=4*Math.floor(r/4),g=r%4,v="\n      if ("+h+") {\n        avgValue += dot(values, ones);\n      } else {\n        minMaxValue = max(values, minMaxValue);\n      }\n    ";this.userCode="\n      const ivec2 strides = ivec2("+i+", "+o+");\n      const ivec2 pads = ivec2("+l+", "+f+");\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 += "+a+") {\n          int xR = xRCorner + wR;\n\n          if (xR < 0 || xR >= "+t.inHeight+") {\n            continue;\n          }\n\n          for (int wC = 0; wC < "+m+"; 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            "+v+"\n          }\n\n          int xC = xCCorner + "+m+";\n          if ("+(1===g)+") {\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              initializationValue,\n              initializationValue,\n              initializationValue\n            );\n\n            "+v+"\n          } else if ("+(2===g)+") {\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              getValue(batch, xR, xC + "+s+", d),\n              initializationValue,\n              initializationValue\n            );\n\n            "+v+"\n          } else if ("+(3===g)+") {\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            "+v+"\n          }\n        }\n        setOutput("+p+");\n      }\n    ";}},la=function la(t,e,n){if(this.variableNames=["x"],"avg"===e&&n)throw new Error("Cannot compute positions for average pool.");var r=t.filterWidth,i=t.strideDepth,o=t.strideHeight,a=t.strideWidth,s=t.dilationDepth,u=t.dilationHeight,c=t.dilationWidth,l=t.effectiveFilterDepth,f=t.effectiveFilterHeight,h=t.effectiveFilterWidth,d=t.padInfo.front,p=t.padInfo.top,m=t.padInfo.left;this.outputShape=t.outShape;var g="avg"===e,v="0.0";if(g||(v="-1.0 / 1e-20"),n)this.userCode="\n        const ivec3 strides =\n            ivec3("+i+", "+o+", "+a+");\n        const ivec3 pads = ivec3("+d+", "+p+", "+m+");\n\n        void main() {\n          ivec5 coords = getOutputCoords();\n          int batch = coords.x;\n          int ch = coords.u;\n\n          ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n          int xDCorner = xCorner.x;\n          int xRCorner = xCorner.y;\n          int xCCorner = xCorner.z;\n\n          // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).\n          // ? = to be determined\n          float minMaxValue = 0.0;\n          float minMaxValueFound = 0.0;\n          int minMaxPosition = 0;\n\n          for (int wD = 0; wD < "+l+";\n              wD += "+s+") {\n            int xD = xDCorner + wD;\n\n            if (xD < 0 || xD >= "+t.inDepth+") {\n              continue;\n            }\n\n            for (int wR = 0; wR < "+f+";\n                wR += "+u+") {\n              int xR = xRCorner + wR;\n\n              if (xR < 0 || xR >= "+t.inHeight+") {\n                continue;\n              }\n\n              for (int wC = 0; wC < "+h+";\n                  wC += "+c+") {\n                int xC = xCCorner + wC;\n\n                if (xC < 0 || xC >= "+t.inWidth+") {\n                  continue;\n                }\n\n                float value = getX(batch, xD, xR, xC, ch);\n\n                // If a min / max value has already been found, use it. If not,\n                // use the current value.\n                float currMinMaxValue = mix(\n                    value, minMaxValue, minMaxValueFound);\n                if (value >= currMinMaxValue) {\n                  minMaxValue = value;\n                  minMaxValueFound = 1.0;\n                  minMaxPosition =\n                      wD * "+f+" * "+h+" +\n                      wR * "+h+" + wC;;\n                }\n              }\n            }\n          }\n          setOutput(float(minMaxPosition));\n        }\n      ";else {var y=e+"("+e+"("+e+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"avg"===e&&(y="avgValue / count");var b=4*Math.floor(r/4),x=r%4,w="\n      if ("+g+") {\n        avgValue += dot(values, ones);\n      } else {\n        minMaxValue = max(values, minMaxValue);\n      }\n    ";this.userCode="\n      const ivec3 strides =\n        ivec3("+i+", "+o+", "+a+");\n      const ivec3 pads = ivec3("+d+", "+p+", "+m+");\n      const float initializationValue = "+v+";\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("+v+");\n        float avgValue = 0.0;\n        count = 0.0;\n\n        for (int wD = 0; wD < "+l+";\n            wD += "+s+") {\n          int xD = xDCorner + wD;\n\n          if (xD < 0 || xD >= "+t.inDepth+") {\n            continue;\n          }\n\n          for (int wR = 0; wR < "+f+";\n            wR += "+u+") {\n            int xR = xRCorner + wR;\n\n            if (xR < 0 || xR >= "+t.inHeight+") {\n              continue;\n            }\n\n            for (int wC = 0; wC < "+b+"; wC += 4) {\n              int xC = xCCorner + wC * "+c+";\n\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + "+c+", ch),\n                getValue(batch, xD, xR, xC + 2 * "+c+", ch),\n                getValue(batch, xD, xR, xC + 3 * "+c+", ch)\n              );\n\n              "+w+"\n            }\n\n            int xC = xCCorner + "+b+";\n            if ("+(1===x)+") {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                initializationValue,\n                initializationValue,\n                initializationValue\n              );\n\n              "+w+"\n            } else if ("+(2===x)+") {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + "+c+", ch),\n                initializationValue,\n                initializationValue\n              );\n\n              "+w+"\n            } else if ("+(3===x)+") {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + "+c+", ch),\n                getValue(batch, xD, xR, xC + 2 * "+c+", ch),\n                initializationValue\n              );\n\n              "+w+"\n            }\n          }\n          setOutput("+y+");\n        }\n      }\n    ";}},fa=function fa(t,e,n,r,i,o,a){this.variableNames=["updates","indices","defaultValue"],this.outputShape=o;var s=xo(i.length),u=xo(o.length),c="";1===n?c="i":2===n&&(c="i, j");var l="getIndices("+c+")",f="";1===r?f="i":2===r&&(f="i, coords[1]");var h="getUpdates("+f+")",d=e>1?"strides[j]":"strides";this.userCode="\n        "+s+" strides = "+s+"("+i+");\n\n        void main() {\n          "+u+" coords = getOutputCoords();\n          float sum = 0.0;\n          bool found = false;\n          for (int i = 0; i < "+t+"; i++) {\n            int flattenedIndex = 0;\n            for (int j = 0; j < "+e+"; j++) {\n              int index = round("+l+");\n              flattenedIndex += index * "+d+";\n            }\n            if (flattenedIndex == coords[0]) {\n              sum += "+h+";\n              found = true;\n            }\n          }\n          setOutput(mix(getDefaultValue(), sum, float(found)));\n        }\n      ";},ha=function(){function t(t){this.variableNames=["source"],this.outputShape=t,this.rank=t.length;var e,n=xo(this.rank),r="uniform int start["+this.rank+"];",i=function(t){if(1===t)return "sourceLoc";if(t<=6)return da.slice(0,t).map(function(t){return "sourceLoc."+t;}).join(",");throw Error("Slicing for rank "+t+" is not yet supported");}(this.rank);e="\n        "+n+" sourceLoc;\n        "+n+" coords = getOutputCoords();\n        "+t.map(function(t,e){return "sourceLoc."+da[e]+" = start["+e+"] + coords."+da[e]+";";}).join("\n")+"\n      ",this.userCode="\n      "+r+"\n      void main() {\n        "+e+"\n        setOutput(getSource("+i+"));\n      }\n    ";}return t.prototype.getCustomSetupFunc=function(t){var e=this;if(t.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the length of start ("+t.length+")");return function(n,r){null==e.startLoc&&(e.startLoc=n.getUniformLocationNoThrow(r,"start"),null==e.startLoc)||n.gl.uniform1iv(e.startLoc,t);};},t;}(),da=["x","y","z","w","u","v"],pa=function(){function t(t){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.rank=t.length;var e=xo(this.rank),n=so("coords",this.rank),r=so("sourceLoc",this.rank),i=1===this.rank?"sourceLoc":"vec2("+r.slice(-2).join()+")",o="getChannel(getSource("+r.join()+"), "+i+")",a="\n      result.x = "+o+";\n      if (++"+n[this.rank-1]+" < "+t[this.rank-1]+") {\n        ++"+r[this.rank-1]+";\n        result.y = "+o+";\n        --"+r[this.rank-1]+";\n      }\n    ",s=1===this.rank?"":"\n      --"+n[this.rank-1]+";\n      if (++"+n[this.rank-2]+" < "+t[this.rank-2]+") {\n        ++"+r[this.rank-2]+";\n        result.z = "+o+";\n        if (++"+n[this.rank-1]+" < "+t[this.rank-1]+") {\n          ++"+r[this.rank-1]+";\n          result.w = "+o+";\n        }\n      }\n    ",u=this.rank<=4?"sourceLoc = coords +\n            "+e+"("+t.map(function(t,e){return "start["+e+"]";}).join()+");":t.map(function(t,e){return r[e]+" = "+n[e]+" + start["+e+"];";}).join("\n");this.userCode="\n      uniform int start["+this.rank+"];\n      void main() {\n        "+e+" coords = getOutputCoords();\n        "+e+" sourceLoc;\n        "+u+"\n        vec4 result = vec4(0.);\n        "+a+"\n        "+s+"\n        setOutput(result);\n      }\n    ";}return t.prototype.getCustomSetupFunc=function(t){var e=this;if(t.length!==this.rank)throw Error("The rank ("+this.rank+") of the program must match the length of start ("+t.length+")");return function(n,r){null==e.startLoc&&(e.startLoc=n.getUniformLocationNoThrow(r,"start"),null==e.startLoc)||n.gl.uniform1iv(e.startLoc,t);};},t;}(),ma=function(){function t(t){this.gpgpu=t,this.numUsedTextures=0,this.numFreeTextures=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={};}return t.prototype.acquireTexture=function(t,e,n){var r,i=ga(e,n),o=va(t,i,n);if(o in this.freeTextures||(this.freeTextures[o]=[]),o in this.usedTextures||(this.usedTextures[o]=[]),this.freeTextures[o].length>0){this.numFreeTextures--,this.numUsedTextures++,this.log();var a=this.freeTextures[o].shift();return this.usedTextures[o].push(a),a;}return this.numUsedTextures++,this.log(),i===Gt.PACKED_2X2_FLOAT32?r=this.gpgpu.createPackedMatrixTexture(t[0],t[1]):i===Gt.PACKED_2X2_FLOAT16?r=this.gpgpu.createFloat16PackedMatrixTexture(t[0],t[1]):i===Gt.UNPACKED_FLOAT32?r=this.gpgpu.createFloat32MatrixTexture(t[0],t[1]):i===Gt.UNPACKED_FLOAT16?r=this.gpgpu.createFloat16MatrixTexture(t[0],t[1]):i===Gt.PACKED_4X1_UNSIGNED_BYTE&&(r=this.gpgpu.createUnsignedBytesMatrixTexture(t[0],t[1])),this.usedTextures[o].push(r),r;},t.prototype.releaseTexture=function(t,e,n,r){if(null!=this.freeTextures){var i=va(e,ga(n,r),r);i in this.freeTextures||(this.freeTextures[i]=[]),this.freeTextures[i].push(t),this.numFreeTextures++,this.numUsedTextures--;var o=this.usedTextures[i],a=o.indexOf(t);if(a<0)throw new Error("Cannot release a texture that was never provided by this texture manager");o.splice(a,1),this.log();}},t.prototype.log=function(){if(this.logEnabled){var t=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",this.numFreeTextures+" / "+this.numUsedTextures,"("+t+")");}},t.prototype.getNumUsedTextures=function(){return this.numUsedTextures;},t.prototype.getNumFreeTextures=function(){return this.numFreeTextures;},t.prototype.dispose=function(){var t=this;if(null!=this.freeTextures){for(var e in this.freeTextures){this.freeTextures[e].forEach(function(e){t.gpgpu.deleteMatrixTexture(e);});}for(var e in this.usedTextures){this.usedTextures[e].forEach(function(e){t.gpgpu.deleteMatrixTexture(e);});}this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0;}},t;}();function ga(t,e){if(t===Ht.UPLOAD)return Gt.PACKED_2X2_FLOAT32;if(t===Ht.RENDER||null==t)return function(t){return f().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?t?Gt.PACKED_2X2_FLOAT32:Gt.UNPACKED_FLOAT32:t?Gt.PACKED_2X2_FLOAT16:Gt.UNPACKED_FLOAT16;}(e);if(t===Ht.DOWNLOAD||t===Ht.PIXELS)return Gt.PACKED_4X1_UNSIGNED_BYTE;throw new Error("Unknown logical texture type "+t);}function va(t,e,n){return t[0]+"_"+t[1]+"_"+e+"_"+n;}var ya=1.7580993408473768,ba=1.0507009873554805,xa=function xa(t,e){this.variableNames=["A"],this.outputShape=t,this.userCode="\n      float unaryOperation(float x) {\n        "+e+"\n      }\n\n      void main() {\n        float x = getAAtOutCoords();\n        float y = unaryOperation(x);\n\n        setOutput(y);\n      }\n    ";},wa="if (isnan(x)) return x;",ka="return x;",Ea="return abs(x);",Ca=wa+"\n  return (x < 0.0) ? 0.0 : x;\n",Aa=wa+"\n  return (x < 0.0) ? 0.0 : min(6.0, x);\n",Oa="return (x >= 0.0) ? x : (exp(x) - 1.0);",_a="return -x;",Sa="return ceil(x);",Da="return floor(x);",Fa="return exp(x);",Ta="return exp(x) - 1.0;",Na="return x;",Ia="return x;",Ra="\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",Ma="\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",ja="\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",Ba=function Ba(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.userCode="\n      vec4 unaryOperation(vec4 x) {\n        "+e+"\n      }\n\n      void main() {\n        vec4 x = getAAtOutCoords();\n        vec4 y = unaryOperation(x);\n\n        setOutput(y);\n      }\n    ";},Pa={};function La(t,e){if(void 0===e&&(e=!1),"linear"===t)return e?Ia:ka;if("relu"===t)return e?Ra:Ca;if("elu"===t)return e?ja:Oa;if("relu6"===t)return e?Ma:Aa;if("prelu"===t)return e?Do:_o;throw new Error("Activation "+t+" has not been implemented for the WebGL backend.");}var za=600,Ua=function(t){function e(e){var n,r=t.call(this)||this;if(r.pendingRead=new WeakMap(),r.pendingDisposal=new WeakSet(),r.dataRefCount=new WeakMap(),r.numBytesInGPU=0,r.uploadWaitMs=0,r.downloadWaitMs=0,r.warnedAboutMemory=!1,r.pendingDeletes=0,r.disposed=!1,!f().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");if(null==e){var i=Jt(f().getNumber("WEBGL_VERSION"));r.binaryCache=(n=f().getNumber("WEBGL_VERSION"))in Pa?Pa[n]:(Pa[n]={},Pa[n]),r.gpgpu=new oa(i),r.canvas=i.canvas,r.gpgpuCreatedLocally=!0;}else r.gpgpu=e,r.binaryCache={},r.gpgpuCreatedLocally=!1,r.canvas=e.gl.canvas;return r.textureManager=new ma(r.gpgpu),r.numMBBeforeWarning=null==f().global.screen?1024:f().global.screen.height*f().global.screen.width*window.devicePixelRatio*za/1024/1024,r.texData=new ki(r,Wt),r;}return s(e,t),e.prototype.numDataIds=function(){return this.texData.numDataIds()+(this.cpuBackend?this.cpuBackend.numDataIds():0)-this.pendingDeletes;},e.prototype.write=function(t,e,n){if(f().getBool("DEBUG")&&this.checkNumericalProblems(t),"complex64"===n&&null!=t)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");var r={};return this.texData.set(r,{shape:e,dtype:n,values:t,usage:Ht.UPLOAD}),r;},e.prototype.move=function(t,e,n,r){if(f().getBool("DEBUG")&&this.checkNumericalProblems(e),"complex64"===r)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(t,{shape:n,dtype:r,values:e,usage:Ht.UPLOAD});},e.prototype.readSync=function(t){var e=this.texData.get(t),n=e.values,r=e.dtype,i=e.complexTensors,o=e.slice,a=e.shape,s=e.isPacked;if(null!=o){var u;u=s?new Ba(a,Na):new xa(a,Na);var c=this.runWebGLProgram(u,[{dataId:t,shape:a,dtype:r}],r),l=this.readSync(c.dataId);return this.disposeData(c.dataId),l;}if(null!=n)return this.convertAndCacheOnCPU(t);if("string"===r)return n;var f,h,d=null!=this.activeTimers;return d&&(f=at()),h="complex64"===r?qi(i.real.dataSync(),i.imag.dataSync()):this.getValuesFromTexture(t),d&&(this.downloadWaitMs+=at()-f),this.convertAndCacheOnCPU(t,h);},e.prototype.read=function(t){return u(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,l,h,d,p,m,g,v,y,b,x,w,k,E,C;return c(this,function(c){switch(c.label){case 0:if(this.pendingRead.has(t))return e=this.pendingRead.get(t),[2,new Promise(function(t){return e.push(t);})];if(n=this.texData.get(t),r=n.values,i=n.shape,o=n.slice,a=n.dtype,s=n.complexTensors,u=n.isPacked,null!=o)return l=void 0,l=u?new Ba(i,Na):new xa(i,Na),h=this.runWebGLProgram(l,[{dataId:t,shape:i,dtype:a}],a),d=this.read(h.dataId),this.disposeData(h.dataId),[2,d];if(null!=r)return [2,this.convertAndCacheOnCPU(t)];if(!f().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&2===f().getNumber("WEBGL_VERSION"))throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");return p=null,"complex64"!==a&&f().get("WEBGL_BUFFER_SUPPORTED")&&(m=this.decode(t),g=this.texData.get(m.dataId),p=(C=this.gpgpu).createBufferFromTexture.apply(C,[g.texture].concat(Zt(i)))),this.pendingRead.set(t,[]),"complex64"===a?[3,2]:[4,this.gpgpu.createAndWaitForFence()];case 1:c.sent(),c.label=2;case 2:return "complex64"!==a?[3,4]:[4,Promise.all([s.real.data(),s.imag.data()])];case 3:return y=c.sent(),b=y[0],x=y[1],v=qi(b,x),[3,5];case 4:null==p?v=this.getValuesFromTexture(t):(w=T(i),v=this.gpgpu.downloadFloat32MatrixFromBuffer(p,w)),c.label=5;case 5:return null!=m&&this.disposeData(m.dataId),k=this.convertAndCacheOnCPU(t,v),E=this.pendingRead.get(t),this.pendingRead.delete(t),E.forEach(function(t){return t(k);}),this.pendingDisposal.has(t)&&(this.pendingDisposal.delete(t),this.disposeData(t),this.pendingDeletes--),[2,k];}});});},e.prototype.checkNumericalProblems=function(t){if(null!=t)for(var e=0;e<t.length;e++){var n=t[e];if(!oe(n)){if(f().getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))throw Error("The value "+n+" cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'");throw Error("The value "+n+" cannot be represented on this device.");}}},e.prototype.getValuesFromTexture=function(t){var e,n=this.texData.get(t),r=n.shape,i=n.dtype,o=n.isPacked,a=T(r);if(f().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){var s=this.decode(t),u=this.texData.get(s.dataId),c=(e=this.gpgpu).downloadMatrixFromPackedTexture.apply(e,[u.texture].concat(Zt(r))).subarray(0,a);return this.disposeData(s.dataId),c;}var l=f().getBool("WEBGL_PACK")&&!0===o,h=l?Re(r):r,d=l?new function(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=Ht.DOWNLOAD;var e=uo();this.outputShape=t,this.userCode="\n      "+fo+"\n\n      void main() {\n        ivec3 coords = getOutputCoords();\n        float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n        "+e.output+" = encode_float(x);\n      }\n    ";}(h):new function(t){this.variableNames=["A"],this.outTexUsage=Ht.DOWNLOAD;var e=uo();this.outputShape=t,this.userCode="\n      "+fo+"\n\n      void main() {\n        float x = getAAtOutCoords();\n        "+e.output+" = encode_float(x);\n      }\n    ";}(h),p=this.runWebGLProgram(d,[{shape:h,dtype:i,dataId:t}],"float32"),m=this.texData.get(p.dataId),g=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(m.texture,m.texShape[0],m.texShape[1]).subarray(0,a);return this.disposeData(p.dataId),g;},e.prototype.time=function(t){return u(this,void 0,void 0,function(){var e,n,r,i,o,a,s;return c(this,function(u){switch(u.label){case 0:return e=this.activeTimers,n=[],r=!1,null==this.programTimersStack?(this.programTimersStack=n,r=!0):this.activeTimers.push(n),this.activeTimers=n,t(),i=F(this.activeTimers.map(function(t){return t.query;})).filter(function(t){return null!=t;}),o=F(this.activeTimers.map(function(t){return t.name;})).filter(function(t){return null!=t;}),this.activeTimers=e,r&&(this.programTimersStack=null),a={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null},f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?[4,Promise.all(i)]:[3,2];case 1:return s=u.sent(),a.kernelMs=O(s),a.getExtraProfileInfo=function(){return s.map(function(t,e){return {name:o[e],ms:t};}).map(function(t){return t.name+": "+t.ms;}).join(", ");},[3,3];case 2:a.kernelMs={error:"WebGL query timers are not supported in this environment."},u.label=3;case 3:return this.uploadWaitMs=0,this.downloadWaitMs=0,[2,a];}});});},e.prototype.memory=function(){return {unreliable:!1,numBytesInGPU:this.numBytesInGPU};},e.prototype.startTimer=function(){return f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:at(),endMs:null};},e.prototype.endTimer=function(t){return f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),t):(t.endMs=at(),t);},e.prototype.getQueryTime=function(t){return u(this,void 0,void 0,function(){var e;return c(this,function(n){return f().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?[2,this.gpgpu.waitForQueryAndGetTime(t)]:[2,(e=t).endMs-e.startMs];});});},e.prototype.disposeData=function(t){if(!this.pendingDisposal.has(t)){if(this.pendingRead.has(t))return this.pendingDisposal.add(t),void this.pendingDeletes++;if(this.texData.has(t)){this.releaseGPUData(t);var e=this.texData.get(t).complexTensors;null!=e&&(e.real.dispose(),e.imag.dispose()),this.texData.delete(t);}}},e.prototype.releaseGPUData=function(t){var e=this.texData.get(t),n=e.texture,r=e.dtype,i=e.texShape,o=e.usage,a=e.isPacked,s=e.slice,u=s&&s.origDataId||t,c=this.dataRefCount.get(u);c>1?this.dataRefCount.set(u,c-1):(this.dataRefCount.delete(u),null!=n&&(this.numBytesInGPU-=this.computeBytes(i,r),this.textureManager.releaseTexture(n,i,o,a)));var l=this.texData.get(t);l.texture=null,l.texShape=null,l.isPacked=!1,l.slice=null;},e.prototype.getTexture=function(t){return this.uploadToGPU(t),this.texData.get(t).texture;},e.prototype.getDataInfo=function(t){return this.texData.get(t);},e.prototype.getCPUBackend=function(){return f().getBool("WEBGL_CPU_FORWARD")?(null==this.cpuBackend&&(this.cpuBackend=Wt.findBackend("cpu")),this.cpuBackend):null;},e.prototype.shouldExecuteOnCPU=function(t,e){var n=this;return void 0===e&&(e=128),null!=this.getCPUBackend()&&t.every(function(t){return null==n.texData.get(t.dataId).texture&&t.size<e;});},e.prototype.getGPGPUContext=function(){return this.gpgpu;},e.prototype.complex=function(t,e){var n=this.makeOutput(t.shape,"complex64");return this.texData.get(n.dataId).complexTensors={real:Wt.keep(t.clone()),imag:Wt.keep(e.clone())},n;},e.prototype.real=function(t){return this.texData.get(t.dataId).complexTensors.real.clone();},e.prototype.imag=function(t){return this.texData.get(t.dataId).complexTensors.imag.clone();},e.prototype.slice=function(t,e,n){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.slice(t,e,n);if(0===T(n))return jn([],n,t.dtype);var r=this.texData.get(t.dataId).isPacked,i=li(t.shape,e,n);if(r||!i){var o=f().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new pa(n):new ha(n),a=o.getCustomSetupFunc(e);return this.compileAndRun(o,[t],null,a);}return this.uploadToGPU(t.dataId),this.shallowSlice(t,e,n);},e.prototype.shallowSlice=function(t,e,n){var r=this.texData.get(t.dataId),i=this.makeOutput(n,t.dtype),o=this.texData.get(i.dataId);Object.assign(o,r),o.shape=n,o.dtype=t.dtype;var a=fi(e,t.strides);r.slice&&(a+=r.slice.flatOffset),o.slice={flatOffset:a,origDataId:r.slice&&r.slice.origDataId||t.dataId};var s=this.dataRefCount.get(o.slice.origDataId)||1;return this.dataRefCount.set(o.slice.origDataId,s+1),i;},e.prototype.stridedSlice=function(t,e,n,r){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.stridedSlice(t,e,n,r);var i=si(e,n,r);if(i.some(function(t){return 0===t;}))return jn([],i);var o=new function(t,e,n){this.variableNames=["x"],this.outputShape=n;var r=n.length,i=xo(n.length),o=xo(n.length),a="";if(1===r)a="coords * strides + begin";else {var s=0;a=n.map(function(t,e){return s++,1===n.length?"coords * strides["+e+"] + begin["+e+"]":"coords["+(s-1)+"] * strides["+e+"] + begin["+e+"]";}).join(",");}this.userCode="\n      "+i+" begin = "+i+"("+t+");\n      "+i+" strides = "+i+"("+e+");\n\n      void main() {\n        "+o+" coords = getOutputCoords();\n        setOutput(getX("+a+"));\n      }\n    ";}(e,r,i);return this.compileAndRun(o,[t]);},e.prototype.reverse=function(t,e){var n=f().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new function(t,e){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;var n=t.length;if(n>4)throw new Error("WebGL backend: Reverse of rank-"+n+" tensor is not yet supported");this.outputShape=t;var r=so("rc",n),i=r[n-1]+" + 1 < "+this.outputShape[n-1],o=r[n-2]+" + 1 < "+this.outputShape[n-2],a=xo(n);function s(n){var r=t.map(function(r,i){return function(n,r){return -1!==e.indexOf(n)&&1!==t[n]?t[n]+" - "+r[n]+" - 1":""+r[n];}(i,n);});return "getChannel(getX("+r.join(",")+"), vec2("+r.slice(-2).join(",")+"))";}this.userCode=1===n?"\n        void main(){\n          int rc = getOutputCoords();\n          vec4 result = vec4(0.);\n          result.r = getChannel(getX("+t[0]+" - rc - 1),\n            "+t[0]+" - rc - 1);\n          if("+i+"){\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          "+a+" rc = getOutputCoords();\n          vec4 result = vec4(0.);\n          result.r = "+s(r.slice())+";\n          if("+i+"){\n            result.g = "+function(t){return t[n-1]="("+t[n-1]+" + 1)",s(t);}(r.slice())+";\n          }\n          if("+o+") {\n            result.b = "+function(t){return t[n-2]="("+t[n-2]+" + 1)",s(t);}(r.slice())+";\n            if("+i+") {\n              result.a = "+function(t){return t[n-1]="("+t[n-1]+" + 1)",t[n-2]="("+t[n-2]+" + 1)",s(t);}(r.slice())+";\n            }\n          }\n          setOutput(result);\n        }\n    ";}(t.shape,e):new function(t,e){this.variableNames=["x"];var n=t.length;if(n>4)throw new Error("WebGL backend: Reverse of rank-"+n+" tensor is not yet supported");if(this.outputShape=t,1!==n){var r=t.map(function(n,r){return function(n){return -1!==e.indexOf(n)&&1!==t[n]?t[n]+" - coords["+n+"] - 1":"coords["+n+"]";}(r);}).join(","),i=xo(n);this.userCode="\n      void main() {\n        "+i+" coords = getOutputCoords();\n        setOutput(getX("+r+"));\n      }\n    ";}else this.userCode="\n        void main() {\n          int coord = getOutputCoords();\n          setOutput(getX("+t[0]+" - coord - 1));\n        }\n      ";}(t.shape,e);return this.compileAndRun(n,[t]);},e.prototype.concat=function(t,e){if("complex64"===t[0].dtype){var n=t.map(function(t){return Rn(t);}),r=t.map(function(t){return Mn(t);});return In(this.concat(n,e),this.concat(r,e));}if(this.shouldExecuteOnCPU(t))return this.cpuBackend.concat(t,e);if(1===t.length)return t[0];if(t.length>f().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")){var i=Math.floor(t.length/2),o=this.concat(t.slice(0,i),e),a=this.concat(t.slice(i),e);return this.concat([o,a],e);}if(f().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&t[0].rank>1){var s=new function(t,e){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=Tn(t,e);var n=this.outputShape,r=n.length,i=xo(r),o=so("coords",r),a=["x","y","z","w","u","v"].slice(0,r);this.variableNames=t.map(function(t,e){return "T"+e;});var s=new Array(t.length-1);s[0]=t[0][e];for(var u=1;u<s.length;u++){s[u]=s[u-1]+t[u][e];}var c=a[e],l=a.slice(-2),f=a.join(),h="if ("+c+" < "+s[0]+") {\n        return getChannel(\n            getT0("+f+"), vec2("+l.join()+"));\n        }";for(u=1;u<s.length;u++){var d=s[u-1];h+="\n        if ("+c+" < "+s[u]+"  && "+c+" >= "+s[u-1]+") {\n          return getChannel(\n            getT"+u+"("+Io(a,c,d)+"),\n            vec2("+Io(l,c,d)+"));\n        }";}var p=s.length,m=s[s.length-1];h+="\n        return getChannel(\n          getT"+p+"("+Io(a,c,m)+"),\n          vec2("+Io(l,c,m)+"));",this.userCode="\n      float getValue("+a.map(function(t){return "int "+t;})+") {\n        "+h+"\n      }\n\n      void main() {\n        "+i+" coords = getOutputCoords();\n        vec4 result = vec4(getValue("+o+"), 0., 0., 0.);\n\n        "+o[r-1]+" = "+o[r-1]+" + 1;\n        if ("+o[r-1]+" < "+n[r-1]+") {\n          result.g = getValue("+o+");\n        }\n\n        "+o[r-2]+" = "+o[r-2]+" + 1;\n        if ("+o[r-2]+" < "+n[r-2]+") {\n          result.a = getValue("+o+");\n        }\n\n        "+o[r-1]+" = "+o[r-1]+" - 1;\n        if ("+o[r-2]+" < "+n[r-2]+" &&\n            "+o[r-1]+" < "+n[r-1]+") {\n          result.b = getValue("+o+");\n        }\n        setOutput(result);\n      }\n    ";}(t.map(function(t){return t.shape;}),e);return this.compileAndRun(s,t);}var u=Tn(t.map(function(t){return t.shape;}),e),c=t.map(function(t){return t.as2D(-1,T(t.shape.slice(e)));}),l=new function(t){this.outputShape=[],this.outputShape=Tn(t,1),this.variableNames=t.map(function(t,e){return "T"+e;});var e=new Array(t.length-1);e[0]=t[0][1];for(var n=1;n<e.length;n++){e[n]=e[n-1]+t[n][1];}var r=["if (yC < "+e[0]+") setOutput(getT0(yR, yC));"];for(n=1;n<e.length;n++){var i=e[n-1];r.push("else if (yC < "+e[n]+") setOutput(getT"+n+"(yR, yC-"+i+"));");}var o=e.length,a=e[e.length-1];r.push("else setOutput(getT"+o+"(yR, yC-"+a+"));"),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    ";}(c.map(function(t){return t.shape;}));return this.compileAndRun(l,c).reshape(u);},e.prototype.neg=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.neg(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,_a,t.dtype);var e=new xa(t.shape,_a);return this.compileAndRun(e,[t]);},e.prototype.batchMatMul=function(t,e,n,r){var i=n?t.shape[2]:t.shape[1],o=r?e.shape[1]:e.shape[2],a=n?t.shape[1]:t.shape[2],s=t.shape[0];if((1===i||1===o)&&a>1e3){n&&(t=t.transpose([0,2,1])),r&&(e=e.transpose([0,2,1]));var u=1===o?t:t.as3D(s,a,1),c=1===o?2:1,l=1===o?e.as3D(s,1,a):e;return this.multiply(u,l).sum(c,!0);}var f=It(t.dtype,e.dtype),h=new sa(t.shape,[s,i,o],n,r);return this.compileAndRun(h,[t,e],f);},e.prototype.fusedBatchMatMul=function(t){var e=t.a,n=t.b,r=t.transposeA,i=t.transposeB,o=t.bias,a=t.activation,s=t.preluActivationWeights,u=r?e.shape[2]:e.shape[1],c=i?n.shape[1]:n.shape[2],l=e.shape[0],f=It(e.dtype,n.dtype),h=null!=o,d=null!=s,p=a?La(a,!0):null,m=new sa(e.shape,[l,u,c],r,i,h,p,d),g=[e,n];return o&&g.push(o),s&&g.push(s),this.compileAndRun(m,g,f);},e.prototype.multiply=function(t,e){if("complex64"===t.dtype){var n=this.texData.get(t.dataId),r=this.texData.get(e.dataId),i=new Eo("return areal * breal - aimag * bimag;",t.shape,e.shape),o=new Eo("return areal * bimag + aimag * breal;",t.shape,e.shape),a=[this.makeComplexComponentTensorInfo(t,n.complexTensors.real),this.makeComplexComponentTensorInfo(t,n.complexTensors.imag),this.makeComplexComponentTensorInfo(e,r.complexTensors.real),this.makeComplexComponentTensorInfo(e,r.complexTensors.imag)],s=this.compileAndRun(i,a),u=this.compileAndRun(o,a),c=this.complex(s,u);return s.dispose(),u.dispose(),c;}if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.multiply(t,e);if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,Oo,t.dtype);var l=new So(Oo,t.shape,e.shape);return this.compileAndRun(l,[t,e],t.dtype);},e.prototype.batchNormalization=function(t,e,n,r,i,o){var a=[t,e,n],s=null;null!=o&&(s=o.shape,a.push(o));var u=null;if(null!=i&&(u=i.shape,a.push(i)),f().getBool("WEBGL_PACK_NORMALIZATION")){var c=new function(t,e,n,r,i,o){this.packedInputs=!0,this.packedOutput=!0,this.variableNames=["x","mean","variance"],_i(t,e),_i(t,n);var a="vec4(0.0)";null!=r&&(_i(t,r),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");var s="vec4(1.0)";null!=i&&(_i(t,i),this.variableNames.push("scale"),s="getScaleAtOutCoords()"),this.outputShape=t,this.userCode="\n      void main() {\n        vec4 offset = "+a+";\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("+o+"));\n\n        setOutput((x - mean) * inv + offset);\n      }\n    ";}(t.shape,e.shape,n.shape,s,u,r);return this.compileAndRun(c,a);}var l=new function(t,e,n,r,i,o){this.outputShape=[],this.variableNames=["x","mean","variance"],_i(t,e),_i(t,n);var a="0.0";null!=r&&(_i(t,r),this.variableNames.push("offset"),a="getOffsetAtOutCoords()");var s="1.0";null!=i&&(_i(t,i),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 = "+a+";\n        float scale = "+s+";\n        float inv = scale * inversesqrt(variance + float("+o+"));\n        setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n      }\n    ";}(t.shape,e.shape,n.shape,s,u,r);return this.compileAndRun(l,a);},e.prototype.localResponseNormalization4D=function(t,e,n,r,i){var o=f().getBool("WEBGL_PACK_NORMALIZATION")?new function(t,e,n,r,i){this.variableNames=["x"],this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0;var o,a=e,s=t[3]-1;this.outputShape=t;var u="float("+n+") + float("+r+") * sum";o=.5===i?"inversesqrt("+u+")":1===i?"1.0/("+u+")":"exp(log("+u+") * float(-"+i+"));",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 - "+a+";\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 = - "+a+"; j <= "+a+"; j++) {\n          ivec2 idx = depth + j;\n          bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n          bvec2 belowUpperBound = lessThanEqual(idx, ivec2("+s+"));\n\n          bool depthInRange = aboveLowerBound.x && belowUpperBound.x;\n          bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;\n\n          if(depthInRange || depthPlusOneInRange){\n            vec4 z = vec4(0.);\n            vec4 xFragAtCurrentDepth;\n            z.xz = cache.xy;\n            if(depthPlusOneInRange && hasNextCol){\n              xFragAtCurrentDepth = idx.y != d ?\n                getX(b, r, c, idx.y) : xFragAtOutputCoords;\n              z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));\n              if(hasNextRow){\n                z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));\n              }\n            }\n            cache.xy = z.yw;\n            sum += z * z;\n          }\n        }\n        vec4 result = xAtOutputCoords * "+o+";\n        setOutput(result);\n      }\n    ";}(t.shape,e,n,r,i):new function(t,e,n,r,i){this.variableNames=["x"],this.outputShape=[];var o,a=e,s=t[3]-1;this.outputShape=t;var u="float("+n+") + float("+r+") * sum";o=.5===i?"inversesqrt("+u+")":1===i?"1.0/("+u+")":"exp(log("+u+") * float(-"+i+"));",this.userCode="\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int r = coords[1];\n        int c = coords[2];\n        int d = coords[3];\n        float x = getX(b, r, c, d);\n        float sum = 0.0;\n        for (int j = -"+a+"; j <= "+a+"; j++) {\n          int idx = d + j;\n          if (idx >= 0 && idx <=  "+s+") {\n            float z = getX(b, r, c, idx);\n            sum += z * z;\n          }\n        }\n        float val = x * "+o+";\n        setOutput(val);\n      }\n    ";}(t.shape,e,n,r,i);return this.compileAndRun(o,[t]);},e.prototype.LRNGrad=function(t,e,n,r,i,o,a){var s=new function(t,e,n,r,i){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=i,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("+i+")\n                * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)\n                / norm;\n              if (k == d) {\n                dyi += pow(norm, -1.0 * "+i+");\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    ";}(e.shape,r,i,o,a);return this.compileAndRun(s,[e,n,t]);},e.prototype.tile=function(t,e){if("string"===t.dtype){var n=this.readSync(t.dataId).map(function(t){return ct(t);});return ro(vr(t.shape,t.dtype,n),e);}var r=new function(t,e){this.variableNames=["A"];for(var n=new Array(t.length),r=0;r<n.length;r++){n[r]=t[r]*e[r];}this.outputShape=n,this.rank=n.length;var i=xo(this.rank),o=function(t){var e=t.length;if(e>5)throw Error("Tile for rank "+e+" is not yet supported");if(1===e)return "imod(resRC, "+t[0]+")";for(var n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u"],r=[],i=0;i<t.length;i++){r.push("imod("+n[i]+", "+t[i]+")");}return r.join();}(t);this.userCode="\n      void main() {\n        "+i+" resRC = getOutputCoords();\n        setOutput(getA("+o+"));\n      }\n    ";}(t.shape,e);return this.compileAndRun(r,[t]);},e.prototype.pad=function(t,e,n){var r=f().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new function(t,e,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e.map(function(e,n){return e[0]+t[n]+e[1];});for(var r=t.length,i=xo(r),o=e.map(function(t){return t[0];}).join(","),a=e.map(function(e,n){return e[0]+t[n];}).join(","),s=so("rc",r),u=so("source",r),c=s[r-1]+" < "+this.outputShape[r-1],l=1===r?"source":"vec2("+u.slice(-2).join()+")",f=[i+" rc = outputLoc;",s[r-1]+" += 1;\n       if("+c+") {\n      ",1===r?"":"}\n       rc = outputLoc;\n       "+s[r-2]+" += 1;\n       if("+s[r-2]+" < "+this.outputShape[r-2]+") {",1===r?"":"  "+s[r-1]+" += 1;\n         if("+c+") {"],h=1===r?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))",d="",p=0,m=1===r?2:4;p<m;p++){d+="\n        "+f[p]+"\n        if ("+h+") {\n          result["+p+"] = float("+n+");\n        } else {\n          "+i+" source = rc - start;\n          result["+p+"] = getChannel(getX("+u.join()+"), "+l+");\n        }\n      ";}d+=1===r?"} ":"}}",this.userCode="\n      const "+i+" start = "+i+"("+o+");\n      const "+i+" end = "+i+"("+a+");\n\n      void main() {\n        "+i+" outputLoc = getOutputCoords();\n        vec4 result = vec4(0.);\n        "+d+"\n        setOutput(result);\n      }\n    ";}(t.shape,e,n):new function(t,e,n){this.variableNames=["x"],this.outputShape=e.map(function(e,n){return e[0]+t[n]+e[1];});var r=t.length,i=xo(r),o=e.map(function(t){return t[0];}).join(","),a=e.map(function(e,n){return e[0]+t[n];}).join(","),s=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);this.userCode=1!==r?"\n      "+i+" start = "+i+"("+o+");\n      "+i+" end = "+i+"("+a+");\n\n      void main() {\n        "+i+" outC = getOutputCoords();\n        if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n          setOutput(float("+n+"));\n        } else {\n          "+i+" coords = outC - start;\n          setOutput(getX("+s+"));\n        }\n      }\n    ":"\n        int start = "+o+";\n        int end = "+a+";\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      ";}(t.shape,e,n);return this.compileAndRun(r,[t]);},e.prototype.transpose=function(t,e){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.transpose(t,e);var n=f().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new function(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;for(var n=new Array(t.length),r=0;r<n.length;r++){n[r]=t[e[r]];}if(this.outputShape=n,this.rank=n.length,this.rank>6)throw Error("Packed transpose for rank "+this.rank+" is not yet supported.");var i=xo(this.rank),o=ao("rc",this.rank),a=new Array(this.rank);for(r=0;r<e.length;r++){a[e[r]]=o[r];}var s="vec2("+a.slice(-2).join()+")",u="++"+o[this.rank-1]+" < "+n[this.rank-1],c="getChannel(getA("+a.join()+"), "+s+")";this.userCode="\n    void main() {\n      "+i+" rc = getOutputCoords();\n      vec4 result = vec4(0.);\n      result[0] = "+c+";\n      if("+u+") {\n        result[1] = "+c+";\n      }\n      --"+o[this.rank-1]+";\n      if(++"+o[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    ";}(t.shape,e):new function(t,e){this.variableNames=["A"];for(var n=new Array(t.length),r=0;r<n.length;r++){n[r]=t[e[r]];}this.outputShape=n,this.rank=n.length;var i=xo(this.rank),o=function(t){var e=t.length;if(e>6)throw Error("Transpose for rank "+e+" is not yet supported");for(var n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(e),i=0;i<t.length;i++){r[t[i]]=n[i];}return r.join();}(e);this.userCode="\n    void main() {\n      "+i+" resRC = getOutputCoords();\n      setOutput(getA("+o+"));\n    }\n    ";}(t.shape,e);return this.compileAndRun(n,[t]);},e.prototype.gather=function(t,e,n){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.gather(t,e,n);var r=new function(t,e,n){this.variableNames=["A","indices"];var r=t.slice();r[n]=e,this.outputShape=r,this.rank=r.length;var i=xo(this.rank),o=function(t,e){var n=t.length;if(n>4)throw Error("Gather for rank "+n+" is not yet supported");if(1===n)return "int(getIndices(resRC))";for(var r=["resRC.x","resRC.y","resRC.z","resRC.w"],i=[],o=0;o<t.length;o++){o===e?i.push("int(getIndices("+r[o]+"))"):i.push(""+r[o]);}return i.join();}(t,n);this.userCode="\n      void main() {\n        "+i+" resRC = getOutputCoords();\n        setOutput(getA("+o+"));\n      }\n    ";}(t.shape,e.size,n);return this.compileAndRun(r,[t,e]);},e.prototype.batchToSpaceND=function(t,e,n){_(t.rank<=4,function(){return "batchToSpaceND for rank > 4 with a WebGL backend not implemented yet";});var r=e.reduce(function(t,e){return t*e;}),i=Hr(t.shape,e,r),o=Gr(i.length,e.length),a=Kr(t.shape,e,r),s=Xr(n,e.length),u=Yr(a,n,e.length);return t.reshape(i).transpose(o).reshape(a).slice(s,u);},e.prototype.spaceToBatchND=function(t,e,n){_(t.rank<=4,function(){return "spaceToBatchND for rank > 4 with a WebGL backend not implemented yet";});var r=e.reduce(function(t,e){return t*e;}),i=[[0,0]];i.push.apply(i,n);for(var o=1+e.length;o<t.shape.length;++o){i.push([0,0]);}var a=t.pad(i),s=Hr(a.shape,e,r,!1),u=Gr(s.length,e.length,!1),c=Kr(a.shape,e,r,!1);return a.reshape(s).transpose(u).reshape(c);},e.prototype.reduce=function(t,e,n){var r=t.shape[0],i=t.shape[1],o=new function(t,e){this.variableNames=["x"];var n=t.windowSize,r=t.batchSize,i=t.inSize,o=Math.ceil(i/n);this.outputShape=[r,o];var a="0.0",s="";"prod"===e?a="1.0":"min"===e?(a="1.0 / 1e-20",s="min"):"max"===e&&(a="-1.0 / 1e-20",s="max");var u=e+"("+e+"("+e+"(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";"sum"===e?u="sumValue":"prod"===e?u="prodValue":"all"===e?u="allValue":"any"===e&&(u="anyValue");var c=4*Math.floor(n/4),l=n%4,f="\n      if ("+("sum"===e)+") {\n        sumValue += dot(values, ones);\n      } else if ("+("prod"===e)+") {\n        vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n        prodValue *= tmp[0] * tmp[1];\n      } else {\n        minMaxValue = "+s+"(values, minMaxValue);\n      }\n    ",h="vec4";"all"===e?(a="1.0",f="\n        bool reducedAllValue = all(values);\n        float floatedReducedAllValue = float(reducedAllValue);\n        allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n      ",h="bvec4"):"any"===e&&(a="0.0",f="\n        bool reducedAnyValue = any(values);\n        float floatedReducedAnyValue = float(reducedAnyValue);\n        anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n      ",h="bvec4");var d="";i%n>0&&(d="\n        if (inIdx < 0 || inIdx >= "+i+") {\n          return initializationValue;\n        }\n      "),this.userCode="\n      const float initializationValue = "+a+";\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("+a+");\n        float prodValue = 1.0;\n        float sumValue = 0.0;\n        float allValue = 1.0;\n        float anyValue = 0.0;\n\n        for (int i = 0; i < "+c+"; i += 4) {\n          int inIdx = inOffset + i;\n          "+h+" values = "+h+"(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            getValue(batch, inIdx + 3)\n          );\n\n          "+f+"\n        }\n\n        int inIdx = inOffset + "+c+";\n        if ("+(1===l)+") {\n          "+h+" values = "+h+"(\n            getValue(batch, inIdx),\n            initializationValue,\n            initializationValue,\n            initializationValue\n          );\n\n          "+f+"\n        } else if ("+(2===l)+") {\n          "+h+" values = "+h+"(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            initializationValue,\n            initializationValue\n          );\n\n          "+f+"\n        } else if ("+(3===l)+") {\n          "+h+" values = "+h+"(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            initializationValue\n          );\n\n          "+f+"\n        }\n        setOutput("+u+");\n      }\n    ";}({windowSize:ti(i),inSize:i,batchSize:r},e),a=this.compileAndRun(o,[t],n);return 1===a.shape[1]?a:this.reduce(a,e,n);},e.prototype.argReduce=function(t,e,n){void 0===n&&(n=null);var r=t.shape[0],i=t.shape[1];null!=n&&(r=n.shape[0],i=n.shape[1]);var o=new function(t,e,n){this.variableNames=["A"];var r=t.windowSize,i=t.batchSize,o=t.inSize,a=Math.ceil(o/r);n||this.variableNames.push("bestIndicesA"),this.outputShape=[i,a];var s="max"===e?">":"<",u=n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode="\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n        int outIdx = coords[1];\n        int inOffset = outIdx * "+r+";\n\n        int bestIndex = inOffset;\n        float bestValue = getA(batch, bestIndex);\n\n        for (int i = 0; i < "+r+"; i++) {\n          int inIdx = "+u+";\n          float candidate = getA(batch, inIdx);\n          if (candidate "+s+" bestValue) {\n            bestValue = candidate;\n            bestIndex = inIdx;\n          }\n        }\n        setOutput(float(bestIndex));\n      }\n    ";}({windowSize:ti(i),inSize:i,batchSize:r},e,null==n),a=[t];null!=n&&a.push(n);var s=this.compileAndRun(o,a,"int32");return 1===s.shape[1]?s:this.argReduce(t,e,s);},e.prototype.argReducePacked=function(t,e,n){void 0===n&&(n=null);var r=null!=n?n.shape:t.shape,i=new function(t,e,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,_(t.length>2,function(){return "Packed arg"+(n.charAt(0).toUpperCase()+n.slice(1))+" supports only inputs with rank above 2.";});var i=t[t.length-1],o=Math.ceil(i/e);this.outputShape=t.slice(0,-1),o>1&&this.outputShape.push(o),r||this.variableNames.push("bestIndicesA");var a,s,u=this.outputShape,c=u.length,l=xo(c),f=so("coords",c);if(1===o){var h=xo(s=c+1);a="\n        "+h+" sourceLocR = "+h+"("+f.join()+", 0);\n        ++"+f[c-1]+";\n        "+h+" sourceLocG = "+h+"("+f.join()+", 0);\n        ++"+f[c-2]+";\n        "+h+" sourceLocA = "+h+"("+f.join()+", 0);\n        --"+f[c-1]+";\n        "+h+" sourceLocB = "+h+"("+f.join()+", 0);\n        --"+f[c-2]+";";}else s=c,a="\n        "+l+" sourceLocR = coords;\n        ++"+f[c-1]+";\n        "+l+" sourceLocG = coords;\n        ++"+f[c-2]+";\n        "+l+" sourceLocA = coords;\n        --"+f[c-1]+";\n        "+l+" sourceLocB = coords;\n        --"+f[c-2]+";";var d=["x","y","z","w","u","v"].slice(0,s),p="."+d[s-1],m=d.map(function(t){return "int "+t;}),g=so("sourceLocR",s-1).concat("inIdx.r"),v=so("sourceLocG",s-1).concat("inIdx.g"),y=so("sourceLocB",s-1).concat("inIdx.b"),b=so("sourceLocA",s-1).concat("inIdx.a"),x="max"===n?"greaterThan":"lessThan",w=r?"":"\n          inIdx = round(vec4(getBestIndicesAChannel("+g.join()+"),\n                             getBestIndicesAChannel("+v.join()+"),\n                             getBestIndicesAChannel("+y.join()+"),\n                             getBestIndicesAChannel("+b.join()+")));",k="vec4(\n            getAChannel("+g.join()+"),\n            hasNextCol ? getAChannel("+v.join()+") : 0.,\n            hasNextRow ? getAChannel("+y.join()+") : 0.,\n            hasNextRow && hasNextCol ? getAChannel("+b.join()+") : 0.)",E=r?"":"\n      float getBestIndicesAChannel("+m.join()+") {\n        return getChannel(getBestIndicesA("+d.join()+"),\n                                          vec2("+d.slice(-2).join()+"));\n      }";this.userCode="\n      float getAChannel("+m.join()+") {\n        return getChannel(getA("+d.join()+"),\n                               vec2("+d.slice(-2).join()+"));\n      }\n      "+E+"\n      void main() {\n        "+l+" coords = getOutputCoords();\n        bool hasNextCol = "+f[c-1]+" < "+(u[c-1]-1)+";\n        bool hasNextRow = "+f[c-2]+" < "+(u[c-2]-1)+";\n        "+a+"\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 = "+k+";\n\n        for (int i = 0; i < "+e+"; i++) {\n          inIdx = srcIdx;\n          "+w+"\n          vec4 candidate = "+k+";\n          bvec4 nan = isnan(candidate);\n          bvec4 replace = bvec4(\n            vec4("+x+"(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));\n\n          bestValue = vec4(replace.x  ? candidate.x : bestValue.x,\n                           replace.y  ? candidate.y : bestValue.y,\n                           replace.z  ? candidate.z : bestValue.z,\n                           replace.w  ? candidate.w : bestValue.w);\n          bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));\n          srcIdx++;\n        }\n        setOutput(bestIndex);\n      }\n    ";}(r,ti(r[r.length-1]),e,null==n),o=null==n?[t]:[t,n],a=this.compileAndRun(i,o,"int32");return a.rank===t.rank?this.argReducePacked(t,e,a):a;},e.prototype.sum=function(t,e){On("sum",e,t.rank);var n=Cn(t.shape,e),r=n[0],i=T(n[1]),o=t.as2D(-1,i),a=Rt(t.dtype);return this.reduce(o,"sum",a).reshape(r);},e.prototype.prod=function(t,e){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.prod(t,e);var n=Cn(t.shape,e),r=n[0],i=T(n[1]),o=t.as2D(-1,i),a=Rt(t.dtype);return this.reduce(o,"prod",a).reshape(r);},e.prototype.unsortedSegmentSum=function(t,e,n){var r=0,i=_n([r],t.rank),o=t;null!=i&&(o=t.transpose(i),r=Dn(1,t.rank)[0]);var a=function(t,e,n){for(var r=[],i=t.length,o=0;o<i;o++){o!==e?r.push(t[o]):r.push(n);}return r;}(o.shape,r,n),s=T([o.shape[r]]),u=o.as2D(-1,s),c=Rt(t.dtype),l=this.segOpCompute(u,"unsortedSegmentSum",e,c,n).reshape(a);return null!=i&&(l=l.transpose(Sn(i))),l;},e.prototype.segOpCompute=function(t,e,n,r,i){var o=t.shape[0],a=t.shape[1],s=function(t,e){var n,r=!1;for(t<=Zr?(n=t,r=!0):n=tt(t,Math.floor(Math.sqrt(t)));!r;){n>e||n===t?r=!0:n=tt(t,n+1);}return n;}(a,i),u=new function(t,e){this.variableNames=["x","segmentIds"];var n=t.windowSize,r=t.batchSize,i=t.inSize,o=t.numSegments,a=o*Math.ceil(i/n);this.outputShape=[r,a];var s=4*Math.floor(n/4),u=n%4,c="\n        sumValue += dot(values, segFilter);\n    ",l="";i%n>0&&(l="\n        if (inIdx < 0 || inIdx >= "+i+") {\n          return initializationValue;\n        }\n      ");var f="";i%n>0&&(f="\n        if (inIdx < 0 || inIdx >= "+i+") {\n          return -1.0;\n        }\n      "),this.userCode="\n      const float initializationValue = 0.0;\n\n      float getValue(int batch, int inIdx) {\n        "+l+"\n        return getX(batch, inIdx);\n      }\n\n      float getSegmentIdAtIndex(int inIdx) {\n        "+f+"\n        return getSegmentIds(inIdx);\n      }\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n        int outIdx = coords[1];\n        int inOffset = int(floor(float(outIdx) / float(\n          "+o+")) * float("+n+"));\n        int currentSeg = int(mod(float(outIdx), float("+o+")));\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    ";}({windowSize:s,inSize:a,batchSize:o,numSegments:i},e),c=this.compileAndRun(u,[t,n],r);return c.shape[1]===i?c:(n=Yn(0,i).tile([a/s]),this.segOpCompute(c,e,n,r,i));},e.prototype.argMinMaxReduce=function(t,e,n){var r=[e];if(On("arg"+n.charAt(0).toUpperCase()+n.slice(1),r,t.rank),!f().getBool("WEBGL_PACK_REDUCE")||t.rank<=2){var i=Cn(t.shape,r),o=i[0],a=T(i[1]),s=t.as2D(-1,a);return this.argReduce(s,n).reshape(o);}return this.argReducePacked(t,n);},e.prototype.argMin=function(t,e){return this.argMinMaxReduce(t,e,"min");},e.prototype.argMax=function(t,e){return this.argMinMaxReduce(t,e,"max");},e.prototype.cumsum=function(t,e,n,r){if(e!==t.rank-1)throw new Error("WebGL cumsum shader expects an inner-most axis="+(t.rank-1)+" but got axis="+e);var i=new function(t,e,n){this.variableNames=["x"],this.outputShape=t;var r=t.length,i=t[t.length-1],o=n?"<":">";this.userCode="\n      int getIndex(int i) {\n        "+(n?"return "+i+" -i - 1;":"return i;")+"\n      }\n\n      void main() {\n        "+xo(r)+" coords = getOutputCoords();\n        int end = "+Bo(r,"coords")+";\n        float val = 0.0;\n        for (int i = "+i+" - 1; i >= 0; i -= 1) {\n          int idx = getIndex(i);\n          if (idx "+o+" end) {\n            continue;\n          }\n          if (idx == end && "+e+") {\n            continue;\n          }\n          "+Bo(r,"coords")+" = idx;\n          val += getX("+function(t,e){if(1===t)return ""+e;if(2===t)return e+".x, "+e+".y";if(3===t)return e+".x, "+e+".y, "+e+".z";if(4===t)return e+".x, "+e+".y, "+e+".z, "+e+".w";throw Error("Cumulative sum for rank "+t+" is not yet supported");}(r,"coords")+");\n        }\n        setOutput(val);\n      }\n    ";}(t.shape,n,r);return this.compileAndRun(i,[t]);},e.prototype.equal=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(equal(a, b));\n","bool");var n=new So("return float(a == b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool");},e.prototype.notEqual=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(notEqual(a, b));\n","bool");var n=new So("return float(a != b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool");},e.prototype.less=function(t,e){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.less(t,e);if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(lessThan(a, b));\n","bool");var n=new So("return float(a < b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool");},e.prototype.lessEqual=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(lessThanEqual(a, b));\n","bool");var n=new So("return float(a <= b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool");},e.prototype.greater=function(t,e){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.greater(t,e);if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(greaterThan(a, b));\n","bool");var n=new So("return float(a > b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool");},e.prototype.greaterEqual=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(greaterThanEqual(a, b));\n","bool");var n=new So("return float(a >= b);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool");},e.prototype.logicalNot=function(t){var e=new xa(t.shape,"return float(!(x >= 1.0));");return this.compileAndRun(e,[t]);},e.prototype.logicalAnd=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return vec4(\n    vec4(greaterThanEqual(a, vec4(1.0))) *\n    vec4(greaterThanEqual(b, vec4(1.0))));\n","bool");var n=new So("return float(a >= 1.0 && b >= 1.0);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool");},e.prototype.logicalOr=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  return min(\n    vec4(greaterThanEqual(a, vec4(1.0))) +\n    vec4(greaterThanEqual(b, vec4(1.0))),\n    vec4(1.0));\n","bool");var n=new So("return float(a >= 1.0 || b >= 1.0);",t.shape,e.shape);return this.compileAndRun(n,[t,e],"bool");},e.prototype.select=function(t,e,n){var r=new function(t,e,n){var r,i;if(this.variableNames=["c","a","b"],this.outputShape=e,n>4)throw Error("Where for rank "+n+" is not yet supported");if(1===n)i="resRC",r="resRC";else {for(var o=["resRC.x","resRC.y","resRC.z","resRC.w"],a=[],s=[],u=0;u<e.length;u++){s.push(""+o[u]),u<t&&a.push(""+o[u]);}r=a.join(),i=s.join();}var c=xo(n);this.userCode="\n      void main() {\n        "+c+" resRC = getOutputCoords();\n        float cVal = getC("+r+");\n        if (cVal >= 1.0) {\n          setOutput(getA("+i+"));\n        } else {\n          setOutput(getB("+i+"));\n        }\n      }\n    ";}(t.rank,e.shape,e.rank);return this.compileAndRun(r,[t,e,n],It(e.dtype,n.dtype));},e.prototype.where=function(t){vn("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");var e=t.dataSync();return oo(t.shape,e);},e.prototype.topk=function(t,e,n){return io(t.dataSync(),t.shape,t.dtype,e);},e.prototype.min=function(t,e){On("min",e,t.rank);var n=Cn(t.shape,e),r=n[0],i=T(n[1]),o=t.as2D(-1,i);return this.reduce(o,"min",o.dtype).reshape(r);},e.prototype.minimum=function(t,e){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.minimum(t,e);var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Fo("\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 So("\n  if (isnan(a)) return a;\n  if (isnan(b)) return b;\n\n  return min(a, b);\n",t.shape,e.shape);return this.compileAndRun(n,[t,e]);},e.prototype.mod=function(t,e){var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Fo("\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 So("if (b == 0.0) return NAN;\n  return mod(a, b);",t.shape,e.shape);return this.compileAndRun(n,[t,e]);},e.prototype.max=function(t,e){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.max(t,e);On("max",e,t.rank);var n=Cn(t.shape,e),r=n[0],i=T(n[1]),o=t.as2D(-1,i);return this.reduce(o,"max",o.dtype).reshape(r);},e.prototype.maximum=function(t,e){if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.maximum(t,e);var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Fo("\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 So("\n  if (isnan(a)) return a;\n  if (isnan(b)) return b;\n\n  return max(a, b);\n",t.shape,e.shape);return this.compileAndRun(n,[t,e]);},e.prototype.all=function(t,e){On("all",e,t.rank);var n=Cn(t.shape,e),r=n[0],i=T(n[1]),o=t.as2D(-1,i);return this.reduce(o,"all",o.dtype).reshape(r);},e.prototype.any=function(t,e){On("any",e,t.rank);var n=Cn(t.shape,e),r=n[0],i=T(n[1]),o=t.as2D(-1,i);return this.reduce(o,"any",o.dtype).reshape(r);},e.prototype.realDivide=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  // vec4 one = vec4(equal(a, b));\n  // return one + (vec4(1.0) - one) * a / b;\n  vec4 result = a / b;\n  if(a.x == b.x) {\n    result.x = 1.;\n  }\n  if(a.y == b.y) {\n    result.y = 1.;\n  }\n  if(a.z == b.z) {\n    result.z = 1.;\n  }\n  if(a.w == b.w) {\n    result.w = 1.;\n  }\n\n  return result;\n","float32",!0);var n=new So("\nif (a == b) {\n  return 1.0;\n};\nreturn a / b;",t.shape,e.shape);return this.compileAndRun(n,[t,e],"float32");},e.prototype.floorDiv=function(t,e){if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,"\n  ivec4 ia = round(a);\n  ivec4 ib = round(b);\n  bvec4 cond = notEqual(ib, ivec4(0));\n  ivec4 result = ivec4(0);\n  vec4 s = sign(a) * sign(b);\n\n  // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n  if (cond[0]) {\n    result[0] = idiv(ia[0], ib[0], s[0]);\n  }\n  if (cond[1]) {\n    result[1] = idiv(ia[1], ib[1], s[1]);\n  }\n  if (cond[2]) {\n    result[2] = idiv(ia[2], ib[2], s[2]);\n  }\n  if (cond[3]) {\n    result[3] = idiv(ia[3], ib[3], s[3]);\n  }\n  return vec4(result);\n","int32");var n=new So("\n  float s = sign(a) * sign(b);\n  int ia = round(a);\n  int ib = round(b);\n  if (ib != 0) {\n    // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n    return float(idiv(ia, ib, s));\n  } else {\n    return NAN;\n  }\n",t.shape,e.shape);return this.compileAndRun(n,[t,e],"int32");},e.prototype.add=function(t,e){if("complex64"===t.dtype&&"complex64"===e.dtype)return this.complexSeparableBinaryOp(t,e,Co);if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.add(t,e);var n=It(t.dtype,e.dtype);if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,Co,n);var r=new So(Co,t.shape,e.shape);return this.compileAndRun(r,[t,e],n);},e.prototype.packedUnaryOp=function(t,e,n){var r=new Ba(t.shape,e);return this.compileAndRun(r,[t],n);},e.prototype.packedBinaryOp=function(t,e,n,r,i){void 0===i&&(i=!1);var o=new Fo(n,t.shape,e.shape,i);return this.compileAndRun(o,[t,e],r);},e.prototype.complexSeparableBinaryOp=function(t,e,n){var r=this,i=this.texData.get(t.dataId),o=this.texData.get(e.dataId),a=[[i.complexTensors.real,o.complexTensors.real],[i.complexTensors.imag,o.complexTensors.imag]].map(function(i){var o=i[0],a=i[1],s=r.makeComplexComponentTensorInfo(t,o),u=r.makeComplexComponentTensorInfo(e,a),c=new So(n,t.shape,e.shape);return r.compileAndRun(c,[s,u],It(o.dtype,a.dtype));}),s=a[0],u=a[1],c=this.complex(s,u);return s.dispose(),u.dispose(),c;},e.prototype.makeComplexComponentTensorInfo=function(t,e){return {dataId:e.dataId,dtype:e.dtype,shape:t.shape};},e.prototype.addN=function(t){if(1===t.length)return t[0];if(t.length>f().get("WEBGL_MAX_TEXTURES_IN_SHADER")){var e=Math.floor(t.length/2),n=this.addN(t.slice(0,e)),r=this.addN(t.slice(e));return this.addN([n,r]);}var i=t.map(function(t){return t.dtype;}).reduce(function(t,e){return It(t,e);}),o=t.map(function(t){return t.shape;}),a=f().getBool("WEBGL_PACK")?new function(t,e){this.outputShape=[],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t,this.variableNames=e.map(function(t,e){return "T"+e;});var n=[];this.variableNames.forEach(function(t){n.push("vec4 v"+t+" = get"+t+"AtOutCoords();");});var r=this.variableNames.map(function(t){return "v"+t;}).join(" + ");this.userCode="\n      void main() {\n        "+n.join("\n        ")+"\n\n        vec4 result = "+r+";\n        setOutput(result);\n      }\n    ";}(t[0].shape,o):new function(t,e){this.outputShape=[],this.outputShape=t,this.variableNames=e.map(function(t,e){return "T"+e;});var n=[];this.variableNames.forEach(function(t){n.push("float v"+t+" = get"+t+"AtOutCoords();");});var r=this.variableNames.map(function(t){return "v"+t;}).join(" + ");this.userCode="\n      void main() {\n        "+n.join("\n        ")+"\n\n        float result = "+r+";\n        setOutput(result);\n      }\n    ";}(t[0].shape,o);return this.compileAndRun(a,t,i);},e.prototype.subtract=function(t,e){if("complex64"===t.dtype&&"complex64"===e.dtype)return this.complexSeparableBinaryOp(t,e,Ao);if(this.shouldExecuteOnCPU([t,e]))return this.cpuBackend.subtract(t,e);var n=It(t.dtype,e.dtype);if(f().getBool("WEBGL_PACK_BINARY_OPERATIONS"))return this.packedBinaryOp(t,e,Ao,t.dtype);var r=new So(Ao,t.shape,e.shape);return this.compileAndRun(r,[t,e],n);},e.prototype.pow=function(t,e){var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Fo("\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 So("\nif(a < 0.0 && floor(b) < b){\n  return NAN;\n}\nif (b == 0.0) {\n  return 1.0;\n}\nreturn (round(mod(b, 2.0)) != 1) ?\n    pow(abs(a), b) : sign(a) * pow(abs(a), b);\n",t.shape,e.shape),r=It(t.dtype,e.dtype);return this.compileAndRun(n,[t,e],r);},e.prototype.ceil=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.ceil(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Sa,t.dtype);var e=new xa(t.shape,Sa);return this.compileAndRun(e,[t]);},e.prototype.floor=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.floor(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Da,t.dtype);var e=new xa(t.shape,Da);return this.compileAndRun(e,[t]);},e.prototype.sign=function(t){var e=new xa(t.shape,"\n  if (isnan(x)) { return 0.0; }\n  return sign(x);\n");return this.compileAndRun(e,[t]);},e.prototype.isNaN=function(t){var e=new xa(t.shape,"return float(isnan(x));");return this.compileAndRun(e,[t],"bool");},e.prototype.isInf=function(t){var e=new xa(t.shape,"return float(isinf(x));");return this.compileAndRun(e,[t],"bool");},e.prototype.isFinite=function(t){var e=new xa(t.shape,"return float(!isnan(x) && !isinf(x));");return this.compileAndRun(e,[t],"bool");},e.prototype.round=function(t){var e=new xa(t.shape,"\n  // OpenGL ES does not support round function.\n  // The algorithm is based on banker's rounding.\n  float base = floor(x);\n  if ((x - base) < 0.5) {\n    return floor(x);\n  } else if ((x - base) > 0.5) {\n    return ceil(x);\n  } else {\n    if (mod(base, 2.0) == 0.0) {\n      return base;\n    } else {\n      return base + 1.0;\n    }\n  }\n");return this.compileAndRun(e,[t]);},e.prototype.exp=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.exp(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Fa,t.dtype);var e=new xa(t.shape,Fa);return this.compileAndRun(e,[t]);},e.prototype.expm1=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.expm1(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Ta,t.dtype);var e=new xa(t.shape,Ta);return this.compileAndRun(e,[t]);},e.prototype.softmax=function(t,e){var n=L([e],t.shape),r=this.max(t,n),i=An(r.shape,n),o=this.subtract(t,r.reshape(i)),a=this.exp(o),s=this.sum(a,n).reshape(i);return this.realDivide(a,s);},e.prototype.log=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.log(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,"\n  vec4 result = log(x);\n  vec4 isNaN = vec4(lessThan(x, vec4(0.0)));\n  result.r = isNaN.r == 1.0 ? NAN : result.r;\n  result.g = isNaN.g == 1.0 ? NAN : result.g;\n  result.b = isNaN.b == 1.0 ? NAN : result.b;\n  result.a = isNaN.a == 1.0 ? NAN : result.a;\n\n  return result;\n",t.dtype);var e=new xa(t.shape,"if (x < 0.0) return NAN;\n  return log(x);");return this.compileAndRun(e,[t]);},e.prototype.log1p=function(t){var e=new xa(t.shape,"return log(1.0 + x);");return this.compileAndRun(e,[t]);},e.prototype.sqrt=function(t){var e=new xa(t.shape,"return sqrt(x);");return this.compileAndRun(e,[t]);},e.prototype.rsqrt=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.rsqrt(t);var e=new xa(t.shape,"return inversesqrt(x);");return this.compileAndRun(e,[t]);},e.prototype.reciprocal=function(t){var e=new xa(t.shape,"return 1.0 / x;");return this.compileAndRun(e,[t]);},e.prototype.relu=function(t){var e;return e=f().getBool("WEBGL_PACK")?new Ba(t.shape,Ra):new xa(t.shape,Ca),this.compileAndRun(e,[t]);},e.prototype.relu6=function(t){var e;return e=f().getBool("WEBGL_PACK")?new Ba(t.shape,Ma):new xa(t.shape,Aa),this.compileAndRun(e,[t]);},e.prototype.prelu=function(t,e){var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Fo(Do,t.shape,e.shape):new So(_o,t.shape,e.shape);return this.compileAndRun(n,[t,e]);},e.prototype.elu=function(t){if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,ja,t.dtype);var e=new xa(t.shape,Oa);return this.compileAndRun(e,[t]);},e.prototype.eluDer=function(t,e){var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Fo("\n  vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n  return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n",t.shape,e.shape):new So("return (b >= 1.0) ? a : a * (b + 1.0);",t.shape,e.shape);return this.compileAndRun(n,[t,e]);},e.prototype.selu=function(t){var e=new xa(t.shape,"\n  // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n  // see: https://arxiv.org/abs/1706.02515\n  float scaleAlpha = 1.7580993408473768;\n  float scale = 1.0507009873554805;\n  return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n");return this.compileAndRun(e,[t]);},e.prototype.int=function(t){var e=new xa(t.shape,"return float(int(x));");return this.compileAndRun(e,[t],"int32");},e.prototype.clip=function(t,e,n){var r,i=(r=f().getBool("WEBGL_PACK_CLIP")?new No(t.shape):new To(t.shape)).getCustomSetupFunc(e,n);return this.compileAndRun(r,[t],null,i);},e.prototype.abs=function(t){if(this.shouldExecuteOnCPU([t]))return this.cpuBackend.abs(t);if(f().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(t,Ea,t.dtype);var e=new xa(t.shape,Ea);return this.compileAndRun(e,[t]);},e.prototype.complexAbs=function(t){var e=this.texData.get(t.dataId),n=new function(t){this.variableNames=["real","imag"],this.outputShape=t,this.userCode="\n      void main() {\n        float re = abs(getRealAtOutCoords());\n        float im = abs(getImagAtOutCoords());\n        float mx = max(re, im);\n\n        // sadly the length function in glsl is not underflow-safe\n        // (at least not on Intel GPUs). So the safe solution is\n        // to ensure underflow-safety in all cases.\n        setOutput(\n          mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))\n        );\n      }\n    ";}(t.shape),r=[this.makeComplexComponentTensorInfo(t,e.complexTensors.real),this.makeComplexComponentTensorInfo(t,e.complexTensors.imag)];return this.compileAndRun(n,r);},e.prototype.sigmoid=function(t){var e=new xa(t.shape,"return 1.0 / (1.0 + exp(-1.0 * x));");return this.compileAndRun(e,[t]);},e.prototype.softplus=function(t){var e=new xa(t.shape,"\n  float epsilon = 1.1920928955078125e-7;\n  float threshold = log(epsilon) + 2.0;\n\n  bool too_large = x > -threshold;\n  bool too_small = x < threshold;\n\n  float result;\n  float exp_x = exp(x);\n\n  if (too_large){\n    result = x;\n  }\n  else if (too_small){\n    result = exp_x;\n  }\n  else{\n    result = log(exp_x + 1.0);\n  }\n  return result;\n");return this.compileAndRun(e,[t]);},e.prototype.sin=function(t){var e=new xa(t.shape,"if (isnan(x)) return x;\n  return sin(x);\n");return this.compileAndRun(e,[t]);},e.prototype.cos=function(t){var e=new xa(t.shape,"if (isnan(x)) return x;\n  return cos(x);\n");return this.compileAndRun(e,[t]);},e.prototype.tan=function(t){var e=new xa(t.shape,"return tan(x);");return this.compileAndRun(e,[t]);},e.prototype.asin=function(t){var e=new xa(t.shape,"if (isnan(x)) return x;\n  if (abs(x) > 1.) {\n    return NAN;\n  }\n  return asin(x);\n");return this.compileAndRun(e,[t]);},e.prototype.acos=function(t){var e=new xa(t.shape,"if (isnan(x)) return x;\n  if (abs(x) > 1.) {\n    return NAN;\n  }\n  return acos(x);\n");return this.compileAndRun(e,[t]);},e.prototype.atan=function(t){var e=new xa(t.shape,"if (isnan(x)) return x;\n  return atan(x);\n");return this.compileAndRun(e,[t]);},e.prototype.atan2=function(t,e){var n=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Fo("\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 So("\n  if (isnan(a)) return a;\n  if (isnan(b)) return b;\n\n  return atan(a, b);\n",t.shape,e.shape);return this.compileAndRun(n,[t,e]);},e.prototype.sinh=function(t){var e=new xa(t.shape,"\n  float e2x = exp(x);\n  return (e2x - 1.0 / e2x) / 2.0;\n");return this.compileAndRun(e,[t]);},e.prototype.cosh=function(t){var e=new xa(t.shape,"\n  float e2x = exp(-x);\n  return (e2x + 1.0 / e2x) / 2.0;\n");return this.compileAndRun(e,[t]);},e.prototype.tanh=function(t){var e=new xa(t.shape,"\n  float e2x = exp(-2.0 * abs(x));\n  return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n");return this.compileAndRun(e,[t]);},e.prototype.asinh=function(t){var e=new xa(t.shape,"if (isnan(x)) return x;return log(x + sqrt(x * x + 1.0));");return this.compileAndRun(e,[t]);},e.prototype.acosh=function(t){var e=new xa(t.shape,"if (isnan(x)) return x;\n  if (x < 1.0) return NAN;\n  return log(x + sqrt(x * x - 1.0));");return this.compileAndRun(e,[t]);},e.prototype.atanh=function(t){var e=new xa(t.shape,"if (isnan(x)) return x;\n  if ((x < -1.0) || (x > 1.0)) return NAN;\n  return (log(1.0 + x) - log(1.0 - x)) / 2.0;");return this.compileAndRun(e,[t]);},e.prototype.erf=function(t){var e=new xa(t.shape,'\n  // Error function is calculated approximately with elementary function.\n  // See "Handbook of Mathematical Functions with Formulas,\n  // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n  float p = 0.3275911;\n  float a1 = 0.254829592;\n  float a2 = -0.284496736;\n  float a3 = 1.421413741;\n  float a4 = -1.453152027;\n  float a5 = 1.061405429;\n\n  float sign = sign(x);\n  x = abs(x);\n  float t = 1.0 / (1.0 + p * x);\n  return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));\n');return this.compileAndRun(e,[t]);},e.prototype.step=function(t,e){var n=new xa(t.shape,function(t){return void 0===t&&(t=0),wa+"\n    return x > 0.0 ? 1.0 : float("+t+");\n  ";}(e));return this.compileAndRun(n,[t]);},e.prototype.conv2dByMatMul=function(t,e,n,r,i,o){var a=t.shape,s=this.texData.get(t.dataId),u=n.inChannels,c=a[0]*a[1]*a[2],l=n.outChannels,h="channelsLast"===n.dataFormat,d=(1===c||1===l)&&u>1e3,p=a[2]%2!=0&&!!s.isPacked;if(d||!f().getBool("WEBGL_LAZILY_UNPACK")||!f().getBool("WEBGL_PACK_BINARY_OPERATIONS")||!p){var m=h?a[0]*a[1]*a[2]:a[0]*a[2]*a[3],g=this.reshape(t,[1,m,n.inChannels]),v=this.reshape(e,[1,n.inChannels,n.outChannels]);return this.reshape(this.fusedBatchMatMul({a:g,b:v,transposeA:!1,transposeB:!1,bias:r,activation:i,preluActivationWeights:o}),n.outShape);}var y=h?a[0]*a[1]*(a[2]+1):a[0]*a[2]*(a[3]+1),b={dataId:t.dataId,shape:[1,y,n.inChannels],dtype:t.dtype},x=s.shape;s.shape=s.shape.slice(),s.shape[s.shape.length-2]++,_(Be(s.shape,b.shape),function(){return "packed reshape "+s.shape+" to "+b.shape+" isn't free";});var w=this.reshape(e,[1,n.inChannels,n.outChannels]),k=this.fusedBatchMatMul({a:b,b:w,transposeA:!1,transposeB:!1,bias:r,activation:i,preluActivationWeights:o}),E=this.texData.get(k.dataId);return _(E.isPacked,function(){return "batchMatMul result is expected to be packed";}),s.shape=x,E.shape=n.outShape,Wt.makeTensorFromDataId(k.dataId,n.outShape,k.dtype);},e.prototype.conv2dWithIm2Row=function(t,e,n,r,i,o){var a=n.filterWidth,s=n.filterHeight,u=n.inChannels,c=n.outWidth,l=n.outHeight,f="channelsLast"===n.dataFormat,h=a*s*u,d=l*c,p=[h,d],m=t.squeeze([0]),g=e.reshape([1,h,-1]),v=new function(t,e,n){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t;for(var r=n.filterWidth,i=n.inChannels,o=n.strideWidth,a=n.strideHeight,s=n.padInfo,u=n.outWidth,c=n.dilationWidth,l=n.dilationHeight,f=n.dataFormat,h=s.left,d=s.top,p=i*r,m=uo(),g="channelsLast"===f,v=g?0:1,y=g?1:2,b="",x=0;x<=1;x++){for(var w=0;w<=1;w++){b+="\n          blockIndex = rc.y + "+w+";\n          pos = rc.x + "+x+";\n\n          if(blockIndex < "+t[1]+" && pos < "+t[0]+") {\n            offsetY = int(blockIndex / ("+u+")) * "+a+" - "+d+";\n            d0 = offsetY + "+l+" * (pos / "+p+");\n\n            if(d0 < "+e[v]+" && d0 >= 0) {\n\n              offsetX = int(mod(float(blockIndex), "+u+".) * "+o+". - "+h+".);\n              d1 = offsetX + "+c+" * (int(mod(float(pos), "+p+".) / "+i+".));\n\n              if(d1 < "+e[y]+" && d1 >= 0) {\n\n                ch = int(mod(float(pos), "+i+".));\n\n                if ("+g+") {\n                  innerDims = vec2(d1, ch);\n                  result["+(2*x+w)+"] = getChannel(\n                    getA(d0, int(innerDims.x),\n                    int(innerDims.y)), innerDims);\n                } else {\n                  innerDims = vec2(d0, d1);\n                  result["+(2*x+w)+"] = getChannel(\n                    getA(ch, int(innerDims.x),\n                    int(innerDims.y)), innerDims);\n                }\n              }\n            }\n          }\n        ";}}this.userCode="\n      void main() {\n        ivec2 rc = getOutputCoords();\n\n        vec4 result = vec4(0);\n\n        int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n        vec2 innerDims;\n\n        "+b+"\n\n        "+m.output+" = result;\n      }\n    ";}(p,m.shape,n),y=this.compileAndRun(v,[m]).reshape([1,p[0],p[1]]),b=null!=r,x=null!=o,w=i?La(i,!0):null,k=new sa(y.shape,[1,d,n.outChannels],!0,!1,b,w,x),E=[y,g];r&&E.push(r),x&&E.push(o);var C=this.compileAndRun(k,E);return f?C.reshape([1,l,c,n.outChannels]):C.reshape([1,n.outChannels,l,c]);},e.prototype.fusedConv2d=function(t){var e=t.input,n=t.filter,r=t.convInfo,i=t.bias,o=t.activation,a=t.preluActivationWeights;if(1===r.filterHeight&&1===r.filterWidth&&1===r.dilationHeight&&1===r.dilationWidth&&1===r.strideHeight&&1===r.strideWidth&&("SAME"===r.padInfo.type||"VALID"===r.padInfo.type))return this.conv2dByMatMul(e,n,r,i,o,a);if(f().getBool("WEBGL_CONV_IM2COL")&&1===e.shape[0])return this.conv2dWithIm2Row(e,n,r,i,o,a);var s=null!=i,u=null!=a,c=o?La(o,!1):null,l=new Ro(r,s,c,u),h=[e,n];return i&&h.push(i),a&&h.push(a),this.compileAndRun(l,h);},e.prototype.conv2d=function(t,e,n){if(1===n.filterHeight&&1===n.filterWidth&&1===n.dilationHeight&&1===n.dilationWidth&&1===n.strideHeight&&1===n.strideWidth&&("SAME"===n.padInfo.type||"VALID"===n.padInfo.type))return this.conv2dByMatMul(t,e,n);if(f().getBool("WEBGL_CONV_IM2COL")&&1===t.shape[0])return this.conv2dWithIm2Row(t,e,n);var r=new Ro(n);return this.compileAndRun(r,[t,e]);},e.prototype.conv2dDerInput=function(t,e,n){var r=new function(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;var e=t.filterHeight,n=t.filterWidth,r=t.strideHeight,i=t.strideWidth,o="channelsLast"===t.dataFormat,a=e-1-t.padInfo.top,s=n-1-t.padInfo.left,u=o?1:2,c=o?2:3,l=o?3:1;this.userCode="\n      const ivec2 pads = ivec2("+a+", "+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) / "+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 = "+n+" - 1 - wC;\n\n            for (int d2 = 0; d2 < "+t.outChannels+"; d2++) {\n\n              if ("+o+") {\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    ";}(n);return this.compileAndRun(r,[t,e]);},e.prototype.conv2dDerFilter=function(t,e,n){var r=new function(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;var e=t.strideHeight,n=t.strideWidth,r=t.padInfo.top,i=t.padInfo.left,o="channelsLast"===t.dataFormat;this.userCode="\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int wR = coords.x;\n        int wC = coords.y;\n        int d1 = coords.z;\n        int d2 = coords.w;\n\n        // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int b = 0; b < "+t.batchSize+"; b++) {\n          for (int yR = 0; yR < "+t.outHeight+"; yR++) {\n            int xR = wR + yR * "+e+" - "+r+";\n\n            if (xR < 0 || xR >= "+t.inHeight+") {\n              continue;\n            }\n\n            for (int yC = 0; yC < "+t.outWidth+"; yC++) {\n              int xC = wC + yC * "+n+" - "+i+";\n\n              if (xC < 0 || xC >= "+t.inWidth+") {\n                continue;\n              }\n\n              if ("+o+") {\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    ";}(n);return this.compileAndRun(r,[t,e]);},e.prototype.fusedDepthwiseConv2D=function(t){var e,n=t.input,r=t.filter,i=t.convInfo,o=t.bias,a=t.activation,s=t.preluActivationWeights,u=f().getBool("WEBGL_PACK_DEPTHWISECONV")&&i.strideWidth<=2&&i.outChannels/i.inChannels==1,c=a?La(a,u):null,l=[n,r],h=null!=o,d=null!=s;return h&&l.push(o),d&&l.push(s),u?(e=new jo(i,h,c,d),this.compileAndRun(e,l)):(e=new Mo(i,h,c,d),this.compileAndRun(e,l));},e.prototype.depthwiseConv2D=function(t,e,n){var r;return f().getBool("WEBGL_PACK_DEPTHWISECONV")&&n.strideWidth<=2&&n.outChannels/n.inChannels==1?(r=new jo(n),this.compileAndRun(r,[t,e])):(r=new Mo(n),this.compileAndRun(r,[t,e]));},e.prototype.depthwiseConv2DDerInput=function(t,e,n){var r=new function(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;var e=t.filterHeight,n=t.filterWidth,r=t.strideHeight,i=t.strideWidth,o=e-1-t.padInfo.top,a=n-1-t.padInfo.left,s=t.outChannels/t.inChannels;this.userCode="\n      const ivec2 pads = ivec2("+o+", "+a+");\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) / "+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 = "+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    ";}(n);return this.compileAndRun(r,[t,e]);},e.prototype.depthwiseConv2DDerFilter=function(t,e,n){var r=new function(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;var e=t.strideHeight,n=t.strideWidth,r=t.padInfo.top,i=t.padInfo.left,o=t.outChannels/t.inChannels;this.userCode="\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int wR = coords.x;\n        int wC = coords.y;\n        int d1 = coords.z;\n        int dm = coords.w;\n        int d2 = d1 * "+o+" + 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+" - "+i+";\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    ";}(n);return this.compileAndRun(r,[t,e]);},e.prototype.conv3d=function(t,e,n){var r=new function(t){this.variableNames=["x","W"],this.outputShape=t.outShape;var e=t.padInfo.front,n=t.padInfo.top,r=t.padInfo.left,i=t.strideDepth,o=t.strideHeight,a=t.strideWidth,s=t.dilationDepth,u=t.dilationHeight,c=t.dilationWidth,l=t.filterDepth,f=t.filterHeight,h=t.filterWidth,d=4*Math.floor(t.inChannels/4),p=t.inChannels%4;this.userCode="\n      const ivec3 strides = ivec3("+i+", "+o+", "+a+");\n      const ivec3 pads = ivec3("+e+", "+n+", "+r+");\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int d2 = coords.u;\n\n        ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n        int xFCorner = xFRCCorner.x;\n        int xRCorner = xFRCCorner.y;\n        int xCCorner = xFRCCorner.z;\n\n        // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get\n        // y(yF, yR, yC, d2). ? = to be determined. : = across all\n        // values in that axis.\n        float dotProd = 0.0;\n        for (int wF = 0; wF < "+l+"; wF++) {\n          int xF = xFCorner + wF * "+s+";\n\n          if (xF < 0 || xF >= "+t.inDepth+") {\n            continue;\n          }\n\n          for (int wR = 0; wR < "+f+"; wR++) {\n            int xR = xRCorner + wR * "+u+";\n\n            if (xR < 0 || xR >= "+t.inHeight+") {\n              continue;\n            }\n\n            for (int wC = 0; wC < "+h+"; wC++) {\n              int xC = xCCorner + wC * "+c+";\n\n              if (xC < 0 || xC >= "+t.inWidth+") {\n                continue;\n              }\n\n              for (int d1 = 0; d1 < "+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    ";}(n);return this.compileAndRun(r,[t,e]);},e.prototype.conv3dDerInput=function(t,e,n){var r=new function(t){this.variableNames=["dy","W"],this.outputShape=t.inShape;var e=t.filterDepth,n=t.filterHeight,r=t.filterWidth,i=t.strideDepth,o=t.strideHeight,a=t.strideWidth,s=e-1-t.padInfo.front,u=n-1-t.padInfo.top,c=r-1-t.padInfo.left;this.userCode="\n      const ivec3 pads = ivec3("+s+", "+u+", "+c+");\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int d1 = coords.u;\n\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyFCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        float dotProd = 0.0;\n        for (int wF = 0; wF < "+e+"; wF++) {\n          float dyF = float(dyFCorner + wF) / "+i+".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) / "+o+".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) / "+a+".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    ";}(n);return this.compileAndRun(r,[t,e]);},e.prototype.conv3dDerFilter=function(t,e,n){var r=new function(t){this.variableNames=["x","dy"],this.outputShape=t.filterShape;var e=t.strideDepth,n=t.strideHeight,r=t.strideWidth,i=t.padInfo.front,o=t.padInfo.top,a=t.padInfo.left;this.userCode="\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int wF = coords.x;\n        int wR = coords.y;\n        int wC = coords.z;\n        int d1 = coords.w;\n        int d2 = coords.u;\n\n        float dotProd = 0.0;\n\n        for (int b = 0; b < "+t.batchSize+"; b++) {\n          for (int yF = 0; yF < "+t.outDepth+"; yF++) {\n            int xF = wF + yF * "+e+" - "+i+";\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+" - "+o+";\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+" - "+a+";\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    ";}(n);return this.compileAndRun(r,[t,e]);},e.prototype.maxPool=function(t,e){var n=new ca(e,"max",!1);return this.compileAndRun(n,[t]);},e.prototype.avgPool=function(t,e){var n=new ca(e,"avg",!1);return this.compileAndRun(n,[t],"float32");},e.prototype.maxPoolBackprop=function(t,e,n,r){var i=new ca(r,"max",!0),o=this.compileAndRun(i,[e]),a=new function(t){this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;var e=t.strideHeight,n=t.strideWidth,r=t.dilationHeight,i=t.effectiveFilterHeight,o=t.effectiveFilterWidth,a=i-1-t.padInfo.top,s=o-1-t.padInfo.left,u=i*o-1;this.userCode="\n      const ivec2 pads = ivec2("+a+", "+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 < "+i+";\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 < "+o+"; 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 * "+o+" + wC;\n            float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n            dotProd += dyValue * mask;\n          }\n        }\n        setOutput(dotProd);\n      }\n    ";}(r),s=this.compileAndRun(a,[t,o],e.dtype);return o.dispose(),s;},e.prototype.avgPoolBackprop=function(t,e,n){var r=new function(t){this.variableNames=["dy"],this.outputShape=t.inShape;var e=t.filterHeight,n=t.filterWidth,r=t.strideHeight,i=t.strideWidth,o=t.dilationHeight,a=t.dilationWidth,s=t.effectiveFilterHeight,u=t.effectiveFilterWidth,c=s-1-t.padInfo.top,l=u-1-t.padInfo.left,f=1/(e*n);this.userCode="\n      const ivec2 pads = ivec2("+c+", "+l+");\n      const float avgMultiplier = float("+f+");\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n\n        ivec2 dyRCCorner = coords.yz - pads;\n        int dyRCorner = dyRCCorner.x;\n        int dyCCorner = dyRCCorner.y;\n\n        // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < "+s+";\n            wR += "+o+") {\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+= "+a+") {\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(b, idyR, idyC, d);\n\n            dotProd += dyValue * avgMultiplier;\n          }\n        }\n        setOutput(dotProd);\n      }\n    ";}(n);return this.compileAndRun(r,[t],e.dtype);},e.prototype.cast=function(t,e){return zi(t,e,this);},e.prototype.unstack=function(t,e){for(var n=t.shape[e],r=new Array(t.rank-1),i=0,o=0;o<t.rank;o++){o!==e&&(r[i++]=t.shape[o]);}var a=new Array(t.rank).fill(0),s=t.shape.slice();s[e]=1;var u=new Array(n);for(o=0;o<u.length;o++){a[e]=o,u[o]=this.slice(t,a,s).reshape(r);}return u;},e.prototype.avgPool3d=function(t,e){var n=new la(e,"avg",!1);return this.compileAndRun(n,[t],"float32");},e.prototype.avgPool3dBackprop=function(t,e,n){var r=new function(t){this.variableNames=["dy"],this.outputShape=t.inShape;var e=t.filterDepth,n=t.filterHeight,r=t.filterWidth,i=t.strideDepth,o=t.strideHeight,a=t.strideWidth,s=t.dilationDepth,u=t.dilationHeight,c=t.dilationWidth,l=t.effectiveFilterDepth,f=t.effectiveFilterHeight,h=t.effectiveFilterWidth,d=l-1-t.padInfo.front,p=f-1-t.padInfo.top,m=h-1-t.padInfo.left,g=1/(e*n*r);this.userCode="\n      const ivec3 pads = ivec3("+d+", "+p+", "+m+");\n      const float avgMultiplier = float("+g+");\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int ch = coords.u;\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyDCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get\n        // dx(xD, xR, xC, ch).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int wD = 0; wD < "+l+";\n            wD += "+s+") {\n          float dyD = float(dyDCorner + wD) / "+i+".0;\n\n          if (dyD < 0.0 || dyD >= "+t.outDepth+".0 || fract(dyD) > 0.0) {\n            continue;\n          }\n          int idyD = int(dyD);\n\n          for (int wR = 0; wR < "+f+";\n              wR += "+u+") {\n            float dyR = float(dyRCorner + wR) / "+o+".0;\n\n            if (dyR < 0.0 || dyR >= "+t.outHeight+".0 ||\n                fract(dyR) > 0.0) {\n              continue;\n            }\n            int idyR = int(dyR);\n\n            for (int wC = 0; wC < "+h+";\n                wC += "+c+") {\n              float dyC = float(dyCCorner + wC) / "+a+".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    ";}(n);return this.compileAndRun(r,[t],e.dtype);},e.prototype.maxPool3d=function(t,e){var n=new la(e,"max",!1);return this.compileAndRun(n,[t],"float32");},e.prototype.maxPool3dBackprop=function(t,e,n,r){var i=new la(r,"max",!0),o=this.compileAndRun(i,[e]),a=new function(t){this.variableNames=["dy","maxPos"],this.outputShape=t.inShape;var e=t.strideDepth,n=t.strideHeight,r=t.strideWidth,i=t.dilationDepth,o=t.dilationHeight,a=t.dilationWidth,s=t.effectiveFilterDepth,u=t.effectiveFilterHeight,c=t.effectiveFilterWidth,l=s-1-t.padInfo.front,f=u-1-t.padInfo.top,h=c-1-t.padInfo.left,d=s*u*c-1;this.userCode="\n      const ivec3 pads = ivec3("+l+", "+f+", "+h+");\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int ch = coords.u;\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyDCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get\n        // dx(xD, xR, xC, ch).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int wD = 0; wD < "+s+";\n           wD += "+i+") {\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 += "+o+") {\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 += "+a+") {\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    ";}(r),s=this.compileAndRun(a,[t,o],e.dtype);return o.dispose(),s;},e.prototype.reshape=function(t,e){var n=this.texData.get(t.dataId);if(n.isPacked&&!Be(t.shape,e)&&(null===n.texture||!Be(n.shape,e))){var r=this.packedReshape(t,e);return Wt.makeTensorFromDataId(r.dataId,r.shape,r.dtype);}return Ui(t,e);},e.prototype.resizeBilinear=function(t,e,n,r){var i=f().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new function(t,e,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];var i=t[0],o=t[1],a=t[2],s=t[3];this.outputShape=[i,e,n,s];var u=[r&&e>1?o-1:o,r&&n>1?a-1:a],c=[r&&e>1?e-1:e,r&&n>1?n-1:n];this.userCode="\n      const vec3 effectiveInputOverOutputRatioRC = vec3(\n          "+u[0]/c[0]+",\n          "+u[1]/c[1]+",\n          "+u[1]/c[1]+");\n      const vec3 inputShapeRC = vec3("+o+".0, "+a+".0,\n                                     "+a+".0);\n\n      float getAValue(int b, int r, int c, int d) {\n        return getChannel(getA(b, r, c, d), vec2(c, d));\n      }\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        // Calculate values for next column in yRC.z.\n        ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n        // Fractional source index.\n        vec3 sourceFracIndexRC = vec3(yRC) * effectiveInputOverOutputRatioRC;\n\n        // Compute the four integer indices.\n        ivec3 sourceFloorRC = ivec3(sourceFracIndexRC);\n        ivec3 sourceCeilRC = ivec3(\n          min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n        // Should we calculate next column and row elements in 2x2 packed cell.\n        bool hasNextCol = d < "+(s-1)+";\n        bool hasNextRow = coords.z < "+(n-1)+";\n\n        // In parallel, construct four corners for all four components in\n        // packed 2x2 cell.\n        vec4 topLeft = vec4(\n          getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),\n          hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n        vec4 bottomLeft = vec4(\n          getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),\n          hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n        vec4 topRight = vec4(\n          getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),\n          hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n        vec4 bottomRight = vec4(\n          getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),\n          hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n        vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);\n\n        vec4 top = mix(topLeft, topRight, fracRC.yyzz);\n        vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);\n        vec4 newValue = mix(top, bottom, fracRC.x);\n\n        setOutput(newValue);\n      }\n    ";}(t.shape,e,n,r):new function(t,e,n,r){this.variableNames=["A"],this.outputShape=[];var i=t[0],o=t[1],a=t[2],s=t[3];this.outputShape=[i,e,n,s];var u=[r&&e>1?o-1:o,r&&n>1?a-1:a],c=[r&&e>1?e-1:e,r&&n>1?n-1:n];this.userCode="\n      const vec2 effectiveInputOverOutputRatioRC = vec2(\n          "+u[0]/c[0]+",\n          "+u[1]/c[1]+");\n      const vec2 inputShapeRC = vec2("+o+".0, "+a+".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    ";}(t.shape,e,n,r);return this.compileAndRun(i,[t],"float32");},e.prototype.resizeBilinearBackprop=function(t,e,n){var r=new function(t,e,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=e.shape;var r=e.shape,i=r[1],o=r[2],a=t.shape,s=a[1],u=a[2],c=[n&&s>1?i-1:i,n&&u>1?o-1:o],l=[n&&s>1?s-1:s,n&&u>1?u-1:u],f=c[0]/l[0],h=c[1]/l[1],d=1/f,p=1/h,m=2*Math.ceil(d)+2,g=2*Math.ceil(p)+2;this.userCode="\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        int r = coords[1];\n        int c = coords[2];\n\n        float accumulator = 0.0;\n\n        const float heightScale = float("+f+");\n        const float widthScale = float("+h+");\n\n        const float invHeightScale = float("+d+");\n        const float invWidthScale = float("+p+");\n\n        const int winHeight = int("+m+");\n        const int winWidth = int("+g+");\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), "+(i-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), "+(o-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    ";}(t,e,n);return this.compileAndRun(r,[t]);},e.prototype.resizeNearestNeighbor=function(t,e,n,r){var i=new function(t,e,n,r){this.variableNames=["A"],this.outputShape=[];var i=t[0],o=t[1],a=t[2],s=t[3];this.outputShape=[i,e,n,s];var u=[r&&e>1?o-1:o,r&&n>1?a-1:a],c=[r&&e>1?e-1:e,r&&n>1?n-1:n],l=r?"0.5":"0.0";this.userCode="\n      const vec2 effectiveInputOverOutputRatioRC = vec2(\n          "+u[0]/c[0]+",\n          "+u[1]/c[1]+");\n      const vec2 inputShapeRC = vec2("+o+".0, "+a+".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    ";}(t.shape,e,n,r);return this.compileAndRun(i,[t]);},e.prototype.resizeNearestNeighborBackprop=function(t,e,n){var r=new function(t,e,n){this.variableNames=["dy"],this.outputShape=[],this.outputShape=e.shape;var r=e.shape,i=r[1],o=r[2],a=t.shape,s=a[1],u=a[2],c=[n&&s>1?i-1:i,n&&u>1?o-1:o],l=[n&&s>1?s-1:s,n&&u>1?u-1:u],f=c[0]/l[0],h=c[1]/l[1],d=1/f,p=1/h,m=2*Math.ceil(d)+2,g=2*Math.ceil(p)+2;this.userCode="\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        int r = coords[1];\n        int c = coords[2];\n\n        float accumulator = 0.0;\n\n        const float heightScale = float("+f+");\n        const float widthScale = float("+h+");\n\n        const float invHeightScale = float("+d+");\n        const float invWidthScale = float("+p+");\n\n        const int winHeight = int("+m+");\n        const int winWidth = int("+g+");\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("+i+") - 1),\n                "+n+" ? float(round(sourceFracRow)) :\n                                  float(floor(sourceFracRow))));\n\n            int sourceNearestCol = int(min(\n                float(int("+o+") - 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    ";}(t,e,n);return this.compileAndRun(r,[t]);},e.prototype.multinomial=function(t,e,n,r){var i=e?t:xi(t),o=i.shape[0],a=i.shape[1],s=new ua(o,a,n),u=s.getCustomSetupFunc(r);return this.compileAndRun(s,[i],"int32",u);},e.prototype.oneHot=function(t,e,n,r){var i=new function(t,e,n,r){this.variableNames=["indices"],this.outputShape=[t,e],this.userCode="\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int index = round(getIndices(coords.x));\n        setOutput(mix(float("+r+"), float("+n+"),\n                      float(index == coords.y)));\n      }\n    ";}(t.size,e,n,r);return this.compileAndRun(i,[t]);},e.prototype.diag=function(t){var e=new function(t){this.variableNames=["X"],this.outputShape=[t,t],this.userCode="\n      void main() {\n          ivec2 coords = getOutputCoords();\n          float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;\n          setOutput(val);\n      }\n    ";}(t.size);return this.compileAndRun(e,[t]);},e.prototype.nonMaxSuppression=function(t,e,n,r,i){return vn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"),Yi(t.dataSync(),e.dataSync(),n,r,i);},e.prototype.cropAndResize=function(t,e,n,r,i,o){var a=new function(t,e,n,r,i){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];var o=t[0],a=t[1],s=t[2],u=t[3],c=e[0],l=n[0],f=n[1];this.outputShape=[c,l,f,u];var h="bilinear"===r?1:0,d=[a-1+".0",s-1+".0"],p=d[0],m=d[1],g=l>1?[""+(a-1)/(l-1),"(y2-y1) * height_ratio","y1*"+p+" + float(y)*(height_scale)"]:["0.0","0.0","0.5 * (y1+y2) * "+p],v=g[0],y=g[1],b=g[2],x=f>1?[""+(s-1)/(f-1),"(x2-x1) * width_ratio","x1*"+m+" + float(x)*(width_scale)"]:["0.0","0.0","0.5 * (x1+x2) * "+m],w=x[0],k=x[1],E=x[2];this.userCode="\n      const float height_ratio = float("+v+");\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 >= "+o+") {\n          return;\n        }\n\n        float height_scale = "+y+";\n        float width_scale = "+k+";\n\n        float in_y = "+b+";\n        if( in_y < 0.0 || in_y > "+p+" ) {\n          setOutput(float("+i+"));\n          return;\n        }\n        float in_x = "+E+";\n        if( in_x < 0.0 || in_x > "+m+" ) {\n          setOutput(float("+i+"));\n          return;\n        }\n\n        vec2 sourceFracIndexCR = vec2(in_x,in_y);\n        if("+h+" == 1) {\n          // Compute the four integer indices.\n          ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);\n          ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));\n\n          float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);\n          float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);\n          float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);\n          float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);\n\n          vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n\n          float top = topLeft + (topRight - topLeft) * fracCR.x;\n          float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n          float newValue = top + (bottom - top) * fracCR.y;\n          setOutput(newValue);\n        } else {\n          // Compute the coordinators of nearest neighbor point.\n          ivec2 sourceNearestCR = ivec2(floor(\n            sourceFracIndexCR + vec2(0.5,0.5)));\n          float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);\n          setOutput(newValue);\n        }\n      }\n    ";}(t.shape,e.shape,r,i,o);return this.compileAndRun(a,[t,e,n],"float32");},e.prototype.depthToSpace=function(t,e,n){_(e>1,function(){return "blockSize should be > 1 for depthToSpace, but was: "+e;});var r=t.shape[0],i="NHWC"===n?t.shape[1]:t.shape[2],o="NHWC"===n?t.shape[2]:t.shape[3],a="NHWC"===n?t.shape[3]:t.shape[1],s=i*e,u=o*e,c=a/(e*e),l=new Po("NHWC"===n?[r,s,u,c]:[r,c,s,u],e,n);return this.compileAndRun(l,[t]);},e.prototype.split=function(t,e,n){return no(t,e,n);},e.prototype.scatterND=function(t,e,n){var r=ri(0,t,n),i=r.sliceRank,o=r.numUpdates,a=r.sliceSize,s=r.strides,u=r.outputSize,c=[u/a,a],l=t.reshape([o,i]),f=e.reshape([o,a]);if(0===u)return Ui(jn([]),n);var h=Pn(0),d=new fa(o,i,l.rank,f.rank,s,c);return this.compileAndRun(d,[f,l,h]).reshape(n);},e.prototype.sparseToDense=function(t,e,n,r){var i=ri(0,t,n),o=i.sliceRank,a=i.numUpdates,s=i.strides,u=i.outputSize,c=new fa(a,o,t.rank,e.rank,s,[u,1],!1);return this.compileAndRun(c,[e,t,r]).reshape(n);},e.prototype.fft=function(t){return this.fftImpl(t,!1);},e.prototype.ifft=function(t){return this.fftImpl(t,!0);},e.prototype.fftImpl=function(t,e){var n=this.texData.get(t.dataId),r=new Lo("return real * expR - imag * expI;",t.shape,e),i=new Lo("return real * expI + imag * expR;",t.shape,e),o=[this.makeComplexComponentTensorInfo(t,n.complexTensors.real),this.makeComplexComponentTensorInfo(t,n.complexTensors.imag)],a=this.compileAndRun(r,o),s=this.compileAndRun(i,o),u=this.complex(a,s).as2D(t.shape[0],t.shape[1]);return a.dispose(),s.dispose(),u;},e.prototype.gatherND=function(t,e){var n=e.shape,r=n[n.length-1],i=Jr(t,e),o=i[0],a=i[1],s=i[2],u=i[3],c=e.reshape([a,r]),l=t.reshape([t.size/s,s]),f=new function(t,e,n){this.sliceDim=t,this.strides=e,this.variableNames=["x","indices"],this.outputShape=n;var r=xo(e.length),i=xo(n.length),o=this.sliceDim>1?"strides[j]":"strides";this.userCode="\n        "+r+" strides = "+r+"("+this.strides+");\n         void main() {\n          "+i+" coords = getOutputCoords();\n          int flattenIndex = 0;\n          for (int j = 0; j < "+this.sliceDim+"; j++) {\n            int index = round(getIndices(coords[0], j));\n            flattenIndex += index * "+o+";\n          }\n          setOutput(getX(flattenIndex, coords[1]));\n        }\n      ";}(r,u,[a,s]);return this.compileAndRun(f,[l,c]).reshape(o);},e.prototype.fill=function(t,e,n){if("string"===(n=n||Q(e))){var r=W(n,T(t));return r.fill(e),Wt.makeTensor(r,t,n,this);}var i=new zo(t,e),o=i.getCustomSetupFunc(e);return this.compileAndRun(i,[],n,o);},e.prototype.onesLike=function(t){if("string"===t.dtype)throw new Error("onesLike is not supported under string dtype");return this.fill(t.shape,1,t.dtype);},e.prototype.zerosLike=function(t){return this.fill(t.shape,"string"===t.dtype?"":0,t.dtype);},e.prototype.linspace=function(t,e,n){return Wi(t,e,n);},e.prototype.makeTensorInfo=function(t,e){var n=this.write(null,t,e);return this.texData.get(n).usage=null,{dataId:n,shape:t,dtype:e};},e.prototype.makeOutput=function(t,e){var n=this.makeTensorInfo(t,e).dataId;return Wt.makeTensorFromDataId(n,t,e,this);},e.prototype.unpackTensor=function(t){var e=new function(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=t;var e=t.length,n=so("rc",e),r=xo(e),i=function(t,e){if(1===t)return "rc";for(var n="",r=0;r<t;r++){n+=e[r],r<t-1&&(n+=",");}return n;}(e,n),o=n.slice(-2),a=e<=1?"rc":"vec2("+o.join(",")+")";this.userCode="\n      void main() {\n        "+r+" rc = getOutputCoords();\n        vec4 packedInput = getA("+i+");\n\n        setOutput(getChannel(packedInput, "+a+"));\n      }\n    ";}(t.shape);return this.runWebGLProgram(e,[t],t.dtype);},e.prototype.packTensor=function(t){var e=new function(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=t;var e=t.length;if(0===e)this.userCode="\n        void main() {\n          setOutput(vec4(getA(), 0., 0., 0.));\n        }\n      ";else {var n=so("rc",e),r=xo(e),i=function(t,e,n){if(1===t)return "rc > "+e[0];for(var r="",i=t-2;i<t;i++){r+=n[i]+" >= "+e[i],i<t-1&&(r+="||");}return r;}(e,t,n),o=function(t,e,n,r){if(1===t)return "";var i=r.slice(-2);return "\n    int r = "+i[0]+";\n    int c = "+i[1]+";\n    int rp1 = r + 1;\n    int cp1 = c + 1;\n\n    bool cEdge = cp1 >= "+e+";\n    bool rEdge = rp1 >= "+n+";\n  ";}(e,t[t.length-1],t[t.length-2],n),a=function(t,e){var n=t.length,r=function(t,e){for(var n=[],r=0;r<=1;r++){for(var i=0;i<=1;i++){for(var o=(0===r?"r":"rp1")+", "+(0===i?"c":"cp1"),a=2;a<t;a++){o=e[e.length-1-a]+","+o;}n.push(o);}}return n;}(n,e);return 1===n?"getA(rc),\n            rc + 1 >= "+t[0]+" ? 0. : getA(rc + 1),\n            0, 0":"getA("+r[0]+"),\n          cEdge ? 0. : getA("+r[1]+"),\n          rEdge ? 0. : getA("+r[2]+"),\n          rEdge || cEdge ? 0. : getA("+r[3]+")";}(t,n);this.userCode="\n        void main() {\n          "+r+" rc = getOutputCoords();\n\n          if("+i+") {\n            setOutput(vec4(0));\n          } else {\n            "+o+"\n\n            setOutput(vec4("+a+"));\n          }\n        }\n      ";}}(t.shape);return this.runWebGLProgram(e,[t],t.dtype,null,!0);},e.prototype.packedReshape=function(t,e){var n=[Ne(t.shape)].concat(Ie(t.shape)),r={dtype:t.dtype,shape:n,dataId:t.dataId},i=new function(t,e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=t;for(var n="",r=0;r<4;r++){var i="thisRC = rc;";r%2==1&&(i+="thisRC.z += 1;"),r>1&&(i+="thisRC.y += 1;"),n+="\n        "+i+"\n        "+(r>0?"if(thisRC.y < rows && thisRC.z < cols){":"")+"\n          int flatIndex = getFlatIndex(thisRC);\n\n          ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);\n          vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n          result["+r+"] =\n            getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n        "+(r>0?"}":"")+"\n      ";}this.userCode="\n      \n    ivec3 inputCoordsFromReshapedOutCoords(int index) {\n      "+co(["r","c","d"],e)+"\n      return ivec3(r, c, d);\n    }\n  \n      "+lo(t)+"\n\n      void main() {\n        ivec3 rc = getOutputCoords();\n\n        vec4 result = vec4(0.);\n\n        ivec3 thisRC;\n        int rows = "+t[1]+";\n        int cols = "+t[2]+";\n\n        "+n+"\n\n        setOutput(result);\n      }\n    ";}([Ne(e)].concat(Ie(e)),n),o=this.runWebGLProgram(i,[r],t.dtype,null,!0);return {dataId:o.dataId,shape:e,dtype:o.dtype};},e.prototype.decode=function(t){var e,n=this.texData.get(t),r=n.isPacked,i=n.shape,o=n.dtype,a=Re(i);return e=r?new function(t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=$t.DENSE;var e=Zt(t),n=uo();this.outputShape=t,this.userCode="\n      ivec3 outCoordsFromFlatIndex(int index) {\n        "+co(["r","c","d"],t)+"\n        return ivec3(r, c, d);\n      }\n\n      void main() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n          vec2("+e[0]+", "+e[1]+"));\n        int index = 4 * (resTexRC.x * "+e[1]+" + resTexRC.y);\n\n        vec4 result = vec4(0.);\n\n        for (int i=0; i<4; i++) {\n          int flatIndex = index + i;\n          ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n          result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));\n        }\n\n        "+n.output+" = result;\n      }\n    ";}(a):new function(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=$t.DENSE;var e=Zt(t),n=uo();this.outputShape=t,this.userCode="\n      ivec3 outCoordsFromFlatIndex(int index) {\n        "+co(["r","c","d"],t)+"\n        return ivec3(r, c, d);\n      }\n\n      void main() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n          vec2("+e[0]+", "+e[1]+"));\n        int index = 4 * (resTexRC.x * "+e[1]+" + resTexRC.y);\n\n        vec4 result = vec4(0.);\n\n        for (int i=0; i<4; i++) {\n          int flatIndex = index + i;\n          ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n          result[i] = getA(rc.x, rc.y, rc.z);\n        }\n\n        "+n.output+" = result;\n      }\n    ";}(a),{dtype:o,shape:i,dataId:this.runWebGLProgram(e,[{shape:a,dtype:o,dataId:t}],o,null,!0).dataId};},e.prototype.runWebGLProgram=function(t,e,n,r,i){var o=this;void 0===i&&(i=!1);var a=this.makeTensorInfo(t.outputShape,n),s=this.texData.get(a.dataId);if(t.packedOutput&&(s.isPacked=!0),t.outPackingScheme===$t.DENSE){var u=Zt(t.outputShape);s.texShape=u.map(function(t){return 2*t;});}if(null!=t.outTexUsage&&(s.usage=t.outTexUsage),0===T(a.shape))return s.values=U(a.dtype,0),a;var c=[],l=e.map(function(e){if("complex64"===e.dtype)throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");var n=o.texData.get(e.dataId);if(null==n.texture){if(!t.packedInputs&&T(e.shape)<=f().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return {shape:e.shape,texData:null,isUniform:!0,uniformValues:n.values};t.packedInputs&&(n.isPacked=!0,n.shape=e.shape);}else if(!!n.isPacked!=!!t.packedInputs)e=n.isPacked?o.unpackTensor(e):o.packTensor(e),c.push(e),n=o.texData.get(e.dataId);else if(n.isPacked&&!Be(n.shape,e.shape)){var r=e,i=e.shape;e.shape=n.shape,e=o.packedReshape(e,i),c.push(e),n=o.texData.get(e.dataId),r.shape=i;}return o.uploadToGPU(e.dataId),{shape:e.shape,texData:n,isUniform:!1};});this.uploadToGPU(a.dataId);var h,d={shape:a.shape,texData:s,isUniform:!1},p=function(t,e,n){var r="";l.concat(n).forEach(function(t){var e=null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0,n=t.isUniform?"uniform":t.texData.texShape;r+=t.shape+"_"+n+"_"+e;});var i=t.userCode;return t.constructor.name+"_"+r+"_"+i;}(t,0,d),m=this.getAndSaveBinary(p,function(){return function(t,e,n,r){var i=e.userCode,o=n.map(function(t,n){var r={logicalShape:t.shape,texShape:t.isUniform?null:t.texData.texShape,isUniform:t.isUniform,isPacked:!t.isUniform&&t.texData.isPacked,flatOffset:null};return null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0&&(r.flatOffset=t.texData.slice.flatOffset),{name:e.variableNames[n],shapeInfo:r};}),a=o.map(function(t){return t.shapeInfo;}),s={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},u=ho(o,s,i,e.packedInputs),c=t.createProgram(u),l=null,h=t.getUniformLocation(c,"NAN",!1);1===f().getNumber("WEBGL_VERSION")&&(l=t.getUniformLocation(c,"INFINITY",!1));for(var d={},p=0;p<e.variableNames.length;p++){var m=e.variableNames[p];d[m]=t.getUniformLocation(c,m,!1),d["offset"+m]=t.getUniformLocation(c,"offset"+m,!1);}return {program:e,source:u,webGLProgram:c,uniformLocations:d,inShapeInfos:a,outShapeInfo:s,infLoc:l,nanLoc:h};}(o.gpgpu,t,l,d);}),g=null!=this.activeTimers;if(g&&(h=this.startTimer()),function(t,e,n,r,i){aa(e.inShapeInfos,n),aa([e.outShapeInfo],[r]);var o=r.texData.texture,a=r.texData.texShape;r.texData.isPacked?t.setOutputPackedMatrixTexture(o,a[0],a[1]):t.setOutputMatrixTexture(o,a[0],a[1]),t.setProgram(e.webGLProgram),1===f().getNumber("WEBGL_VERSION")&&null!==e.infLoc&&t.gl.uniform1f(e.infLoc,1/0),null!==e.nanLoc&&t.gl.uniform1f(e.nanLoc,NaN),n.forEach(function(n,r){var i=e.program.variableNames[r],o=e.uniformLocations[i],a=e.uniformLocations["offset"+i];if(null!=o)if(n.isUniform){if(T(n.shape)<2)t.gl.uniform1f(o,n.uniformValues[0]);else {var s=n.uniformValues;s instanceof Float32Array||(s=new Float32Array(s)),t.gl.uniform1fv(o,s);}}else null!=n.texData.slice&&null!=a&&t.gl.uniform1i(a,n.texData.slice.flatOffset),t.setInputMatrixTexture(n.texData.texture,o,r);}),null!=i&&i(t,e.webGLProgram),t.executeProgram();}(this.gpgpu,m,l,d,r),c.forEach(function(t){return o.disposeData(t.dataId);}),g&&(h=this.endTimer(h),this.activeTimers.push({name:t.constructor.name,query:this.getQueryTime(h)})),!f().getBool("WEBGL_LAZILY_UNPACK")&&s.isPacked&&!1===i){var v=this.unpackTensor(a);return this.disposeData(a.dataId),v;}return a;},e.prototype.compileAndRun=function(t,e,n,r,i){void 0===i&&(i=!1),n=n||e[0].dtype;var o=this.runWebGLProgram(t,e,n,r,i);return Wt.makeTensorFromDataId(o.dataId,o.shape,o.dtype);},e.prototype.getAndSaveBinary=function(t,e){return t in this.binaryCache||(this.binaryCache[t]=e()),this.binaryCache[t];},e.prototype.getTextureManager=function(){return this.textureManager;},e.prototype.dispose=function(){var t=this;this.disposed||(f().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach(function(e){t.gpgpu.deleteProgram(t.binaryCache[e].webGLProgram),delete t.binaryCache[e];}),this.textureManager.dispose(),null!=this.canvas&&"undefined"!=typeof HTMLCanvasElement&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0);},e.prototype.floatPrecision=function(){var t=this;return null==this.floatPrecisionValue&&(this.floatPrecisionValue=rn(function(){if(!f().get("WEBGL_RENDER_FLOAT32_ENABLED")){var e=f().getBool("DEBUG");f().set("DEBUG",!1);var n=t.abs(Pn(1e-8)).dataSync()[0];if(f().set("DEBUG",e),n>0)return 32;}return 16;})),this.floatPrecisionValue;},e.prototype.epsilon=function(){return 32===this.floatPrecision()?1e-7:1e-4;},e.prototype.uploadToGPU=function(t){var e,n=this.texData.get(t),r=n.shape,i=n.dtype,o=n.values,a=n.texture,s=n.usage,u=n.isPacked;if(null==a){var c,l=null!=this.activeTimers;l&&(c=at());var f=n.texShape;if(null==f&&(f=Me(r,u),n.texShape=f),null!=o){var h=Re(r),d=void 0,p=f[1],m=f[0],g=o instanceof Uint8Array;u?(p=(e=te(f[0],f[1]))[0],d=new function(t,e,n){void 0===n&&(n=!1),this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var r=uo(),i=e[0],o=e[1];this.outputShape=t;var a="",s="result";n&&(s="floor(result * 255. + 0.5)");for(var u=0;u<=1;u++){for(var c=0;c<=1;c++){var l=2*u+c;a+="\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 / "+o+";\n              c = imod(flatIndex, "+o+");\n              uv = (vec2(c, r) + halfCR) / vec2("+o+".0, "+i+".0);\n              values = "+r.texture2D+"(A, uv);\n\n              if(offset == 0) {\n                result["+l+"] = values[0];\n              } else if(offset == 1) {\n                result["+l+"] = values[1];\n              } else if(offset == 2) {\n                result["+l+"] = values[2];\n              } else {\n                result["+l+"] = values[3];\n              }\n            }\n          }\n        ";}}this.userCode="\n      "+lo(t)+"\n\n      void main() {\n        ivec3 coords = getOutputCoords();\n\n        vec4 result = vec4(0.);\n        int flatIndex, r, c, offset;\n        ivec3 localCoords;\n        vec2 uv;\n        vec4 values;\n\n        "+a+"\n\n        "+r.output+" = "+s+";\n      }\n    ";}(h,[m=e[1],p],g)):d=new function(t,e,n){void 0===n&&(n=!1),this.variableNames=["A"];var r=uo(),i=e[0],o=e[1];this.outputShape=t;var a="result";n&&(a="floor(result * 255. + 0.5)"),this.userCode="\n      "+lo(t)+"\n\n      void main() {\n        ivec3 coords = getOutputCoords();\n\n        int flatIndex = getFlatIndex(coords);\n        int offset = imod(flatIndex, 4);\n\n        flatIndex = idiv(flatIndex, 4, 1.);\n        \n        int r = flatIndex / "+o+";\n        int c = imod(flatIndex, "+o+");\n        vec2 uv = (vec2(c, r) + halfCR) / vec2("+o+".0, "+i+".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("+a+", 0., 0., 0.);\n      }\n    ";}(h,[m,p],g);var v=this.makeTensorInfo([m,p],i);this.texData.get(v.dataId).usage=g?Ht.PIXELS:Ht.UPLOAD,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(v.dataId),p,m,o);var y=this.runWebGLProgram(d,[v],i,null,!0),b=this.texData.get(y.dataId);n.texture=b.texture,n.texShape=b.texShape,n.isPacked=b.isPacked,n.usage=b.usage,this.disposeData(v.dataId),this.texData.delete(y.dataId),n.values=null,l&&(this.uploadWaitMs+=at()-c);}else {var x=this.acquireTexture(f,s,i,u);n.texture=x;}}},e.prototype.convertAndCacheOnCPU=function(t,e){var n=this.texData.get(t),r=n.dtype;return this.releaseGPUData(t),null!=e&&(n.values=function(t,e){if("float32"===e||"complex64"===e)return t;if("int32"===e||"bool"===e){for(var n="int32"===e?new Int32Array(t.length):new Uint8Array(t.length),r=0;r<n.length;++r){n[r]=Math.round(t[r]);}return n;}throw new Error("Unknown dtype "+e);}(e,r)),n.values;},e.prototype.acquireTexture=function(t,e,n,r){if(this.numBytesInGPU+=this.computeBytes(t,n),!this.warnedAboutMemory&&this.numBytesInGPU>1024*this.numMBBeforeWarning*1024){var i=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn("High memory usage in GPU: "+i+" MB, most likely due to a memory leak");}return this.textureManager.acquireTexture(t,e,r);},e.prototype.computeBytes=function(t,e){return t[0]*t[1]*G(e);},e;}(Ei);Vt()&&Wt.registerBackend("webgl",function(){return new Ua();},2);var Wa=Nn({square_:function square_(t){var e=xn(t,"x","square"),n=[e];return Wt.runKernelFunc(function(t,n){return n([e]),t.square(e);},{x:e},null,"Square",{},n,[]);}}),Va="SquaredDifference",qa=Nn({squaredDifference_:function squaredDifference_(t,e){var n,r=xn(t,"a","squaredDifference"),i=xn(e,"b","squaredDifference");n=Mt(r,i),r=n[0],i=n[1],_i(r.shape,i.shape);var o={a:r,b:i},a=[r,i];return Wt.runKernelFunc(function(t,e){var n=t.squaredDifference(r,i);return e([r,i]),n;},o,function(t,e){var n=e[0],r=e[1],i=Pn(2);return {a:function a(){return t.mul(n.sub(r).mul(i));},b:function b(){return t.mul(r.sub(n).mul(i));}};},Va,{},a,[]);}}),$a=Nn({abs_:function abs_(t){var e=xn(t,"x","abs");return "complex64"===e.dtype?Wt.runKernelFunc(function(t){return t.complexAbs(e);},{$x:e}):Wt.runKernelFunc(function(t,n){var r=t.abs(e);return n([e]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return t.mul(n.toFloat().step(-1));}};},"Abs");}}),Ha=Nn({acos_:function acos_(t){var e=xn(t,"x","acos");return Wt.runKernelFunc(function(t,n){var r=t.acos(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.divStrict(Pn(1).sub(n.toFloat().square()).sqrt()).neg();}};});}}),Ga=Nn({acosh_:function acosh_(t){var e=xn(t,"x","acosh");return Wt.runKernelFunc(function(t,n){var r=t.acosh(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.divStrict(n.toFloat().square().sub(1).sqrt());}};});}}),Ka=Nn({asin_:function asin_(t){var e=xn(t,"x","asin");return Wt.runKernelFunc(function(t,n){var r=t.asin(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.divStrict(Pn(1).sub(n.toFloat().square()).sqrt());}};});}}),Xa=Nn({asinh_:function asinh_(t){var e=xn(t,"x","asinh");return Wt.runKernelFunc(function(t,n){var r=t.asinh(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.divStrict(Pn(1).add(n.toFloat().square()).sqrt());}};});}}),Ya=Nn({atan_:function atan_(t){var e=xn(t,"x","atan");return Wt.runKernelFunc(function(t,n){var r=t.atan(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(n.toFloat().square().add(1));}};});}}),Ja=Nn({atanh_:function atanh_(t){var e=xn(t,"x","atanh");return Wt.runKernelFunc(function(t,n){var r=t.atanh(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(Pn(1).sub(n.toFloat().square()));}};});}}),Qa=Nn({ceil_:function ceil_(t){var e=xn(t,"x","ceil");return Wt.runKernelFunc(function(t){return t.ceil(e);},{$x:e},function(t){return {$x:function $x(){return Qn(t);}};});}}),Za=Nn({clipByValue_:function clipByValue_(t,e,n){var r=xn(t,"x","clipByValue");_(e<=n,function(){return "Error in clip: min ("+e+") must be less than or equal to max ("+n+").";});var i=[r],o={min:e,max:n};return Wt.runKernelFunc(function(t,i){var o=t.clip(r,e,n);return i([r]),o;},{x:r},function(t,r){var i=r[0];return {x:function x(){return t.where(i.greaterEqual(e).logicalAnd(i.lessEqual(n)),Qn(t));}};},"ClipByValue",o,i);}}),ts=Nn({cos_:function cos_(t){var e=xn(t,"x","cos"),n=[e];return Wt.runKernelFunc(function(t,n){var r=t.cos(e);return n([e]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return n.toFloat().sin().neg().mul(t);}};},"Cos",{},n);}}),es=Nn({cosh_:function cosh_(t){var e=xn(t,"x","cosh");return Wt.runKernelFunc(function(t,n){var r=t.cosh(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return n.toFloat().sinh().mulStrict(t);}};});}}),ns=Nn({erf_:function erf_(t){var e=xn(t,"x","erf");return _("int32"===e.dtype||"float32"===e.dtype,function(){return "Input dtype must be `int32` or `float32`.";}),"int32"===e.dtype&&(e=e.toFloat()),Wt.runKernelFunc(function(t,n){var r=t.erf(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.mul(n.square().neg().exp().mul(2/Math.sqrt(Math.PI)));}};});}}),rs=Nn({exp_:function exp_(t){var e=xn(t,"x","exp");return Wt.runKernelFunc(function(t,n){var r=t.exp(e);return n([r]),r;},{x:e},function(t,e){return {x:function x(){return t.mulStrict(e[0]);}};},"Exp",{},[],[!0]);}}),is=Nn({expm1_:function expm1_(t){var e=xn(t,"x","expm1");return Wt.runKernelFunc(function(t,n){var r=t.expm1(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.mul(n.exp());}};});}}),os=Nn({floor_:function floor_(t){var e=xn(t,"x","floor");return Wt.runKernelFunc(function(t){return t.floor(e);},{$x:e},function(t){return {$x:function $x(){return Qn(t);}};});}}),as=Nn({log_:function log_(t){var e=xn(t,"x","log"),n=[e];return Wt.runKernelFunc(function(t,n){var r=t.log(e);return n([e]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return t.div(n.toFloat());}};},"Log",{},n);}}),ss=Nn({log1p_:function log1p_(t){var e=xn(t,"x","log1p");return Wt.runKernelFunc(function(t,n){var r=t.log1p(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(n.add(1));}};});}}),us=Nn({logSigmoid_:function logSigmoid_(t){var e=xn(t,"x","logSigmoid");return Wt.runKernelFunc(function(t,n){var r=t.softplus(e.neg()).neg();return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.mul(n.neg().sigmoid());}};});}}),cs=Nn({neg_:function neg_(t){var e=xn(t,"x","neg"),n=[e];return Wt.runKernelFunc(function(t){return t.neg(e);},{x:e},function(t){return {x:function x(){return t.neg();}};},"Neg",{},n);}}),ls=Nn({reciprocal_:function reciprocal_(t){var e=xn(t,"x","reciprocal");return Wt.runKernelFunc(function(t,n){var r=t.reciprocal(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(n.square().neg());}};});}}),fs=Nn({round_:function round_(t){var e=xn(t,"x","round");return Wt.runKernelFunc(function(t){return t.round(e);},{$x:e},function(t){return {$x:function $x(){return Qn(t);}};});}}),hs=Nn({rsqrt_:function rsqrt_(t){var e=xn(t,"x","rsqrt"),n=[e];return Wt.runKernelFunc(function(t,n){var r=t.rsqrt(e);return n([e]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return t.div(n.pow(1.5).mul(2)).neg();}};},"Rsqrt",{},n);}}),ds=Nn({sigmoid_:function sigmoid_(t){var e=xn(t,"x","sigmoid");return Wt.runKernelFunc(function(t,n){var r=t.sigmoid(e);return n([r]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return t.mul(n.mul(Pn(1).sub(n)));}};},"Sigmoid");}}),ps=Nn({sign_:function sign_(t){var e=xn(t,"x","sign");return Wt.runKernelFunc(function(t){return t.sign(e);},{$x:e},function(t){return {$x:function $x(){return Qn(t);}};});}}),ms=Nn({isNaN_:function isNaN_(t){var e=xn(t,"x","isNaN");return Wt.runKernelFunc(function(t){return t.isNaN(e);},{$x:e},function(t){return {$x:function $x(){return Qn(t);}};});}}),gs=Nn({isInf_:function isInf_(t){var e=xn(t,"x","isInf");return Wt.runKernelFunc(function(t){return t.isInf(e);},{$x:e},function(t){return {$x:function $x(){return Qn(t);}};});}}),vs=Nn({isFinite_:function isFinite_(t){var e=xn(t,"x","isFinite");return Wt.runKernelFunc(function(t){return t.isFinite(e);},{$x:e},function(t){return {$x:function $x(){return Qn(t);}};});}}),ys=Nn({sin_:function sin_(t){var e=xn(t,"x","sin"),n=[e];return Wt.runKernelFunc(function(t,n){var r=t.sin(e);return n([e]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return n.toFloat().cos().mul(t);}};},"Sin",{},n);}}),bs=Nn({sinh_:function sinh_(t){var e=xn(t,"x","sinh");return Wt.runKernelFunc(function(t,n){var r=t.sinh(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return n.toFloat().cosh().mulStrict(t);}};});}}),xs=Nn({softplus_:function softplus_(t){var e=xn(t,"x","softplus");return Wt.runKernelFunc(function(t,n){var r=t.softplus(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.mul(n.sigmoid());}};});}}),ws=Nn({sqrt_:function sqrt_(t){var e=xn(t,"x","sqrt");return Wt.runKernelFunc(function(t,n){var r=t.sqrt(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(n.toFloat().sqrt().mul(2));}};});}}),ks=Nn({step_:function step_(t,e){void 0===e&&(e=0);var n=xn(t,"x","step");return Wt.runKernelFunc(function(t){return t.step(n,e);},{$x:n},function(t){return {$x:function $x(){return Qn(t);}};});}}),Es=Nn({tan_:function tan_(t){var e=xn(t,"x","tan");return Wt.runKernelFunc(function(t,n){var r=t.tan(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(n.cos().square());}};});}}),Cs=Nn({tanh_:function tanh_(t){var e=xn(t,"x","tanh");return Wt.runKernelFunc(function(t,n){var r=t.tanh(e);return n([r]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return Pn(1).sub(n.square()).mulStrict(t);}};},"Tanh",{},null,[!0]);}});function As(t,e,n,r,i,o){var a,s,u=xn(t,"x","batchNorm"),c=xn(e,"mean","batchNorm"),l=xn(n,"variance","batchNorm");return null!=i&&(a=xn(i,"scale","batchNorm")),null!=r&&(s=xn(r,"offset","batchNorm")),_(2===u.rank,function(){return "Error in batchNorm3D: x must be rank 3 but got rank "+u.rank+".";}),_(2===c.rank||1===c.rank,function(){return "Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank "+c.rank+".";}),_(2===l.rank||1===l.rank,function(){return "Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank "+l.rank+".";}),null!=a&&_(2===a.rank||1===a.rank,function(){return "Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank "+a.rank+".";}),null!=s&&_(2===s.rank||1===s.rank,function(){return "Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank "+s.rank+".";}),Ss(u,c,l,s,a,o);}function Os(t,e,n,r,i,o){var a,s,u=xn(t,"x","batchNorm"),c=xn(e,"mean","batchNorm"),l=xn(n,"variance","batchNorm");return null!=i&&(a=xn(i,"scale","batchNorm")),null!=r&&(s=xn(r,"offset","batchNorm")),_(3===u.rank,function(){return "Error in batchNorm3D: x must be rank 3 but got rank "+u.rank+".";}),_(3===c.rank||1===c.rank,function(){return "Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank "+c.rank+".";}),_(3===l.rank||1===l.rank,function(){return "Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank "+l.rank+".";}),null!=a&&_(3===a.rank||1===a.rank,function(){return "Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank "+a.rank+".";}),null!=s&&_(3===s.rank||1===s.rank,function(){return "Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank "+s.rank+".";}),Ss(u,c,l,s,a,o);}function _s(t,e,n,r,i,o){var a,s,u=xn(t,"x","batchNorm"),c=xn(e,"mean","batchNorm"),l=xn(n,"variance","batchNorm");return null!=i&&(a=xn(i,"scale","batchNorm")),null!=r&&(s=xn(r,"offset","batchNorm")),_(4===u.rank,function(){return "Error in batchNorm4D: x must be rank 4 but got rank "+u.rank+".";}),_(4===c.rank||1===c.rank,function(){return "Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank "+c.rank+".";}),_(4===l.rank||1===l.rank,function(){return "Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank "+l.rank+".";}),null!=a&&_(4===a.rank||1===a.rank,function(){return "Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank "+a.rank+".";}),null!=s&&_(4===s.rank||1===s.rank,function(){return "Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank "+s.rank+".";}),Ss(u,c,l,s,a,o);}function Ss(t,e,n,r,i,o){null==o&&(o=.001);var a,s,u,c=xn(t,"x","batchNorm"),l=xn(e,"mean","batchNorm"),f=xn(n,"variance","batchNorm");null!=i&&(a=xn(i,"scale","batchNorm")),null!=r&&(s=xn(r,"offset","batchNorm")),_(l.rank===f.rank,function(){return "Batch normalization gradient requires mean and variance to have equal ranks.";}),_(null==s||l.rank===s.rank,function(){return "Batch normalization gradient requires mean and offset to have equal ranks.";}),_(null==a||l.rank===a.rank,function(){return "Batch normalization gradient requires mean and scale to have equal ranks.";}),u=0===c.rank||1===c.rank?c.as4D(1,1,1,c.size):2===c.rank?c.as4D(1,1,c.shape[0],c.shape[1]):3===c.rank?c.as4D(1,c.shape[0],c.shape[1],c.shape[2]):c;var h=[c,l,f,a];return Wt.runKernelFunc(function(t,e){var n=t.batchNormalization(u,Ds(l),Ds(f),o,Ds(a),Ds(s));return e([c,l,f,a]),n;},{x:c,mean:l,variance:f,scale:a,offset:s},function(t,e){var n=e,r=n[0],i=n[1],a=n[2],s=n[3],c=null==s?Pn(1):s,l=Oi(i.shape,u.shape),f=[];if(1===i.rank){for(var h=0;h<u.shape.length-1;++h){f.push(u.shape[h]);}f.push(1);}var d=r.sub(i),p=t.mul(c),m=hs(a.add(Pn(o))),g=m.mul(m).mul(m).mul(Pn(-.5));return {x:function x(){return 1===i.rank?t.mul(Wr(m.as4D(1,1,1,i.shape[0]),f)).mul(c).reshape(r.shape):t.mul(m).mul(c).reshape(r.shape);},mean:function mean(){var t=m.mul(Pn(-1)).mul(p);return 1===i.rank&&(t=t.sum(l)),t.reshape(i.shape);},variance:function variance(){var t=g.mul(d).mul(p);return 1===i.rank&&(t=t.sum(l)),t.reshape(i.shape);},scale:function scale(){var e=d.mul(m),n=t.mul(e);return 1===i.rank&&(n=n.sum(l)),n.reshape(i.shape);},offset:function offset(){var e=t;return 1===i.rank&&(e=e.sum(l)),e.reshape(i.shape);}};},"BatchNormalization",{varianceEpsilon:o},h).reshape(c.shape);}function Ds(t){return null==t?null:0===t.rank?t.as1D():1===t.rank?t:2===t.rank?t.as4D(1,1,t.shape[0],t.shape[1]):3===t.rank?t.as4D(1,t.shape[0],t.shape[1],t.shape[2]):t;}function Fs(){Qe("tf.batchNormalization() is going away. Use tf.batchNorm() instead, and note the positional argument change of scale, offset, and varianceEpsilon");}var Ts=Nn({batchNormalization2d_:function batchNormalization2d_(t,e,n,r,i,o){return void 0===r&&(r=.001),Fs(),As(t,e,n,o,i,r);}}),Ns=Nn({batchNormalization3d_:function batchNormalization3d_(t,e,n,r,i,o){return void 0===r&&(r=.001),Fs(),Os(t,e,n,o,i,r);}}),Is=Nn({batchNormalization4d_:function batchNormalization4d_(t,e,n,r,i,o){return void 0===r&&(r=.001),Fs(),_s(t,e,n,o,i,r);}}),Rs=Nn({batchNormalization_:function batchNormalization_(t,e,n,r,i,o){return void 0===r&&(r=.001),Fs(),Ss(t,e,n,o,i,r);}}),Ms=Nn({batchNorm_:Ss}),js=Nn({batchNorm2d_:As}),Bs=Nn({batchNorm3d_:Os}),Ps=Nn({batchNorm4d_:_s}),Ls=Nn({logicalAnd_:function logicalAnd_(t,e){var n=xn(t,"a","logicalAnd","bool"),r=xn(e,"b","logicalAnd","bool");return _i(n.shape,r.shape),Wt.runKernelFunc(function(t){return t.logicalAnd(n,r);},{a:n,b:r},null,"LogicalAnd");}}),zs=Nn({logicalNot_:function logicalNot_(t){var e=xn(t,"x","logicalNot","bool");return Wt.runKernelFunc(function(t){return t.logicalNot(e);},{$x:e});}}),Us=Nn({logicalOr_:function logicalOr_(t,e){var n=xn(t,"a","logicalOr","bool"),r=xn(e,"b","logicalOr","bool");return _i(n.shape,r.shape),Wt.runKernelFunc(function(t){return t.logicalOr(n,r);},{$a:n,$b:r});}}),Ws=Nn({logicalXor_:function logicalXor_(t,e){var n=xn(t,"a","logicalXor","bool"),r=xn(e,"b","logicalXor","bool");return _i(n.shape,r.shape),Us(t,e).logicalAnd(Ls(t,e).logicalNot());}}),Vs=Nn({where_:function where_(t,e,n){var r=xn(e,"a","where"),i=xn(n,"b","where"),o=xn(t,"condition","where","bool");return S(r.shape,i.shape,"Error in where: "),1===o.rank?_(o.shape[0]===r.shape[0],function(){return "The first dimension of `a` must match the size of `condition`.";}):S(o.shape,i.shape,"Error in where: "),Wt.runKernelFunc(function(t,e){var n=t.select(o,r,i);return e([o]),n;},{$condition:o,$a:r,$b:i},function(t,e){var n=e[0];return {$condition:function $condition(){return Qn(n).toFloat();},$a:function $a(){return t.mul(n.cast(t.dtype));},$b:function $b(){return t.mul(n.logicalNot().cast(t.dtype));}};});}}),qs=function qs(t){return u(this,void 0,void 0,function(){var e,n,r;return c(this,function(i){switch(i.label){case 0:return [4,(e=xn(t,"condition","whereAsync","bool")).data()];case 1:return n=i.sent(),r=oo(e.shape,n),t!==e&&e.dispose(),[2,r];}});});},$s=Nn({add_:function add_(t,e){var n,r=xn(t,"a","add"),i=xn(e,"b","add");n=Mt(r,i),r=n[0],i=n[1];var o=_i(r.shape,i.shape);return Wt.runKernelFunc(function(t){return t.add(r,i);},{a:r,b:i},function(t){return {a:function a(){var e=t,n=Oi(r.shape,o);return n.length>0&&(e=e.sum(n)),e.reshape(r.shape);},b:function b(){var e=t,n=Oi(i.shape,o);return n.length>0&&(e=e.sum(n)),e.reshape(i.shape);}};},"Add");}}),Hs=Nn({addN_:function addN_(t){_(Array.isArray(t),function(){return "The argument passed to tf.addN() must be a list of tensors";}),_(t.length>=1,function(){return "Must pass at least one tensor to tf.addN(), but got "+t.length;});var e=t.map(function(t,e){return xn(t,"tensors"+e,"addN");}),n=e[0];e.forEach(function(t){if(t.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype");}),e.forEach(function(t){if(!N(t.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape");});var r=e;return Wt.runKernelFunc(function(t){return t.addN(e);},r,function(t){var n={};return e.forEach(function(e,r){n[r]=function(){return t.clone();};}),n;},"AddN");}}),Gs=Nn({addStrict_:function addStrict_(t,e){var n=xn(t,"a","addStrict"),r=xn(e,"b","addStrict");return S(n.shape,r.shape,"Error in addStrict: "),n.add(r);}}),Ks=Nn({atan2_:function atan2_(t,e){var n,r=xn(t,"a","atan2"),i=xn(e,"b","atan2");n=Mt(r,i),r=n[0],i=n[1];var o=_i(r.shape,i.shape);return Wt.runKernelFunc(function(t,e){var n=t.atan2(r,i);return e([r,i]),n;},{$a:r,$b:i},function(t,e){var n=e[0],r=e[1];return {$a:function $a(){var e=$s(n.square(),r.square()),i=t.mul(r.div(e)),a=Oi(n.shape,o);return a.length>0&&(i=i.sum(a)),i.reshape(n.shape);},$b:function $b(){var e=$s(n.square(),r.square()),i=cs(t.mul(n.div(e))),a=Oi(r.shape,o);return a.length>0&&(i=i.sum(a)),i.reshape(r.shape);}};});}}),Xs=Nn({div_:function div_(t,e){var n,r=xn(t,"a","div"),i=xn(e,"b","div");if(n=Mt(r,i),r=n[0],i=n[1],"int32"===r.dtype&&"int32"===i.dtype)return Qs(r,i);var o=_i(r.shape,i.shape);return Wt.runKernelFunc(function(t,e){var n=t.realDivide(r,i);return e([r,i]),n;},{a:r,b:i},function(t,e){var n=e[0],r=e[1];return {a:function a(){var e=t.div(r.toFloat()),i=Oi(n.shape,o);return i.length>0?e.sum(i).reshape(n.shape):e;},b:function b(){var e=t.mul(n.toFloat()),i=Oi(r.shape,o);i.length>0&&(e=e.sum(i).reshape(r.shape));var a=r.square();return e.div(a.toFloat()).neg();}};},"Div");}}),Ys=Nn({divNoNan_:function divNoNan_(t,e){var n,r=xn(t,"a","div"),i=xn(e,"b","div");r=(n=Mt(r,i))[0],i=n[1];var o=Xs(r,i),a=Qn(o),s=i.equal(a);return Vs(s,a,o);}}),Js=Nn({divStrict_:function divStrict_(t,e){var n=xn(t,"a","div"),r=xn(e,"b","div");return S(n.shape,r.shape,"Error in divideStrict: "),n.div(r);}}),Qs=Nn({floorDiv_:function floorDiv_(t,e){var n,r=xn(t,"a","floorDiv"),i=xn(e,"b","floorDiv");n=Mt(r,i),r=n[0],i=n[1];var o=_i(r.shape,i.shape);return Wt.runKernelFunc(function(t,e){var n=t.floorDiv(r,i);return e([r,i]),n;},{a:r,b:i},function(t,e){var n=e[0],r=e[1];return {a:function a(){var e=t.div(r.toFloat()),i=Oi(n.shape,o);return i.length>0?e.sum(i).reshape(n.shape):e;},b:function b(){var e=t.mul(n.toFloat()),i=Oi(r.shape,o);i.length>0&&(e=e.sum(i).reshape(r.shape));var a=r.square();return e.div(a.toFloat()).neg();}};},"FloorDiv");}}),Zs=Nn({maximum_:function maximum_(t,e){var n,r=xn(t,"a","maximum"),i=xn(e,"b","maximum");return n=Mt(r,i),r=n[0],i=n[1],"bool"===r.dtype&&(r=r.toInt(),i=i.toInt()),_i(r.shape,i.shape),Wt.runKernelFunc(function(t,e){var n=t.maximum(r,i);return e([r,i]),n;},{a:r,b:i},function(t,e){var n=e[0],r=e[1];return {a:function a(){return t.mul(n.greaterEqual(r).toFloat());},b:function b(){return t.mul(n.less(r).toFloat());}};},"Maximum");}}),tu=Nn({maximumStrict_:function maximumStrict_(t,e){var n=xn(t,"a","maximumStrict"),r=xn(e,"b","maximumStrict");return S(n.shape,r.shape,"Error in maximumStrict: "),n.maximum(r);}}),eu=Nn({minimum_:function minimum_(t,e){var n,r=xn(t,"a","minimum"),i=xn(e,"b","minimum");return n=Mt(r,i),r=n[0],i=n[1],"bool"===r.dtype&&(r=r.toInt(),i=i.toInt()),_i(r.shape,i.shape),Wt.runKernelFunc(function(t,e){var n=t.minimum(r,i);return e([r,i]),n;},{a:r,b:i},function(t,e){var n=e[0],r=e[1];return {a:function a(){return t.mul(n.lessEqual(r).toFloat());},b:function b(){return t.mul(n.greater(r).toFloat());}};},"Minimum");}}),nu=Nn({minimumStrict_:function minimumStrict_(t,e){var n=xn(t,"a","minimumStrict"),r=xn(e,"b","minimumStrict");return S(n.shape,r.shape,"Error in minimumStrict: "),n.minimum(r);}}),ru=Nn({mod_:function mod_(t,e){var n,r=xn(t,"a","mod"),i=xn(e,"b","mod");n=Mt(r,i),r=n[0],i=n[1];var o=_i(r.shape,i.shape);return Wt.runKernelFunc(function(t,e){var n=t.mod(r,i);return e([r,i]),n;},{$a:r,$b:i},function(t,e){var n=e[0],r=e[1];return {$a:function $a(){var e=Oi(n.shape,o);return e.length>0?t.sum(e).reshape(n.shape):t;},$b:function $b(){var e=t.mul(n.div(r).floor().neg()),i=Oi(r.shape,o);return i.length>0?e.sum(i).reshape(r.shape):e;}};});}}),iu=Nn({modStrict_:function modStrict_(t,e){var n=xn(t,"a","modStrict"),r=xn(e,"b","modStrict");return S(n.shape,r.shape,"Error in modStrict: "),n.mod(r);}}),ou=Nn({mul_:function mul_(t,e){var n,r=xn(t,"a","mul"),i=xn(e,"b","mul");n=Mt(r,i),r=n[0],i=n[1];var o=_i(r.shape,i.shape);return Wt.runKernelFunc(function(t,e){var n=t.multiply(r,i);return e([r,i]),n;},{a:r,b:i},function(t,e){var n=e[0],r=e[1];return {a:function a(){var e=t.mul(r.toFloat()),i=Oi(n.shape,o);return i.length>0?e.sum(i).reshape(n.shape):e;},b:function b(){var e=t.mul(n.toFloat()),i=Oi(r.shape,o);return i.length>0?e.sum(i).reshape(r.shape):e;}};},"Mul");}}),au=Nn({mulStrict_:function mulStrict_(t,e){var n=xn(t,"a","mul"),r=xn(e,"b","mul");return S(n.shape,r.shape,"Error in multiplyStrict: "),n.mul(r);}}),su=Nn({pow_:function pow_(t,e){var n,r=xn(t,"base","pow"),i=xn(e,"exp","pow");n=Mt(r,i),r=n[0],i=n[1];var o=_i(r.shape,i.shape),a=[r,i];return Wt.runKernelFunc(function(t,e){var n=t.pow(r,i);return e([r,i,n]),n;},{a:r,b:i},function(t,e){var n=e[0],r=e[1],i=e[2];return {a:function a(){var e=r.toFloat(),i=t.mul(e.mul(n.pow(e.sub(Pn(1))))),a=Oi(n.shape,o);return a.length>0&&(i=i.sum(a)),i.reshape(n.shape);},b:function b(){var e=n.greater(0),a=n.log().where(e,Qn(n)),s=t.mul(i.mul(a)),u=Oi(r.shape,o);return u.length>0&&(s=s.sum(u)),s.reshape(r.shape);}};},"Pow",{},a,[!0]);}}),uu=Nn({powStrict_:function powStrict_(t,e){return S(t.shape,e.shape,"Error in powStrict: "),t.pow(e);}}),cu=Nn({squaredDifferenceStrict_:function squaredDifferenceStrict_(t,e){var n=xn(t,"a","squaredDifferenceStrict"),r=xn(e,"b","squaredDifferenceStrict");return S(n.shape,r.shape,"Error in squaredDifferenceStrict: "),n.squaredDifference(r);}}),lu=Nn({sub_:function sub_(t,e){var n,r=xn(t,"a","sub"),i=xn(e,"b","sub");n=Mt(r,i),r=n[0],i=n[1];var o=_i(r.shape,i.shape);return Wt.runKernelFunc(function(t){return t.subtract(r,i);},{a:r,b:i},function(t){return {a:function a(){var e=t,n=Oi(r.shape,o);return n.length>0&&(e=e.sum(n)),e.reshape(r.shape);},b:function b(){var e=t,n=Oi(i.shape,o);return n.length>0&&(e=e.sum(n)),e.neg().reshape(i.shape);}};},"Sub");}}),fu=Nn({subStrict_:function subStrict_(t,e){var n=xn(t,"a","subStrict"),r=xn(e,"b","subStrict");return S(n.shape,r.shape,"Error in subStrict: "),n.sub(r);}}),hu=Nn({equal_:function equal_(t,e){var n,r=xn(t,"a","equal"),i=xn(e,"b","equal");return n=Mt(r,i),r=n[0],i=n[1],_i(r.shape,i.shape),Wt.runKernelFunc(function(t){return t.equal(r,i);},{$a:r,$b:i});}}),du=Nn({equalStrict_:function equalStrict_(t,e){var n=xn(t,"a","equalStrict"),r=xn(e,"b","equalStrict");return S(n.shape,r.shape,"Error in equalStrict: "),n.equal(r);}}),pu=Nn({greater_:function greater_(t,e){var n,r=xn(t,"a","greater"),i=xn(e,"b","greater");return n=Mt(r,i),r=n[0],i=n[1],_i(r.shape,i.shape),Wt.runKernelFunc(function(t){return t.greater(r,i);},{a:r,b:i},null,"Greater");}}),mu=Nn({greaterEqual_:function greaterEqual_(t,e){var n,r=xn(t,"a","greaterEqual"),i=xn(e,"b","greaterEqual");return n=Mt(r,i),r=n[0],i=n[1],_i(r.shape,i.shape),Wt.runKernelFunc(function(t,e){var n=t.greaterEqual(r,i);return e([r,i]),n;},{a:r,b:i},function(t,e){var n=e[0],r=e[1];return {a:function a(){return Qn(n);},b:function b(){return Qn(r);}};},"GreaterEqual");}}),gu=Nn({greaterEqualStrict_:function greaterEqualStrict_(t,e){var n=xn(t,"a","greaterEqualStrict"),r=xn(e,"b","greaterEqualStrict");return S(n.shape,r.shape,"Error in greaterEqualStrict: "),n.greaterEqual(r);}}),vu=Nn({greaterStrict_:function greaterStrict_(t,e){var n=xn(t,"a","greaterStrict"),r=xn(e,"b","greaterStrict");return S(n.shape,r.shape,"Error in greaterStrict: "),n.greater(r);}}),yu=Nn({less_:function less_(t,e){var n,r=xn(t,"a","less"),i=xn(e,"b","less");return n=Mt(r,i),r=n[0],i=n[1],_i(r.shape,i.shape),Wt.runKernelFunc(function(t){return t.less(r,i);},{a:r,b:i},null,"Less");}}),bu=Nn({lessEqual_:function lessEqual_(t,e){var n,r=xn(t,"a","lessEqual"),i=xn(e,"b","lessEqual");return n=Mt(r,i),r=n[0],i=n[1],_i(r.shape,i.shape),Wt.runKernelFunc(function(t,e){var n=t.lessEqual(r,i);return e([r,i]),n;},{a:r,b:i},null,"LessEqual");}}),xu=Nn({lessEqualStrict_:function lessEqualStrict_(t,e){var n=xn(t,"a","lessEqualStrict"),r=xn(e,"b","lessEqualStrict");return S(n.shape,r.shape,"Error in lessEqualStrict: "),n.lessEqual(r);}}),wu=Nn({lessStrict_:function lessStrict_(t,e){var n=xn(t,"a","lessStrict"),r=xn(e,"b","lessStrict");return S(n.shape,r.shape,"Error in lessStrict: "),n.less(r);}}),ku=Nn({notEqual_:function notEqual_(t,e){var n,r=xn(t,"a","notEqual"),i=xn(e,"b","notEqual");return n=Mt(r,i),r=n[0],i=n[1],_i(r.shape,i.shape),Wt.runKernelFunc(function(t){return t.notEqual(r,i);},{a:r,b:i},null,"NotEqual");}}),Eu=Nn({notEqualStrict_:function notEqualStrict_(t,e){var n=xn(t,"a","notEqualStrict"),r=xn(e,"b","notEqualStrict");return S(n.shape,r.shape,"Error in notEqualStrict: "),n.notEqual(r);}});function Cu(t,e){for(var n=[],r=t;r<e;++r){n.push(r);}return n;}function Au(t){for(var e=[],n=0;n<t.length;++n){for(var r=0;r<t[n].length;++r){e.push(t[n][r]);}}return e;}var Ou=Nn({gather_:function gather_(t,e,n){void 0===n&&(n=0);var r=xn(t,"x","gather"),i=xn(e,"indices","gather","int32");n=L(n,r.shape)[0];var o=function(t,e,n){for(var r=t.shape[n],i=[],o=1,a=1,s=0;s<n;s++){i.push(t.shape[s]),o*=t.shape[s];}for(s=0;s<e.rank;s++){i.push(e.shape[s]);}for(s=n+1;s<t.rank;s++){i.push(t.shape[s]),a*=t.shape[s];}return {batchSize:o,sliceSize:a,dimSize:r,outputShape:i};}(r,i,n);return Wt.runKernelFunc(function(t,e){var o=t.gather(r,i.flatten(),n);return e([i]),o;},{x:r,indices:i},function(t,e){var i=e[0];return {x:function x(){var e=r.shape,o=i.size,a=e.slice(0,n),s=a.length,u=e.slice(n,e.length).slice(1),c=u.length,l=Cu(0,s),f=Cu(s+1,s+1+c),h=Au([a,[o],u]),d=t.reshape(h),p=i.reshape([o]),m=Au([[s],l,f]),g=d.transpose(m),v=_u(g,p,r.shape[n]),y=Sn(m);return v.transpose(y);},indices:function indices(){return i;}};},"Gather",{axis:n}).reshape(o.outputShape);}}),_u=Nn({unsortedSegmentSum_:function unsortedSegmentSum_(t,e,n){var r=xn(t,"x","unsortedSegmentSum"),i=xn(e,"segmentIds","unsortedSegmentSum","int32");return _(I(n),function(){return "numSegments must be of dtype int";}),Wt.runKernelFunc(function(t,e){var o=t.unsortedSegmentSum(r,i,n);return e([i]),o;},{$x:r},function(t,e){var n=e[0];return {$x:function $x(){return function(t,e){for(var n=Zs(e,Qn(e)),r=Ou(t,n),i=mu(e,Pn(0,"int32")),o=r.rank-i.rank,a=0;a<o;++a){i=Ar(i,a+1);}i=Ls(i,Hn(r.shape,"bool"));var s=Qn(r);return Vs(i,r,s);}(t,n);}};});}}),Su=function Su(t,e,n){return u(this,void 0,void 0,function(){var r,i,o,a,s,u,l,f,h,d,p,m,g;return c(this,function(c){switch(c.label){case 0:for(r=xn(t,"tensor","boolMask"),i=xn(e,"mask","boolMask","bool"),o=null==n?0:n,a=i.rank,s=r.shape,_(a>0,function(){return "mask cannot be scalar";}),S(s.slice(o,o+a),i.shape,"mask's shape must match the first K dimensions of tensor's shape,"),u=1,l=o;l<o+a;l++){u*=s[l];}return f=s.slice(0,o).concat([u],s.slice(o+a)),h=r.reshape(f),d=i.reshape([-1]),[4,qs(d)];case 1:return p=c.sent(),m=p.squeeze([1]),g=Ou(h,m,o),t!==r&&r.dispose(),e!==i&&i.dispose(),m.dispose(),h.dispose(),d.dispose(),p.dispose(),[2,g];}});});};function Du(t,e,n,r,i,o,a){void 0===o&&(o="NHWC"),_(t.length===e.rank,function(){return "Length of inShape ("+t.length+") and rank of dy ("+e.rank+") must match";});var s=t,u=e,c=!1;3===e.rank&&(c=!0,u=e.as4D(1,e.shape[0],e.shape[1],e.shape[2]),s=[1,t[0],t[1],t[2]]),_(4===s.length,function(){return "Error in conv2dDerInput: inShape must be length 4, but got length "+s.length+".";}),_(4===u.rank,function(){return "Error in conv2dDerInput: dy must be rank 4, but got rank "+u.rank;}),_(4===n.rank,function(){return "Error in conv2dDerInput: filter must be rank 4, but got rank "+n.rank;});var l="NHWC"===o?s[3]:s[1],f="NHWC"===o?u.shape[3]:u.shape[1];_(l===n.shape[2],function(){return "Error in conv2dDerInput: depth of input ("+l+") must match input depth for filter "+n.shape[2]+".";}),_(f===n.shape[3],function(){return "Error in conv2dDerInput: depth of output ("+f+") must match output depth for filter "+n.shape[3]+".";}),null!=a&&_(I(i),function(){return "Error in conv2dDerInput: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+i+".";});var h=Li(o),d=Fi(s,n.shape,r,1,i,a,!1,h),p=Wt.runKernelFunc(function(t,e){var r=t.conv2dDerInput(u,n,d);return e([n,u]),r;},{dy4D:u,filter:n},function(t,e){var n=e[0],s=e[1];return {dy4D:function dy4D(){return Iu(t,n,r,i,o,1,a);},filter:function filter(){return Mu(t,s,n.shape,r,i,o,a);}};});return c?p.as3D(p.shape[1],p.shape[2],p.shape[3]):p;}function Fu(t){var e=function(t){return "number"==typeof t?[t,t,t]:2===t.length?[t[0],t[1],1]:t;}(t),n=e[0],r=e[1],i=e[2];return 1===n&&1===r&&1===i;}function Tu(t,e,n,r,i){_(t.length===e.rank,function(){return "Length of inShape ("+t.length+") and rank of dy ("+e.rank+") must match";});var o=t,a=e,s=!1;4===e.rank&&(s=!0,a=e.as5D(1,e.shape[0],e.shape[1],e.shape[2],e.shape[3]),o=[1,t[0],t[1],t[2],t[3]]);var u=o[4],c=a.shape[4];_(5===o.length,function(){return "Error in conv3dDerInput: inShape must be length 5, but got length "+o.length+".";}),_(5===a.rank,function(){return "Error in conv3dDerInput: dy must be rank 5, but got rank "+a.rank;}),_(5===n.rank,function(){return "Error in conv3dDerInput: filter must be rank 5, but got rank "+n.rank;}),_(u===n.shape[3],function(){return "Error in conv3dDerInput: depth of input ("+u+") must match input depth for filter "+n.shape[3]+".";}),_(c===n.shape[4],function(){return "Error in conv3dDerInput: depth of output ("+c+") must match output depth for filter "+n.shape[4]+".";});var l=Ti(o,n.shape,r,1,i),f=Wt.runKernelFunc(function(t){return t.conv3dDerInput(a,n,l);},{dy5D:a});return s?f.as4D(f.shape[1],f.shape[2],f.shape[3],f.shape[4]):f;}var Nu=Nn({conv1d_:function conv1d_(t,e,n,r,i,o,a){void 0===i&&(i="NWC"),void 0===o&&(o=1);var s=xn(t,"x","conv1d"),u=xn(e,"filter","conv1d"),c=s,l=!1;2===s.rank&&(l=!0,c=s.as3D(1,s.shape[0],s.shape[1])),_(3===c.rank,function(){return "Error in conv1d: input must be rank 3, but got rank "+c.rank+".";}),_(3===u.rank,function(){return "Error in conv1d: filter must be rank 3, but got rank "+u.rank+".";}),null!=a&&_(I(r),function(){return "Error in conv1d: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+r+".";}),_(c.shape[2]===u.shape[1],function(){return "Error in conv1d: depth of input ("+c.shape[2]+") must match input depth for filter "+u.shape[1]+".";}),_(Pi(n,o),function(){return "Error in conv1D: Either stride or dilation must be 1. Got stride "+n+" and dilation '"+o+"'";}),_("NWC"===i,function(){return "Error in conv1d: got dataFormat of "+i+" but only NWC is currently supported.";});var f=u.as4D(1,u.shape[0],u.shape[1],u.shape[2]),h=c.as4D(c.shape[0],1,c.shape[1],c.shape[2]),d=Iu(h,f,[1,n],r,"NHWC",[1,o],a);return l?d.as2D(d.shape[2],d.shape[3]):d.as3D(d.shape[0],d.shape[2],d.shape[3]);}}),Iu=Nn({conv2d_:function conv2d_(t,e,n,r,i,o,a){void 0===i&&(i="NHWC"),void 0===o&&(o=[1,1]);var s=xn(t,"x","conv2d"),u=xn(e,"filter","conv2d"),c=s,l=!1;3===s.rank&&(l=!0,c=s.as4D(1,s.shape[0],s.shape[1],s.shape[2])),_(4===c.rank,function(){return "Error in conv2d: input must be rank 4, but got rank "+c.rank+".";}),_(4===u.rank,function(){return "Error in conv2d: filter must be rank 4, but got rank "+u.rank+".";}),null!=a&&_(I(r),function(){return "Error in conv2d: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+r+".";});var f="NHWC"===i?c.shape[3]:c.shape[1];_(f===u.shape[2],function(){return "Error in conv2d: depth of input ("+f+") must match input depth for filter "+u.shape[2]+".";}),_(Pi(n,o),function(){return "Error in conv2D: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+o+"'";});var h=Li(i),d=Fi(c.shape,u.shape,n,o,r,a,!1,h),p=[u,c],m=Wt.runKernelFunc(function(t,e){var n=t.conv2d(c,u,d);return e([u,c]),n;},{x:c,filter:u},function(t,e){var a=e,s=a[0],u=a[1];return _(Bi(o),function(){return "Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+o+"'";}),{x:function x(){return ju(u.shape,t,s,n,r,i);},filter:function filter(){return Mu(u,t,s.shape,n,r,i);}};},"Conv2D",d,p);return l?m.as3D(m.shape[1],m.shape[2],m.shape[3]):m;}}),Ru=Nn({conv3d_:function conv3d_(t,e,n,r,i,o){void 0===i&&(i="NDHWC"),void 0===o&&(o=[1,1,1]);var a=xn(t,"x","conv3d"),s=xn(e,"filter","conv3d"),u=a,c=!1;4===a.rank&&(c=!0,u=a.as5D(1,a.shape[0],a.shape[1],a.shape[2],a.shape[3])),_(5===u.rank,function(){return "Error in conv3d: input must be rank 5, but got rank "+u.rank+".";}),_(5===s.rank,function(){return "Error in conv3d: filter must be rank 5, but got rank "+s.rank+".";}),_(u.shape[4]===s.shape[3],function(){return "Error in conv3d: depth of input ("+u.shape[4]+") must match input depth for filter "+s.shape[3]+".";}),_(function(t,e){return Fu(n)||Fu(e);}(0,o),function(){return "Error in conv3D: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+o+"'";}),_("NDHWC"===i,function(){return "Error in conv3d: got dataFormat of "+i+" but only NDHWC is currently supported.";});var l=Ti(u.shape,s.shape,n,o,r),f=Wt.runKernelFunc(function(t,e){var n=t.conv3d(u,s,l);return e([u,s]),n;},{x:u,$filter:s},function(t,e){_(Fu(o),function(){return "Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+o+"'";});var i=e[0],a=e[1];return {x:function x(){return Tu(i.shape,t,a,n,r);},$filter:function $filter(){return function(t,e,n,r,i){var o=t;4===t.rank&&(o=t.as5D(1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]));var a=e;4===a.rank&&(a=e.as5D(1,e.shape[0],e.shape[1],e.shape[2],e.shape[3])),_(5===o.rank,function(){return "Error in conv3dDerFilter: input must be rank 5, but got shape "+o.shape+".";}),_(5===a.rank,function(){return "Error in conv3dDerFilter: dy must be rank 5, but got shape "+a.shape+".";}),_(5===n.length,function(){return "Error in conv3dDerFilter: filterShape must be length 5, but got "+n+".";}),_(o.shape[4]===n[3],function(){return "Error in conv3dDerFilter: depth of input "+o.shape[4]+") must match input depth in filter ("+n[3]+".";}),_(a.shape[4]===n[4],function(){return "Error in conv3dDerFilter: depth of dy ("+a.shape[4]+") must match output depth for filter ("+n[4]+").";});var s=Ti(o.shape,n,r,1,i);return Wt.runKernelFunc(function(t){return t.conv3dDerFilter(o,a,s);},{x5D:o,dy5D:a});}(i,t,a.shape,n,r);}};});return c?f.as4D(f.shape[1],f.shape[2],f.shape[3],f.shape[4]):f;}}),Mu=Nn({conv2dDerFilter_:function conv2dDerFilter_(t,e,n,r,i,o,a){void 0===o&&(o="NHWC");var s=t;3===t.rank&&(s=t.as4D(1,t.shape[0],t.shape[1],t.shape[2]));var u=e;3===u.rank&&(u=e.as4D(1,e.shape[0],e.shape[1],e.shape[2])),_(4===s.rank,function(){return "Error in conv2dDerFilter: input must be rank 4, but got shape "+s.shape+".";}),_(4===u.rank,function(){return "Error in conv2dDerFilter: dy must be rank 4, but got shape "+u.shape+".";}),_(4===n.length,function(){return "Error in conv2dDerFilter: filterShape must be length 4, but got "+n+".";});var c="NHWC"===o?s.shape[3]:s.shape[1],l="NHWC"===o?u.shape[3]:u.shape[1];_(c===n[2],function(){return "Error in conv2dDerFilter: depth of input "+c+") must match input depth in filter ("+n[2]+".";}),_(l===n[3],function(){return "Error in conv2dDerFilter: depth of dy ("+l+") must match output depth for filter ("+n[3]+").";}),null!=a&&_(I(i),function(){return "Error in conv2dDerFilter: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+i+".";});var f=Li(o),h=Fi(s.shape,n,r,1,i,a,!1,f);return Wt.runKernelFunc(function(t){return t.conv2dDerFilter(s,u,h);},{x4D:s,dy4D:u});}}),ju=Nn({conv2dDerInput_:Du}),Bu=Nn({depthwiseConv2d_:function depthwiseConv2d_(t,e,n,r,i,o,a){void 0===o&&(o=[1,1]);var s=xn(t,"x","depthwiseConv2d"),u=xn(e,"filter","depthwiseConv2d"),c=s,l=!1;3===s.rank&&(l=!0,c=s.as4D(1,s.shape[0],s.shape[1],s.shape[2])),_(4===c.rank,function(){return "Error in depthwiseConv2d: input must be rank 4, but got rank "+c.rank+".";}),_(4===u.rank,function(){return "Error in depthwiseConv2d: filter must be rank 4, but got rank "+u.rank+".";}),_(c.shape[3]===u.shape[2],function(){return "Error in depthwiseConv2d: number of input channels ("+c.shape[3]+") must match the inChannels dimension in filter "+u.shape[2]+".";}),null==o&&(o=[1,1]),_(Pi(n,o),function(){return "Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+o+"'";}),null!=a&&_(I(r),function(){return "Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+r+".";});var f=Fi(c.shape,u.shape,n,o,r,a,!0),h=[c,u],d=Wt.runKernelFunc(function(t,e){var n=t.depthwiseConv2D(c,u,f);return e([c,u]),n;},{x:c,filter:u},function(t,e){_(Bi(o),function(){return "Error in gradient of depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '"+o+"'";});var n=e[0],r=e[1];return {x:function x(){return Pu(n.shape,t,r,f);},filter:function filter(){return Lu(n,t,r.shape,f);}};},"DepthwiseConv2dNative",f,h);return l?d.as3D(d.shape[1],d.shape[2],d.shape[3]):d;}}),Pu=Nn({depthwiseConv2dDerInput_:function depthwiseConv2dDerInput_(t,e,n,r){var i=e,o=!1;3===e.rank&&(o=!0,i=e.as4D(1,e.shape[0],e.shape[1],e.shape[2]));var a=Wt.runKernelFunc(function(t){return t.depthwiseConv2DDerInput(i,n,r);},{dy4D:i});return o?a.as3D(a.shape[1],a.shape[2],a.shape[3]):a;}}),Lu=Nn({depthwiseConv2dDerFilter_:function depthwiseConv2dDerFilter_(t,e,n,r){var i=t;3===t.rank&&(i=t.as4D(1,t.shape[0],t.shape[1],t.shape[2]));var o=e;return 3===o.rank&&(o=e.as4D(1,e.shape[0],e.shape[1],e.shape[2])),Wt.runKernelFunc(function(t){return t.depthwiseConv2DDerFilter(i,o,r);},{x4D:i,dy4D:o});}}),zu=Nn({separableConv2d_:function separableConv2d_(t,e,n,r,i,o,a){void 0===o&&(o=[1,1]),void 0===a&&(a="NHWC");var s=xn(t,"x","separableConv2d"),u=xn(e,"depthwiseFilter","separableConv2d"),c=xn(n,"pointwiseFilter","separableConv2d"),l=s,f=!1;if(3===s.rank&&(f=!0,l=s.as4D(1,s.shape[0],s.shape[1],s.shape[2])),"NCHW"===a)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");_(4===l.rank,function(){return "Error in separableConv2d: input must be rank 4, but got rank "+l.rank+".";}),_(4===u.rank,function(){return "Error in separableConv2d: depthwise filter must be rank 4, but got rank "+u.rank+".";}),_(4===c.rank,function(){return "Error in separableConv2d: pointwise filter must be rank 4, but got rank "+u.rank+".";}),_(1===c.shape[0],function(){return "Error in separableConv2d: the first dimension of pointwise filter  must be 1, but got "+c.shape[0]+".";}),_(1===c.shape[1],function(){return "Error in separableConv2d: the second dimension of pointwise filter must be 1, but got "+c.shape[1]+".";});var h=u.shape[2],d=u.shape[3];_(c.shape[2]===h*d,function(){return "Error in separableConv2d: the third dimension of pointwise filter must be "+h*d+", but got "+c.shape[2]+".";});var p=Bu(l,u,r,i,a,o),m=Iu(p,c,1,"valid",a);return f?m.as3D(m.shape[1],m.shape[2],m.shape[3]):m;}}),Uu=Nn({conv2dTranspose_:function conv2dTranspose_(t,e,n,r,i,o){return Du(n,xn(t,"x","conv2dTranspose"),xn(e,"filter","conv2dTranspose"),r,i,"NHWC",o);}}),Wu=Nn({conv3dTranspose_:function conv3dTranspose_(t,e,n,r,i){return Tu(n,xn(t,"x","conv3dTranspose"),xn(e,"filter","conv3dTranspose"),r,i);}}),Vu=Nn({matMul_:function matMul_(t,e,n,r){var i;void 0===n&&(n=!1),void 0===r&&(r=!1);var o=xn(t,"a","matMul"),a=xn(e,"b","matMul");i=Mt(o,a),o=i[0],a=i[1];var s=n?o.shape[o.rank-2]:o.shape[o.rank-1],u=r?a.shape[a.rank-1]:a.shape[a.rank-2],c=n?o.shape[o.rank-1]:o.shape[o.rank-2],l=r?a.shape[a.rank-2]:a.shape[a.rank-1],f=o.shape.slice(0,-2),h=a.shape.slice(0,-2),d=T(f),p=T(h);_(o.rank>=2&&a.rank>=2&&o.rank===a.rank,function(){return "Error in matMul: inputs must have the same rank of at least 2, got ranks "+o.rank+" and "+a.rank+".";}),_(N(f,h),function(){return "Error in matMul: outer dimensions ("+f+") and ("+h+") of Tensors with shapes "+o.shape+" and "+a.shape+" must match.";}),_(s===u,function(){return "Error in matMul: inner shapes ("+s+") and ("+u+") of Tensors with shapes "+o.shape+" and "+a.shape+" and transposeA="+n+" and transposeB="+r+" must match.";});var m=o.shape.slice(0,-2).concat([c,l]),g=n?o.as3D(d,s,c):o.as3D(d,c,s),v=r?a.as3D(p,l,u):a.as3D(p,u,l),y={transposeA:n,transposeB:r};return Wt.runKernelFunc(function(t,e){var i=t.batchMatMul(g,v,n,r);return e([g,v]),i;},{a:g,b:v},function(t,e){var i=e,o=i[0],_a6=i[1];return n||r?!n&&r?{a:function a(){return t.matMul(_a6,!1,!1);},b:function b(){return t.matMul(o,!0,!1);}}:n&&!r?{a:function a(){return _a6.matMul(t,!1,!0);},b:function b(){return o.matMul(t,!1,!1);}}:{a:function a(){return _a6.matMul(t,!0,!0);},b:function b(){return t.matMul(o,!0,!0);}}:{a:function a(){return t.matMul(_a6,!1,!0);},b:function b(){return o.matMul(t,!0,!1);}};},"BatchMatMul",y).reshape(m);}}),qu=Nn({dot_:function dot_(t,e){var n=xn(t,"t1","dot"),r=xn(e,"t2","dot");_(!(1!==n.rank&&2!==n.rank||1!==r.rank&&2!==r.rank),function(){return "Error in dot: inputs must all be rank 1 or 2, but got ranks "+n.rank+" and "+r.rank+".";});var i=1===n.rank?n.size:n.shape[1],o=1===r.rank?r.size:r.shape[0];return _(i===o,function(){return "Error in dot: inner dimensions of inputs must match, but got "+i+" and "+o+".";}),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]));}}),$u=Nn({outerProduct_:function outerProduct_(t,e){var n=xn(t,"v1","outerProduct"),r=xn(e,"v2","outerProduct");return _(1===n.rank&&1===r.rank,function(){return "Error in outerProduct: inputs must be rank 1, but got ranks "+n.rank+" and "+r.rank+".";}),n.as2D(-1,1).matMul(r.as2D(1,-1));}}),Hu=Nn({reverse_:function reverse_(t,e){var n=xn(t,"x","reverse");if(0===n.rank)return n.clone();var r=L(e,n.shape);return Wt.runKernelFunc(function(t){return t.reverse(n,r);},{$x:n},function(t){return {$x:function $x(){return t.reverse(r);}};}).reshapeAs(n);}}),Gu=Nn({reverse1d_:function reverse1d_(t){var e=xn(t,"x","reverse");return _(1===e.rank,function(){return "Error in reverse1D: x must be rank 1 but got rank "+e.rank+".";}),Hu(e,0);}}),Ku=Nn({reverse2d_:function reverse2d_(t,e){var n=xn(t,"x","reverse");return _(2===n.rank,function(){return "Error in reverse2D: x must be rank 2 but got rank "+n.rank+".";}),Hu(n,e);}}),Xu=Nn({reverse3d_:function reverse3d_(t,e){var n=xn(t,"x","reverse");return _(3===n.rank,function(){return "Error in reverse3D: x must be rank 3 but got rank "+n.rank+".";}),Hu(n,e);}}),Yu=Nn({reverse4d_:function reverse4d_(t,e){var n=xn(t,"x","reverse");return _(4===n.rank,function(){return "Error in reverse4D: x must be rank 4 but got rank "+n.rank+".";}),Hu(n,e);}});function Ju(t,e,n,r,i,o){var a=xn(t,"x","maxPool"),s=a,u=!1;3===a.rank&&(u=!0,s=a.as4D(1,a.shape[0],a.shape[1],a.shape[2])),null==r&&(r=[1,1]),_(4===s.rank,function(){return "Error in maxPool: input must be rank 4 but got rank "+s.rank+".";}),_(Pi(n,r),function(){return "Error in maxPool: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+r+"'";}),null!=o&&_(I(i),function(){return "Error in maxPool: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+i+".";});var c=Si(s.shape,e,n,r,i,o);if(1===c.filterWidth&&1===c.filterHeight&&N(c.inShape,c.outShape))return a.clone();var l=[s],f=Wt.runKernelFunc(function(t,e){var n=t.maxPool(s,c);return e([s,n]),n;},{x:s},function(t,o){var a=o[0],s=o[1];return {x:function x(){return function(t,e,n,r,i,o,a,s){var u=xn(t,"dy","maxPoolBackprop"),c=xn(e,"input","maxPoolBackprop"),l=xn(n,"output","maxPoolBackprop");_(c.rank===u.rank,function(){return "Rank of input ("+c.rank+") does not match rank of dy ("+u.rank+")";}),null==o&&(o=[1,1]),_(Pi(i,o),function(){return "Error in maxPoolBackProp: Either strides or dilations must be 1. Got strides "+i+" and dilations '"+o+"'";}),_(4===u.rank,function(){return "Error in maxPoolBackprop: dy must be rank 4 but got rank "+u.rank+".";}),_(4===c.rank,function(){return "Error in maxPoolBackprop: input must be rank 4 but got rank "+c.rank+".";});var f=Si(c.shape,r,i,o,a,s);return Wt.runKernelFunc(function(t){return t.maxPoolBackprop(u,c,l,f);},{$dy:u,$input:c});}(t,a,s,e,n,r,i);}};},"MaxPool",c,l);return u?f.as3D(f.shape[1],f.shape[2],f.shape[3]):f;}function Qu(t,e,n,r,i,o){var a=xn(t,"x","avgPool","float32");null==r&&(r=[1,1]),_(Pi(n,r),function(){return "Error in avgPool: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+r+"'";});var s=a,u=!1;3===a.rank&&(u=!0,s=a.as4D(1,a.shape[0],a.shape[1],a.shape[2])),_(4===s.rank,function(){return "Error in avgPool: x must be rank 4 but got rank "+s.rank+".";}),null!=o&&_(I(i),function(){return "Error in avgPool: pad must be an integer when using, dimRoundingMode "+o+" but got pad "+i+".";});var c=Si(s.shape,e,n,r,i,o);if(1===c.filterWidth&&1===c.filterHeight&&N(c.inShape,c.outShape))return a.clone();var l=Wt.runKernelFunc(function(t){return t.avgPool(s,c);},{x:s},function(t){return {x:function x(){return function(t,e,n,r,i,o){var a=xn(t,"dy","avgPoolBackprop"),s=xn(e,"input","avgPoolBackprop");_(s.rank===a.rank,function(){return "Rank of input ("+s.rank+") does not match rank of dy ("+a.rank+")";}),null==i&&(i=[1,1]),_(Pi(r,i),function(){return "Error in avgPoolBackprop: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+i+"'";});var u=s,c=a,l=!1;3===s.rank&&(l=!0,u=s.as4D(1,s.shape[0],s.shape[1],s.shape[2]),c=a.as4D(1,a.shape[0],a.shape[1],a.shape[2])),_(4===c.rank,function(){return "Error in avgPoolBackprop: dy must be rank 4 but got rank "+c.rank+".";}),_(4===u.rank,function(){return "Error in avgPoolBackprop: input must be rank 4 but got rank "+u.rank+".";});var f=Si(u.shape,n,r,i,o),h=Wt.runKernelFunc(function(t){return t.avgPoolBackprop(c,u,f);},{dy4D:c,input4D:u});return l?h.as3D(h.shape[1],h.shape[2],h.shape[3]):h;}(t,s,e,n,r,i);}};},"AvgPool",c);return l=l.cast(a.dtype),u?l.as3D(l.shape[1],l.shape[2],l.shape[3]):l;}var Zu=Nn({maxPool_:function maxPool_(t,e,n,r,i){return Ju(t,e,n,1,r,i);}}),tc=Nn({avgPool_:function avgPool_(t,e,n,r,i){return Qu(t,e,n,1,r,i);}}),ec=Nn({pool_:function pool_(t,e,n,r,i,o){null==i&&(i=[1,1]),null==o&&(o=1),0===r&&(r="valid");var a=xn(t,"x","maxPool"),s=a,u=!1;3===a.rank&&(u=!0,s=a.as4D(1,a.shape[0],a.shape[1],a.shape[2])),_(Pi(o,i),function(){return "Error in pool: Either strides or dilations must be 1. Got strides "+o+" and dilations '"+i+"'";});var c,l=Si(s.shape,e,o,i,r),f=[l.dilationHeight,l.dilationWidth];c="same"===r?function(t,e){var n=t.map(function(t,n){return t+(t-1)*(e[n]-1);}).map(function(t){return t-1;}),r=n.map(function(t){return Math.floor(t/2);}),i=n.map(function(t,e){return t-r[e];});return n.map(function(t,e){return [r[e],i[e]];});}([l.filterHeight,l.filterWidth],f):[[0,0],[0,0]];var h=1===f[0]&&1===f[1],d=function(t,e,n){var r=n.map(function(t){return t[0];}),i=n.map(function(t){return t[1];}),o=t.concat(r,i),a=e.map(function(t,e){return (t-o[e]%t)%t;}),s=i.map(function(t,e){return t+a[e];});return [e.map(function(t,e){return [r[e],s[e]];}),e.map(function(t,e){return [0,a[e]];})];}([l.inHeight,l.inWidth],f,c),p=d[0],m=d[1],g=h?r:"valid",v=h?s:Lr(s,f,p),y=("avg"===n?function(){return Qu(v,e,o,1,g);}:function(){return Ju(v,e,o,1,g);})(),b=h?y:br(y,f,m);return u?b.as3D(b.shape[1],b.shape[2],b.shape[3]):b;}}),nc=Nn({maxPool3d_:function maxPool3d_(t,e,n,r,i,o,a){void 0===o&&(o="NDHWC");var s=xn(t,"x","maxPool3d"),u=s,c=!1;4===s.rank&&(c=!0,u=s.as5D(1,s.shape[0],s.shape[1],s.shape[2],s.shape[3])),null==a&&(a=[1,1,1]),_(5===u.rank,function(){return "Error in maxPool3d: x must be rank 5 but got rank "+u.rank+".";}),_("NDHWC"===o,function(){return "Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of "+o;}),_(Pi(n,a),function(){return "Error in maxPool3d: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+a+"'";}),null!=i&&_(I(r),function(){return "Error in maxPool3d: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+r+".";});var l=Di(u.shape,e,n,a,r,i,o),f=Wt.runKernelFunc(function(t,e){var n=t.maxPool3d(u,l);return e([u,n]),n;},{x:u},function(t,o){var s=o[0],u=o[1];return {x:function x(){return function(t,e,n,r,i,o,a,s){var u=xn(t,"dy","maxPool3dBackprop"),c=xn(e,"input","maxPool3dBackprop"),l=xn(n,"output","maxPool3dBackprop"),f=u,h=c,d=l,p=!1;4===c.rank&&(p=!0,f=u.as5D(1,u.shape[0],u.shape[1],u.shape[2],u.shape[3]),h=c.as5D(1,c.shape[0],c.shape[1],c.shape[2],c.shape[3]),d=l.as5D(1,l.shape[0],l.shape[1],l.shape[2],l.shape[3])),_(5===f.rank,function(){return "Error in maxPool3dBackprop: dy must be rank 5 but got rank "+f.rank+".";}),_(5===h.rank,function(){return "Error in maxPool3dBackprop: input must be rank 5 but got rank "+h.rank+".";}),_(5===d.rank,function(){return "Error in maxPool3dBackprop: output must be rank 5 but got rank "+d.rank+".";}),null==o&&(o=[1,1,1]),_(Pi(i,o),function(){return "Error in maxPool3dBackprop: Either strides or dilations must be 1. Got strides "+i+" and dilations '"+o+"'";}),null!=s&&_(I(a),function(){return "Error in maxPool3dBackprop: pad must be an integer when using, dimRoundingMode "+s+" but got pad "+a+".";});var m=Di(h.shape,r,i,o,a,s),g=Wt.runKernelFunc(function(t){return t.maxPool3dBackprop(f,h,d,m);},{dy5D:f,input5D:h});return p?g.as4D(g.shape[1],g.shape[2],g.shape[3],g.shape[4]):g;}(t,s,u,e,n,a,r,i);}};});return c?f.as4D(f.shape[1],f.shape[2],f.shape[3],f.shape[4]):f;}}),rc=Nn({avgPool3d_:function avgPool3d_(t,e,n,r,i,o,a){void 0===o&&(o="NDHWC");var s=xn(t,"x","avgPool3d","float32"),u=s,c=!1;4===s.rank&&(c=!0,u=s.as5D(1,s.shape[0],s.shape[1],s.shape[2],s.shape[3])),null==a&&(a=[1,1,1]),_(5===u.rank,function(){return "Error in avgPool3d: x must be rank 5 but got rank "+u.rank+".";}),_("NDHWC"===o,function(){return "Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of "+o;}),_(Pi(n,a),function(){return "Error in avgPool3d: Either strides or dilations must be 1. Got strides "+n+" and dilations '"+a+"'";}),null!=i&&_(I(r),function(){return "Error in avgPool3d: pad must be an integer when using, dimRoundingMode "+i+" but got pad "+r+".";});var l=Di(u.shape,e,n,a,r,i,o),f=Wt.runKernelFunc(function(t){return t.avgPool3d(u,l);},{x:u},function(t){return {x:function x(){return function(t,e,n,r,i,o,a){var s=xn(t,"dy","avgPool3dBackprop"),u=xn(e,"input","avgPool3dBackprop"),c=s,l=u,f=!1;4===u.rank&&(f=!0,c=s.as5D(1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]),l=u.as5D(1,u.shape[0],u.shape[1],u.shape[2],u.shape[3])),_(5===c.rank,function(){return "Error in avgPool3dBackprop: dy must be rank 5 but got rank "+c.rank+".";}),_(5===l.rank,function(){return "Error in avgPool3dBackprop: input must be rank 5 but got rank "+l.rank+".";}),null==i&&(i=[1,1,1]),_(Pi(r,i),function(){return "Error in avgPool3dBackprop: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+i+"'";}),null!=a&&_(I(o),function(){return "Error in maxPool3dBackprop: pad must be an integer when using, dimRoundingMode "+a+" but got pad "+o+".";});var h=Di(l.shape,n,r,i,o,a),d=Wt.runKernelFunc(function(t){return t.avgPool3dBackprop(c,l,h);},{dy5D:c,input5D:l});return f?d.as4D(d.shape[1],d.shape[2],d.shape[3],d.shape[4]):d;}(t,u,e,n,a,r,i);}};});return f=f.cast(u.dtype),c?f.as4D(f.shape[1],f.shape[2],f.shape[3],f.shape[4]):f;}}),ic=Nn({slice_:function slice_(t,e,n){var r,i,o=xn(t,"x","slice");if(0===o.rank)throw new Error("Slicing scalar is not possible");(r="number"==typeof e?[e].concat(new Array(o.rank-1).fill(0)):e.length<o.rank?e.concat(new Array(o.rank-e.length).fill(0)):e.slice()).forEach(function(t){_(-1!==t,function(){return "slice() does not support negative begin indexing.";});}),i=(i=null==n?new Array(o.rank).fill(-1):"number"==typeof n?[n].concat(new Array(o.rank-1).fill(-1)):n.length<o.rank?n.concat(new Array(o.rank-n.length).fill(-1)):n).map(function(t,e){return t>=0?t:(_(-1===t,function(){return "Negative size values should be exactly -1 but got "+t+" for the slice() size at index "+e+".";}),o.shape[e]-r[e]);}),oi(o,r,i);var a=o.shape,s={begin:r,size:i};return Wt.runKernelFunc(function(t){return t.slice(o,r,i);},{x:o},function(t){for(var e=[],n=0;n<t.rank;n++){e.push([r[n],a[n]-r[n]-i[n]]);}return {x:function x(){return t.pad(e);}};},"Slice",s);}}),oc=Nn({slice1d_:function slice1d_(t,e,n){var r=xn(t,"x","slice1d");return _(1===r.rank,function(){return "slice1d expects a rank-1 tensor, but got a rank-"+r.rank+" tensor";}),ic(r,[e],[n]);}}),ac=Nn({slice2d_:function slice2d_(t,e,n){var r=xn(t,"x","slice2d");return _(2===r.rank,function(){return "slice2d expects a rank-2 tensor, but got a rank-"+r.rank+" tensor";}),ic(r,e,n);}}),sc=Nn({slice3d_:function slice3d_(t,e,n){var r=xn(t,"x","slice3d");return _(3===r.rank,function(){return "slice3d expects a rank-3 tensor, but got a rank-"+r.rank+" tensor";}),ic(r,e,n);}}),uc=Nn({slice4d_:function slice4d_(t,e,n){var r=xn(t,"x","slice4d");return _(4===r.rank,function(){return "slice4d expects a rank-4 tensor, but got a rank-"+r.rank+" tensor";}),ic(r,e,n);}});function cc(t,e,n,r,i){return e.rank<n.rank&&(e=e.reshape(An(e.shape,r))),t.rank<n.rank&&(t=t.reshape(An(t.shape,r))),{x:function x(){var r=t.mul(n.equal(e).cast(t.dtype));return null==i?r:r.transpose(i);}};}var lc=Nn({all_:function all_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=xn(t,"x","all","bool"),i=L(e,r.shape),o=i,a=_n(o,r.rank);null!=a&&(r=r.transpose(a),o=Dn(o.length,r.rank));var s=Wt.runKernelFunc(function(t){return t.all(r,o);},{$x:r});if(n){var u=An(s.shape,i);return s.reshape(u);}return s;}}),fc=Nn({any_:function any_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=xn(t,"x","any","bool"),i=L(e,r.shape),o=i,a=_n(o,r.rank);null!=a&&(r=r.transpose(a),o=Dn(o.length,r.rank));var s=Wt.runKernelFunc(function(t){return t.any(r,o);},{$x:r});if(n){var u=An(s.shape,i);return s.reshape(u);}return s;}}),hc=Nn({argMax_:function argMax_(t,e){void 0===e&&(e=0);var n=xn(t,"x","argMax");null==e&&(e=0);var r=L(e,n.shape),i=_n(r,n.rank);null!=i&&(n=n.transpose(i),r=Dn(r.length,n.rank));var o={axis:r[0]},a=[n];return Wt.runKernelFunc(function(t,e){var i=t.argMax(n,r[0]);return e([n]),i;},{x:n},function(t,e){var n=e[0];return {x:function x(){return Qn(n);}};},"ArgMax",o,a);}}),dc=Nn({argMin_:function argMin_(t,e){void 0===e&&(e=0);var n=xn(t,"x","argMin");null==e&&(e=0);var r=L(e,n.shape),i=_n(r,n.rank);return null!=i&&(n=n.transpose(i),r=Dn(r.length,n.rank)),Wt.runKernelFunc(function(t,e){var i=t.argMin(n,r[0]);return e([n]),i;},{$x:n},function(t,e){var n=e[0];return {$x:function $x(){return Qn(n);}};});}}),pc=Nn({logSumExp_:function logSumExp_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=xn(t,"x","logSumExp"),i=L(e,r.shape),o=r.max(i,!0),a=r.sub(o).exp().sum(i).log(),s=o.reshape(a.shape).add(a);if(n){var u=An(s.shape,i);return s.reshape(u);}return s;}}),mc=Nn({max_:function max_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=xn(t,"x","max"),i=r,o=L(e,r.shape),a=o,s=_n(a,r.rank);null!=s&&(r=r.transpose(s),a=Dn(a.length,r.rank));var u=[r],c=Wt.runKernelFunc(function(t,e){var n=t.max(r,a);return e([i,n]),n;},{x:r},function(t,e){return cc(t,e[1],e[0],o,s);},"Max",{axes:a},u,[!0]);if(n){var l=An(c.shape,o);c=c.reshape(l);}return c;}}),gc=Nn({mean_:function mean_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=xn(t,"x","mean"),i=L(e,r.shape),o=T(Cn(r.shape,i)[1]);return yi(function(t){var r=Pn(o);return {value:(r.dtype===t.dtype?t:t.cast(r.dtype)).div(r).sum(e,n),gradFunc:function gradFunc(e){var n=t.shape.slice();return i.forEach(function(t){n[t]=1;}),e.reshape(n).mul(Hn(t.shape,"float32")).div(o);}};})(r);}}),vc=Nn({min_:function min_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=xn(t,"x","min"),i=r,o=L(e,r.shape),a=o,s=_n(a,r.rank);null!=s&&(r=r.transpose(s),a=Dn(a.length,r.rank));var u=[r],c=Wt.runKernelFunc(function(t,e){var n=t.min(r,a);return e([i,n]),n;},{x:r},function(t,e){return cc(t,e[1],e[0],o,s);},"Min",{axes:a},u,[!0]);if(n){var l=An(c.shape,o);c=c.reshape(l);}return c;}}),yc=Nn({moments_:function moments_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=L(e,(t=xn(t,"x","moments")).shape),i=t.mean(r,n),o=i.shape;return n||(o=An(i.shape,r)),{mean:i,variance:t.toFloat().sub(i.reshape(o)).square().mean(r,n)};}}),bc=Nn({sum_:function sum_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=xn(t,"x","sum");"bool"===r.dtype&&(r=r.toInt());var i=L(e,r.shape);return yi(function(t){var e=_n(i,t.rank),r=i,o=t;null!=e&&(o=t.transpose(e),r=Dn(r.length,t.rank));var a=function a(e){var n=t.shape.slice();return i.forEach(function(t){n[t]=1;}),e.reshape(n).mul(Hn(t.shape,"float32"));},s={axes:r},u=Wt.runKernelFunc(function(t){return t.sum(o,r);},{x:o},function(t){return {x:function x(){return a(t);}};},"Sum",s);if(n){var c=An(u.shape,i);u=u.reshape(c);}return {value:u,gradFunc:a};})(r);}}),xc=Nn({prod_:function prod_(t,e,n){void 0===e&&(e=null),void 0===n&&(n=!1);var r=xn(t,"x","prod");"bool"===r.dtype&&(r=r.toInt());var i=L(e,r.shape),o=_n(i,r.rank),a=i,s=r;null!=o&&(s=r.transpose(o),a=Dn(a.length,r.rank));var u=Wt.runKernelFunc(function(t){return t.prod(s,a);},{permutedX:s});if(n){var c=An(u.shape,i);u=u.reshape(c);}return u;}}),wc=Nn({elu_:function elu_(t){var e=xn(t,"x","elu");return Wt.runKernelFunc(function(t,n){var r=t.elu(e);return n([r]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return Wt.runKernelFunc(function(e){return e.eluDer(t,n);},{dy:t,y:n});}};});}}),kc=Nn({leakyRelu_:function leakyRelu_(t,e){void 0===e&&(e=.2);var n=xn(t,"x","leakyRelu");return Zs(Pn(e).mul(n),n);}}),Ec=Nn({prelu_:function prelu_(t,e){var n=xn(t,"x","prelu"),r=xn(e,"alpha","prelu");return Wt.runKernelFunc(function(t,e){var i=t.prelu(n,r);return e([n,r]),i;},{x:n,alpha:r},function(t,e){var n=e[0],r=e[1],i=n.greater(0);return {x:function x(){return Vs(i,t,t.mul(r));},alpha:function alpha(){var e=Vs(i,Qn(t),t.mul(n)),o=Oi(r.shape,t.shape);return o.length>0&&(e=e.sum(o)),e.reshape(r.shape);}};},"Prelu");}}),Cc=Nn({relu_:function relu_(t){var e=xn(t,"x","relu");return "bool"===e.dtype?e.toInt():Wt.runKernelFunc(function(t,n){var r=t.relu(e);return n([e]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return t.mulStrict(n.step().toFloat());}};},"Relu");}}),Ac=Nn({relu6_:function relu6_(t){var e=xn(t,"x","relu6");return "bool"===e.dtype?e.toInt():Wt.runKernelFunc(function(t,n){var r=t.relu6(e);return n([e]),r;},{x:e},function(t,e){var n=e[0],r=n.lessEqual(6).mul(n.step());return {x:function x(){return t.mulStrict(r.toFloat());}};},"Relu6");}}),Oc=Nn({selu_:function selu_(t){var e=xn(t,"x","selu");return Wt.runKernelFunc(function(t,n){var r=t.selu(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){var e=n.greater(Pn(0)),r=Pn(ya),i=Pn(ba),o=t.mul(i),a=t.mul(r).mul(n.toFloat().exp());return Vs(e,o,a);}};});}}),_c=Nn({transpose_:function transpose_(t,e){var n=xn(t,"x","transpose");if(null==e&&(e=n.shape.map(function(t,e){return e;}).reverse()),_(n.rank===e.length,function(){return "Error in transpose: rank of input "+n.rank+" must match length of perm "+e+".";}),e.forEach(function(t){_(t>=0&&t<n.rank,function(){return "All entries in 'perm' must be between 0 and "+(n.rank-1)+" but got "+e;});}),n.rank<=1)return n.clone();var r={perm:e};return Wt.runKernelFunc(function(t){return t.transpose(n,e);},{x:n},function(t){var n=Sn(e);return {x:function x(){return t.transpose(n);}};},"Transpose",r);}}),Sc=Nn({localResponseNormalization_:function localResponseNormalization_(t,e,n,r,i){void 0===e&&(e=5),void 0===n&&(n=1),void 0===r&&(r=1),void 0===i&&(i=.5);var o=xn(t,"x","localResponseNormalization");_(4===o.rank||3===o.rank,function(){return "Error in localResponseNormalization: x must be rank 3 or 4 but got\n               rank "+o.rank+".";}),_(I(e),function(){return "Error in localResponseNormalization: depthRadius must be an integer but got depthRadius "+e+".";});var a=o,s=!1;3===o.rank&&(s=!0,a=o.as4D(1,o.shape[0],o.shape[1],o.shape[2]));var u=Wt.runKernelFunc(function(t,o){var s=t.localResponseNormalization4D(a,e,n,r,i);return o([a,s]),s;},{x4D:a},function(t,o){var a=o[0],s=o[1];return {x4D:function x4D(){return Wt.runKernelFunc(function(o){return o.LRNGrad(t,a,s,e,n,r,i);},{});}};});return s?u.as3D(u.shape[1],u.shape[2],u.shape[3]):u;}}),Dc=Nn({norm_:function norm_(t,e,n,r){void 0===e&&(e="euclidean"),void 0===n&&(n=null),void 0===r&&(r=!1);var i=function t(e,n,r){if(void 0===r&&(r=null),0===e.rank)return e.abs();if(1!==e.rank&&null===r)return t(e.reshape([-1]),n,r);if(1===e.rank||"number"==typeof r||Array.isArray(r)&&1===r.length){if(1===n)return e.abs().sum(r);if(n===1/0)return e.abs().max(r);if(n===-1/0)return e.abs().min(r);if("euclidean"===n||2===n)return e.abs().pow(Pn(2,"int32")).sum(r).sqrt();throw new Error("Error in norm: invalid ord value: "+n);}if(Array.isArray(r)&&2===r.length){if(1===n)return e.abs().sum(r[0]).max(r[1]-1);if(n===1/0)return e.abs().sum(r[1]).max(r[0]);if(n===-1/0)return e.abs().sum(r[1]).min(r[0]);if("fro"===n||"euclidean"===n)return e.square().sum(r).sqrt();throw new Error("Error in norm: invalid ord value: "+n);}throw new Error("Error in norm: invalid axis: "+r);}(t=xn(t,"x","norm"),e,n),o=i.shape;if(r){var a=L(n,t.shape);o=An(i.shape,a);}return i.reshape(o);}}),Fc=Nn({basicLSTMCell_:function basicLSTMCell_(t,e,n,r,i,o){var a=xn(t,"forgetBias","basicLSTMCell"),s=xn(e,"lstmKernel","basicLSTMCell"),u=xn(n,"lstmBias","basicLSTMCell"),c=xn(r,"data","basicLSTMCell"),l=xn(i,"c","basicLSTMCell"),f=xn(o,"h","basicLSTMCell"),h=c.concat(f,1).matMul(s).add(u),d=h.shape[0],p=h.shape[1]/4,m=[d,p],g=h.slice([0,0],m),v=h.slice([0,p],m),y=h.slice([0,2*p],m),b=h.slice([0,3*p],m),x=g.sigmoid().mulStrict(v.tanh()).addStrict(l.mulStrict(a.add(y).sigmoid()));return [x,x.tanh().mulStrict(b.sigmoid())];}}),Tc=Nn({multiRNNCell_:function multiRNNCell_(t,e,n,r){for(var i=xn(e,"data","multiRNNCell"),o=wn(n,"c","multiRNNCell"),a=wn(r,"h","multiRNNCell"),s=i,u=[],c=0;c<t.length;c++){var l=t[c](s,o[c],a[c]);u.push(l[0]),u.push(l[1]),s=l[1];}var f=[],h=[];for(c=0;c<u.length;c+=2){f.push(u[c]),h.push(u[c+1]);}return [f,h];}}),Nc=Nn({movingAverage_:function movingAverage_(t,e,n,r,i){void 0===i&&(i=!0);var o=xn(t,"v","movingAverage"),a=xn(e,"x","movingAverage"),s=xn(n,"decay","movingAverage");jt(o,a),_(N(o.shape,a.shape),function(){return "Shape mismatch in v and x";});var u=Pn(1),c=u.sub(s),l=a.sub(o).mul(c);if(i){_(null!=r,function(){return "When using zeroDebias: true, step is required.";});var f=xn(r,"step","movingAverage");l=l.div(u.sub(su(s,f)));}return o.add(l);}}),Ic=Nn({stridedSlice_:function stridedSlice_(t,e,n,r,i,o,a,s,u){if(void 0===i&&(i=0),void 0===o&&(o=0),void 0===a&&(a=0),void 0===s&&(s=0),void 0===u&&(u=0),null==r&&(r=new Array(e.length)),0!==a)throw new Error("ellipsis mask is not yet supported");var c=xn(t,"x","stridedSlice"),l=ai(s),f=c.shape.slice();l.forEach(function(t){e[t]=0,n[t]=1,f.splice(t,0,1);}),c=c.reshape(f);for(var h=0;h<c.rank;h++){e[h]=ui(i,e,r,c.shape,h),n[h]=ci(o,n,r,c.shape,h),r[h]=r[h]||1;}var d=ai(u);d.forEach(function(t){n[t]=e[t]+1,r[t]=1;});var p=si(e,n,r),m=p.filter(function(t,e){return -1===d.indexOf(e);});return r.every(function(t){return 1===t;})?ic(c,e,p).reshape(m):Wt.runKernelFunc(function(t){return t.stridedSlice(c,e,n,r);},{$x:c}).reshape(m);}}),Rc=Nn({topk_:function topk_(t,e,n){void 0===e&&(e=1),void 0===n&&(n=!0);var r=xn(t,"x","topk");if(0===r.rank)throw new Error("topk() expects the input to be of rank 1 or higher");var i=r.shape[r.shape.length-1];if(e>i)throw new Error("'k' passed to topk() must be <= the last dimension ("+i+") but got "+e);var o=Wt.runKernelFunc(function(t){return t.topk(r,e,n);},{$x:r});return {values:o[0],indices:o[1]};}}),Mc=Nn({scatterND_:function scatterND_(t,e,n){var r=xn(t,"indices","scatterND","int32"),i=xn(e,"updates","scatterND");return ni(i,r,n),Wt.runKernelFunc(function(t){return t.scatterND(r,i,n);},{indices:r,updates:i},null,"ScatterNd",{shape:n});}}),jc=Nn({fft_:function fft_(t){_("complex64"===t.dtype,function(){return "The dtype for tf.spectral.fft() must be complex64 but got "+t.dtype+".";});var e=t.shape[t.shape.length-1],n=t.size/e,r=t.as2D(n,e);return Wt.runKernelFunc(function(t){return t.fft(r);},{input:t}).reshape(t.shape);}}),Bc=Nn({ifft_:function ifft_(t){_("complex64"===t.dtype,function(){return "The dtype for tf.spectral.ifft() must be complex64 but got "+t.dtype+".";});var e=t.shape[t.shape.length-1],n=t.size/e,r=t.as2D(n,e);return Wt.runKernelFunc(function(t){return t.ifft(r);},{input:t}).reshape(t.shape);}}),Pc=Nn({rfft_:function rfft_(t,e){_("float32"===t.dtype,function(){return "The dtype for rfft() must be real value but got "+t.dtype;});var n,r=t.shape[t.shape.length-1],i=t.size/r;if(null!=e&&e<r){var o=t.shape.map(function(t){return 0;}),a=t.shape.map(function(t){return t;});a[t.shape.length-1]=e,n=t.slice(o,a),r=e;}else if(null!=e&&e>r){var s=t.shape.map(function(t){return t;});s[t.shape.length-1]=e-r,n=t.concat(Gn(s),t.shape.length-1),r=e;}else n=t;var u=n.zerosLike(),c=In(n,u).as2D(i,r),l=jc(c),f=Math.floor(r/2)+1,h=Rn(l),d=Mn(l),p=h.split([f,r-f],h.shape.length-1),m=d.split([f,r-f],d.shape.length-1),g=n.shape.slice();return g[n.shape.length-1]=f,In(p[0],m[0]).reshape(g);}}),Lc=Nn({irfft_:function irfft_(t){var e=t.shape[t.shape.length-1],n=t.size/e;if(e<=2){var r=t.as2D(n,e),i=Bc(r);return Rn(i);}var o=[n,2*(e-1)],a=Rn(t).as2D(n,e),s=Mn(t).as2D(n,e),u=a.slice([0,1],[n,e-2]).reverse(1),c=s.slice([0,1],[n,e-2]).reverse(1).mul(Pn(-1)),l=a.concat(u,1),f=s.concat(c,1);return r=In(l,f).as2D(o[0],o[1]),i=Bc(r),Rn(i);}}),zc=Object.freeze({fft:jc,ifft:Bc,rfft:Pc,irfft:Lc}),Uc=Nn({sparseToDense_:function sparseToDense_(t,e,n,r){void 0===r&&(r=0);var i=xn(t,"sparseIndices","sparseToDense","int32"),o=xn(e,"sparseValues","sparseToDense"),a=xn(r,"defaultValue","sparseToDense",o.dtype);return function(t,e,n,r){if("int32"!==t.dtype)throw new Error("tf.sparseToDense() expects the indices to be int32 type, but the dtype was "+t.dtype+".");if(t.rank>2)throw new Error("sparseIndices should be a scalar, vector, or matrix, but got shape "+t.shape+".");var i=t.rank>0?t.shape[0]:1,o=t.rank>1?t.shape[1]:1;if(n.length!==o)throw new Error("outputShape has incorrect number of elements:, "+n.length+", should be: "+o+".");var a=e.size;if(0!==e.rank&&(1!==e.rank||a!==i))throw new Error("sparseValues has incorrect shape "+e.shape+", should be [] or ["+i+"]");if(e.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype");}(i,o,n,a),Wt.runKernelFunc(function(t){return t.sparseToDense(i,o,n,a);},{$sparseIndices:i,$sparseValues:o,$defaultValue:a});}}),Wc=Nn({gatherND_:function gatherND_(t,e){var n=xn(e,"indices","gatherND","int32"),r=xn(t,"x","gatherND");return Wt.runKernelFunc(function(t){return t.gatherND(r,n);},{x:r,indices:n},null,"GatherNd");}}),Vc=Nn({diag_:function diag_(t){var e=xn(t,"x","diag").flatten(),n=t.shape.concat(t.shape);return Wt.runKernelFunc(function(t){return t.diag(e);},{$x:e}).reshape(n);}}),qc=Nn({dropout_:function dropout_(t,e,n,r){var i=xn(t,"x","dropout");if(_("float32"===i.dtype,function(){return "x has to be a floating point tensor since it's going to be scaled, but got a "+i.dtype+" tensor instead.";}),_(e>=0&&e<1,function(){return "rate must be a float in the range [0, 1), but got "+e+".";}),0===e)return t instanceof At?i.clone():i;var o=function(t,e){if(null==e)return t.shape.slice();if(N(t.shape,e))return e;if(t.shape.length===e.length){for(var n=[],r=0;r<t.shape.length;r++){null==e[r]&&null!=t.shape[r]?n.push(t.shape[r]):n.push(e[r]);}return n;}return e;}(i,n),a=1-e,s=Br(o,0,1,"float32",r).add(a).floor().div(a);return i.mul(s);}});function $c(t,e,n){for(var r=1-t%2,i=new Float32Array(t),o=0;o<t;++o){var a=2*Math.PI*o/(t+r-1);i[o]=e-n*Math.cos(a);}return Ln(i,"float32");}var Hc,Gc=Nn({hannWindow_:function hannWindow_(t){return $c(t,.5,.5);}}),Kc=Nn({hammingWindow_:function hammingWindow_(t){return $c(t,.54,.46);}}),Xc=Nn({frame_:function frame_(t,e,n,r,i){void 0===r&&(r=!1),void 0===i&&(i=0);for(var o=0,a=[];o+e<=t.size;){a.push(ic(t,o,e)),o+=n;}if(r)for(;o<t.size;){var s=o+e-t.size,u=Zn([ic(t,o,e-s),Kn([s],i)]);a.push(u),o+=n;}return 0===a.length?zn([],[0,e]):Zn(a).as2D(a.length,e);}}),Yc=Nn({stft_:function stft_(t,e,n,r,i){var o;void 0===i&&(i=Gc),null==r&&(o=e,r=Math.floor(Math.pow(2,Math.ceil(Math.log(o)/Math.log(2)))));for(var a=Xc(t,e,n),s=ou(a,i(e)),u=[],c=0;c<a.shape[0];c++){u.push(Pc(s.slice([c,0],[1,e]),r));}return Zn(u);}}),Jc=Object.freeze({hannWindow:Gc,hammingWindow:Kc,frame:Xc,stft:Yc}),Qc=function Qc(t,e,n){return void 0===n&&(n=1),u(this,void 0,void 0,function(){var r,i,o,a,s,u,l,f,h,d,p,m,g,v;return c(this,function(c){switch(c.label){case 0:return r=xn(t,"predictions","inTopK"),i=xn(e,"targets","inTopK"),_(r.rank>1,function(){return "inTopK() expects the predictions to be of rank 2 or higher, but got "+r.rank;}),_(r.rank-1===i.rank,function(){return "predictions rank should be 1 larger than targets rank, but got predictions rank "+r.rank+" and targets rank "+i.rank;}),S(r.shape.slice(0,r.shape.length-1),i.shape,"predictions's shape should be align with the targets' shape, except the last dimension."),o=r.shape[r.shape.length-1],_(n>0&&n<=o,function(){return "'k' passed to inTopK() must be > 0 && <= the predictions last dimension ("+o+"), but got "+n;}),[4,r.data()];case 1:return a=c.sent(),[4,i.data()];case 2:for(s=c.sent(),u=[a.length/o,o],f=u[1],h=U("bool",l=u[0]),d=0;d<l;d++){for(p=d*f,m=a.subarray(p,p+f),g=[],v=0;v<m.length;v++){g.push({value:m[v],index:v});}for(g.sort(function(t,e){return e.value-t.value;}),h[d]=0,v=0;v<n;v++){if(g[v].index===s[d]){h[d]=1;break;}}}return t!==r&&r.dispose(),e!==i&&i.dispose(),[2,jn(h,i.shape,"bool")];}});});};!function(t){t[t.NONE=0]="NONE",t[t.MEAN=1]="MEAN",t[t.SUM=2]="SUM",t[t.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS";}(Hc||(Hc={}));var Zc=Nn({absoluteDifference_:function absoluteDifference_(t,e,n,r){void 0===r&&(r=Hc.SUM_BY_NONZERO_WEIGHTS);var i=xn(t,"labels","absoluteDifference"),o=xn(e,"predictions","absoluteDifference"),a=null;null!=n&&(a=xn(n,"weights","absoluteDifference")),S(i.shape,o.shape,"Error in absoluteDifference: ");var s=i.sub(o).abs();return tl(s,a,r);}}),tl=Nn({computeWeightedLoss_:function computeWeightedLoss_(t,e,n){void 0===n&&(n=Hc.SUM_BY_NONZERO_WEIGHTS);var r=xn(t,"losses","computeWeightedLoss"),i=null;null!=e&&(i=xn(e,"weights","computeWeightedLoss"));var o=null==i?r:r.mul(i);if(n===Hc.NONE)return o;if(n===Hc.SUM)return o.sum();if(n===Hc.MEAN){if(null==i)return o.mean();var a=r.size/i.size,s=o.sum().div(i.sum());return a>1?s.div(Pn(a)):s;}if(n===Hc.SUM_BY_NONZERO_WEIGHTS){if(null==i)return o.sum().div(Pn(r.size));var u=i.mul(Hn(r.shape)).notEqual(Pn(0)).sum().toFloat();return o.sum().div(u);}throw Error("Unknown reduction: "+n);}}),el=Nn({cosineDistance_:function cosineDistance_(t,e,n,r,i){void 0===i&&(i=Hc.SUM_BY_NONZERO_WEIGHTS);var o=xn(t,"labels","cosineDistance"),a=xn(e,"predictions","cosineDistance"),s=null;null!=r&&(s=xn(r,"weights","cosineDistance")),S(o.shape,a.shape,"Error in cosineDistance: ");var u=Pn(1).sub(o.mul(a).sum(n,!0));return tl(u,s,i);}}),nl=Nn({hingeLoss_:function hingeLoss_(t,e,n,r){void 0===r&&(r=Hc.SUM_BY_NONZERO_WEIGHTS);var i=xn(t,"labels","hingeLoss"),o=xn(e,"predictions","hingeLoss"),a=null;null!=n&&(a=xn(n,"weights","hingeLoss")),S(i.shape,o.shape,"Error in hingeLoss: ");var s=Pn(1);i=Pn(2).mul(i).sub(s);var u=s.sub(i.mul(o)).relu();return tl(u,a,r);}}),rl=Nn({huberLoss_:function huberLoss_(t,e,n,r,i){void 0===r&&(r=1),void 0===i&&(i=Hc.SUM_BY_NONZERO_WEIGHTS);var o=xn(t,"labels","huberLoss"),a=xn(e,"predictions","huberLoss"),s=null;null!=n&&(s=xn(n,"weights","huberLoss")),S(o.shape,a.shape,"Error in huberLoss: ");var u=Pn(r),c=a.sub(o).abs(),l=eu(c,u),f=c.sub(l),h=Pn(.5).mul(l.square()).add(u.mul(f));return tl(h,s,i);}}),il=Nn({logLoss_:function logLoss_(t,e,n,r,i){void 0===r&&(r=1e-7),void 0===i&&(i=Hc.SUM_BY_NONZERO_WEIGHTS);var o=xn(t,"labels","logLoss"),a=xn(e,"predictions","logLoss"),s=null;null!=n&&(s=xn(n,"weights","logLoss")),S(o.shape,a.shape,"Error in logLoss: ");var u=Pn(1),c=Pn(r),l=o.mul(a.add(c).log()).neg().sub(u.sub(o).mul(u.sub(a).add(c).log()));return tl(l,s,i);}}),ol=Nn({meanSquaredError_:function meanSquaredError_(t,e,n,r){void 0===r&&(r=Hc.SUM_BY_NONZERO_WEIGHTS);var i=xn(t,"labels","meanSquaredError"),o=xn(e,"predictions","meanSquaredError"),a=null;null!=n&&(a=xn(n,"weights","meanSquaredError")),S(i.shape,o.shape,"Error in meanSquaredError: ");var s=i.squaredDifference(o);return tl(s,a,r);}}),al=Nn({sigmoidCrossEntropy_:function sigmoidCrossEntropy_(t,e,n,r,i){void 0===r&&(r=0),void 0===i&&(i=Hc.SUM_BY_NONZERO_WEIGHTS);var o=xn(t,"multiClassLabels","sigmoidCrossEntropy"),a=xn(e,"logits","sigmoidCrossEntropy"),s=null;if(null!=n&&(s=xn(n,"weights","sigmoidCrossEntropy")),S(o.shape,a.shape,"Error in sigmoidCrossEntropy: "),r>0){var u=Pn(r),c=Pn(1),l=Pn(.5);o=o.mul(c.sub(u)).add(l.mul(u));}var f=function(t,e){var n=xn(t,"labels","sigmoidCrossEntropyWithLogits"),r=xn(e,"logits","sigmoidCrossEntropyWithLogits");S(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");var i=r.relu(),o=r.mul(n),a=r.abs().neg().exp().log1p();return i.sub(o).add(a);}(o,a);return tl(f,s,i);}}),sl=Nn({softmaxCrossEntropy_:function softmaxCrossEntropy_(t,e,n,r,i){void 0===r&&(r=0),void 0===i&&(i=Hc.SUM_BY_NONZERO_WEIGHTS);var o=xn(t,"onehotLabels","softmaxCrossEntropy"),a=xn(e,"logits","softmaxCrossEntropy"),s=null;if(null!=n&&(s=xn(n,"weights","softmaxCrossEntropy")),S(o.shape,a.shape,"Error in softmaxCrossEntropy: "),r>0){var u=Pn(r),c=Pn(1),l=Pn(o.shape[1]);o=o.mul(c.sub(u)).add(u.div(l));}var f=function(t,e,n){if(void 0===n&&(n=-1),-1===n&&(n=e.rank-1),n!==e.rank-1)throw Error("Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank "+e.rank+" and dim was "+n);return yi(function(t,e,r){var i=e.logSumExp([n],!0),o=e.toFloat().sub(i);return r([t,o]),{value:o.mul(t).neg().sum([n]),gradFunc:function gradFunc(t,e){var r=e[0],i=e[1],o=An(t.shape,[n]);return [t.reshape(o).mul(r.toFloat().sub(i.exp())),t.reshape(o).mul(i.exp().sub(r.toFloat()))];}};})(t,e);}(o,a);return tl(f,s,i);}}),ul=Object.freeze({get Reduction(){return Hc;},absoluteDifference:Zc,computeWeightedLoss:tl,cosineDistance:el,hingeLoss:nl,huberLoss:rl,logLoss:il,meanSquaredError:ol,sigmoidCrossEntropy:al,softmaxCrossEntropy:sl});function cl(t,e){return void 0===e&&(e=!1),Wt.tidy(function(){if(2!==t.shape.length)throw new Error("qr2d() requires a 2D Tensor, but got a "+t.shape.length+"D Tensor.");for(var n=t.shape[0],r=t.shape[1],i=Or(n),o=t.clone(),a=zn([[1]],[1,1]),s=a.clone(),u=n>=r?r:n,c=function c(t){var e,u=o,c=s,l=i;e=Wt.tidy(function(){var e=o.slice([t,t],[n-t,1]),u=e.norm(),c=o.slice([t,t],[1,1]),l=zn([[-1]]).where(c.greater(0),zn([[1]])),f=c.sub(l.mul(u)),h=e.div(f);s=1===h.shape[0]?a.clone():a.concat(h.slice([1,0],[h.shape[0]-1,h.shape[1]]),0);var d=l.matMul(f).div(u).neg(),p=o.slice([t,0],[n-t,r]),m=d.mul(s);if(0===t)o=p.sub(m.matMul(s.transpose().matMul(p)));else {var g=p.sub(m.matMul(s.transpose().matMul(p)));o=o.slice([0,0],[t,r]).concat(g,0);}var v=i.slice([0,t],[n,i.shape[1]-t]);if(0===t)i=v.sub(v.matMul(s).matMul(m.transpose()));else {var y=v.sub(v.matMul(s).matMul(m.transpose()));i=i.slice([0,0],[n,t]).concat(y,1);}return [s,o,i];}),s=e[0],o=e[1],i=e[2],on([u,c,l]);},l=0;l<u;++l){c(l);}return !e&&n>r&&(i=i.slice([0,0],[n,r]),o=o.slice([0,0],[r,r])),[i,o];});}var ll=Nn({bandPart_:function bandPart_(t,e,n){if(e%1!=0)throw new Error("bandPart(): numLower must be an integer, got "+e+".");if(n%1!=0)throw new Error("bandPart(): numUpper must be an integer, got "+n+".");var r=xn(t,"a","bandPart");if(r.rank<2)throw new Error("bandPart(): Rank must be at least 2, got "+r.rank+".");var i=r.shape,o=r.shape.slice(-2),a=o[0],s=o[1];if(!(e<=a))throw new Error("bandPart(): numLower ("+e+") must not be greater than the number of rows ("+a+").");if(!(n<=s))throw new Error("bandPart(): numUpper ("+n+") must not be greater than the number of columns ("+s+").");e<0&&(e=a),n<0&&(n=s);var u=Yn(0,a,1,"int32").reshape([-1,1]),c=Yn(0,s,1,"int32"),l=lu(u,c),f=Ls(l.lessEqual(Pn(+e,"int32")),l.greaterEqual(Pn(-n,"int32"))),h=Gn([a,s],r.dtype);return Ur(qr(r.reshape([-1,a,s])).map(function(t){return Vs(f,t,h);})).reshape(i);}}),fl=Nn({gramSchmidt_:function gramSchmidt_(t){var e;if(Array.isArray(t)){e=!1,_(null!=t&&t.length>0,function(){return "Gram-Schmidt process: input must not be null, undefined, or empty";});for(var n=t[0].shape[0],r=function r(e){_(t[e].shape[0]===n,function(){return "Gram-Schmidt: Non-unique lengths found in the input vectors: ("+t[e].shape[0]+" vs. "+n+")";});},i=1;i<t.length;++i){r(i);}}else e=!0,t=ir(t,t.shape[0],0).map(function(t){return zr(t,[0]);});_(t.length<=t[0].shape[0],function(){return "Gram-Schmidt: Number of vectors ("+t.length+") exceeds number of dimensions ("+t[0].shape[0]+").";});var o=[],a=t,s=function s(t){o.push(Wt.tidy(function(){var e=a[t];if(t>0)for(var n=0;n<t;++n){var r=bc(o[n].mulStrict(e)).mul(o[n]);e=e.sub(r);}return e.div(Dc(e,"euclidean"));}));};for(i=0;i<t.length;++i){s(i);}return e?Ur(o,0):o;}}),hl=Nn({qr_:function qr_(t,e){if(void 0===e&&(e=!1),t.rank<2)throw new Error("qr() requires input tensor to have a rank >= 2, but got rank "+t.rank);if(2===t.rank)return cl(t,e);var n=t.shape.slice(0,t.shape.length-2).reduce(function(t,e){return t*e;}),r=[],i=[];return qr(t.reshape([n,t.shape[t.shape.length-2],t.shape[t.shape.length-1]]),0).forEach(function(t){var n=cl(t,e),o=n[0],a=n[1];r.push(o),i.push(a);}),[Ur(r,0).reshape(t.shape),Ur(i,0).reshape(t.shape)];}}),dl=Object.freeze({bandPart:ll,gramSchmidt:fl,qr:hl});function pl(t,e,n,r,i,o){null==r&&(r=.5),null==i&&(i=Number.NEGATIVE_INFINITY),null==o&&(o=0);var a=t.shape[0];return n=Math.min(n,a),_(0<=r&&r<=1,function(){return "iouThreshold must be in [0, 1], but was '"+r+"'";}),_(2===t.rank,function(){return "boxes must be a 2D tensor, but was of rank '"+t.rank+"'";}),_(4===t.shape[1],function(){return "boxes must have 4 columns, but 2nd dimension was "+t.shape[1];}),_(1===e.rank,function(){return "scores must be a 1D tensor";}),_(e.shape[0]===a,function(){return "scores has incompatible shape with boxes. Expected "+a+", but was "+e.shape[0];}),_(0<=o&&o<=1,function(){return "softNmsSigma must be in [0, 1], but was '"+o+"'";}),{maxOutputSize:n,iouThreshold:r,scoreThreshold:i,softNmsSigma:o};}var ml=Nn({resizeBilinear_:function resizeBilinear_(t,e,n){void 0===n&&(n=!1);var r=xn(t,"images","resizeBilinear");_(3===r.rank||4===r.rank,function(){return "Error in resizeBilinear: x must be rank 3 or 4, but got rank "+r.rank+".";}),_(2===e.length,function(){return "Error in resizeBilinear: new shape must 2D, but got shape "+e+".";});var i=r,o=!1;3===r.rank&&(o=!0,i=r.as4D(1,r.shape[0],r.shape[1],r.shape[2]));var a=e[0],s=e[1],u=Wt.runKernelFunc(function(t,e){return e([i]),t.resizeBilinear(i,a,s,n);},{x:i},function(t,e){return {x:function x(){return Wt.runKernelFunc(function(r){return r.resizeBilinearBackprop(t,e[0],n);},{});}};},"ResizeBilinear",{alignCorners:n,newHeight:a,newWidth:s});return o?u.as3D(u.shape[1],u.shape[2],u.shape[3]):u;}}),gl=Nn({resizeNearestNeighbor_:function resizeNearestNeighbor_(t,e,n){void 0===n&&(n=!1);var r=xn(t,"images","resizeNearestNeighbor");_(3===r.rank||4===r.rank,function(){return "Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank "+r.rank+".";}),_(2===e.length,function(){return "Error in resizeNearestNeighbor: new shape must 2D, but got shape "+e+".";}),_("float32"===r.dtype||"int32"===r.dtype,function(){return "`images` must have `int32` or `float32` as dtype";});var i=r,o=!1;3===r.rank&&(o=!0,i=r.as4D(1,r.shape[0],r.shape[1],r.shape[2]));var a=e[0],s=e[1],u=Wt.runKernelFunc(function(t,e){return e([i]),t.resizeNearestNeighbor(i,a,s,n);},{batchImages:i},function(t,e){return {batchImages:function batchImages(){return Wt.runKernelFunc(function(r){return r.resizeNearestNeighborBackprop(t,e[0],n);},{});}};});return o?u.as3D(u.shape[1],u.shape[2],u.shape[3]):u;}}),vl=Nn({nonMaxSuppression_:function nonMaxSuppression_(t,e,n,r,i){void 0===r&&(r=.5),void 0===i&&(i=Number.NEGATIVE_INFINITY);var o=xn(t,"boxes","nonMaxSuppression"),a=xn(e,"scores","nonMaxSuppression"),s=pl(o,a,n,r,i);n=s.maxOutputSize,r=s.iouThreshold,i=s.scoreThreshold;var u={maxOutputSize:n,iouThreshold:r,scoreThreshold:i};return Wt.runKernelFunc(function(t){return t.nonMaxSuppression(o,a,n,r,i);},{boxes:o,scores:a},null,"NonMaxSuppressionV3",u);}}),yl=Nn({nonMaxSuppressionWithScore_:function nonMaxSuppressionWithScore_(t,e,n,r,i,o){void 0===r&&(r=.5),void 0===i&&(i=Number.NEGATIVE_INFINITY),void 0===o&&(o=0);var a=xn(t,"boxes","nonMaxSuppression"),s=xn(e,"scores","nonMaxSuppression"),u=pl(a,s,n,r,i,o),c={maxOutputSize:n=u.maxOutputSize,iouThreshold:r=u.iouThreshold,scoreThreshold:i=u.scoreThreshold,softNmsSigma:o=u.softNmsSigma},l=Wt.runKernel("NonMaxSuppressionV5",{boxes:a,scores:s},c);return {selectedIndices:l[0],selectedScores:l[1]};}}),bl=Nn({cropAndResize_:function cropAndResize_(t,e,n,r,i,o){var a=xn(t,"image","cropAndResize"),s=xn(e,"boxes","cropAndResize","float32"),u=xn(n,"boxInd","cropAndResize","int32");i=i||"bilinear",o=o||0;var c=s.shape[0];return _(4===a.rank,function(){return "Error in cropAndResize: image must be rank 4,but got rank "+a.rank+".";}),_(2===s.rank&&4===s.shape[1],function(){return "Error in cropAndResize: boxes must be have size ["+c+",4] but had shape "+s.shape+".";}),_(1===u.rank&&u.shape[0]===c,function(){return "Error in cropAndResize: boxInd must be have size ["+c+"] but had shape "+s.shape+".";}),_(2===r.length,function(){return "Error in cropAndResize: cropSize must be of length 2, but got length "+r.length+".";}),_(r[0]>=1&&r[1]>=1,function(){return "cropSize must be atleast [1,1], but was "+r;}),_("bilinear"===i||"nearest"===i,function(){return "method must be bilinear or nearest, but was "+i;}),Wt.runKernelFunc(function(t,e){return t.cropAndResize(a,s,u,r,i,o);},{images:a,boxes:s,boxInd:u},null,"CropAndResize",{method:i,extrapolationValue:o,cropSize:r});}}),xl=Object.freeze({resizeBilinear:ml,resizeNearestNeighbor:gl,nonMaxSuppression:vl,nonMaxSuppressionAsync:function nonMaxSuppressionAsync(t,e,n,r,i){return void 0===r&&(r=.5),void 0===i&&(i=Number.NEGATIVE_INFINITY),u(this,void 0,void 0,function(){var o,a,s,u,l,f,h;return c(this,function(c){switch(c.label){case 0:return o=xn(t,"boxes","nonMaxSuppressionAsync"),a=xn(e,"scores","nonMaxSuppressionAsync"),s=pl(o,a,n,r,i),n=s.maxOutputSize,r=s.iouThreshold,i=s.scoreThreshold,[4,Promise.all([o.data(),a.data()])];case 1:return u=c.sent(),l=u[0],f=u[1],h=Yi(l,f,n,r,i),o!==t&&o.dispose(),a!==e&&a.dispose(),[2,h];}});});},nonMaxSuppressionWithScore:yl,nonMaxSuppressionWithScoreAsync:function nonMaxSuppressionWithScoreAsync(t,e,n,r,i,o){return void 0===r&&(r=.5),void 0===i&&(i=Number.NEGATIVE_INFINITY),void 0===o&&(o=0),u(this,void 0,void 0,function(){var a,s,u,l,f,h,d;return c(this,function(c){switch(c.label){case 0:return a=xn(t,"boxes","nonMaxSuppressionAsync"),s=xn(e,"scores","nonMaxSuppressionAsync"),u=pl(a,s,n,r,i,o),n=u.maxOutputSize,r=u.iouThreshold,i=u.scoreThreshold,o=u.softNmsSigma,[4,Promise.all([a.data(),s.data()])];case 1:return l=c.sent(),f=l[0],h=l[1],d=Ji(f,h,n,r,i,o),a!==t&&a.dispose(),s!==e&&s.dispose(),[2,d];}});});},cropAndResize:bl}),wl=function wl(t,e){return !(t>0)||"linear"===e;},kl=function kl(t,e,n){if(null==n||"linear"===n)return t;if("relu"===n)return t.mul(e.step());throw new Error("Gradient for activation "+n+" has not been implemented yet.");},El=function El(t,e){var n=e,r=Oi(t.shape,e.shape);return r.length>0&&(n=n.sum(r)),n.reshape(t.shape);},Cl=function Cl(t,e,n){if("linear"===e)return t;if("relu"===e)return Cc(t);if("elu"===e)return wc(t);if("relu6"===e)return Ac(t);if("prelu"===e)return Ec(t,n);throw new Error("Unknown fused activation "+e+".");},Al=Nn({fusedMatMul_:function fusedMatMul_(t){var e,n=t.a,r=t.b,i=t.transposeA,o=void 0!==i&&i,a=t.transposeB,s=void 0!==a&&a,u=t.bias,c=t.activation,l=void 0===c?"linear":c,f=t.preluActivationWeights;if(!1===wl(Wt.state.gradientDepth,l)){var h=Vu(n,r,o,s);return null!=u&&(h=$s(h,u)),Cl(h,l,f);}var d=xn(n,"a","fused matMul"),p=xn(r,"b","fused matMul");e=Mt(d,p),d=e[0],p=e[1];var m=o?d.shape[d.rank-2]:d.shape[d.rank-1],g=s?p.shape[p.rank-1]:p.shape[p.rank-2],v=o?d.shape[d.rank-1]:d.shape[d.rank-2],y=s?p.shape[p.rank-2]:p.shape[p.rank-1],b=d.shape.slice(0,-2),x=p.shape.slice(0,-2),w=T(b),k=T(x);_(d.rank>=2&&p.rank>=2&&d.rank===p.rank,function(){return "Error in fused matMul: inputs must have the same rank of at least 2, got ranks "+d.rank+" and "+p.rank+".";}),_(N(b,x),function(){return "Error in fused matMul: outer dimensions ("+b+") and ("+x+") of Tensors with shapes "+d.shape+" and "+p.shape+" must match.";}),_(m===g,function(){return "Error in fused matMul: inner shapes ("+m+") and ("+g+") of Tensors with shapes "+d.shape+" and "+p.shape+" and transposeA="+o+" and transposeB="+s+" must match.";});var E,C,A=d.shape.slice(0,-2).concat([v,y]),O=o?d.as3D(w,m,v):d.as3D(w,v,m),S=s?p.as3D(k,y,g):p.as3D(k,g,y);null!=u&&_i(A,(E=Mt(E=xn(u,"bias","fused matMul"),d)[0]).shape),null!=f&&(C=xn(f,"prelu weights","fused matMul"));var D={a:O,b:S};null!=u&&(D.bias=E),null!=f&&(D.preluActivationWeights=C);var F=[O,S];return Wt.runKernelFunc(function(t,e){var n=t.fusedBatchMatMul({a:O,b:S,transposeA:o,transposeB:s,bias:E,activation:l,preluActivationWeights:C});return e([O,S,n]),n;},D,function(t,e){var n=e[0],r=e[1],i=e[2],_a7=kl(t,i,l),c={};return null!=u&&(c={bias:function bias(){return El(E,_a7);}}),o||s?!o&&s?Object.assign({a:function a(){return _a7.matMul(r,!1,!1);},b:function b(){return _a7.matMul(n,!0,!1);}},c):o&&!s?Object.assign({a:function a(){return r.matMul(_a7,!1,!0);},b:function b(){return n.matMul(_a7,!1,!1);}},c):Object.assign({a:function a(){return r.matMul(_a7,!0,!0);},b:function b(){return _a7.matMul(n,!0,!0);}},c):Object.assign({a:function a(){return _a7.matMul(r,!1,!0);},b:function b(){return n.matMul(_a7,!0,!1);}},c);},"_FusedMatMul",{transposeA:o,transposeB:s,activation:l},F,[!0]).reshape(A);}}),Ol=Nn({fusedConv2d_:function fusedConv2d_(t){var e=t.x,n=t.filter,r=t.strides,i=t.pad,o=t.dataFormat,a=void 0===o?"NHWC":o,s=t.dilations,u=void 0===s?[1,1]:s,c=t.dimRoundingMode,l=t.bias,f=t.activation,h=void 0===f?"linear":f,d=t.preluActivationWeights;if(h=h||"linear",!1===wl(Wt.state.gradientDepth,h)){var p=Iu(e,n,r,i,a,u,c);return null!=l&&(p=$s(p,l)),Cl(p,h,d);}var m=xn(e,"x","conv2d"),g=xn(n,"filter","conv2d"),v=m,y=!1;3===m.rank&&(y=!0,v=m.as4D(1,m.shape[0],m.shape[1],m.shape[2])),_(4===v.rank,function(){return "Error in fused conv2d: input must be rank 4, but got rank "+v.rank+".";}),_(4===g.rank,function(){return "Error in fused conv2d: filter must be rank 4, but got rank "+g.rank+".";}),null!=c&&_(I(i),function(){return "Error in fused conv2d: pad must be an integer when using, dimRoundingMode "+c+" but got pad "+i+".";}),_(v.shape[3]===g.shape[2],function(){return "Error in conv2d: depth of input ("+v.shape[3]+") must match input depth for filter "+g.shape[2]+".";}),_(Pi(r,u),function(){return "Error in conv2D: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+u+"'";}),_("NHWC"===a,function(){return "Error in conv2d: got dataFormat of "+a+" but only NHWC is currently supported.";});var b,x,w=Fi(v.shape,g.shape,r,u,i,c);null!=l&&(b=Mt(b=xn(l,"bias","fused conv2d"),m)[0],_i(w.outShape,b.shape)),null!=d&&(x=xn(d,"prelu weights","fused conv2d"));var k={x:v,filter:g};null!=l&&(k.bias=b),null!=d&&(k.preluActivationWeights=x);var E=[g,v],C=Wt.runKernelFunc(function(t,e){var n=t.fusedConv2d({input:v,filter:g,convInfo:w,bias:b,activation:h,preluActivationWeights:x});return e([g,v,n]),n;},k,function(t,e){var n=e,o=n[0],a=n[1],s=n[2],c=kl(t,s,h);_(Bi(u),function(){return "Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '"+u+"'";});var f={};return null!=l&&(f={bias:function bias(){return El(b,c);}}),Object.assign({x:function x(){return ju(a.shape,c,o,r,i);},filter:function filter(){return Mu(a,c,o.shape,r,i);}},f);},"FusedConv2D",{convInfo:w,activation:h},E,[!0]);return y?C.as3D(C.shape[1],C.shape[2],C.shape[3]):C;}}),_l=Nn({fusedDepthwiseConv2d_:function fusedDepthwiseConv2d_(t){var e=t.x,n=t.filter,r=t.strides,i=t.pad,o=t.dataFormat,a=void 0===o?"NHWC":o,s=t.dilations,u=void 0===s?[1,1]:s,c=t.dimRoundingMode,l=t.bias,f=t.activation,h=void 0===f?"linear":f,d=t.preluActivationWeights;if(!1===wl(Wt.state.gradientDepth,h)){var p=Bu(e,n,r,i,a,u,c);return null!=l&&(p=$s(p,l)),Cl(p,h,d);}var m=xn(e,"x","depthwiseConv2d"),g=xn(n,"filter","depthwiseConv2d"),v=m,y=!1;3===m.rank&&(y=!0,v=m.as4D(1,m.shape[0],m.shape[1],m.shape[2])),_(4===v.rank,function(){return "Error in fused depthwiseConv2d: input must be rank 4, but got rank "+v.rank+".";}),_(4===g.rank,function(){return "Error in fused depthwiseConv2d: filter must be rank 4, but got rank "+g.rank+".";}),_(v.shape[3]===g.shape[2],function(){return "Error in fused depthwiseConv2d: number of input channels ("+v.shape[3]+") must match the inChannels dimension in filter "+g.shape[2]+".";}),null==u&&(u=[1,1]),_(Pi(r,u),function(){return "Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides "+r+" and dilations '"+u+"'";}),null!=c&&_(I(i),function(){return "Error in fused depthwiseConv2d: pad must be an integer when using dimRoundingMode "+c+" but got pad "+i+".";});var b,x,w=Fi(v.shape,g.shape,r,u,i,c,!0);null!=l&&(b=Mt(b=xn(l,"bias","fused conv2d"),m)[0],_i(w.outShape,b.shape)),null!=d&&(x=xn(d,"prelu weights","fused depthwiseConv2d"));var k={x:v,filter:g};null!=l&&(k.bias=b),null!=d&&(k.preluActivationWeights=x);var E=[g,v],C=Wt.runKernelFunc(function(t,e){var n=t.fusedDepthwiseConv2D({input:v,filter:g,convInfo:w,bias:b,activation:h,preluActivationWeights:x});return e([g,v,n]),n;},k,function(t,e){_(Bi(u),function(){return "Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '"+u+"'";});var n=e[0],r=e[1],i=e[2],o=kl(t,i,h),a={};return null!=l&&(a={bias:function bias(){return El(b,o);}}),Object.assign({x:function x(){return Pu(r.shape,o,n,w);},filter:function filter(){return Lu(r,o,n.shape,w);}},a);},"FusedDepthwiseConv2D",{convInfo:w,activation:h},E,[!0]);return y?C.as3D(C.shape[1],C.shape[2],C.shape[3]):C;}}),Sl=Object.freeze({matMul:Al,conv2d:Ol,depthwiseConv2d:_l}),Dl=Object.freeze({image:xl,linalg:dl,losses:ul,spectral:zc,fused:Sl,signal:Jc,square:Wa,squaredDifference:qa,conv1d:Nu,conv2d:Iu,conv3d:Ru,depthwiseConv2d:Bu,separableConv2d:zu,conv2dTranspose:Uu,conv3dTranspose:Wu,op:Nn,batchNormalization2d:Ts,batchNormalization3d:Ns,batchNormalization4d:Is,batchNormalization:Rs,batchNorm:Ms,batchNorm2d:js,batchNorm3d:Bs,batchNorm4d:Ps,booleanMaskAsync:Su,complex:In,real:Rn,imag:Mn,concat:Zn,concat1d:tr,concat2d:er,concat3d:nr,concat4d:rr,split:ir,matMul:Vu,dot:qu,outerProduct:$u,reverse:Hu,reverse1d:Gu,reverse2d:Ku,reverse3d:Xu,reverse4d:Yu,maxPool:Zu,avgPool:tc,pool:ec,maxPool3d:nc,avgPool3d:rc,slice:ic,slice1d:oc,slice2d:ac,slice3d:sc,slice4d:uc,abs:$a,acos:Ha,acosh:Ga,asin:Ka,asinh:Xa,atan:Ya,atanh:Ja,ceil:Qa,clipByValue:Za,cos:ts,cosh:es,erf:ns,exp:rs,expm1:is,floor:os,log:as,log1p:ss,logSigmoid:us,neg:cs,reciprocal:ls,round:fs,rsqrt:hs,sigmoid:ds,sign:ps,isNaN:ms,isInf:gs,isFinite:vs,sin:ys,sinh:bs,softplus:xs,sqrt:ws,step:ks,tan:Es,tanh:Cs,all:lc,any:fc,argMax:hc,argMin:dc,logSumExp:pc,max:mc,mean:gc,min:vc,moments:yc,sum:bc,prod:xc,equal:hu,equalStrict:du,greater:pu,greaterEqual:mu,greaterEqualStrict:gu,greaterStrict:vu,less:yu,lessEqual:bu,lessEqualStrict:xu,lessStrict:wu,notEqual:ku,notEqualStrict:Eu,add:$s,addN:Hs,addStrict:Gs,atan2:Ks,div:Xs,divNoNan:Ys,divStrict:Js,floorDiv:Qs,maximum:Zs,maximumStrict:tu,minimum:eu,minimumStrict:nu,mod:ru,modStrict:iu,mul:ou,mulStrict:au,pow:su,powStrict:uu,squaredDifferenceStrict:cu,sub:lu,subStrict:fu,elu:wc,leakyRelu:kc,prelu:Ec,relu:Cc,relu6:Ac,selu:Oc,logicalAnd:Ls,logicalNot:zs,logicalOr:Us,logicalXor:Ws,where:Vs,whereAsync:qs,buffer:vr,print:yr,batchToSpaceND:br,broadcastTo:xr,cast:wr,clone:kr,cumsum:Er,depthToSpace:Cr,expandDims:Ar,eye:Or,multinomial:_r,oneHot:Sr,pad:Dr,pad1d:Fr,pad2d:Tr,pad3d:Nr,pad4d:Ir,rand:Rr,randomNormal:Mr,randomGamma:jr,randomUniform:Br,reshape:Pr,spaceToBatchND:Lr,squeeze:zr,stack:Ur,tile:Wr,truncatedNormal:Vr,unstack:qr,setdiff1dAsync:$r,fill:Kn,linspace:Xn,ones:Hn,range:Yn,scalar:Pn,tensor:jn,tensor1d:Ln,tensor2d:zn,tensor3d:Un,tensor4d:Wn,tensor5d:Vn,tensor6d:qn,variable:$n,zeros:Gn,onesLike:Jn,zerosLike:Qn,transpose:_c,softmax:xi,logSoftmax:wi,localResponseNormalization:Sc,norm:Dc,gather:Ou,unsortedSegmentSum:_u,basicLSTMCell:Fc,multiRNNCell:Tc,movingAverage:Nc,stridedSlice:Ic,topk:Rc,scatterND:Mc,fft:jc,ifft:Bc,rfft:Pc,irfft:Lc,sparseToDense:Uc,gatherND:Wc,diag:Vc,dropout:qc,hannWindow:Gc,hammingWindow:Kc,frame:Xc,stft:Yc,inTopKAsync:Qc});function Fl(t,e){Array.isArray(t)||(t=[t]),t.forEach(function(t){null!=t&&_("complex64"!==t.dtype,function(){return e+" does not support complex64 tensors.";});});}function Tl(t,e,n,r){if("linear"===n)return t.linear(e);if("relu"===n)return t.relu(e);if("elu"===n)return t.elu(e);if("relu6"===n)return t.relu6(e);if("prelu"===n)return t.prelu(e,r);throw new Error("Activation "+n+" has not been implemented for the CPU backend.");}var Nl=function(t){function e(){var e=t.call(this)||this;return e.blockSize=48,e.firstUse=!0,e.data=new ki(e,Wt),e;}return s(e,t),e.prototype.write=function(t,e,n){this.firstUse&&(this.firstUse=!1,f().get("IS_NODE")&&vn("\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============================"));var r={};return this.data.set(r,{values:t,dtype:n}),r;},e.prototype.move=function(t,e,n,r){this.data.set(t,{values:e,dtype:r});},e.prototype.numDataIds=function(){return this.data.numDataIds();},e.prototype.read=function(t){return u(this,void 0,void 0,function(){return c(this,function(e){return [2,this.readSync(t)];});});},e.prototype.readSync=function(t){var e=this.data.get(t),n=e.dtype,r=e.complexTensors;return "complex64"===n?qi(this.readSync(r.real.dataId),this.readSync(r.imag.dataId)):this.data.get(t).values;},e.prototype.bufferSync=function(t){var e=this.readSync(t.dataId),n=e;if("string"===t.dtype)try{n=e.map(function(t){return ct(t);});}catch(t){throw new Error("Failed to decode encoded string bytes into utf-8");}return vr(t.shape,t.dtype,n);},e.prototype.makeOutput=function(t,e,n){var r=this.write(t,e,n);return Wt.makeTensorFromDataId(r,e,n,this);},e.prototype.disposeData=function(t){if(this.data.has(t)){var e=this.data.get(t).complexTensors;null!=e&&(e.real.dispose(),e.imag.dispose()),this.data.delete(t);}},e.prototype.time=function(t){return u(this,void 0,void 0,function(){var e;return c(this,function(n){return e=at(),t(),[2,{kernelMs:at()-e}];});});},e.prototype.memory=function(){return {unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]};},e.prototype.complex=function(t,e){var n=this.makeOutput(null,t.shape,"complex64");return this.data.get(n.dataId).complexTensors={real:Wt.keep(t.clone()),imag:Wt.keep(e.clone())},n;},e.prototype.real=function(t){return this.data.get(t.dataId).complexTensors.real.clone();},e.prototype.imag=function(t){return this.data.get(t.dataId).complexTensors.imag.clone();},e.prototype.slice=function(t,e,n){if(Fl(t,"slice"),li(t.shape,e,n)){var r=fi(e,t.strides),i=T(n);return jn(this.readSync(t.dataId).subarray(r,r+i),n,t.dtype);}for(var o=vr(n,t.dtype),a=this.bufferSync(t),s=0;s<o.size;++s){var u=o.indexToLoc(s).map(function(t,n){return t+e[n];});o.values[s]=a.get.apply(a,u);}return o.toTensor();},e.prototype.stridedSlice=function(t,e,n,r){Fl(t,"stridedSlice");var i=si(e,n,r);if(i.some(function(t){return 0===t;}))return jn([],i);for(var o=vr(i,t.dtype),a=this.bufferSync(t),s=0;s<o.size;s++){for(var u=o.indexToLoc(s),c=new Array(u.length),l=0;l<c.length;l++){c[l]=u[l]*r[l]+e[l];}o.set.apply(o,[a.get.apply(a,c)].concat(u));}return o.toTensor();},e.prototype.diag=function(t){for(var e=this.readSync(t.dataId),n=vr([t.size,t.size],t.dtype),r=n.values,i=0;i<e.length;i++){r[i*t.size+i]=e[i];}return n.toTensor();},e.prototype.unstack=function(t,e){for(var n=t.shape[e],r=new Array(t.rank-1),i=0,o=0;o<t.rank;o++){o!==e&&(r[i++]=t.shape[o]);}var a=new Array(t.rank).fill(0),s=t.shape.slice();s[e]=1;var u=new Array(n);for(o=0;o<u.length;o++){a[e]=o,u[o]=this.slice(t,a,s).reshape(r);}return u;},e.prototype.reverse=function(t,e){Fl(t,"reverse");for(var n=vr(t.shape,t.dtype),r=this.bufferSync(t),i=function i(_i7){var o=n.indexToLoc(_i7),a=o.slice();e.forEach(function(e){return a[e]=t.shape[e]-1-a[e];}),n.set.apply(n,[r.get.apply(r,a)].concat(o));},o=0;o<n.size;o++){i(o);}return n.toTensor();},e.prototype.concat=function(t,e){var n=this;if("complex64"===t[0].dtype){var r=t.map(function(t){return Rn(t);}),i=t.map(function(t){return Mn(t);});return In(this.concat(r,e),this.concat(i,e));}var o=t.map(function(t){var n=T(t.shape.slice(e));return t.as2D(-1,n);}),a=Tn(o.map(function(t){return t.shape;}),1),s=vr(a,t[0].dtype).values;if(1===o[0].shape[0]){var u=0;o.forEach(function(t){s.set(n.readSync(t.dataId),u),u+=t.size;});}else {var c=0;o.forEach(function(t){for(var e=n.readSync(t.dataId),r=0,i=0;i<t.shape[0];++i){for(var o=i*a[1]+c,u=0;u<t.shape[1];++u){s[o+u]=e[r++];}}c+=t.shape[1];});}var l=Tn(t.map(function(t){return t.shape;}),e);return jn(s,l,t[0].dtype);},e.prototype.neg=function(t){return Fl(t,"neg"),this.multiply(Pn(-1),t);},e.prototype.add=function(t,e){return "complex64"===t.dtype||"complex64"===e.dtype?this.broadcastedBinaryComplexOp(t.cast("complex64"),e.cast("complex64"),function(t,e,n,r){return {real:t+n,imag:e+r};}):this.broadcastedBinaryOp(t,e,It(t.dtype,e.dtype),function(t,e){return t+e;});},e.prototype.addN=function(t){var e=this;Fl(t,"addN");for(var n=t.map(function(t){return e.readSync(t.dataId);}),r=vr(t[0].shape,t[0].dtype),i=r.values,o=0;o<t.length;o++){for(var a=n[o],s=0;s<i.length;s++){i[s]+=a[s];}}return r.toTensor();},e.prototype.softmax=function(t,e){var n=L([e],t.shape),r=this.max(t,n),i=An(r.shape,n),o=this.subtract(t,r.reshape(i)),a=this.exp(o),s=this.sum(a,n).reshape(i);return this.realDivide(a,s);},e.prototype.subtract=function(t,e){return "complex64"===t.dtype||"complex64"===e.dtype?this.broadcastedBinaryComplexOp(t.cast("complex64"),e.cast("complex64"),function(t,e,n,r){return {real:t-n,imag:e-r};}):this.broadcastedBinaryOp(t,e,It(t.dtype,e.dtype),function(t,e){return t-e;});},e.prototype.pow=function(t,e){return Fl([t,e],"pow"),this.broadcastedBinaryOp(t,e,t.dtype,function(t,e){return Math.pow(t,e);});},e.prototype.batchMatMul=function(t,e,n,r){Fl([t,e],"matMul");for(var i=n?t.shape[1]:t.shape[2],o=n?t.shape[2]:t.shape[1],a=r?e.shape[1]:e.shape[2],s=t.shape[0],u=this.readSync(t.dataId),c=this.readSync(e.dataId),l=n?[t.strides[0],1,t.strides[1]]:[t.strides[0],t.strides[1],1],f=l[0],h=l[1],d=l[2],p=r?[1,e.strides[1],e.strides[0]]:[e.strides[1],1,e.strides[0]],m=p[0],g=p[1],v=p[2],y=o*a,b=vr([s,o,a],t.dtype),x=b.values,w=this.blockSize,k=0;k<s;k++){for(var E=0;E<o;E+=w){for(var C=0;C<a;C+=w){for(var A=0;A<i;A+=w){for(var O=Math.min(E+w,o),_=Math.min(C+w,a),S=Math.min(A+w,i),D=E;D<O;D++){for(var F=C;F<_;F++){for(var T=0,N=A;N<S;N++){T+=u[k*f+D*h+N*d]*c[N*m+F*g+k*v];}x[k*y+(D*a+F)]+=T;}}}}}}return b.toTensor();},e.prototype.fusedBatchMatMul=function(t){var e=t.a,n=t.b,r=t.transposeA,i=t.transposeB,o=t.bias,a=t.activation,s=t.preluActivationWeights,u=this.batchMatMul(e,n,r,i);return o&&(u=this.add(u,o)),a&&(u=Tl(this,u,a,s)),u;},e.prototype.multiply=function(t,e){return "complex64"===t.dtype||"complex64"===e.dtype?this.broadcastedBinaryComplexOp(t.cast("complex64"),e.cast("complex64"),function(t,e,n,r){return {real:t*n-e*r,imag:t*r+e*n};}):this.broadcastedBinaryOp(t,e,It(t.dtype,e.dtype),function(t,e){return t*e;});},e.prototype.realDivide=function(t,e){return Fl([t,e],"realDivide"),this.broadcastedBinaryOp(t,e,"float32",function(t,e){return t/e;});},e.prototype.floorDiv=function(t,e){return Fl([t,e],"floorDiv"),this.broadcastedBinaryOp(t,e,"int32",function(t,e){return Math.floor(t/e);});},e.prototype.sum=function(t,e){Fl(t,"sum"),On("sum",e,t.rank);for(var n=Cn(t.shape,e),r=n[0],i=n[1],o=Gn(r,It(t.dtype,"int32")),a=T(i),s=this.readSync(o.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*a,f=0,h=0;h<a;++h){f+=u[l+h];}s[c]=f;}return o;},e.prototype.prod=function(t,e){Fl(t,"sum");for(var n=Cn(t.shape,e),r=n[0],i=n[1],o=Gn(r,It(t.dtype,"int32")),a=T(i),s=this.readSync(o.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*a,f=1,h=0;h<a;++h){f*=u[l+h];}s[c]=f;}return o;},e.prototype.unsortedSegmentSum=function(t,e,n){Fl(t,"unsortedSegmentSum");for(var r=[],i=t.rank-e.rank,o=0;o<i;++o){e=e.expandDims(o+1);}for(o=0;o<n;++o){var a=Pn(o,"int32"),s=hu(a,e).asType("float32").mul(t).sum(0);r.push(s);}return Ur(r);},e.prototype.argMin=function(t,e){Fl(t,"argMin");var n=[e];On("argMin",n,t.rank);for(var r=Cn(t.shape,n),i=r[0],o=r[1],a=Gn(i,"int32"),s=T(o),u=this.readSync(a.dataId),c=this.readSync(t.dataId),l=0;l<u.length;++l){for(var f=l*s,h=c[f],d=0,p=0;p<s;++p){var m=c[f+p];m<h&&(h=m,d=p);}u[l]=d;}return a;},e.prototype.argMax=function(t,e){Fl(t,"argMax");var n=[e];On("argMax",n,t.rank);for(var r=Cn(t.shape,n),i=r[0],o=r[1],a=Gn(i,"int32"),s=T(o),u=this.readSync(a.dataId),c=this.readSync(t.dataId),l=0;l<u.length;++l){for(var f=l*s,h=c[f],d=0,p=0;p<s;++p){var m=c[f+p];m>h&&(h=m,d=p);}u[l]=d;}return a;},e.prototype.cumsum=function(t,e,n,r){if(Fl(t,"cumsum"),e!==t.rank-1)throw new Error("backend.cumsum in CPU expects an inner-most axis="+(t.rank-1)+" but got axis="+e);for(var i=It(t.dtype,"int32"),o=Gn(t.shape,i),a=this.readSync(o.dataId),s=this.readSync(t.dataId),u=t.shape[t.rank-1],c=r?function(t,e){return t+u-e-1;}:function(t,e){return t+e;},l=0;l<s.length;l+=u){for(var f=0;f<u;f++){var h=c(l,f);if(0===f)a[h]=n?0:s[h];else {var d=c(l,f-1);a[h]=n?s[d]+a[d]:s[h]+a[d];}}}return o;},e.prototype.equal=function(t,e){return Fl([t,e],"equal"),this.broadcastedBinaryOp(t,e,"bool",function(t,e){return t===e?1:0;});},e.prototype.notEqual=function(t,e){return Fl([t,e],"notEqual"),this.broadcastedBinaryOp(t,e,"bool",function(t,e){return t!==e?1:0;});},e.prototype.less=function(t,e){return Fl([t,e],"less"),this.broadcastedBinaryOp(t,e,"bool",function(t,e){return t<e?1:0;});},e.prototype.lessEqual=function(t,e){return Fl([t,e],"lessEqual"),this.broadcastedBinaryOp(t,e,"bool",function(t,e){return t<=e?1:0;});},e.prototype.greater=function(t,e){return Fl([t,e],"greater"),this.broadcastedBinaryOp(t,e,"bool",function(t,e){return t>e?1:0;});},e.prototype.greaterEqual=function(t,e){return Fl([t,e],"greaterEqual"),this.broadcastedBinaryOp(t,e,"bool",function(t,e){return t>=e?1:0;});},e.prototype.logicalNot=function(t){Fl(t,"logicalNot");for(var e=this.readSync(t.dataId),n=new Uint8Array(e.length),r=0;r<e.length;++r){n[r]=e[r]?0:1;}return this.makeOutput(n,t.shape,"bool");},e.prototype.logicalAnd=function(t,e){return Fl([t,e],"logicalAnd"),this.broadcastedBinaryOp(t,e,"bool",function(t,e){return t&&e;});},e.prototype.logicalOr=function(t,e){return Fl([t,e],"logicalOr"),this.broadcastedBinaryOp(t,e,"bool",function(t,e){return t||e;});},e.prototype.select=function(t,e,n){Fl([t,e,n],"select");for(var r=this.readSync(t.dataId),i=this.readSync(e.dataId),o=this.readSync(n.dataId),a=Gn(e.shape,It(e.dtype,n.dtype)),s=this.readSync(a.dataId),u=0,c=0===t.rank||t.rank>1||1===e.rank?1:T(e.shape.slice(1)),l=0;l<r.length;l++){for(var f=0;f<c;f++){1===r[l]?s[u++]=i[l]:s[u++]=o[l];}}return a;},e.prototype.where=function(t){Fl([t],"where");var e=this.readSync(t.dataId);return oo(t.shape,e);},e.prototype.topk=function(t,e,n){return Fl(t,"topk"),io(this.readSync(t.dataId),t.shape,t.dtype,e);},e.prototype.min=function(t,e){Fl(t,"min"),On("min",e,t.rank);for(var n=Cn(t.shape,e),r=n[0],i=n[1],o=Gn(r,t.dtype),a=T(i),s=this.readSync(o.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*a,f=u[l],h=0;h<a;++h){var d=u[l+h];d<f&&(f=d);}s[c]=f;}return o;},e.prototype.minimum=function(t,e){return Fl([t,e],"minimum"),this.broadcastedBinaryOp(t,e,t.dtype,function(t,e){return Math.min(t,e);});},e.prototype.mod=function(t,e){return Fl([t,e],"mod"),this.broadcastedBinaryOp(t,e,t.dtype,function(t,e){var n=t%e;return t<0&&e<0||t>=0&&e>=0?n:(n+e)%e;});},e.prototype.max=function(t,e){Fl(t,"max"),On("max",e,t.rank);for(var n=Cn(t.shape,e),r=n[0],i=n[1],o=Gn(r,t.dtype),a=T(i),s=this.readSync(o.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*a,f=u[l],h=0;h<a;++h){var d=u[l+h];d>f&&(f=d);}s[c]=f;}return o;},e.prototype.maximum=function(t,e){return Fl([t,e],"maximum"),this.broadcastedBinaryOp(t,e,t.dtype,function(t,e){return Math.max(t,e);});},e.prototype.all=function(t,e){Fl(t,"all"),On("all",e,t.rank);for(var n=Cn(t.shape,e),r=n[0],i=n[1],o=Gn(r,t.dtype),a=T(i),s=this.readSync(o.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*a,f=u[l],h=0;h<a;++h){var d=u[l+h];f=f&&d;}s[c]=f;}return o;},e.prototype.any=function(t,e){Fl(t,"any"),On("any",e,t.rank);for(var n=Cn(t.shape,e),r=n[0],i=n[1],o=Gn(r,t.dtype),a=T(i),s=this.readSync(o.dataId),u=this.readSync(t.dataId),c=0;c<s.length;++c){for(var l=c*a,f=u[l],h=0;h<a;++h){var d=u[l+h];f=f||d;}s[c]=f;}return o;},e.prototype.squaredDifference=function(t,e){return Fl([t,e],"squaredDifference"),this.broadcastedBinaryOp(t,e,t.dtype,function(t,e){var n=t-e;return n*n;});},e.prototype.ceil=function(t){Fl(t,"ceil");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){n[r]=Math.ceil(e[r]);}return this.makeOutput(n,t.shape,"float32");},e.prototype.floor=function(t){Fl(t,"floor");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){n[r]=Math.floor(e[r]);}return this.makeOutput(n,t.shape,"float32");},e.prototype.sign=function(t){Fl(t,"x");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){e[r]<0?n[r]=-1:e[r]>0?n[r]=1:n[r]=0;}return this.makeOutput(n,t.shape,"float32");},e.prototype.isNaN=function(t){Fl(t,"x");for(var e=this.readSync(t.dataId),n=new Uint8Array(e.length),r=0;r<e.length;++r){Number.isNaN(e[r])&&(n[r]=1);}return this.makeOutput(n,t.shape,"bool");},e.prototype.isInf=function(t){Fl(t,"x");for(var e=this.readSync(t.dataId),n=new Uint8Array(e.length),r=0;r<e.length;++r){Math.abs(e[r])===1/0&&(n[r]=1);}return this.makeOutput(n,t.shape,"bool");},e.prototype.isFinite=function(t){Fl(t,"x");for(var e=this.readSync(t.dataId),n=new Uint8Array(e.length),r=0;r<e.length;++r){Number.isFinite(e[r])&&(n[r]=1);}return this.makeOutput(n,t.shape,"bool");},e.prototype.round=function(t){Fl(t,"round");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var i=Math.floor(e[r]);e[r]-i<.5?n[r]=Math.floor(e[r]):e[r]-i>.5?n[r]=Math.ceil(e[r]):n[r]=i%2==0?i:i+1;}return this.makeOutput(n,t.shape,"float32");},e.prototype.exp=function(t){Fl(t,"exp");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){n[r]=Math.exp(e[r]);}return this.makeOutput(n,t.shape,"float32");},e.prototype.expm1=function(t){Fl(t,"expm1");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){n[r]=Math.expm1(e[r]);}return this.makeOutput(n,t.shape,"float32");},e.prototype.log=function(t){Fl(t,"log");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var i=e[r];n[r]=Math.log(i);}return this.makeOutput(n,t.shape,"float32");},e.prototype.log1p=function(t){Fl(t,"log1p");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var i=e[r];n[r]=Math.log1p(i);}return this.makeOutput(n,t.shape,"float32");},e.prototype.sqrt=function(t){Fl(t,"sqrt");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var i=e[r];n[r]=Math.sqrt(i);}return this.makeOutput(n,t.shape,"float32");},e.prototype.rsqrt=function(t){Fl(t,"rsqrt");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){var i=e[r];n[r]=1/Math.sqrt(i);}return this.makeOutput(n,t.shape,"float32");},e.prototype.reciprocal=function(t){Fl(t,"reciprocal");for(var e=this.readSync(t.dataId),n=new Float32Array(e.length),r=0;r<e.length;++r){n[r]=1/e[r];}return this.makeOutput(n,t.shape,"float32");},e.prototype.linear=function(t){return t;},e.prototype.relu=function(t){Fl(t,"relu");for(var e=Gn(t.shape,t.dtype),n=this.readSync(e.dataId),r=this.readSync(t.dataId),i=0;i<r.length;++i){n[i]=Math.max(0,r[i]);}return e;},e.prototype.relu6=function(t){Fl(t,"relu");for(var e=Gn(t.shape,t.dtype),n=this.readSync(e.dataId),r=this.readSync(t.dataId),i=0;i<r.length;++i){n[i]=Math.min(Math.max(0,r[i]),6);}return e;},e.prototype.prelu=function(t,e){return Fl([t,e],"prelu"),this.broadcastedBinaryOp(t,e,t.dtype,function(t,e){return t<0?e*t:t;});},e.prototype.elu=function(t){Fl(t,"elu");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){var i=n[r];e[r]=i>=0?i:Math.exp(i)-1;}return this.makeOutput(e,t.shape,"float32");},e.prototype.eluDer=function(t,e){Fl([t,e],"eluDer");for(var n=new Float32Array(e.size),r=this.readSync(e.dataId),i=this.readSync(t.dataId),o=0;o<r.length;++o){var a=r[o];n[o]=a>=1?i[o]:i[o]*(a+1);}return this.makeOutput(n,e.shape,"float32");},e.prototype.selu=function(t){Fl(t,"selu");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){var i=n[r];e[r]=i>=0?1.0507009873554805*i:1.7580993408473768*(Math.exp(i)-1);}return this.makeOutput(e,t.shape,"float32");},e.prototype.clip=function(t,e,n){Fl(t,"clip");for(var r=new Float32Array(t.size),i=this.readSync(t.dataId),o=0;o<i.length;++o){var a=i[o];r[o]=a>n?n:a<e?e:a;}return this.makeOutput(r,t.shape,"float32");},e.prototype.abs=function(t){for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.abs(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.complexAbs=function(t){for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<t.size;++r){var i=n[2*r],o=n[2*r+1];e[r]=Math.hypot(i,o);}return this.makeOutput(e,t.shape,"float32");},e.prototype.int=function(t){Fl(t,"int");for(var e=new Int32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=n[r];}return this.makeOutput(e,t.shape,"int32");},e.prototype.sigmoid=function(t){Fl(t,"sigmoid");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=1/(1+Math.exp(-n[r]));}return this.makeOutput(e,t.shape,"float32");},e.prototype.softplus=function(t){Fl(t,"softplus");for(var e=Math.log(1.1920928955078125e-7)+2,n=new Float32Array(t.size),r=this.readSync(t.dataId),i=0;i<r.length;++i){var o,a=r[i]>-e,s=r[i]<e,u=Math.exp(r[i]);o=s?u:a?r[i]:Math.log(1+u),n[i]=o;}return this.makeOutput(n,t.shape,"float32");},e.prototype.sin=function(t){Fl(t,"sin");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.sin(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.cos=function(t){Fl(t,"cos");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.cos(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.tan=function(t){Fl(t,"tan");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.tan(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.asin=function(t){Fl(t,"asin");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.asin(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.acos=function(t){Fl(t,"acos");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.acos(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.atan=function(t){Fl(t,"atan");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.atan(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.atan2=function(t,e){return Fl([t,e],"atan2"),this.broadcastedBinaryOp(t,e,t.dtype,function(t,e){return Math.atan2(t,e);});},e.prototype.sinh=function(t){Fl(t,"sinh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.sinh(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.cosh=function(t){Fl(t,"cosh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.cosh(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.tanh=function(t){Fl(t,"tanh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=R(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.asinh=function(t){Fl(t,"asinh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.asinh(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.acosh=function(t){Fl(t,"acosh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.acosh(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.atanh=function(t){Fl(t,"atanh");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){e[r]=Math.atanh(n[r]);}return this.makeOutput(e,t.shape,"float32");},e.prototype.erf=function(t){Fl(t,"erf");for(var e=new Float32Array(t.size),n=this.readSync(t.dataId),r=0;r<n.length;++r){var i=Math.sign(n[r]),o=Math.abs(n[r]),a=1/(1+.3275911*o);e[r]=i*(1-((((1.061405429*a-1.453152027)*a+1.421413741)*a-.284496736)*a+.254829592)*a*Math.exp(-o*o));}return this.makeOutput(e,t.shape,"float32");},e.prototype.step=function(t,e){void 0===e&&(e=0),Fl(t,"step");for(var n=new Float32Array(t.size),r=this.readSync(t.dataId),i=0;i<r.length;++i){var o=r[i];isNaN(o)?n[i]=NaN:n[i]=o>0?1:e;}return this.makeOutput(n,t.shape,"float32");},e.prototype.fusedConv2d=function(t){var e=t.input,n=t.filter,r=t.convInfo,i=t.bias,o=t.activation,a=t.preluActivationWeights,s=this.conv2d(e,n,r);return i&&(s=this.add(s,i)),o&&(s=Tl(this,s,o,a)),s;},e.prototype.conv2d=function(t,e,n){Fl([t,e],"conv2d");for(var r=n.filterHeight,i=n.filterWidth,o=n.dilationHeight,a=n.dilationWidth,s=n.padInfo.left,u=n.padInfo.top,c="channelsLast"===n.dataFormat,l=vr(n.outShape,t.dtype),f=t.strides[0],h=c?t.strides[1]:t.strides[2],d=c?t.strides[2]:1,p=c?1:t.strides[1],m=l.strides[0],g=c?l.strides[1]:l.strides[2],v=c?l.strides[2]:1,y=c?1:l.strides[1],b=this.readSync(t.dataId),x=this.readSync(e.dataId),w=l.values,k=0;k<n.batchSize;++k){for(var E=k*f,C=k*m,A=0;A<n.outHeight;++A){for(var O=C+A*g,_=A*n.strideHeight-u,S=0;S<r;S++){var D=_+S*o;if(!(D<0||D>=n.inHeight))for(var F=S*e.strides[0],T=E+D*h,N=0;N<n.outWidth;++N){for(var I=O+N*v,R=N*n.strideWidth-s,M=0;M<i;M++){var j=R+M*a;if(!(j<0||j>=n.inWidth))for(var B=T+j*d,P=F+M*e.strides[1],L=0;L<n.inChannels;++L){for(var z=b[B+L*p],U=0;U<n.outChannels;++U){w[I+U*y]+=z*x[P+U];}P+=n.outChannels;}}}}}}return l.toTensor();},e.prototype.conv3d=function(t,e,n){for(var r=n.filterDepth,i=n.filterHeight,o=n.filterWidth,a=n.dilationDepth,s=n.dilationHeight,u=n.dilationWidth,c=n.padInfo.front,l=n.padInfo.left,f=n.padInfo.top,h=vr(n.outShape,t.dtype),d=this.readSync(t.dataId),p=this.readSync(e.dataId),m=h.values,g=0;g<n.batchSize;++g){for(var v=g*t.strides[0],y=g*h.strides[0],b=0;b<n.outDepth;++b){for(var x=y+b*h.strides[1],w=b*n.strideDepth-c,k=0;k<r;k++){var E=w+k*a;if(!(E<0||E>=n.inDepth))for(var C=k*e.strides[0],A=v+E*t.strides[1],O=0;O<n.outHeight;++O){for(var _=x+O*h.strides[2],S=O*n.strideHeight-f,D=0;D<i;D++){var F=S+D*s;if(!(F<0||F>=n.inHeight))for(var T=C+D*e.strides[1],N=A+F*t.strides[2],I=0;I<n.outWidth;++I){for(var R=_+I*n.outChannels,M=I*n.strideWidth-l,j=0;j<o;j++){var B=M+j*u;if(!(B<0||B>=n.inWidth))for(var P=T+j*e.strides[2],L=N+B*n.inChannels,z=P,U=0;U<n.inChannels;++U){for(var W=d[L+U],V=0;V<n.outChannels;++V){m[R+V]+=W*p[z+V];}z+=n.outChannels;}}}}}}}}return h.toTensor();},e.prototype.conv2dDerInput=function(t,e,n){Fl([t,e],"conv2dDerInput");for(var r=vr(n.inShape,"float32"),i=r.values,o=this.readSync(t.dataId),a=this.readSync(e.dataId),s=e.strides,u=s[0],c=s[1],l=s[2],f=n.batchSize,h=n.filterHeight,d=n.filterWidth,p=n.inChannels,m=n.inHeight,g=n.inWidth,v=n.outChannels,y=n.outHeight,b=n.outWidth,x=n.strideHeight,w=n.strideWidth,k=n.dataFormat,E=h-1-n.padInfo.top,C=d-1-n.padInfo.left,A="channelsLast"===k,O=r.strides[0],_=A?r.strides[1]:r.strides[2],S=A?r.strides[2]:1,D=A?1:r.strides[1],F=t.strides[0],T=A?t.strides[1]:t.strides[2],N=A?t.strides[2]:1,I=A?1:t.strides[1],R=0;R<f;++R){for(var M=0;M<p;++M){for(var j=0;j<m;++j){for(var B=j-E,P=Math.max(0,Math.ceil(B/x)),L=Math.min(y,(h+B)/x),z=0;z<g;++z){for(var U=z-C,W=Math.max(0,Math.ceil(U/w)),V=Math.min(b,(d+U)/w),q=0,$=P;$<L;++$){for(var H=$*x-B,G=W;G<V;++G){for(var K=F*R+T*$+N*G,X=u*(h-1-H)+c*(d-1-(G*w-U))+l*M,Y=0;Y<v;++Y){q+=o[K+I*Y]*a[X+Y];}}}i[O*R+_*j+S*z+D*M]=q;}}}}return r.toTensor();},e.prototype.conv3dDerInput=function(t,e,n){for(var r=vr(n.inShape,"float32"),i=r.values,o=r.strides,a=o[0],s=o[1],u=o[2],c=o[3],l=this.readSync(t.dataId),f=t.strides,h=f[0],d=f[1],p=f[2],m=f[3],g=this.readSync(e.dataId),v=e.strides,y=v[0],b=v[1],x=v[2],w=v[3],k=n.batchSize,E=n.filterDepth,C=n.filterHeight,A=n.filterWidth,O=n.inChannels,_=n.inDepth,S=n.inHeight,D=n.inWidth,F=n.outChannels,T=n.outDepth,N=n.outHeight,I=n.outWidth,R=n.strideDepth,M=n.strideHeight,j=n.strideWidth,B=E-1-n.padInfo.front,P=C-1-n.padInfo.top,L=A-1-n.padInfo.left,z=0;z<k;++z){for(var U=0;U<O;++U){for(var W=0;W<_;++W){for(var V=W-B,q=Math.max(0,Math.ceil(V/R)),$=Math.min(T,(E+V)/R),H=0;H<S;++H){for(var G=H-P,K=Math.max(0,Math.ceil(G/M)),X=Math.min(N,(C+G)/M),Y=0;Y<D;++Y){for(var J=Y-L,Q=Math.max(0,Math.ceil(J/j)),Z=Math.min(I,(A+J)/j),tt=0,et=q;et<$;++et){for(var nt=et*R-V,rt=K;rt<X;++rt){for(var it=rt*M-G,ot=Q;ot<Z;++ot){for(var at=h*z+d*et+p*rt+m*ot,st=y*(E-1-nt)+b*(C-1-it)+x*(A-1-(ot*j-J))+w*U,ut=0;ut<F;++ut){tt+=l[at+ut]*g[st+ut];}}}}i[a*z+s*W+u*H+c*Y+U]=tt;}}}}}return r.toTensor();},e.prototype.conv2dDerFilter=function(t,e,n){Fl([t,e],"conv2dDerFilter");for(var r=n.strideHeight,i=n.strideWidth,o=n.filterHeight,a=n.filterWidth,s="channelsLast"===n.dataFormat,u=vr(n.filterShape,"float32"),c=n.padInfo.left,l=n.padInfo.top,f=this.bufferSync(t),h=this.bufferSync(e),d=0;d<o;++d){for(var p=Math.max(0,Math.ceil((l-d)/r)),m=Math.min(n.outHeight,(n.inHeight+l-d)/r),g=0;g<a;++g){for(var v=Math.max(0,Math.ceil((c-g)/i)),y=Math.min(n.outWidth,(n.inWidth+c-g)/i),b=0;b<n.inChannels;++b){for(var x=0;x<n.outChannels;++x){for(var w=0,k=0;k<n.batchSize;++k){for(var E=p;E<m;++E){for(var C=d+E*r-l,A=v;A<y;++A){var O=g+A*i-c;w+=s?f.get(k,C,O,b)*h.get(k,E,A,x):f.get(k,b,C,O)*h.get(k,x,E,A);}}}u.set(w,d,g,b,x);}}}}return u.toTensor();},e.prototype.conv3dDerFilter=function(t,e,n){for(var r=n.strideDepth,i=n.strideHeight,o=n.strideWidth,a=n.filterDepth,s=n.filterHeight,u=n.filterWidth,c=vr(n.filterShape,"float32"),l=c.values,f=c.strides,h=f[0],d=f[1],p=f[2],m=f[3],g=this.readSync(e.dataId),v=e.strides,y=v[0],b=v[1],x=v[2],w=v[3],k=this.readSync(t.dataId),E=t.strides,C=E[0],A=E[1],O=E[2],_=E[3],S=n.padInfo.front,D=n.padInfo.left,F=n.padInfo.top,T=0;T<a;++T){for(var N=Math.max(0,Math.ceil((S-T)/r)),I=Math.min(n.outDepth,(n.inDepth+S-T)/r),R=T*h,M=0;M<s;++M){for(var j=Math.max(0,Math.ceil((F-M)/i)),B=Math.min(n.outHeight,(n.inHeight+F-M)/i),P=M*d+R,L=0;L<u;++L){for(var z=Math.max(0,Math.ceil((D-L)/o)),U=Math.min(n.outWidth,(n.inWidth+D-L)/o),W=L*p+P,V=0;V<n.inChannels;++V){for(var q=V*m+W,$=0;$<n.outChannels;++$){for(var H=0,G=0;G<n.batchSize;++G){for(var K=G*C,X=G*y,Y=N;Y<I;++Y){for(var J=(T+Y*r-S)*A+K,Q=Y*b+X,Z=j;Z<B;++Z){for(var tt=(M+Z*i-F)*O+J,et=Z*x+Q,nt=z;nt<U;++nt){var rt=nt*w+et;H+=k[(L+nt*o-D)*_+tt+V]*g[rt+$];}}}}l[q+$]=H;}}}}}return c.toTensor();},e.prototype.fusedDepthwiseConv2D=function(t){var e=t.input,n=t.filter,r=t.convInfo,i=t.bias,o=t.activation,a=t.preluActivationWeights,s=this.depthwiseConv2D(e,n,r);return i&&(s=this.add(s,i)),o&&(s=Tl(this,s,o,a)),s;},e.prototype.depthwiseConv2D=function(t,e,n){Fl([t,e],"depthwiseConv2D");for(var r=n.filterHeight,i=n.filterWidth,o=n.dilationHeight,a=n.dilationWidth,s=n.padInfo.left,u=n.padInfo.top,c=n.outChannels/n.inChannels,l=vr(n.outShape,t.dtype),f=this.readSync(t.dataId),h=this.readSync(e.dataId),d=l.values,p=0;p<n.batchSize;++p){for(var m=p*t.strides[0],g=p*l.strides[0],v=0;v<n.outHeight;++v){for(var y=g+v*l.strides[1],b=v*n.strideHeight-s,x=0;x<r;++x){var w=b+x*o;if(!(w<0||w>=n.inHeight))for(var k=x*e.strides[0],E=m+w*t.strides[1],C=0;C<n.outWidth;++C){for(var A=y+C*l.strides[2],O=C*n.strideWidth-u,_=0;_<i;++_){var S=O+_*a;if(!(S<0||S>=n.inWidth))for(var D=k+_*e.strides[1],F=E+S*n.inChannels,T=A,N=D,I=0;I<n.inChannels;++I){for(var R=f[F+I],M=0;M<c;++M){d[T+M]+=R*h[N+M];}T+=c,N+=c;}}}}}}return l.toTensor();},e.prototype.depthwiseConv2DDerInput=function(t,e,n){Fl([t,e],"depthwiseConv2DDerInput");for(var r=vr(n.inShape,"float32"),i=r.values,o=r.strides,a=o[0],s=o[1],u=o[2],c=this.readSync(t.dataId),l=t.strides,f=l[0],h=l[1],d=l[2],p=this.readSync(e.dataId),m=e.strides,g=m[0],v=m[1],y=m[2],b=n.batchSize,x=n.filterHeight,w=n.filterWidth,k=n.inChannels,E=n.inHeight,C=n.inWidth,A=n.outChannels,O=n.outHeight,_=n.outWidth,S=n.strideHeight,D=n.strideWidth,F=x-1-n.padInfo.top,T=w-1-n.padInfo.left,N=A/k,I=0;I<b;++I){for(var R=0;R<k;++R){for(var M=0;M<E;++M){for(var j=M-F,B=Math.max(0,Math.ceil(j/S)),P=Math.min(O,(x+j)/S),L=0;L<C;++L){for(var z=L-T,U=Math.max(0,Math.ceil(z/D)),W=Math.min(_,(w+z)/D),V=0,q=B;q<P;++q){for(var $=q*S-j,H=U;H<W;++H){for(var G=f*I+h*q+d*H,K=g*(x-1-$)+v*(w-1-(H*D-z))+y*R,X=0;X<N;++X){V+=c[G+(R*N+X)]*p[K+X];}}}i[a*I+s*M+u*L+R]=V;}}}}return r.toTensor();},e.prototype.depthwiseConv2DDerFilter=function(t,e,n){Fl([t,e],"depthwiseConv2DDerFilter");for(var r=n.strideHeight,i=n.strideWidth,o=n.filterHeight,a=n.filterWidth,s=vr(n.filterShape,"float32"),u=n.padInfo.left,c=n.padInfo.top,l=n.outChannels/n.inChannels,f=this.bufferSync(t),h=this.bufferSync(e),d=0;d<o;++d){for(var p=Math.max(0,Math.ceil((c-d)/r)),m=Math.min(n.outHeight,(n.inHeight+c-d)/r),g=0;g<a;++g){for(var v=Math.max(0,Math.ceil((u-g)/i)),y=Math.min(n.outWidth,(n.inWidth+u-g)/i),b=0;b<n.outChannels;++b){for(var x=Math.trunc(b/l),w=b%l,k=0,E=0;E<n.batchSize;++E){for(var C=p;C<m;++C){for(var A=d+C*r-c,O=v;O<y;++O){var _=g+O*i-u;k+=f.get(E,A,_,x)*h.get(E,C,O,b);}}}s.set(k,d,g,x,w);}}}return s.toTensor();},e.prototype.tile=function(t,e){return Fl(t,"tile"),ro(this.bufferSync(t),e);},e.prototype.pad=function(t,e,n){Fl(t,"pad");var r=e.map(function(e,n){return e[0]+t.shape[n]+e[1];}),i=e.map(function(t){return t[0];}),o=this.bufferSync(t),a=vr(r,t.dtype);0!==n&&a.values.fill(n);for(var s=0;s<t.size;s++){var u=o.indexToLoc(s),c=u.map(function(t,e){return t+i[e];});a.set.apply(a,[o.get.apply(o,u)].concat(c));}return a.toTensor();},e.prototype.transpose=function(t,e){Fl(t,"transpose");for(var n=new Array(t.rank),r=0;r<n.length;r++){n[r]=t.shape[e[r]];}var i=this.readSync(t.dataId),o=vr(n,t.dtype),a=this.bufferSync(t);for(r=0;r<t.size;++r){for(var s=a.indexToLoc(r),u=new Array(s.length),c=0;c<u.length;c++){u[c]=s[e[c]];}var l=o.locToIndex(u);o.values[l]=i[r];}return o.toTensor();},e.prototype.gather=function(t,e,n){Fl([t,e],"gather");var r=t.shape.slice(),i=this.readSync(e.dataId);r[n]=i.length;for(var o=vr(r,t.dtype),a=this.bufferSync(t),s=0;s<o.size;++s){var u=o.indexToLoc(s),c=u.slice();c[n]=i[u[n]];var l=a.locToIndex(c);o.values[s]=a.values[l];}return o.toTensor();},e.prototype.batchToSpaceND=function(t,e,n){Fl([t],"batchToSpaceND");var r=e.reduce(function(t,e){return t*e;}),i=Hr(t.shape,e,r),o=Gr(i.length,e.length),a=Kr(t.shape,e,r),s=Xr(n,e.length),u=Yr(a,n,e.length);return t.reshape(i).transpose(o).reshape(a).slice(s,u);},e.prototype.spaceToBatchND=function(t,e,n){Fl([t],"spaceToBatchND");var r=e.reduce(function(t,e){return t*e;}),i=[[0,0]];i.push.apply(i,n);for(var o=1+e.length;o<t.shape.length;++o){i.push([0,0]);}var a=t.pad(i),s=Hr(a.shape,e,r,!1),u=Gr(s.length,e.length,!1),c=Kr(a.shape,e,r,!1);return a.reshape(s).transpose(u).reshape(c);},e.prototype.pool=function(t,e,n){Fl(t,"pool");for(var r=e.strideHeight,i=e.strideWidth,o=e.dilationHeight,a=e.dilationWidth,s=e.effectiveFilterHeight,u=e.effectiveFilterWidth,c=e.padInfo.top,l=e.padInfo.left,f="max"===n?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,h=this.readSync(t.dataId),d=vr(e.outShape,t.dtype),p=d.values,m=e.outShape[1]*e.outShape[2]*e.outShape[3],g=e.outShape[2]*e.outShape[3],v=e.outShape[3],y=0;y<e.batchSize;++y){for(var b=y*m,x=y*t.strides[0],w=0;w<e.inChannels;++w){for(var k=0;k<e.outHeight;++k){for(var E=k*r-c,C=Math.max(0,E),A=Math.min(e.inHeight,s+E),O=b+k*g,_=0;_<e.outWidth;++_){for(var S=_*i-l,D=Math.max(0,S),F=Math.min(e.inWidth,u+S),T=f,N=0,I=0,R=C;R<A;R+=o){for(var M=x+R*t.strides[1],j=D;j<F;j+=a){var B=h[M+j*t.strides[2]+w];"max"===n&&B>T?T=B:"avg"===n&&(N+=B,I++);}if(isNaN(T))break;}p[O+_*v+w]="avg"===n?N/I:T;}}}}return d.toTensor();},e.prototype.maxPool=function(t,e){return this.pool(t,e,"max");},e.prototype.maxPoolPositions=function(t,e){for(var n=vr(e.outShape,"int32"),r=e.strideHeight,i=e.strideWidth,o=e.dilationHeight,a=e.dilationWidth,s=e.effectiveFilterHeight,u=e.effectiveFilterWidth,c=e.padInfo.top,l=e.padInfo.left,f=this.bufferSync(t),h=0;h<e.batchSize;++h){for(var d=0;d<e.inChannels;++d){for(var p=0;p<e.outHeight;++p){for(var m=p*r-c,g=m;g<0;){g+=o;}for(var v=Math.min(e.inHeight,s+m),y=0;y<e.outWidth;++y){for(var b=y*i-l,x=b;x<0;){x+=a;}for(var w=Math.min(e.inWidth,u+b),k=Number.NEGATIVE_INFINITY,E=-1,C=g;C<v;C+=o){for(var A=C-m,O=x;O<w;O+=a){var _=O-b,S=f.get(h,C,O,d);S>k&&(k=S,E=A*u+_);}}n.set(E,h,p,y,d);}}}}return n.toTensor();},e.prototype.maxPoolBackprop=function(t,e,n,r){Fl([e,n],"maxPoolBackprop");for(var i=this.maxPoolPositions(e,r),o=r.strideHeight,a=r.strideWidth,s=r.dilationHeight,u=r.dilationWidth,c=r.effectiveFilterHeight,l=r.effectiveFilterWidth,f=l-1-r.padInfo.left,h=c-1-r.padInfo.top,d=vr(e.shape,"float32"),p=this.bufferSync(i),m=this.bufferSync(t),g=0;g<r.batchSize;++g){for(var v=0;v<r.inChannels;++v){for(var y=0;y<r.inHeight;++y){for(var b=0;b<r.inWidth;++b){for(var x=y-h,w=b-f,k=0,E=0;E<c;E+=s){var C=(x+E)/o;if(!(C<0||C>=r.outHeight||Math.floor(C)!==C))for(var A=0;A<l;A+=u){var O=(w+A)/a;if(!(O<0||O>=r.outWidth||Math.floor(O)!==O)){var _=c*l-1-p.get(g,C,O,v)===E*l+A?1:0;0!==_&&(k+=m.get(g,C,O,v)*_);}}}d.set(k,g,y,b,v);}}}}return d.toTensor();},e.prototype.avgPoolBackprop=function(t,e,n){Fl([t,e],"avgPoolBackprop");for(var r=n.strideHeight,i=n.strideWidth,o=n.filterHeight,a=n.filterWidth,s=n.dilationHeight,u=n.dilationWidth,c=n.effectiveFilterHeight,l=n.effectiveFilterWidth,f=l-1-n.padInfo.left,h=c-1-n.padInfo.top,d=vr(e.shape,"float32"),p=1/(o*a),m=this.bufferSync(t),g=0;g<n.batchSize;++g){for(var v=0;v<n.inChannels;++v){for(var y=0;y<n.inHeight;++y){for(var b=0;b<n.inWidth;++b){for(var x=y-h,w=b-f,k=0,E=0;E<c;E+=s){var C=(x+E)/r;if(!(C<0||C>=n.outHeight||Math.floor(C)!==C))for(var A=0;A<l;A+=u){var O=(w+A)/i;O<0||O>=n.outWidth||Math.floor(O)!==O||(k+=m.get(g,C,O,v));}}d.set(k*p,g,y,b,v);}}}}return d.toTensor();},e.prototype.pool3d=function(t,e,n){Fl(t,"pool3d");for(var r=e.strideDepth,i=e.strideHeight,o=e.strideWidth,a=e.dilationDepth,s=e.dilationHeight,u=e.dilationWidth,c=e.effectiveFilterDepth,l=e.effectiveFilterHeight,f=e.effectiveFilterWidth,h=e.padInfo.front,d=e.padInfo.top,p=e.padInfo.left,m="max"===n?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,g=this.readSync(t.dataId),v=vr(e.outShape,t.dtype),y=v.values,b=e.outShape[1]*e.outShape[2]*e.outShape[3]*e.outShape[4],x=e.outShape[2]*e.outShape[3]*e.outShape[4],w=e.outShape[3]*e.outShape[4],k=e.outShape[4],E=0;E<e.batchSize;++E){for(var C=E*b,A=E*t.strides[0],O=0;O<e.inChannels;++O){for(var _=0;_<e.outDepth;++_){for(var S=_*r-h,D=S;D<0;){D+=a;}for(var F=Math.min(e.inDepth,c+S),T=C+_*x,N=0;N<e.outHeight;++N){for(var I=N*i-d,R=I;R<0;){R+=s;}for(var M=Math.min(e.inHeight,l+I),j=T+N*w,B=0;B<e.outWidth;++B){for(var P=B*o-p,L=P;L<0;){L+=u;}for(var z=Math.min(e.inWidth,f+P),U=j+B*k,W=m,V=0,q=0,$=D;$<F;$+=a){for(var H=A+$*t.strides[1],G=R;G<M;G+=s){for(var K=H+G*t.strides[2],X=L;X<z;X+=u){var Y=g[K+X*t.strides[3]+O];if("max"===n&&Y>W?W=Y:"avg"===n&&(V+=Y,q++),isNaN(W))break;}if(isNaN(W))break;}if(isNaN(W))break;}y[U+O]="avg"===n?V/q:W;}}}}}return v.toTensor();},e.prototype.avgPool3d=function(t,e){return Fl(t,"avgPool3d"),this.pool3d(t,e,"avg").toFloat();},e.prototype.avgPool3dBackprop=function(t,e,n){Fl([t,e],"avgPool3dBackprop");for(var r=n.strideDepth,i=n.strideHeight,o=n.strideWidth,a=n.filterDepth,s=n.filterHeight,u=n.filterWidth,c=n.dilationDepth,l=n.dilationHeight,f=n.dilationWidth,h=n.effectiveFilterDepth,d=n.effectiveFilterHeight,p=n.effectiveFilterWidth,m=h-1-n.padInfo.front,g=p-1-n.padInfo.left,v=d-1-n.padInfo.top,y=vr(e.shape,"float32"),b=1/(a*s*u),x=this.bufferSync(t),w=0;w<n.batchSize;++w){for(var k=0;k<n.inChannels;++k){for(var E=0;E<n.inDepth;++E){for(var C=0;C<n.inHeight;++C){for(var A=0;A<n.inWidth;++A){for(var O=E-m,_=C-v,S=A-g,D=0,F=0;F<h;F+=c){var T=(O+F)/r;if(!(T<0||T>=n.outDepth||Math.floor(T)!==T))for(var N=0;N<d;N+=l){var I=(_+N)/i;if(!(I<0||I>=n.outHeight||Math.floor(I)!==I))for(var R=0;R<p;R+=f){var M=(S+R)/o;M<0||M>=n.outWidth||Math.floor(M)!==M||(D+=x.get(w,T,I,M,k));}}}y.set(D*b,w,E,C,A,k);}}}}}return y.toTensor();},e.prototype.maxPool3d=function(t,e){return Fl(t,"maxPool3d"),this.pool3d(t,e,"max").toFloat();},e.prototype.maxPool3dPositions=function(t,e){for(var n=vr(e.outShape,"int32"),r=e.strideDepth,i=e.strideHeight,o=e.strideWidth,a=e.dilationDepth,s=e.dilationHeight,u=e.dilationWidth,c=e.effectiveFilterDepth,l=e.effectiveFilterHeight,f=e.effectiveFilterWidth,h=e.padInfo.front,d=e.padInfo.top,p=e.padInfo.left,m=this.bufferSync(t),g=0;g<e.batchSize;++g){for(var v=0;v<e.inChannels;++v){for(var y=0;y<e.outDepth;++y){for(var b=y*r-h,x=b;x<0;){x+=a;}for(var w=Math.min(e.inDepth,c+b),k=0;k<e.outHeight;++k){for(var E=k*i-d,C=E;C<0;){C+=s;}for(var A=Math.min(e.inHeight,l+E),O=0;O<e.outWidth;++O){for(var _=O*o-p,S=_;S<0;){S+=u;}for(var D=Math.min(e.inWidth,f+_),F=Number.NEGATIVE_INFINITY,T=-1,N=x;N<w;N+=a){for(var I=N-b,R=C;R<A;R+=s){for(var M=R-E,j=S;j<D;j+=u){var B=j-_,P=m.get(g,N,R,j,v);P>=F&&(F=P,T=I*l*f+M*l+B);}}}n.set(T,g,y,k,O,v);}}}}}return n.toTensor();},e.prototype.maxPool3dBackprop=function(t,e,n,r){Fl([e,n],"maxPool3dBackprop");for(var i=this.maxPool3dPositions(e,r),o=r.strideDepth,a=r.strideHeight,s=r.strideWidth,u=r.dilationDepth,c=r.dilationHeight,l=r.dilationWidth,f=r.effectiveFilterDepth,h=r.effectiveFilterHeight,d=r.effectiveFilterWidth,p=f-1-r.padInfo.front,m=d-1-r.padInfo.left,g=h-1-r.padInfo.top,v=vr(e.shape,"float32"),y=this.bufferSync(i),b=this.bufferSync(t),x=0;x<r.batchSize;++x){for(var w=0;w<r.inChannels;++w){for(var k=0;k<r.inDepth;++k){for(var E=0;E<r.inHeight;++E){for(var C=0;C<r.inWidth;++C){for(var A=k-p,O=E-g,_=C-m,S=0,D=0;D<f;D+=u){var F=(A+D)/o;if(!(F<0||F>=r.outDepth||Math.floor(F)!==F))for(var T=0;T<h;T+=c){var N=(O+T)/a;if(!(N<0||N>=r.outHeight||Math.floor(N)!==N))for(var I=0;I<d;I+=l){var R=(_+I)/s;if(!(R<0||R>=r.outWidth||Math.floor(R)!==R)){var M=f*h*d-1-y.get(x,F,N,R,w)===D*h*d+T*d+I?1:0;0!==M&&(S+=b.get(x,F,N,R,w)*M);}}}}v.set(S,x,k,E,C,w);}}}}}return v.toTensor();},e.prototype.cast=function(t,e){return zi(t,e,this);},e.prototype.reshape=function(t,e){return Ui(t,e);},e.prototype.avgPool=function(t,e){return Fl(t,"avgPool"),this.pool(t,e,"avg").toFloat();},e.prototype.resizeBilinear=function(t,e,n,r){Fl(t,"resizeBilinear");for(var i=t.shape,o=i[0],a=i[1],s=i[2],u=i[3],c=this.readSync(t.dataId),l=new Float32Array(T([o,e,n,u])),f=[r&&e>1?a-1:a,r&&n>1?s-1:s],h=[r&&e>1?e-1:e,r&&n>1?n-1:n],d=0,p=f[0]/h[0],m=f[1]/h[1],g=0;g<o;g++){for(var v=0;v<e;v++){for(var y=p*v,b=Math.floor(y),x=y-b,w=Math.min(a-1,Math.ceil(y)),k=g*t.strides[0]+b*t.strides[1],E=g*t.strides[0]+w*t.strides[1],C=0;C<n;C++){for(var A=m*C,O=Math.floor(A),_=A-O,S=Math.min(s-1,Math.ceil(A)),D=k+O*t.strides[2],F=E+O*t.strides[2],N=k+S*t.strides[2],I=E+S*t.strides[2],R=0;R<u;R++){var M=c[D+R],j=c[F+R],B=M+(c[N+R]-M)*_,P=B+(j+(c[I+R]-j)*_-B)*x;l[d++]=P;}}}}return jn(l,[o,e,n,u]);},e.prototype.resizeBilinearBackprop=function(t,e,n){Fl([t,e],"resizeBilinearBackprop");for(var r=e.shape,i=r[0],o=r[1],a=r[2],s=r[3],u=t.shape,c=u[1],l=u[2],f=new Float32Array(i*o*a*s),h=[n&&c>1?o-1:o,n&&l>1?a-1:a],d=[n&&c>1?c-1:c,n&&l>1?l-1:l],p=h[0]/d[0],m=h[1]/d[1],g=this.readSync(t.dataId),v=0,y=0;y<i;y++){for(var b=y*e.strides[0],x=0;x<c;x++){for(var w=x*p,k=Math.floor(w),E=Math.min(Math.ceil(w),o-1),C=b+k*e.strides[1],A=b+E*e.strides[1],O=w-k,_=1-O,S=0;S<l;S++){for(var D=S*m,F=Math.floor(D),T=Math.min(Math.ceil(D),a-1),N=D-F,I=1-N,R=C+F*e.strides[2],M=C+T*e.strides[2],j=A+F*e.strides[2],B=A+T*e.strides[2],P=_*I,L=_*N,z=O*I,U=O*N,W=0;W<s;W++){var V=g[v++];f[R+W]+=V*P,f[M+W]+=V*L,f[j+W]+=V*z,f[B+W]+=V*U;}}}}return Wn(f,[i,a,o,s],e.dtype);},e.prototype.resizeNearestNeighbor=function(t,e,n,r){Fl(t,"resizeNearestNeighbor");for(var i=t.shape,o=i[0],a=i[1],s=i[2],u=i[3],c=this.readSync(t.dataId),l=new Float32Array(o*e*n*u),f=[r&&e>1?a-1:a,r&&n>1?s-1:s],h=[r&&e>1?e-1:e,r&&n>1?n-1:n],d=f[0]/h[0],p=f[1]/h[1],m=0,g=0;g<o;g++){for(var v=g*t.strides[0],y=0;y<e;y++){for(var b=d*y,x=v+Math.min(a-1,r?Math.round(b):Math.floor(b))*t.strides[1],w=0;w<n;w++){for(var k=p*w,E=x+Math.min(s-1,r?Math.round(k):Math.floor(k))*t.strides[2],C=0;C<u;C++){var A=c[E+C];l[m++]=A;}}}}return jn(l,[o,e,n,u],t.dtype);},e.prototype.resizeNearestNeighborBackprop=function(t,e,n){Fl([t,e],"resizeNearestNeighborBackprop");for(var r=e.shape,i=r[0],o=r[1],a=r[2],s=r[3],u=t.shape,c=u[1],l=u[2],f=new Float32Array(i*o*a*s),h=this.readSync(t.dataId),d=[n&&c>1?o-1:o,n&&l>1?a-1:a],p=[n&&c>1?c-1:c,n&&l>1?l-1:l],m=d[0]/p[0],g=d[1]/p[1],v=1/m,y=1/g,b=2*Math.ceil(v)+2,x=2*Math.ceil(y)+2,w=0;w<i;w++){for(var k=w*e.strides[0],E=0;E<o;E++){for(var C=k+E*e.strides[1],A=Math.floor(E*v),O=Math.floor(A-b/2),_=0;_<a;_++){for(var S=C+_*e.strides[2],D=Math.floor(_*y),F=Math.floor(D-x/2),T=0;T<s;T++){for(var N=0,I=0;I<b;I++){var R=I+O;if(!(R<0||R>=c)){var M=k+R*t.strides[1],j=R*m;if(E===Math.min(o-1,n?Math.round(j):Math.floor(j)))for(var B=0;B<x;B++){var P=B+F;if(!(P<0||P>=l)){var L=M+P*t.strides[2],z=P*g;_===Math.min(a-1,n?Math.round(z):Math.floor(z))&&(N+=h[L+T]);}}}}f[S+T]=N;}}}}return Wn(f,e.shape,e.dtype);},e.prototype.batchNormalization=function(t,e,n,r,i,o){Fl([t,e,n,i,o],"batchNorm");for(var a=this.readSync(t.dataId),s=this.readSync(e.dataId),u=this.readSync(n.dataId),c=i?this.readSync(i.dataId):new Float32Array([1]),l=o?this.readSync(o.dataId):new Float32Array([0]),f=new Float32Array(a.length),h=l.length,d=c.length,p=u.length,m=s.length,g=0,v=0,y=0,b=0,x=0;x<a.length;++x){f[x]=l[g++]+(a[x]-s[v++])*c[y++]/Math.sqrt(u[b++]+r),g>=h&&(g=0),v>=m&&(v=0),y>=d&&(y=0),b>=p&&(b=0);}return Wn(f,t.shape);},e.prototype.localResponseNormalization4D=function(t,e,n,r,i){Fl(t,"localResponseNormalization4D");var o=t.shape[3],a=o-1,s=this.readSync(t.dataId),u=t.size,c=new Float32Array(u);function l(t){for(var n=t%o,r=t-n+Math.max(0,n-e),i=t-n+Math.min(n+e,a),u=0;r<=i;r++){var c=s[r];u+=c*c;}return u;}for(var f=0;f<u;f++){var h=l(f),d=s[f]*Math.pow(n+r*h,-i);c[f]=d;}return Wn(c,t.shape);},e.prototype.LRNGrad=function(t,e,n,r,i,o,a){Fl(t,"LRNGrad");for(var s=t.shape[3],u=this.readSync(t.dataId),c=this.readSync(e.dataId),l=this.readSync(n.dataId),f=new Float32Array(t.size),h=t.size,d=0;d<h;d++){for(var p=d%s,m=d-p+Math.max(0,p-r),g=d-p+Math.min(s,p+r+1),v=0,y=m;y<g;y++){v+=Math.pow(c[y],2);}for(v=o*v+i,y=m;y<g;y++){var b=-2*o*a*c[y]*l[d]/v;d===y&&(b+=Math.pow(v,-a)),b*=u[d],f[y]+=b;}}return Wn(f,t.shape);},e.prototype.multinomial=function(t,e,n,r){Fl(t,"multinomial");for(var i=e?t:xi(t),o=i.shape[0],a=i.shape[1],s=Gn([o,n],"int32"),u=this.readSync(s.dataId),c=this.readSync(i.dataId),l=0;l<o;++l){var f=l*a,h=new Float32Array(a-1);h[0]=c[f];for(var d=1;d<h.length;++d){h[d]=h[d-1]+c[f+d];}for(var p=dr(r.toString()),m=l*n,g=0;g<n;++g){var v=p();u[m+g]=h.length;for(var y=0;y<h.length;y++){if(v<h[y]){u[m+g]=y;break;}}}}return s;},e.prototype.oneHot=function(t,e,n,r){Fl(t,"oneHot");var i=new Float32Array(t.size*e);i.fill(r);for(var o=this.readSync(t.dataId),a=0;a<t.size;++a){o[a]>=0&&o[a]<e&&(i[a*e+o[a]]=n);}return zn(i,[t.size,e],"int32");},e.prototype.nonMaxSuppression=function(t,e,n,r,i){return Fl(t,"nonMaxSuppression"),Yi(this.readSync(t.dataId),this.readSync(e.dataId),n,r,i);},e.prototype.fft=function(t){return this.fftBatch(t,!1);},e.prototype.ifft=function(t){return this.fftBatch(t,!0);},e.prototype.fftBatch=function(t,e){for(var n=t.shape[0],r=t.shape[1],i=vr(t.shape,"float32"),o=vr(t.shape,"float32"),a=Rn(t).as2D(n,r),s=Mn(t).as2D(n,r),u=0;u<n;u++){for(var c=a.slice([u,0],[1,r]),l=s.slice([u,0],[1,r]),f=In(c,l),h=this.readSync(this.fftImpl(f,e).dataId),d=0;d<r;d++){var p=$i(h,d);i.values[u*r+d]=p.real,o.values[u*r+d]=p.imag;}}return In(i.toTensor(),o.toTensor()).as2D(n,r);},e.prototype.fftImpl=function(t,e){var n=t.as1D(),r=n.size;if(this.isExponentOf2(r)){var i=this.fftRadix2(n,r,e).as2D(t.shape[0],t.shape[1]);return e&&(i=In(Rn(i).div(Pn(r)),Mn(i).div(Pn(r)))),i;}var o=this.readSync(t.dataId),a=function(t){for(var e=new Float32Array(t.length/2),n=new Float32Array(t.length/2),r=0;r<t.length;r+=2){e[r/2]=t[r],n[r/2]=t[r+1];}return {real:e,imag:n};}(this.fourierTransformByMatmul(o,r,e));return In(a.real,a.imag).as2D(t.shape[0],t.shape[1]);},e.prototype.isExponentOf2=function(t){return 0==(t&t-1);},e.prototype.fftRadix2=function(t,e,n){if(1===e)return t;var r=this.readSync(t.dataId),i=e/2,o=function(t){for(var e=Math.ceil(t.length/4),n=new Float32Array(e),r=new Float32Array(e),i=0;i<t.length;i+=4){n[Math.floor(i/4)]=t[i],r[Math.floor(i/4)]=t[i+1];}return {real:n,imag:r};}(r),a=In(o.real,o.imag).as1D(),s=function(t){for(var e=Math.floor(t.length/4),n=new Float32Array(e),r=new Float32Array(e),i=2;i<t.length;i+=4){n[Math.floor(i/4)]=t[i],r[Math.floor(i/4)]=t[i+1];}return {real:n,imag:r};}(r),u=In(s.real,s.imag).as1D();a=this.fftRadix2(a,i,n),u=this.fftRadix2(u,i,n);var c=function(t,e){for(var n=new Float32Array(t/2),r=new Float32Array(t/2),i=0;i<Math.ceil(t/2);i++){var o=(e?2:-2)*Math.PI*(i/t);n[i]=Math.cos(o),r[i]=Math.sin(o);}return {real:n,imag:r};}(e,n),l=In(c.real,c.imag).mul(u),f=a.add(l),h=a.sub(l),d=Rn(f).concat(Rn(h)),p=Mn(f).concat(Mn(h));return In(d,p).as1D();},e.prototype.fourierTransformByMatmul=function(t,e,n){for(var r=new Float32Array(2*e),i=0;i<e;i++){for(var o=0,a=0,s=0;s<e;s++){var u=Gi(i*s,e,n),c=$i(t,s);o+=c.real*u.real-c.imag*u.imag,a+=c.real*u.imag+c.imag*u.real;}n&&(o/=e,a/=e),Hi(r,o,a,i);}return r;},e.prototype.depthToSpace=function(t,e,n){_("NHWC"===n,function(){return "Only NHWC dataFormat supported on CPU for depthToSpace. Got "+n;}),_(e>1,function(){return "blockSize should be > 1 for depthToSpace, but was: "+e;});for(var r=t.shape[0],i=t.shape[1],o=t.shape[2],a=t.shape[3],s=i*e,u=o*e,c=a/(e*e),l=this.readSync(t.dataId),f=new Float32Array(r*s*u*c),h=0,d=0;d<r;++d){for(var p=0;p<s;++p){for(var m=Math.floor(p/e),g=p%e,v=0;v<u;++v){for(var y=Math.floor(v/e),b=(g*e+v%e)*c,x=0;x<c;++x){var w=x+b+a*(y+o*(m+i*d));f[h++]=l[w];}}}}return Wn(f,[r,s,u,c]);},e.prototype.broadcastedBinaryOp=function(t,e,n,r){var i=_i(t.shape,e.shape),o=vr(i,n),a=this.readSync(t.dataId),s=this.readSync(e.dataId),u=Ai(t.shape,i),c=Ai(e.shape,i),l=o.values;if(u.length+c.length===0)for(var f=0;f<l.length;++f){l[f]=r(a[f%a.length],s[f%s.length]);}else {var h=this.bufferSync(t),d=this.bufferSync(e),p=function p(n){var i=o.indexToLoc(n),f=i.slice(-t.rank);u.forEach(function(t){return f[t]=0;});var p=h.locToIndex(f),m=i.slice(-e.rank);c.forEach(function(t){return m[t]=0;});var g=d.locToIndex(m);l[n]=r(a[p],s[g]);};for(f=0;f<l.length;++f){p(f);}}return o.toTensor();},e.prototype.broadcastedBinaryComplexOp=function(t,e,n){var r=_i(t.shape,e.shape),i=vr(r,"float32"),o=vr(r,"float32"),a=this.readSync(t.dataId),s=this.readSync(e.dataId),u=Ai(t.shape,r),c=Ai(e.shape,r),l=i.values,f=o.values;if(u.length+c.length===0)for(var h=0;h<l.length;h++){var d=h%a.length,p=h%s.length,m=n(a[2*d],a[2*d+1],s[2*p],s[2*p+1]);l[h]=m.real,f[h]=m.imag;}else {var g=this.bufferSync(this.data.get(t.dataId).complexTensors.real),v=this.bufferSync(this.data.get(e.dataId).complexTensors.real),y=function y(r){var o=i.indexToLoc(r),h=o.slice(-t.rank);u.forEach(function(t){return h[t]=0;});var d=g.locToIndex(h),p=o.slice(-e.rank);c.forEach(function(t){return p[t]=0;});var m=v.locToIndex(p),y=n(a[2*d],a[2*d+1],s[2*m],s[2*m+1]);l[r]=y.real,f[r]=y.imag;};for(h=0;h<l.length;h++){y(h);}}return this.complex(i.toTensor(),o.toTensor());},e.prototype.split=function(t,e,n){return no(t,e,n);},e.prototype.dispose=function(){},e.prototype.floatPrecision=function(){return 32;},e.prototype.epsilon=function(){return 1e-7;},e.prototype.cropAndResize=function(t,e,n,r,i,o){for(var a=t.shape,s=a[0],u=a[1],c=a[2],l=a[3],f=e.shape[0],h=r[0],d=r[1],p=vr([f,h,d,l],"float32"),m=this.readSync(e.dataId),g=this.readSync(n.dataId),v=this.readSync(t.dataId),y=t.strides,b=p.strides,x=0;x<f;x++){var w=4*x,k=m[w],E=m[w+1],C=m[w+2],A=m[w+3],O=g[x];if(!(O>=s))for(var _=h>1?(C-k)*(u-1)/(h-1):0,S=d>1?(A-E)*(c-1)/(d-1):0,D=0;D<h;D++){var F=h>1?k*(u-1)+D*_:.5*(k+C)*(u-1);if(F<0||F>u-1)for(var T=0;T<d;T++){for(var N=0;N<l;N++){var I=N+T*b[2]+D*b[1]+x*b[0];p.values[I]=o;}}else if("bilinear"===i){var R=Math.floor(F),M=Math.ceil(F),j=F-R;for(T=0;T<d;T++){if(($=d>1?E*(c-1)+T*S:.5*(E+A)*(c-1))<0||$>c-1)for(N=0;N<l;N++){I=N+T*b[2]+D*b[1]+x*b[0],p.values[I]=o;}else {var B=Math.floor($),P=Math.ceil($),L=$-B;for(N=0;N<l;N++){var z=v[I=N+B*y[2]+R*y[1]+O*y[0]],U=v[I=N+P*y[2]+R*y[1]+O*y[0]],W=v[I=N+B*y[2]+M*y[1]+O*y[0]],V=z+(U-z)*L,q=W+(v[I=N+P*y[2]+M*y[1]+O*y[0]]-W)*L;I=N+T*b[2]+D*b[1]+x*b[0],p.values[I]=V+(q-V)*j;}}}}else for(T=0;T<d;++T){var $;if(($=d>1?E*(c-1)+T*S:.5*(E+A)*(c-1))<0||$>c-1)for(N=0;N<l;N++){I=N+T*b[2]+D*b[1]+x*b[0],p.values[I]=o;}else {var H=Math.round($),G=Math.round(F);for(N=0;N<l;N++){var K=N+H*y[2]+G*y[1]+O*y[0],X=N+T*b[2]+D*b[1]+x*b[0];p.values[X]=v[K];}}}}}return p.toTensor();},e.prototype.sparseToDense=function(t,e,n,r){var i=ri(0,t,n),o=i.sliceRank,a=i.numUpdates,s=i.sliceSize,u=i.strides,c=i.outputSize;return this.scatter(t,e,n,c,s,a,o,u,r,!1);},e.prototype.gatherND=function(t,e){var n=e.shape,r=n[n.length-1],i=Jr(t,e),o=i[0],a=i[1],s=i[2],u=i[3];if(0===a)return jn([],o,t.dtype);for(var c=new wt([a,s],t.dtype),l=this.readSync(e.dataId),f=this.readSync(t.dataId),h=0;h<a;h++){for(var d=[],p=0,m=0;m<r;m++){var g=l[h*r+m];p+=g*u[m],d.push(g);}if(p<0||p>=t.size/s)throw new Error("Invalid indices: "+d+" does not index into "+t.shape);for(var v=0;v<s;v++){c.values[h*s+v]=f[p*s+v];}}return c.toTensor().reshape(o);},e.prototype.scatterND=function(t,e,n){var r=ri(0,t,n),i=r.sliceRank,o=r.numUpdates,a=r.sliceSize,s=r.strides,u=r.outputSize,c=Pn(0);return this.scatter(t,e,n,u,a,o,i,s,c,!0);},e.prototype.fill=function(t,e,n){var r=W(n=n||Q(e),T(t));return r.fill(e),Wt.makeTensor(r,t,n,this);},e.prototype.onesLike=function(t){if("string"===t.dtype)throw new Error("onesLike is not supported for string tensors");return this.fill(t.shape,1,t.dtype);},e.prototype.zerosLike=function(t){var e=W(t.dtype,T(t.shape));return this.makeOutput(e,t.shape,t.dtype);},e.prototype.linspace=function(t,e,n){return Wi(t,e,n);},e.prototype.scatter=function(t,e,n,r,i,o,a,s,u,c){var l=[r/i,i],f=this.readSync(t.dataId),h=this.readSync(e.dataId);if(0===r)return jn([],n,e.dtype);var d=new wt(l,e.dtype);d.values.fill(this.readSync(u.dataId)[0]);for(var p=0;p<o;p++){for(var m=[],g=0,v=0;v<a;v++){var y=f[p*a+v];m.push(y),g+=y*s[v];}if(g<0||g>=r/i)throw new Error("Invalid indices: "+m+" does not index into "+n);for(var b=0;b<i;b++){c?d.values[g*i+b]+=h[p*i+b]:d.values[g*i+b]=0===e.rank?h[0]:h[p*i+b];}}return d.toTensor().reshape(n);},e;}(Ei);Wt.registerBackend("cpu",function(){return new Nl();},1);for(var Il=0,Rl=[{kernelName:"NonMaxSuppressionV5",backendName:"cpu",kernelFunc:function kernelFunc(t){var e=t.inputs,n=t.backend,r=t.attrs,i=e,o=i.boxes,a=i.scores,s=r,u=s.maxOutputSize,c=s.iouThreshold,l=s.scoreThreshold,f=s.softNmsSigma,h=n;Fl(o,"NonMaxSuppressionWithScore");var d=Ji(h.data.get(o.dataId).values,h.data.get(a.dataId).values,u,c,l,f);return [d.selectedIndices,d.selectedScores];}},{kernelName:"Square",backendName:"cpu",kernelFunc:function kernelFunc(t){var e=t.inputs,n=t.backend,r=e.x,i=n;Fl(r,"square");for(var o=i.data.get(r.dataId).values,a=new Float32Array(o.length),s=0;s<o.length;++s){var u=o[s];a[s]=u*u;}return {dataId:i.write(a,r.shape,r.dtype),shape:r.shape,dtype:r.dtype};}},{kernelName:Va,backendName:"cpu",kernelFunc:function kernelFunc(t){var e=t.inputs,n=t.backend,r=e,i=r.a,o=r.b,a=n;Fl([i,o],Va);var s=a.data.get(i.dataId).values,u=a.data.get(o.dataId).values,c=function(t,e,n,r,i,o){var a=_i(t,e),s=a.length,u=et(a),c=U(i,T(a)),l=t.length,f=e.length,h=et(t),d=et(e),p=Ai(t,a),m=Ai(e,a);if(p.length+m.length===0)for(var g=0;g<c.length;++g){c[g]=o(n[g%n.length],r[g%r.length]);}else {var v=function v(t){var e=ft(t,s,u),i=e.slice(-l);p.forEach(function(t){return i[t]=0;});var a=lt(i,l,h),g=e.slice(-f);m.forEach(function(t){return g[t]=0;});var v=lt(g,f,d);c[t]=o(n[a],r[v]);};for(g=0;g<c.length;++g){v(g);}}return [c,a];}(i.shape,o.shape,s,u,i.dtype,function(t,e){var n=t-e;return n*n;}),l=c[0],f=c[1];return {dataId:a.write(l,f,i.dtype),shape:f,dtype:i.dtype};}}];Il<Rl.length;Il++){y(Rl[Il]);}for(var Ml,jl=0,Bl=[{kernelName:"FromPixels",backendName:"webgl",kernelFunc:function kernelFunc(t){var e=t.inputs,n=t.backend,r=t.attrs,i=e.pixels,o=r.numChannels,a="undefined"!=typeof HTMLVideoElement&&i instanceof HTMLVideoElement,s="undefined"!=typeof HTMLImageElement&&i instanceof HTMLImageElement,u=a?[i.videoWidth,i.videoHeight]:[i.width,i.height],c=u[0],l=u[1],h=[l,c],d=[l,c,o];(s||a)&&(null==Ml&&(Ml=document.createElement("canvas").getContext("2d")),Ml.canvas.width=c,Ml.canvas.height=l,Ml.drawImage(i,0,0,c,l),i=Ml.canvas);var p=n.makeTensorInfo(h,"int32");n.texData.get(p.dataId).usage=Ht.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(p.dataId),i);var m=f().getBool("WEBGL_PACK")?new function(t){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;var e=uo(),n=t[0],r=t[1];this.outputShape=t,this.userCode="\n      void main() {\n        ivec3 coords = getOutputCoords();\n        int texR = coords[0];\n        int texC = coords[1];\n        int depth = coords[2];\n\n        vec4 result = vec4(0.);\n\n        for(int row=0; row<=1; row++) {\n          for(int col=0; col<=1; col++) {\n            texC = coords[1] + row;\n            depth = coords[2] + col;\n\n            vec2 uv = (vec2(texC, texR) + halfCR) /\n                       vec2("+r+".0, "+n+".0);\n            vec4 values = "+e.texture2D+"(A, uv);\n            float value;\n            if (depth == 0) {\n              value = values.r;\n            } else if (depth == 1) {\n              value = values.g;\n            } else if (depth == 2) {\n              value = values.b;\n            } else if (depth == 3) {\n              value = values.a;\n            }\n\n            result[row * 2 + col] = floor(value * 255.0 + 0.5);\n          }\n        }\n\n        "+e.output+" = result;\n      }\n    ";}(d):new function(t){this.variableNames=["A"];var e=uo(),n=t[0],r=t[1];this.outputShape=t,this.userCode="\n      void main() {\n        ivec3 coords = getOutputCoords();\n        int texR = coords[0];\n        int texC = coords[1];\n        int depth = coords[2];\n        vec2 uv = (vec2(texC, texR) + halfCR) / vec2("+r+".0, "+n+".0);\n\n        vec4 values = "+e.texture2D+"(A, uv);\n        float value;\n        if (depth == 0) {\n          value = values.r;\n        } else if (depth == 1) {\n          value = values.g;\n        } else if (depth == 2) {\n          value = values.b;\n        } else if (depth == 3) {\n          value = values.a;\n        }\n\n        setOutput(floor(value * 255.0 + 0.5));\n      }\n    ";}(d),g=n.runWebGLProgram(m,[p],"int32");return n.disposeData(p.dataId),g;}},{kernelName:"NonMaxSuppressionV5",backendName:"webgl",kernelFunc:function kernelFunc(t){var e=t.inputs,n=t.backend,r=t.attrs;vn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");var i=e,o=i.boxes,a=i.scores,s=r,u=s.maxOutputSize,c=s.iouThreshold,l=s.scoreThreshold,f=s.softNmsSigma,h=n,d=Ji(h.readSync(o.dataId),h.readSync(a.dataId),u,c,l,f);return [d.selectedIndices,d.selectedScores];}},{kernelName:"Square",backendName:"webgl",kernelFunc:function kernelFunc(t){var e=t.inputs,n=t.backend,r=e.x,i=n,o=new xa(r.shape,"return x * x;");return i.runWebGLProgram(o,[r],r.dtype);}},{kernelName:Va,backendName:"webgl",kernelFunc:function kernelFunc(t){var e=t.inputs,n=t.backend,r=e,i=r.a,o=r.b,a=n,s=f().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new Fo("return (a - b) * (a - b);",i.shape,o.shape):new So("return (a - b) * (a - b);",i.shape,o.shape);return a.compileAndRun(s,[i,o]);}}];jl<Bl.length;jl++){y(Bl[jl]);}for(var Pl=0,Ll=[{kernelName:"Square",gradFunc:function gradFunc(t,e){var n=e[0];return {x:function x(){return t.mul(n.toFloat().mul(2));}};}},{kernelName:Va,gradFunc:function gradFunc(t,e){var n=e[0],r=e[1],i=Pn(2);return {a:function a(){return ou(t,ou(i,lu(n,r)));},b:function b(){return ou(t,ou(i,lu(r,n)));}};}}];Pl<Ll.length;Pl++){b(Ll[Pl]);}var zl=function(){function t(){}return t.prototype.fetch=function(t,e){return fetch(t,e);},t.prototype.now=function(){return performance.now();},t.prototype.encode=function(t,e){if("utf-8"!==e&&"utf8"!==e)throw new Error("Browser's encoder only supports utf-8, but got "+e);return null==this.textEncoder&&(this.textEncoder=new TextEncoder()),this.textEncoder.encode(t);},t.prototype.decode=function(t,e){return new TextDecoder(e).decode(t);},t;}();f().get("IS_BROWSER")&&f().setPlatform("browser",new zl());var Ul,Wl=function(){function t(){this.util=n(249),this.textEncoder=new this.util.TextEncoder();}return t.prototype.fetch=function(t,e){return null!=f().global.fetch?f().global.fetch(t,e):(null==Ul&&(Ul=n(250)),Ul(t,e));},t.prototype.now=function(){var t=r.hrtime();return 1e3*t[0]+t[1]/1e6;},t.prototype.encode=function(t,e){if("utf-8"!==e&&"utf8"!==e)throw new Error("Node built-in encoder only supports utf-8, but got "+e);return this.textEncoder.encode(t);},t.prototype.decode=function(t,e){return 0===t.length?"":new this.util.TextDecoder(e).decode(t);},t;}();f().get("IS_NODE")&&f().setPlatform("node",new Wl());var Vl={float32:4,int32:4,uint16:2,uint8:1,bool:1},ql=4;function $l(t,e){for(var n={},r=0,i=function i(e){var i=e.name,o=e.dtype,a=e.shape,s=T(a),u=void 0;if(("quantization"in e)){var c=e.quantization;if("uint8"!==c.dtype&&"uint16"!==c.dtype)throw new Error("Weight "+e.name+" has unknown quantization dtype "+c.dtype+". Supported quantization dtypes are: 'uint8' and 'uint16'.");var l=Vl[c.dtype],f=t.slice(r,r+s*l),h="uint8"===c.dtype?new Uint8Array(f):new Uint16Array(f);if("float32"===o)u=Float32Array.from(h,function(t){return t*c.scale+c.min;});else {if("int32"!==o)throw new Error("Unsupported dtype in weight '"+i+"': "+o);u=Int32Array.from(h,function(t){return Math.round(t*c.scale+c.min);});}r+=s*l;}else if("string"===o){var d=T(e.shape);u=[];for(var p=0;p<d;p++){var m=new Uint32Array(t.slice(r,r+ql))[0];r+=ql;var g=new Uint8Array(t.slice(r,r+m));u.push(g),r+=m;}}else {var v=Vl[o];if(f=t.slice(r,r+s*v),"float32"===o)u=new Float32Array(f);else if("int32"===o)u=new Int32Array(f);else {if("bool"!==o)throw new Error("Unsupported dtype in weight '"+i+"': "+o);u=new Uint8Array(f);}r+=s*v;}n[i]=jn(u,a,o);},o=0,a=e;o<a.length;o++){i(a[o]);}return n;}var Hl=void 0!==i&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function Gl(t){return Hl?i.byteLength(t):new Blob([t]).size;}function Kl(t){var e=0;t.forEach(function(t){e+=t.byteLength;});var n=new Uint8Array(e),r=0;return t.forEach(function(t){n.set(new Uint8Array(t),r),r+=t.byteLength;}),n.buffer;}function Xl(t){for(t=t.trim();t.endsWith("/");){t=t.slice(0,t.length-1);}var e=t.split("/");return e[e.length-1];}function Yl(t){if(t.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return {dateSaved:new Date(),modelTopologyType:"JSON",modelTopologyBytes:null==t.modelTopology?0:Gl(JSON.stringify(t.modelTopology)),weightSpecsBytes:null==t.weightSpecs?0:Gl(JSON.stringify(t.weightSpecs)),weightDataBytes:null==t.weightData?0:t.weightData.byteLength};}var Jl=function(){function t(){this.saveRouters=[],this.loadRouters=[];}return t.getInstance=function(){return null==t.instance&&(t.instance=new t()),t.instance;},t.registerSaveRouter=function(e){t.getInstance().saveRouters.push(e);},t.registerLoadRouter=function(e){t.getInstance().loadRouters.push(e);},t.getSaveHandlers=function(e){return t.getHandlers(e,"save");},t.getLoadHandlers=function(e,n){return t.getHandlers(e,"load",n);},t.getHandlers=function(e,n,r){var i=[];return ("load"===n?t.getInstance().loadRouters:t.getInstance().saveRouters).forEach(function(t){var n=t(e,r);null!==n&&i.push(n);}),i;},t;}(),Ql="://",Zl=function(){function t(){this.managers={};}return t.getInstance=function(){return null==t.instance&&(t.instance=new t()),t.instance;},t.registerManager=function(e,n){_(null!=e,function(){return "scheme must not be undefined or null.";}),e.endsWith(Ql)&&(e=e.slice(0,e.indexOf(Ql))),_(e.length>0,function(){return "scheme must not be an empty string.";});var r=t.getInstance();_(null==r.managers[e],function(){return "A model store manager is already registered for scheme '"+e+"'.";}),r.managers[e]=n;},t.getManager=function(t){var e=this.getInstance().managers[t];if(null==e)throw new Error("Cannot find model manager for scheme '"+t+"'");return e;},t.getSchemes=function(){return Object.keys(this.getInstance().managers);},t;}();function tf(t){if(-1===t.indexOf(Ql))throw new Error("The url string provided does not contain a scheme. Supported schemes are: "+Zl.getSchemes().join(","));return {scheme:t.split(Ql)[0],path:t.split(Ql)[1]};}function ef(t,e,n){return void 0===n&&(n=!1),u(this,void 0,void 0,function(){var r,i,o,a,s,u,l,f,h;return c(this,function(c){switch(c.label){case 0:return _(t!==e,function(){return "Old path and new path are the same: '"+t+"'";}),_((r=Jl.getLoadHandlers(t)).length>0,function(){return "Copying failed because no load handler is found for source URL "+t+".";}),_(r.length<2,function(){return "Copying failed because more than one ("+r.length+") load handlers for source URL "+t+".";}),i=r[0],_((o=Jl.getSaveHandlers(e)).length>0,function(){return "Copying failed because no save handler is found for destination URL "+e+".";}),_(o.length<2,function(){return "Copying failed because more than one ("+r.length+") save handlers for destination URL "+e+".";}),a=o[0],s=tf(t).scheme,u=tf(t).path,l=s===tf(t).scheme,[4,i.load()];case 1:return f=c.sent(),n&&l?[4,Zl.getManager(s).removeModel(u)]:[3,3];case 2:c.sent(),c.label=3;case 3:return [4,a.save(f)];case 4:return h=c.sent(),!n||l?[3,6]:[4,Zl.getManager(s).removeModel(u)];case 5:c.sent(),c.label=6;case 6:return [2,h.modelArtifactsInfo];}});});}var nf="models_store",rf="model_info_store";function of(){if(!f().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");var t=window||self,e=t.indexedDB||t.mozIndexedDB||t.webkitIndexedDB||t.msIndexedDB||t.shimIndexedDB;if(null==e)throw new Error("The current browser does not appear to support IndexedDB.");return e;}function af(t){var e=t.result;e.createObjectStore(nf,{keyPath:"modelPath"}),e.createObjectStore(rf,{keyPath:"modelPath"});}var sf=function(){function t(t){if(this.indexedDB=of(),null==t||!t)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=t;}return t.prototype.save=function(t){return u(this,void 0,void 0,function(){return c(this,function(e){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return [2,this.databaseAction(this.modelPath,t)];});});},t.prototype.load=function(){return u(this,void 0,void 0,function(){return c(this,function(t){return [2,this.databaseAction(this.modelPath)];});});},t.prototype.databaseAction=function(t,e){var n=this;return new Promise(function(t,r){var i=n.indexedDB.open("tensorflowjs",1);i.onupgradeneeded=function(){return af(i);},i.onsuccess=function(){var o=i.result;if(null==e){var a=o.transaction(nf,"readonly"),s=a.objectStore(nf).get(n.modelPath);s.onsuccess=function(){if(null==s.result)return o.close(),r(new Error("Cannot find model with path '"+n.modelPath+"' in IndexedDB."));t(s.result.modelArtifacts);},s.onerror=function(t){return o.close(),r(s.error);},a.oncomplete=function(){return o.close();};}else {var u,c=Yl(e),l=o.transaction(rf,"readwrite"),f=l.objectStore(rf),h=f.put({modelPath:n.modelPath,modelArtifactsInfo:c});h.onsuccess=function(){var i=(u=o.transaction(nf,"readwrite")).objectStore(nf).put({modelPath:n.modelPath,modelArtifacts:e,modelArtifactsInfo:c});i.onsuccess=function(){return t({modelArtifactsInfo:c});},i.onerror=function(t){var e=(f=l.objectStore(rf)).delete(n.modelPath);e.onsuccess=function(){return o.close(),r(i.error);},e.onerror=function(t){return o.close(),r(i.error);};};},h.onerror=function(t){return o.close(),r(h.error);},l.oncomplete=function(){null==u?o.close():u.oncomplete=function(){return o.close();};};}},i.onerror=function(t){return r(i.error);};});},t.URL_SCHEME="indexeddb://",t;}(),uf=function uf(t){return f().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(sf.URL_SCHEME)?(e=t.slice(sf.URL_SCHEME.length),new sf(e)):null;var e;};Jl.registerSaveRouter(uf),Jl.registerLoadRouter(uf);var cf=function(){function t(){this.indexedDB=of();}return t.prototype.listModels=function(){return u(this,void 0,void 0,function(){var t=this;return c(this,function(e){return [2,new Promise(function(e,n){var r=t.indexedDB.open("tensorflowjs",1);r.onupgradeneeded=function(){return af(r);},r.onsuccess=function(){var t=r.result,i=t.transaction(rf,"readonly"),o=i.objectStore(rf).getAll();o.onsuccess=function(){for(var t={},n=0,r=o.result;n<r.length;n++){var i=r[n];t[i.modelPath]=i.modelArtifactsInfo;}e(t);},o.onerror=function(e){return t.close(),n(o.error);},i.oncomplete=function(){return t.close();};},r.onerror=function(t){return n(r.error);};})];});});},t.prototype.removeModel=function(t){return u(this,void 0,void 0,function(){var e=this;return c(this,function(n){var r;return t=(r=t).startsWith(sf.URL_SCHEME)?r.slice(sf.URL_SCHEME.length):r,[2,new Promise(function(n,r){var i=e.indexedDB.open("tensorflowjs",1);i.onupgradeneeded=function(){return af(i);},i.onsuccess=function(){var e,o=i.result,a=o.transaction(rf,"readwrite"),s=a.objectStore(rf),u=s.get(t);u.onsuccess=function(){if(null==u.result)return o.close(),r(new Error("Cannot find model with path '"+t+"' in IndexedDB."));var i=s.delete(t),a=function a(){var i=(e=o.transaction(nf,"readwrite")).objectStore(nf).delete(t);i.onsuccess=function(){return n(u.result.modelArtifactsInfo);},i.onerror=function(t){return r(u.error);};};i.onsuccess=a,i.onerror=function(t){return a(),o.close(),r(u.error);};},u.onerror=function(t){return o.close(),r(u.error);},a.oncomplete=function(){null==e?o.close():e.oncomplete=function(){return o.close();};};},i.onerror=function(t){return r(i.error);};})];});});},t;}();if(f().getBool("IS_BROWSER"))try{Zl.registerManager(sf.URL_SCHEME,new cf());}catch(a){}var lf="/",ff="tensorflowjs_models",hf="info",df="model_topology",pf="weight_specs",mf="weight_data",gf="model_metadata";function vf(t){return {info:[ff,t,hf].join(lf),topology:[ff,t,df].join(lf),weightSpecs:[ff,t,pf].join(lf),weightData:[ff,t,mf].join(lf),modelMetadata:[ff,t,gf].join(lf)};}function yf(t){var e=t.split(lf);if(e.length<3)throw new Error("Invalid key format: "+t);return e.slice(1,e.length-1).join(lf);}var bf=function(){function t(t){if(!f().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==t||!t)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=t,this.keys=vf(this.modelPath);}return t.prototype.save=function(t){return u(this,void 0,void 0,function(){var e,n,r;return c(this,function(o){if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");e=JSON.stringify(t.modelTopology),n=JSON.stringify(t.weightSpecs),r=Yl(t);try{return this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,e),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,function(t){if(Hl)return i.from(t).toString("base64");for(var e=new Uint8Array(t),n="",r=0,o=e.length;r<o;r++){n+=String.fromCharCode(e[r]);}return btoa(n);}(t.weightData)),this.LS.setItem(this.keys.modelMetadata,JSON.stringify({format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,userDefinedMetadata:t.userDefinedMetadata})),[2,{modelArtifactsInfo:r}];}catch(t){throw this.LS.removeItem(this.keys.info),this.LS.removeItem(this.keys.topology),this.LS.removeItem(this.keys.weightSpecs),this.LS.removeItem(this.keys.weightData),this.LS.removeItem(this.keys.modelMetadata),new Error("Failed to save model '"+this.modelPath+"' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes="+r.modelTopologyBytes+", weightSpecsBytes="+r.weightSpecsBytes+", weightDataBytes="+r.weightDataBytes+".");}return [2];});});},t.prototype.load=function(){return u(this,void 0,void 0,function(){var t,e,n,r,o,a,s;return c(this,function(u){if(null==(t=JSON.parse(this.LS.getItem(this.keys.info))))throw new Error("In local storage, there is no model with name '"+this.modelPath+"'");if("JSON"!==t.modelTopologyType)throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");if(e={},null==(n=JSON.parse(this.LS.getItem(this.keys.topology))))throw new Error("In local storage, the topology of model '"+this.modelPath+"' is missing.");if(e.modelTopology=n,null==(r=JSON.parse(this.LS.getItem(this.keys.weightSpecs))))throw new Error("In local storage, the weight specs of model '"+this.modelPath+"' are missing.");if(e.weightSpecs=r,null!=(o=this.LS.getItem(this.keys.modelMetadata))&&(a=JSON.parse(o),e.format=a.format,e.generatedBy=a.generatedBy,e.convertedBy=a.convertedBy,e.userDefinedMetadata=a.userDefinedMetadata),null==(s=this.LS.getItem(this.keys.weightData)))throw new Error("In local storage, the binary weight values of model '"+this.modelPath+"' are missing.");return e.weightData=function(t){if(Hl){var e=i.from(t,"base64");return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);}for(var n=atob(t),r=new Uint8Array(n.length),o=0;o<n.length;++o){r.set([n.charCodeAt(o)],o);}return r.buffer;}(s),[2,e];});});},t.URL_SCHEME="localstorage://",t;}(),xf=function xf(t){return f().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(bf.URL_SCHEME)?(e=t.slice(bf.URL_SCHEME.length),new bf(e)):null;var e;};Jl.registerSaveRouter(xf),Jl.registerLoadRouter(xf);var wf=function(){function t(){_(f().getBool("IS_BROWSER"),function(){return "Current environment is not a web browser";}),_("undefined"==typeof window||void 0!==window.localStorage,function(){return "Current browser does not appear to support localStorage";}),this.LS=window.localStorage;}return t.prototype.listModels=function(){return u(this,void 0,void 0,function(){var t,e,n,r,i,o;return c(this,function(a){for(t={},e=ff+lf,n=lf+hf,r=0;r<this.LS.length;++r){(i=this.LS.key(r)).startsWith(e)&&i.endsWith(n)&&(o=yf(i),t[o]=JSON.parse(this.LS.getItem(i)));}return [2,t];});});},t.prototype.removeModel=function(t){return u(this,void 0,void 0,function(){var e,n;return c(this,function(r){var i;if(t=(i=t).startsWith(bf.URL_SCHEME)?i.slice(bf.URL_SCHEME.length):i,e=vf(t),null==this.LS.getItem(e.info))throw new Error("Cannot find model at path '"+t+"'");return n=JSON.parse(this.LS.getItem(e.info)),this.LS.removeItem(e.info),this.LS.removeItem(e.topology),this.LS.removeItem(e.weightSpecs),this.LS.removeItem(e.weightData),[2,n];});});},t;}();if(f().getBool("IS_BROWSER"))try{Zl.registerManager(bf.URL_SCHEME,new wf());}catch(a){}var kf="model",Ef=".json",Cf=".weights.bin";function Af(t){return new Promise(function(t){return setTimeout(t);}).then(t);}var Of=function(){function t(e){if(!f().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(t.URL_SCHEME)&&(e=e.slice(t.URL_SCHEME.length)),null!=e&&0!==e.length||(e=kf),this.modelTopologyFileName=e+Ef,this.weightDataFileName=e+Cf;}return t.prototype.save=function(t){return u(this,void 0,void 0,function(){var e,n,r,i,o,a;return c(this,function(s){switch(s.label){case 0:if("undefined"==typeof document)throw new Error("Browser downloads are not supported in this environment since `document` is not present");if(e=window.URL.createObjectURL(new Blob([t.weightData],{type:"application/octet-stream"})),!(t.modelTopology instanceof ArrayBuffer))return [3,1];throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");case 1:return n=[{paths:["./"+this.weightDataFileName],weights:t.weightSpecs}],r={modelTopology:t.modelTopology,format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,weightsManifest:n},i=window.URL.createObjectURL(new Blob([JSON.stringify(r)],{type:"application/json"})),(o=null==this.jsonAnchor?document.createElement("a"):this.jsonAnchor).download=this.modelTopologyFileName,o.href=i,[4,Af(function(){return o.dispatchEvent(new MouseEvent("click"));})];case 2:return s.sent(),null==t.weightData?[3,4]:((a=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor).download=this.weightDataFileName,a.href=e,[4,Af(function(){return a.dispatchEvent(new MouseEvent("click"));})]);case 3:s.sent(),s.label=4;case 4:return [2,{modelArtifactsInfo:Yl(t)}];}});});},t.URL_SCHEME="downloads://",t;}(),_f=function(){function t(t){if(null==t||t.length<1)throw new Error("When calling browserFiles, at least 1 file is required, but received "+t);this.files=t;}return t.prototype.load=function(){return u(this,void 0,void 0,function(){var t,e,n=this;return c(this,function(r){return t=this.files[0],e=this.files.slice(1),[2,new Promise(function(r,i){var o=new FileReader();o.onload=function(o){var a=JSON.parse(o.target.result),s=a.modelTopology;if(null!=s){0===e.length&&r({modelTopology:s});var u=a.weightsManifest;if(null!=u){var c;try{c=n.checkManifestAndWeightFiles(u,e);}catch(t){return void i(t);}var l=[],f=[],h=[];u.forEach(function(t){t.paths.forEach(function(t){f.push(t),h.push(null);}),l.push.apply(l,t.weights);}),u.forEach(function(t){t.paths.forEach(function(t){var e=new FileReader();e.onload=function(e){var n=e.target.result,i=f.indexOf(t);h[i]=n,-1===h.indexOf(null)&&r({modelTopology:s,weightSpecs:l,weightData:Kl(h),format:a.format,generatedBy:a.generatedBy,convertedBy:a.convertedBy,userDefinedMetadata:a.userDefinedMetadata});},e.onerror=function(e){return i("Failed to weights data from file of path '"+t+"'.");},e.readAsArrayBuffer(c[t]);});});}else i(new Error("weightManifest field is missing from file "+t.name));}else i(new Error("modelTopology field is missing from file "+t.name));},o.onerror=function(e){return i("Failed to read model topology and weights manifest JSON from file '"+t.name+"'. BrowserFiles supports loading Keras-style tf.Model artifacts only.");},o.readAsText(t);})];});});},t.prototype.checkManifestAndWeightFiles=function(t,e){for(var n=[],r=e.map(function(t){return Xl(t.name);}),i={},o=0,a=t;o<a.length;o++){a[o].paths.forEach(function(t){var o=Xl(t);if(-1!==n.indexOf(o))throw new Error("Duplicate file basename found in weights manifest: '"+o+"'");if(n.push(o),-1===r.indexOf(o))throw new Error("Weight file with basename '"+o+"' is not provided.");i[t]=e[r.indexOf(o)];});}if(n.length!==e.length)throw new Error("Mismatch in the number of files in weights manifest ("+n.length+") and the number of weight files provided ("+e.length+").");return i;},t;}();function Sf(t,e,n,r){!function(t){_(null!=t&&Array.isArray(t)&&t.length>0,function(){return "promises must be a none empty array";});}(t),function(t,e){_(t>=0&&t<=1,function(){return "Progress fraction must be in range [0, 1], but got startFraction "+t;}),_(e>=0&&e<=1,function(){return "Progress fraction must be in range [0, 1], but got endFraction "+e;}),_(e>=t,function(){return "startFraction must be no more than endFraction, but got startFraction "+t+" and endFraction "+e;});}(n=null==n?0:n,r=null==r?1:r);var i=0;return Promise.all(t.map(function(o){return o.then(function(o){var a=n+ ++i/t.length*(r-n);return e(a),o;}),o;}));}function Df(t,e){return u(this,void 0,void 0,function(){var n,r,i,o,a,s,u,l,h;return c(this,function(c){switch(c.label){case 0:return null==e&&(e={}),n=null==e.fetchFunc?f().platform.fetch:e.fetchFunc,r=t.map(function(t){return n(t,e.requestInit,{isBinary:!0});}),i=0,o=.5,null!=e.onProgress?[3,2]:[4,Promise.all(r)];case 1:return a=c.sent(),[3,4];case 2:return [4,Sf(r,e.onProgress,i,o)];case 3:a=c.sent(),c.label=4;case 4:return s=a.map(function(t){return t.arrayBuffer();}),u=.5,l=1,null!=e.onProgress?[3,6]:[4,Promise.all(s)];case 5:return h=c.sent(),[3,8];case 6:return [4,Sf(s,e.onProgress,u,l)];case 7:h=c.sent(),c.label=8;case 8:return [2,h];}});});}function Ff(t){var e=this;return function(n,r,i){return void 0===r&&(r=""),u(e,void 0,void 0,function(){var e,o,a,s,u,l,f,h,d,p;return c(this,function(c){switch(c.label){case 0:if(e=n.map(function(){return !1;}),o={},a=null!=i?i.map(function(){return !1;}):[],s=[],n.forEach(function(t,n){var r=0;t.weights.forEach(function(t){var u="quantization"in t?t.quantization.dtype:t.dtype,c=Vl[u]*T(t.shape),l=function l(){e[n]=!0,null==o[n]&&(o[n]=[]),o[n].push({manifestEntry:t,groupOffset:r,sizeBytes:c});};null!=i?i.forEach(function(e,n){e===t.name&&(l(),a[n]=!0);}):l(),s.push(t.name),r+=c;});}),!a.every(function(t){return t;}))throw u=i.filter(function(t,e){return !a[e];}),new Error("Could not find weights in manifest with names: "+u.join(", ")+". \nManifest JSON has weights with names: "+s.join(", ")+".");return l=e.reduce(function(t,e,n){return e&&t.push(n),t;},[]),f=[],l.forEach(function(t){n[t].paths.forEach(function(t){var e=r+(r.endsWith("/")?"":"/")+t;f.push(e);});}),[4,t(f)];case 1:return h=c.sent(),d={},p=0,l.forEach(function(t){for(var e=n[t].paths.length,r=0,i=0;i<e;i++){r+=h[p+i].byteLength;}for(var a=new ArrayBuffer(r),s=new Uint8Array(a),u=0,c=0;c<e;c++){var l=new Uint8Array(h[p+c]);s.set(l,u),u+=l.byteLength;}o[t].forEach(function(t){var e=$l(a.slice(t.groupOffset,t.groupOffset+t.sizeBytes),[t.manifestEntry]);for(var n in e){d[n]=e[n];}}),p+=e;}),[2,d];}});});};}Jl.registerSaveRouter(function(t){return f().getBool("IS_BROWSER")&&!Array.isArray(t)&&t.startsWith(Of.URL_SCHEME)?function(t){return void 0===t&&(t="model"),new Of(t);}(t.slice(Of.URL_SCHEME.length)):null;});var Tf=function(){function t(t,e){if(this.DEFAULT_METHOD="POST",null==e&&(e={}),this.weightPathPrefix=e.weightPathPrefix,this.onProgress=e.onProgress,null!=e.fetchFunc?(_("function"==typeof e.fetchFunc,function(){return "Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)";}),this.fetch=e.fetchFunc):this.fetch=f().platform.fetch,_(null!=t&&t.length>0,function(){return "URL path for http must not be null, undefined or empty.";}),Array.isArray(t)&&_(2===t.length,function(){return "URL paths for http must have a length of 2, (actual length is "+t.length+").";}),this.path=t,null!=e.requestInit&&null!=e.requestInit.body)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=e.requestInit||{};}return t.prototype.save=function(t){return u(this,void 0,void 0,function(){var e,n,r,i;return c(this,function(o){switch(o.label){case 0:if(t.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");return (e=Object.assign({method:this.DEFAULT_METHOD},this.requestInit)).body=new FormData(),n=[{paths:["./model.weights.bin"],weights:t.weightSpecs}],r={modelTopology:t.modelTopology,format:t.format,generatedBy:t.generatedBy,convertedBy:t.convertedBy,userDefinedMetadata:t.userDefinedMetadata,weightsManifest:n},e.body.append("model.json",new Blob([JSON.stringify(r)],{type:"application/json"}),"model.json"),null!=t.weightData&&e.body.append("model.weights.bin",new Blob([t.weightData],{type:"application/octet-stream"}),"model.weights.bin"),[4,this.fetch(this.path,e)];case 1:if((i=o.sent()).ok)return [2,{modelArtifactsInfo:Yl(t),responses:[i]}];throw new Error("BrowserHTTPRequest.save() failed due to HTTP response status "+i.status+".");}});});},t.prototype.load=function(){return u(this,void 0,void 0,function(){var t,e,n,r,i,o,a,s,u,l,f,h;return c(this,function(c){switch(c.label){case 0:return [4,this.fetch(this.path,this.requestInit)];case 1:if(!(t=c.sent()).ok)throw new Error("Request to "+this.path+" failed with status code "+t.status+". Please verify this URL points to the model JSON of the model to load.");c.label=2;case 2:return c.trys.push([2,4,,5]),[4,t.json()];case 3:return e=c.sent(),[3,5];case 4:throw c.sent(),n="Failed to parse model JSON of response from "+this.path+".",this.path.endsWith(".pb")?n+=" Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository.":n+=" Please make sure the server is serving valid JSON for this request.",new Error(n);case 5:if(r=e.modelTopology,i=e.weightsManifest,o=e.generatedBy,a=e.convertedBy,s=e.format,u=e.userDefinedMetadata,null==r&&null==i)throw new Error("The JSON from HTTP path "+this.path+" contains neither model topology or manifest for weights.");return null==i?[3,7]:[4,this.loadWeights(i)];case 6:h=c.sent(),l=h[0],f=h[1],c.label=7;case 7:return [2,{modelTopology:r,weightSpecs:l,weightData:f,userDefinedMetadata:u,generatedBy:o,convertedBy:a,format:s}];}});});},t.prototype.loadWeights=function(t){return u(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,l,f,h;return c(this,function(c){switch(c.label){case 0:for(e=Array.isArray(this.path)?this.path[1]:this.path,n=function(t){var e=t.lastIndexOf("/"),n=t.lastIndexOf("?");return [t.substring(0,e)+"/",n>e?t.substring(n):""];}(e),r=n[0],i=n[1],o=this.weightPathPrefix||r,a=[],s=0,u=t;s<u.length;s++){l=u[s],a.push.apply(a,l.weights);}return f=[],t.forEach(function(t){t.paths.forEach(function(t){f.push(o+t+i);});}),[4,Df(f,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress})];case 1:return h=c.sent(),[2,[a,Kl(h)]];}});});},t.URL_SCHEME_REGEX=/^https?:\/\//,t;}();function Nf(t){return null!=t.match(Tf.URL_SCHEME_REGEX);}var If=function If(t,e){return "undefined"==typeof fetch?null:(Array.isArray(t)?t.every(function(t){return Nf(t);}):Nf(t))?Rf(t,{onProgress:e}):null;};function Rf(t,e){return new Tf(t,e);}Jl.registerSaveRouter(If),Jl.registerLoadRouter(If);var Mf,jf=function(){function t(t){this.modelArtifacts=t;}return t.prototype.load=function(){return u(this,void 0,void 0,function(){return c(this,function(t){return [2,this.modelArtifacts];});});},t;}(),Bf=function(){function t(t){this.saveHandler=t;}return t.prototype.save=function(t){return u(this,void 0,void 0,function(){return c(this,function(e){return [2,this.saveHandler(t)];});});},t;}(),Pf=Object.freeze({browserFiles:function browserFiles(t){return new _f(t);},browserHTTPRequest:function browserHTTPRequest(t,e){return Rf(t,e);},concatenateArrayBuffers:Kl,decodeWeights:$l,encodeWeights:function encodeWeights(t,e){return u(this,void 0,void 0,function(){var n,r,i,o,a,s=this;return c(this,function(l){switch(l.label){case 0:for(n=[],r=[],i=Array.isArray(t)?t.map(function(t){return t.name;}):Object.keys(t),o=function o(_o5){var a=i[_o5],l=Array.isArray(t)?t[_o5].tensor:t[a];if("float32"!==l.dtype&&"int32"!==l.dtype&&"bool"!==l.dtype&&"string"!==l.dtype)throw new Error("Unsupported dtype in weight '"+a+"': "+l.dtype);var f={name:a,shape:l.shape,dtype:l.dtype};if("string"===l.dtype){var h=new Promise(function(t){return u(s,void 0,void 0,function(){var e,n,r,i,o,a,s;return c(this,function(u){switch(u.label){case 0:return [4,l.bytes()];case 1:for(e=u.sent(),n=e.reduce(function(t,e){return t+e.length;},0)+ql*e.length,r=new Uint8Array(n),i=0,o=0;o<e.length;o++){a=e[o],s=new Uint8Array(new Uint32Array([a.length]).buffer),r.set(s,i),i+=ql,r.set(a,i),i+=a.length;}return t(r),[2];}});});});r.push(h);}else r.push(l.data());null!=e&&(f.group=e),n.push(f);},a=0;a<i.length;++a){o(a);}return [4,Promise.all(r)];case 1:return [2,{data:function(t){if(null===t)throw new Error("Invalid input value: "+JSON.stringify(t));var e=0,n=[];t.forEach(function(t){if(e+=t.byteLength,n.push(t.byteLength===t.buffer.byteLength?t:new t.constructor(t)),!(t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array))throw new Error("Unsupported TypedArray subtype: "+t.constructor.name);});var r=new Uint8Array(e),i=0;return n.forEach(function(t){r.set(new Uint8Array(t.buffer),i),i+=t.byteLength;}),r.buffer;}(l.sent()),specs:n}];}});});},fromMemory:function fromMemory(t,e,n,r){return 1===arguments.length?null!=t.modelTopology||null!=t.weightSpecs?new jf(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 jf({modelTopology: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 jf({modelTopology:t,weightSpecs:e,weightData:n,trainingConfig:r}));},getLoadHandlers:function getLoadHandlers(t,e){return Jl.getLoadHandlers(t,e);},getModelArtifactsInfoForJSON:Yl,getSaveHandlers:function getSaveHandlers(t){return Jl.getSaveHandlers(t);},http:Rf,isHTTPScheme:Nf,loadWeights:function loadWeights(t,e,n,r){return void 0===e&&(e=""),u(this,void 0,void 0,function(){return c(this,function(i){return [2,Ff(function(t){return Df(t,{requestInit:r});})(t,e,n)];});});},registerLoadRouter:function registerLoadRouter(t){return Jl.registerLoadRouter(t);},registerSaveRouter:function registerSaveRouter(t){return Jl.registerSaveRouter(t);},weightsLoaderFactory:Ff,withSaveHandler:function withSaveHandler(t){return new Bf(t);},copyModel:function copyModel(t,e){return u(this,void 0,void 0,function(){return c(this,function(n){return [2,ef(t,e,!1)];});});},listModels:function listModels(){return u(this,void 0,void 0,function(){var t,e,n,r,i,o,a;return c(this,function(s){switch(s.label){case 0:t=Zl.getSchemes(),e={},n=0,r=t,s.label=1;case 1:return n<r.length?(i=r[n],[4,Zl.getManager(i).listModels()]):[3,4];case 2:for(a in o=s.sent()){e[i+Ql+a]=o[a];}s.label=3;case 3:return n++,[3,1];case 4:return [2,e];}});});},moveModel:function moveModel(t,e){return u(this,void 0,void 0,function(){return c(this,function(n){return [2,ef(t,e,!0)];});});},removeModel:function removeModel(t){return u(this,void 0,void 0,function(){var e;return c(this,function(n){return e=tf(t),[2,Zl.getManager(e.scheme).removeModel(e.path)];});});}}),Lf=Nn({confusionMatrix_:function confusionMatrix_(t,e,n){var r=xn(t,"labels","confusionMatrix"),i=xn(e,"predictions","confusionMatrix");_(null==n||n>0&&Number.isInteger(n),function(){return "If provided, numClasses must be a positive integer, but got "+n;}),_(1===r.rank,function(){return "Expected the rank of labels to be 1, but got "+r.rank;}),_(1===i.rank,function(){return "Expected the rank of predictions to be 1, but got "+i.rank;}),_(r.shape[0]===i.shape[0],function(){return "Mismatch in the number of examples: "+r.shape[0]+" vs. "+i.shape[0]+". Labels and predictions should have the same number of elements.";}),_(n>0&&Number.isInteger(n),function(){return "numClasses is required to be a positive integer, but got "+n;});var o=Sr(r.asType("int32"),n),a=Sr(i.asType("int32"),n);return o.transpose().matMul(a).asType("int32");}}),zf=Object.freeze({confusionMatrix:Lf}),Uf=Nn({fromPixels_:function fromPixels_(t,e){if(void 0===e&&(e=3),e>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==t)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");var n=!1,r=!1,i=!1,o=!1,a=!1;if(t.data instanceof Uint8Array)n=!0;else if("undefined"!=typeof ImageData&&t instanceof ImageData)r=!0;else if("undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement)i=!0;else if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement)o=!0;else {if(null==t.getContext)throw new Error("pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was "+t.constructor.name);a=!0;}if(i&&i&&t.readyState<2)throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the <video> element.");if(null!=m("FromPixels",Wt.backendName))return Wt.runKernel("FromPixels",{pixels:t},{numChannels:e});var s,u,c=i?[t.videoWidth,t.videoHeight]:[t.width,t.height],l=c[0],f=c[1];if(a?s=t.getContext("2d").getImageData(0,0,l,f).data:r||n?s=t.data:(o||i)&&(null==Mf&&(Mf=document.createElement("canvas").getContext("2d")),Mf.canvas.width=l,Mf.canvas.height=f,Mf.drawImage(t,0,0,l,f),s=Mf.getImageData(0,0,l,f).data),4===e)u=new Int32Array(s);else {var h=l*f;u=new Int32Array(h*e);for(var d=0;d<h;d++){for(var p=0;p<e;++p){u[d*e+p]=s[4*d+p];}}}return Un(u,[f,l,e],"int32");}}),Wf=Object.freeze({toPixels:function toPixels(t,e){return u(this,void 0,void 0,function(){var n,r,i,o,a,s,u,l,f,h,d,p,m,g,v,y,b,x,w,k,E,C,A;return c(this,function(c){switch(c.label){case 0:if(n=xn(t,"img","toPixels"),t instanceof At||(n=n.toInt()),2!==n.rank&&3!==n.rank)throw new Error("toPixels only supports rank 2 or 3 tensors, got rank "+n.rank+".");if(r=n.shape.slice(0,2),i=r[0],o=r[1],(a=2===n.rank?1:n.shape[2])>4||2===a)throw new Error("toPixels only supports depth of size 1, 3 or 4 but got "+a);return [4,n.data()];case 1:return s=c.sent(),u=n.min(),l=n.max(),[4,Promise.all([u.data(),l.data()])];case 2:if(f=c.sent(),h=f[0],d=f[1],p=h[0],m=d[0],u.dispose(),l.dispose(),"float32"===n.dtype){if(p<0||m>1)throw new Error("Tensor values for a float32 Tensor must be in the range [0 - 1] but got range ["+p+" - "+m+"].");}else {if("int32"!==n.dtype)throw new Error("Unsupported type for toPixels: "+n.dtype+". Please use float32 or int32 tensors.");if(p<0||m>255)throw new Error("Tensor values for a int32 Tensor must be in the range [0 - 255] but got range ["+p+" - "+m+"].");}for(g="float32"===n.dtype?255:1,v=new Uint8ClampedArray(o*i*4),y=0;y<i*o;++y){b=void 0,x=void 0,w=void 0,k=void 0,1===a?(b=s[y]*g,x=s[y]*g,w=s[y]*g,k=255):3===a?(b=s[3*y]*g,x=s[3*y+1]*g,w=s[3*y+2]*g,k=255):4===a&&(b=s[4*y]*g,x=s[4*y+1]*g,w=s[4*y+2]*g,k=s[4*y+3]*g),v[0+(E=4*y)]=Math.round(b),v[E+1]=Math.round(x),v[E+2]=Math.round(w),v[E+3]=Math.round(k);}return null!=e&&(e.width=o,e.height=i,C=e.getContext("2d"),A=new ImageData(v,o,i),C.putImageData(A,0,0)),n!==t&&n.dispose(),[2,v];}});});},fromPixels:Uf}),Vf=function(){function t(){}return t.prototype.getClassName=function(){return this.constructor.className;},t.fromConfig=function(t,e){return new t(e);},t;}(),qf=function(){function t(){this.classNameMap={};}return t.getMap=function(){return null==t.instance&&(t.instance=new t()),t.instance;},t.register=function(e){t.getMap().classNameMap[e.className]=[e,e.fromConfig];},t;}();function $f(t){_(null!=t.className,function(){return "Class being registered does not have the static className property defined.";}),_("string"==typeof t.className,function(){return "className is required to be a string, but got type "+_typeof$1(t.className);}),_(t.className.length>0,function(){return "Class being registered has an empty-string as its className, which is disallowed.";}),qf.register(t);}var Hf=Object.freeze({Serializable:Vf,SerializationMap:qf,registerClass:$f}),Gf=.001,Kf=.1;function Xf(){return 32===Wt.backend.floatPrecision()?Gf:Kf;}function Yf(t,e,n){var r=!0;if((H(t)||H(e))&&(r=!1),H(t)&&H(e)&&(r=!0),r){var i=t.constructor.name,o=e.constructor.name;if(i!==o)throw new Error("Arrays are of different type. Actual: "+i+". Expected: "+o);}if(Array.isArray(t)&&Array.isArray(e)){var a=yn(t),s=yn(e);if(!N(a,s))throw new Error("Arrays have different shapes. Actual: ["+a+"]. Expected: ["+s+"]");}var u=H(t)?t:F(t),c=H(e)?e:F(e);if(u.length!==c.length)throw new Error("Arrays have different lengths actual: "+u.length+" vs expected: "+c.length+".\nActual:   "+u+".\nExpected: "+c+".");for(var l=0;l<c.length;++l){var f=u[l],h=c[l];if(!n(f,h))throw new Error("Arrays differ: actual["+l+"] = "+f+", expected["+l+"] = "+h+".\nActual:   "+u+".\nExpected: "+c+".");}}function Jf(t,e,n){return !isFinite(t)&&!isFinite(e)||!(isNaN(t)||isNaN(e)||Math.abs(t-e)>n);}var Qf=Object.freeze({TEST_EPSILON_FLOAT16:Kf,expectArraysClose:function expectArraysClose(t,e,n){return null==n&&(n=Xf()),Yf(t,e,function(t,e){return Jf(t,e,n);});},testEpsilon:Xf,expectPromiseToFail:function expectPromiseToFail(t,e){t().then(function(){return e.fail();},function(){return e();});},expectArraysEqual:function expectArraysEqual(t,e){var n="string"==typeof e||"number"==typeof e||"boolean"==typeof e?[e]:e;return X(t)||X(t[0])||X(e)||X(e[0])?Yf(t,n,function(t,e){return t==e;}):Yf(t,e,function(t,e){return Jf(t,e,0);});},expectNumbersClose:function expectNumbersClose(t,e,n){if(null==n&&(n=Xf()),!Jf(t,e,n))throw new Error("Numbers differ: actual === "+t+", expected === "+e);},expectValuesInRange:function expectValuesInRange(t,e,n){for(var r=0;r<t.length;r++){if(t[r]<e||t[r]>n)throw new Error("Value out of range:"+t[r]+" low: "+e+", high: "+n);}},expectArrayBuffersEqual:function expectArrayBuffersEqual(t,e){expect(new Float32Array(t)).toEqual(new Float32Array(e));}}),Zf="1.7.0",th=Object.freeze({gpgpu_util:ia,webgl_util:Ge,forceHalfFloat:function forceHalfFloat(){f().set("WEBGL_FORCE_F16_TEXTURES",!0);},MathBackendWebGL:Ua,setWebGLContext:Yt,GPGPUContext:oa}),eh=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return s(e,t),e.prototype.minimize=function(t,e,n){void 0===e&&(e=!1);var r=this.computeGradients(t,n),i=r.value,o=r.grads;if(null!=n){var a=n.map(function(t){return {name:t.name,tensor:o[t.name]};});this.applyGradients(a);}else this.applyGradients(o);return on(o),e?i:(i.dispose(),null);},Object.defineProperty(e.prototype,"iterations",{get:function get(){return null==this.iterations_&&(this.iterations_=0),this.iterations_;},enumerable:!0,configurable:!0}),e.prototype.incrementIterations=function(){this.iterations_=this.iterations+1;},e.prototype.computeGradients=function(t,e){return vi(t,e);},e.prototype.dispose=function(){null!=this.iterations_&&on(this.iterations_);},e.prototype.saveIterations=function(){return u(this,void 0,void 0,function(){return c(this,function(t){return null==this.iterations_&&(this.iterations_=0),[2,{name:"iter",tensor:Pn(this.iterations_,"int32")}];});});},e.prototype.getWeights=function(){return u(this,void 0,void 0,function(){return c(this,function(t){throw new Error("getWeights() is not implemented for this optimizer yet.");});});},e.prototype.setWeights=function(t){return u(this,void 0,void 0,function(){return c(this,function(t){throw new Error("setWeights() is not implemented for this optimizer class "+this.getClassName());});});},e.prototype.extractIterations=function(t){return u(this,void 0,void 0,function(){var e;return c(this,function(n){switch(n.label){case 0:return e=this,[4,t[0].tensor.data()];case 1:return e.iterations_=n.sent()[0],[2,t.slice(1)];}});});},e;}(Vf);Object.defineProperty(eh,Symbol.hasInstance,{value:function value(t){return null!=t.minimize&&null!=t.computeGradients&&null!=t.applyGradients;}});var nh=function(t){function e(e,n,r){void 0===r&&(r=null);var i=t.call(this)||this;return i.learningRate=e,i.rho=n,i.epsilon=r,i.accumulatedGrads=[],i.accumulatedUpdates=[],null==r&&(i.epsilon=Wt.backend.epsilon()),i;}return s(e,t),e.prototype.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map(function(t){return t.name;}):Object.keys(t)).forEach(function(n,r){var i=Wt.registeredVariables[n];null==e.accumulatedGrads[r]&&(e.accumulatedGrads[r]={originalName:n+"/accum_grad",variable:rn(function(){return Qn(i).variable(!1);})}),null==e.accumulatedUpdates[r]&&(e.accumulatedUpdates[r]={originalName:n+"/accum_var",variable:rn(function(){return Qn(i).variable(!1);})});var o=Array.isArray(t)?t[r].tensor:t[n];if(null!=o){var a=e.accumulatedGrads[r].variable,s=e.accumulatedUpdates[r].variable;rn(function(){var t=a.mul(e.rho).add(o.square().mul(1-e.rho)),n=s.add(e.epsilon).sqrt().div(a.add(e.epsilon).sqrt()).mul(o),r=s.mul(e.rho).add(n.square().mul(1-e.rho));a.assign(t),s.assign(r);var u=n.mul(-e.learningRate).add(i);i.assign(u);});}}),this.incrementIterations();},e.prototype.dispose=function(){null!=this.accumulatedUpdates&&(on(this.accumulatedGrads.map(function(t){return t.variable;})),on(this.accumulatedUpdates.map(function(t){return t.variable;})));},e.prototype.getWeights=function(){return u(this,void 0,void 0,function(){var t;return c(this,function(e){switch(e.label){case 0:return t=this.accumulatedGrads.concat(this.accumulatedUpdates),[4,this.saveIterations()];case 1:return [2,[e.sent()].concat(t.map(function(t){return {name:t.originalName,tensor:t.variable};}))];}});});},e.prototype.setWeights=function(t){return u(this,void 0,void 0,function(){var e;return c(this,function(n){switch(n.label){case 0:return [4,this.extractIterations(t)];case 1:return t=n.sent(),e=t.length/2,this.accumulatedGrads=t.slice(0,e).map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};}),this.accumulatedUpdates=t.slice(e,2*e).map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};}),[2];}});});},e.prototype.getConfig=function(){return {learningRate:this.learningRate,rho:this.rho,epsilon:this.epsilon};},e.fromConfig=function(t,e){return new t(e.learningRate,e.rho,e.epsilon);},e.className="Adadelta",e;}(eh);$f(nh);var rh=function(t){function e(e,n){void 0===n&&(n=.1);var r=t.call(this)||this;return r.learningRate=e,r.initialAccumulatorValue=n,r.accumulatedGrads=[],r;}return s(e,t),e.prototype.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map(function(t){return t.name;}):Object.keys(t)).forEach(function(n,r){var i=Wt.registeredVariables[n];null==e.accumulatedGrads[r]&&(e.accumulatedGrads[r]={originalName:n+"/accumulator",variable:rn(function(){return Kn(i.shape,e.initialAccumulatorValue).variable(!1);})});var o=Array.isArray(t)?t[r].tensor:t[n];if(null!=o){var a=e.accumulatedGrads[r].variable;rn(function(){var t=a.add(o.square());a.assign(t);var n=o.div(t.add(Wt.backend.epsilon()).sqrt()).mul(-e.learningRate).add(i);i.assign(n);});}}),this.incrementIterations();},e.prototype.dispose=function(){null!=this.accumulatedGrads&&on(this.accumulatedGrads.map(function(t){return t.variable;}));},e.prototype.getWeights=function(){return u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return [4,this.saveIterations()];case 1:return [2,[t.sent()].concat(this.accumulatedGrads.map(function(t){return {name:t.originalName,tensor:t.variable};}))];}});});},e.prototype.setWeights=function(t){return u(this,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return [4,this.extractIterations(t)];case 1:return t=e.sent(),this.accumulatedGrads=t.map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};}),[2];}});});},e.prototype.getConfig=function(){return {learningRate:this.learningRate,initialAccumulatorValue:this.initialAccumulatorValue};},e.fromConfig=function(t,e){return new t(e.learningRate,e.initialAccumulatorValue);},e.className="Adagrad",e;}(eh);$f(rh);var ih=function(t){function e(e,n,r,i){void 0===i&&(i=null);var o=t.call(this)||this;return o.learningRate=e,o.beta1=n,o.beta2=r,o.epsilon=i,o.accumulatedFirstMoment=[],o.accumulatedSecondMoment=[],rn(function(){o.accBeta1=Pn(n).variable(),o.accBeta2=Pn(r).variable();}),null==i&&(o.epsilon=Wt.backend.epsilon()),o;}return s(e,t),e.prototype.applyGradients=function(t){var e=this,n=Array.isArray(t)?t.map(function(t){return t.name;}):Object.keys(t);rn(function(){var r=lu(1,e.accBeta1),i=lu(1,e.accBeta2);n.forEach(function(n,o){var a=Wt.registeredVariables[n];null==e.accumulatedFirstMoment[o]&&(e.accumulatedFirstMoment[o]={originalName:n+"/m",variable:rn(function(){return Qn(a).variable(!1);})}),null==e.accumulatedSecondMoment[o]&&(e.accumulatedSecondMoment[o]={originalName:n+"/v",variable:rn(function(){return Qn(a).variable(!1);})});var s=Array.isArray(t)?t[o].tensor:t[n];if(null!=s){var u=e.accumulatedFirstMoment[o].variable,c=e.accumulatedSecondMoment[o].variable,l=u.mul(e.beta1).add(s.mul(1-e.beta1)),f=c.mul(e.beta2).add(s.square().mul(1-e.beta2)),h=l.div(r),d=f.div(i);u.assign(l),c.assign(f);var p=h.div(d.sqrt().add(e.epsilon)).mul(-e.learningRate).add(a);a.assign(p);}}),e.accBeta1.assign(e.accBeta1.mul(e.beta1)),e.accBeta2.assign(e.accBeta2.mul(e.beta2));}),this.incrementIterations();},e.prototype.dispose=function(){this.accBeta1.dispose(),this.accBeta2.dispose(),null!=this.accumulatedFirstMoment&&on(this.accumulatedFirstMoment.map(function(t){return t.variable;})),null!=this.accumulatedSecondMoment&&on(this.accumulatedSecondMoment.map(function(t){return t.variable;}));},e.prototype.getWeights=function(){return u(this,void 0,void 0,function(){var t;return c(this,function(e){switch(e.label){case 0:return t=this.accumulatedFirstMoment.concat(this.accumulatedSecondMoment),[4,this.saveIterations()];case 1:return [2,[e.sent()].concat(t.map(function(t){return {name:t.originalName,tensor:t.variable};}))];}});});},e.prototype.setWeights=function(t){return u(this,void 0,void 0,function(){var e,n=this;return c(this,function(r){switch(r.label){case 0:return [4,this.extractIterations(t)];case 1:return t=r.sent(),rn(function(){n.accBeta1.assign(su(n.beta1,n.iterations_+1)),n.accBeta2.assign(su(n.beta2,n.iterations_+1));}),e=t.length/2,this.accumulatedFirstMoment=t.slice(0,e).map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};}),this.accumulatedSecondMoment=t.slice(e,2*e).map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};}),[2];}});});},e.prototype.getConfig=function(){return {learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon};},e.fromConfig=function(t,e){return new t(e.learningRate,e.beta1,e.beta2,e.epsilon);},e.className="Adam",e;}(eh);$f(ih);var oh=function(t){function e(e,n,r,i,o){void 0===i&&(i=null),void 0===o&&(o=0);var a=t.call(this)||this;return a.learningRate=e,a.beta1=n,a.beta2=r,a.epsilon=i,a.decay=o,a.accumulatedFirstMoment=[],a.accumulatedWeightedInfNorm=[],rn(function(){a.iteration=Pn(0).variable(),a.accBeta1=Pn(n).variable();}),null==i&&(a.epsilon=Wt.backend.epsilon()),a;}return s(e,t),e.prototype.applyGradients=function(t){var e=this,n=Array.isArray(t)?t.map(function(t){return t.name;}):Object.keys(t);rn(function(){var r=lu(1,e.accBeta1),i=Xs(-e.learningRate,e.iteration.mul(e.decay).add(1));n.forEach(function(n,o){var a=Wt.registeredVariables[n];null==e.accumulatedFirstMoment[o]&&(e.accumulatedFirstMoment[o]={originalName:n+"/m",variable:Qn(a).variable(!1)}),null==e.accumulatedWeightedInfNorm[o]&&(e.accumulatedWeightedInfNorm[o]={originalName:n+"/v",variable:Qn(a).variable(!1)});var s=Array.isArray(t)?t[o].tensor:t[n];if(null!=s){var u=e.accumulatedFirstMoment[o].variable,c=e.accumulatedWeightedInfNorm[o].variable,l=u.mul(e.beta1).add(s.mul(1-e.beta1)),f=c.mul(e.beta2),h=s.abs(),d=f.maximum(h);u.assign(l),c.assign(d);var p=i.div(r).mul(l.div(d.add(e.epsilon))).add(a);a.assign(p);}}),e.iteration.assign(e.iteration.add(1)),e.accBeta1.assign(e.accBeta1.mul(e.beta1));}),this.incrementIterations();},e.prototype.dispose=function(){this.accBeta1.dispose(),this.iteration.dispose(),null!=this.accumulatedFirstMoment&&on(this.accumulatedFirstMoment.map(function(t){return t.variable;})),null!=this.accumulatedWeightedInfNorm&&on(this.accumulatedWeightedInfNorm.map(function(t){return t.variable;}));},e.prototype.getWeights=function(){return u(this,void 0,void 0,function(){return c(this,function(t){throw new Error("getWeights() is not implemented for Adamax yet.");});});},e.prototype.setWeights=function(t){return u(this,void 0,void 0,function(){return c(this,function(t){throw new Error("setWeights() is not implemented for Adamax yet.");});});},e.prototype.getConfig=function(){return {learningRate:this.learningRate,beta1:this.beta1,beta2:this.beta2,epsilon:this.epsilon,decay:this.decay};},e.fromConfig=function(t,e){return new t(e.learningRate,e.beta1,e.beta2,e.epsilon,e.decay);},e.className="Adamax",e;}(eh);$f(oh);var ah=function(t){function e(e){var n=t.call(this)||this;return n.learningRate=e,n.setLearningRate(e),n;}return s(e,t),e.prototype.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map(function(t){return t.name;}):Object.keys(t)).forEach(function(n,r){var i=Array.isArray(t)?t[r].tensor:t[n];if(null!=i){var o=Wt.registeredVariables[n];rn(function(){var t=e.c.mul(i).add(o);o.assign(t);});}}),this.incrementIterations();},e.prototype.setLearningRate=function(t){this.learningRate=t,null!=this.c&&this.c.dispose(),this.c=an(Pn(-t));},e.prototype.dispose=function(){this.c.dispose();},e.prototype.getWeights=function(){return u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return [4,this.saveIterations()];case 1:return [2,[t.sent()]];}});});},e.prototype.setWeights=function(t){return u(this,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return [4,this.extractIterations(t)];case 1:if(0!==(t=e.sent()).length)throw new Error("SGD optimizer does not have settable weights.");return [2];}});});},e.prototype.getConfig=function(){return {learningRate:this.learningRate};},e.fromConfig=function(t,e){return new t(e.learningRate);},e.className="SGD",e;}(eh);$f(ah);var sh=function(t){function e(e,n,r){void 0===r&&(r=!1);var i=t.call(this,e)||this;return i.learningRate=e,i.momentum=n,i.useNesterov=r,i.accumulations=[],i.m=Pn(i.momentum),i;}return s(e,t),e.prototype.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map(function(t){return t.name;}):Object.keys(t)).forEach(function(n,r){var i=Wt.registeredVariables[n];null==e.accumulations[r]&&(e.accumulations[r]={originalName:n+"/momentum",variable:rn(function(){return Qn(i).variable(!1);})});var o=e.accumulations[r].variable,a=Array.isArray(t)?t[r].tensor:t[n];null!=a&&rn(function(){var t,n=e.m.mul(o).add(a);t=e.useNesterov?e.c.mul(a.add(n.mul(e.m))).add(i):e.c.mul(n).add(i),o.assign(n),i.assign(t);});}),this.incrementIterations();},e.prototype.dispose=function(){this.m.dispose(),null!=this.accumulations&&on(this.accumulations.map(function(t){return t.variable;}));},e.prototype.setMomentum=function(t){this.momentum=t;},e.prototype.getWeights=function(){return u(this,void 0,void 0,function(){return c(this,function(t){switch(t.label){case 0:return [4,this.saveIterations()];case 1:return [2,[t.sent()].concat(this.accumulations.map(function(t){return {name:t.originalName,tensor:t.variable};}))];}});});},e.prototype.setWeights=function(t){return u(this,void 0,void 0,function(){return c(this,function(e){switch(e.label){case 0:return [4,this.extractIterations(t)];case 1:return t=e.sent(),this.accumulations=t.map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};}),[2];}});});},e.prototype.getConfig=function(){return {learningRate:this.learningRate,momentum:this.momentum,useNesterov:this.useNesterov};},e.fromConfig=function(t,e){return new t(e.learningRate,e.momentum,e.useNesterov);},e.className="Momentum",e;}(ah);$f(sh);var uh=function(t){function e(e,n,r,i,o){void 0===n&&(n=.9),void 0===r&&(r=0),void 0===i&&(i=null),void 0===o&&(o=!1);var a=t.call(this)||this;if(a.learningRate=e,a.decay=n,a.momentum=r,a.epsilon=i,a.accumulatedMeanSquares=[],a.accumulatedMoments=[],a.accumulatedMeanGrads=[],a.centered=o,null==i&&(a.epsilon=Wt.backend.epsilon()),null==e)throw new Error("learningRate for RMSPropOptimizer must be defined.");return a;}return s(e,t),e.prototype.applyGradients=function(t){var e=this;(Array.isArray(t)?t.map(function(t){return t.name;}):Object.keys(t)).forEach(function(n,r){var i=Wt.registeredVariables[n];null==e.accumulatedMeanSquares[r]&&(e.accumulatedMeanSquares[r]={originalName:n+"/rms",variable:rn(function(){return Qn(i).variable(!1);})}),null==e.accumulatedMoments[r]&&(e.accumulatedMoments[r]={originalName:n+"/momentum",variable:rn(function(){return Qn(i).variable(!1);})}),null==e.accumulatedMeanGrads[r]&&e.centered&&(e.accumulatedMeanGrads[r]={originalName:n+"/mg",variable:rn(function(){return Qn(i).variable(!1);})});var o=Array.isArray(t)?t[r].tensor:t[n];if(null!=o){var a=e.accumulatedMeanSquares[r].variable,s=e.accumulatedMoments[r].variable;rn(function(){var t=a.mul(e.decay).add(o.square().mul(1-e.decay));if(e.centered){var n=e.accumulatedMeanGrads[r].variable,u=n.mul(e.decay).add(o.mul(1-e.decay)),c=s.mul(e.momentum).add(o.mul(e.learningRate).div(t.sub(u.square().add(e.epsilon)).sqrt()));a.assign(t),n.assign(u),s.assign(c);var l=i.sub(c);i.assign(l);}else {var f=a.mul(e.decay).add(o.square().mul(1-e.decay));c=s.mul(e.momentum).add(o.mul(e.learningRate).div(f.add(e.epsilon).sqrt())),a.assign(f),s.assign(c),l=i.sub(c),i.assign(l);}});}}),this.incrementIterations();},e.prototype.dispose=function(){null!=this.accumulatedMeanSquares&&on(this.accumulatedMeanSquares.map(function(t){return t.variable;})),null!=this.accumulatedMeanGrads&&this.centered&&on(this.accumulatedMeanGrads.map(function(t){return t.variable;})),null!=this.accumulatedMoments&&on(this.accumulatedMoments.map(function(t){return t.variable;}));},e.prototype.getWeights=function(){return u(this,void 0,void 0,function(){var t;return c(this,function(e){switch(e.label){case 0:return t=this.accumulatedMeanSquares.concat(this.accumulatedMoments),this.centered&&t.push.apply(t,this.accumulatedMeanGrads),[4,this.saveIterations()];case 1:return [2,[e.sent()].concat(t.map(function(t){return {name:t.originalName,tensor:t.variable};}))];}});});},e.prototype.setWeights=function(t){return u(this,void 0,void 0,function(){var e;return c(this,function(n){switch(n.label){case 0:return [4,this.extractIterations(t)];case 1:return t=n.sent(),e=this.centered?t.length/3:t.length/2,this.accumulatedMeanSquares=t.slice(0,e).map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};}),this.accumulatedMoments=t.slice(e,2*e).map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};}),this.centered&&(this.accumulatedMeanGrads=t.slice(2*e,3*e).map(function(t){return {originalName:t.name,variable:t.tensor.variable(!1)};})),[2];}});});},e.prototype.getConfig=function(){return {learningRate:this.learningRate,decay:this.decay,momentum:this.momentum,epsilon:this.epsilon,centered:this.centered};},e.fromConfig=function(t,e){return new t(e.learningRate,e.decay,e.momentum,e.epsilon,e.centered);},e.className="RMSProp",e;}(eh);$f(uh);var ch=function(){function t(){}return t.sgd=function(t){return new ah(t);},t.momentum=function(t,e,n){return void 0===n&&(n=!1),new sh(t,e,n);},t.rmsprop=function(t,e,n,r,i){return void 0===e&&(e=.9),void 0===n&&(n=0),void 0===r&&(r=null),void 0===i&&(i=!1),new uh(t,e,n,r,i);},t.adam=function(t,e,n,r){return void 0===t&&(t=.001),void 0===e&&(e=.9),void 0===n&&(n=.999),void 0===r&&(r=null),new ih(t,e,n,r);},t.adadelta=function(t,e,n){return void 0===t&&(t=.001),void 0===e&&(e=.95),void 0===n&&(n=null),new nh(t,e,n);},t.adamax=function(t,e,n,r,i){return void 0===t&&(t=.002),void 0===e&&(e=.9),void 0===n&&(n=.999),void 0===r&&(r=null),void 0===i&&(i=0),new oh(t,e,n,r,i);},t.adagrad=function(t,e){return void 0===e&&(e=.1),new rh(t,e);},t;}(),lh={sgd:ch.sgd,momentum:ch.momentum,adadelta:ch.adadelta,adagrad:ch.adagrad,rmsprop:ch.rmsprop,adamax:ch.adamax,adam:ch.adam},fh="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:void 0!==o?o:function(t){return t();};function hh(){return new Promise(function(t){return fh(function(){return t();});});}At.prototype.squaredDifference=function(t){return qa(this,t);},Et=Dl;}.call(this,n(59),n(75),n(92).Buffer,n(207).setImmediate);},function(t,e,n){t.exports=n(281);},function(t,e,n){n.d(e,"c",function(){return i;}),n.d(e,"a",function(){return _o6;}),n.d(e,"b",function(){return a;}),n.d(e,"d",function(){return s;}),n.d(e,"e",function(){return u;});/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var _r12=function r(t,e){return (_r12=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e;}||function(t,e){for(var n in e){e.hasOwnProperty(n)&&(t[n]=e[n]);}})(t,e);};function i(t,e){function n(){this.constructor=t;}_r12(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n());}var _o6=function o(){return (_o6=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){for(var i in e=arguments[n]){Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);}}return t;}).apply(this,arguments);};function a(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):function(t){return t instanceof n?t:new n(function(e){e(t);});}(t.value).then(a,s);}u((r=r.apply(t,e||[])).next());});}function s(t,e){var n,r,i,o,a={label:0,sent:function sent(){if(1&i[0])throw i[1];return i[1];},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this;}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;){try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue;}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break;}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break;}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break;}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(t,a);}catch(t){o=[6,t],r=0;}finally{n=i=0;}}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:!0};}([o,s]);};}}function u(){for(var t=0,e=0,n=arguments.length;e<n;e++){t+=arguments[e].length;}var r=Array(t),i=0;for(e=0;e<n;e++){for(var o=arguments[e],a=0,s=o.length;a<s;a++,i++){r[i]=o[a];}}return r;}},function(t,e){function n(t,e,n,r,i,o,a){try{var s=t[o](a),u=s.value;}catch(t){return void n(t);}s.done?e(u):Promise.resolve(u).then(r,i);}t.exports=function(t){return function(){var e=this,r=arguments;return new Promise(function(i,o){var a=t.apply(e,r);function s(t){n(a,i,o,s,u,"next",t);}function u(t){n(a,i,o,s,u,"throw",t);}s(void 0);});};},t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e){function n(e){"@babel/helpers - typeof";return t.exports=n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t;}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t;},t.exports.__esModule=!0,t.exports.default=t.exports,n(e);}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e,n){var r=n(16),i=n(24),o=n(42),a=n(38),s=n(56),u=function u(t,e,n){var c,l,f,h,d=t&u.F,p=t&u.G,m=t&u.S,g=t&u.P,v=t&u.B,y=p?r:m?r[e]||(r[e]={}):(r[e]||{}).prototype,b=p?i:i[e]||(i[e]={}),x=b.prototype||(b.prototype={});for(c in p&&(n=e),n){f=((l=!d&&y&&void 0!==y[c])?y:n)[c],h=v&&l?s(f,r):g&&"function"==typeof f?s(Function.call,f):f,y&&a(y,c,f,t&u.U),b[c]!=f&&o(b,c,h),g&&x[c]!=f&&(x[c]=f);}};r.core=i,u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,t.exports=u;},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r);}}t.exports=function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;},t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function");},t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e,n){var _R2,_Q2,_Z,_et,_nt,_it,_ot;n.d(e,"a",function(){return C;}),n.d(e,"b",function(){return A;}),n.d(e,"c",function(){return O;}),n.d(e,"d",function(){return _;}),n.d(e,"e",function(){return F;}),n.d(e,"f",function(){return S;}),n.d(e,"g",function(){return k;}),n.d(e,"h",function(){return w;}),n.d(e,"i",function(){return D;}),n.d(e,"j",function(){return T;}),n.d(e,"k",function(){return E;}),n.d(e,"l",function(){return x;}),n.d(e,"m",function(){return P;}),n.d(e,"n",function(){return Et;}),n.d(e,"o",function(){return tt;}),n.d(e,"p",function(){return at;}),n.d(e,"q",function(){return ct;}),n.d(e,"r",function(){return ht;}),n.d(e,"s",function(){return M;}),n.d(e,"t",function(){return I;}),n.d(e,"u",function(){return rt;}),n.d(e,"v",function(){return st;}),n.d(e,"w",function(){return lt;}),n.d(e,"x",function(){return dt;}),n.d(e,"y",function(){return q;}),n.d(e,"z",function(){return $;}),n.d(e,"A",function(){return L;});var r=n(1),i=n(72),o=n(40),a=n(71),s=n(39),u=n(70),c=n(135),l=n(184),f=n(183),h=n(69),d=n(182),p=n(68),m=n(134),g=n(181),v=n(180),y=n(108),b=n(45);var x="year",w="quarter",k="month",E="week",C="date",A="day",O="dayofyear",_="hours",S="minutes",D="seconds",F="milliseconds",T=[x,w,k,E,C,A,O,_,S,D,F],N=T.reduce(function(t,e,n){return t[e]=1+n,t;},{});function I(t){var e=Object(r.i)(t).slice(),n={};return e.length||Object(r.o)("Missing time unit."),e.forEach(function(t){Object(r.w)(N,t)?n[t]=1:Object(r.o)("Invalid time unit: ".concat(t,"."));}),(n[E]||n[A]?1:0)+(n[w]||n[k]||n[C]?1:0)+(n[O]?1:0)>1&&Object(r.o)("Incompatible time units: ".concat(t)),e.sort(function(t,e){return N[t]-N[e];}),e;}var R=(_R2={},_defineProperty(_R2,x,"%Y "),_defineProperty(_R2,w,"Q%q "),_defineProperty(_R2,k,"%b "),_defineProperty(_R2,C,"%d "),_defineProperty(_R2,E,"W%U "),_defineProperty(_R2,A,"%a "),_defineProperty(_R2,O,"%j "),_defineProperty(_R2,_,"%H:00"),_defineProperty(_R2,S,"00:%M"),_defineProperty(_R2,D,":%S"),_defineProperty(_R2,F,".%L"),_defineProperty(_R2,"".concat(x,"-").concat(k),"%Y-%m "),_defineProperty(_R2,"".concat(x,"-").concat(k,"-").concat(C),"%Y-%m-%d "),_defineProperty(_R2,"".concat(_,"-").concat(S),"%H:%M"),_R2);function M(t,e){var n=Object(r.p)({},R,e),i=I(t),o=i.length;var a,s,u="",c=0;for(c=0;c<o;){for(a=i.length;a>c;--a){if(null!=n[s=i.slice(c,a).join("-")]){u+=n[s],c=a;break;}}}return u.trim();}var j=new Date();function B(t){return j.setFullYear(t),j.setMonth(0),j.setDate(1),j.setHours(0,0,0,0),j;}function P(t){return z(new Date(t));}function L(t){return U(new Date(t));}function z(t){return i.a.count(B(t.getFullYear())-1,t);}function U(t){return o.b.count(B(t.getFullYear())-1,t);}function W(t){return B(t).getDay();}function V(t,e,n,r,i,o,a){if(0<=t&&t<100){var _s3=new Date(-1,e,n,r,i,o,a);return _s3.setFullYear(t),_s3;}return new Date(t,e,n,r,i,o,a);}function q(t){return H(new Date(t));}function $(t){return G(new Date(t));}function H(t){var e=Date.UTC(t.getUTCFullYear(),0,1);return a.a.count(e-1,t);}function G(t){var e=Date.UTC(t.getUTCFullYear(),0,1);return s.b.count(e-1,t);}function K(t){return j.setTime(Date.UTC(t,0,1)),j.getUTCDay();}function X(t,e,n,r,i,o,a){if(0<=t&&t<100){var _t4=new Date(Date.UTC(-1,e,n,r,i,o,a));return _t4.setUTCFullYear(n.y),_t4;}return new Date(Date.UTC(t,e,n,r,i,o,a));}function Y(t,e,n,i,o){var a=e||1,s=Object(r.W)(t),u=function u(t,e,r){return function(t,e,n,r){var i=n<=1?t:r?function(e,i){return r+n*Math.floor((t(e,i)-r)/n);}:function(e,r){return n*Math.floor(t(e,r)/n);};return e?function(t,n){return e(i(t,n),n);}:i;}(n[r=r||t],i[r],t===s&&a,e);},c=new Date(),l=Object(r.Fa)(t),f=l[x]?u(x):Object(r.m)(2012),h=l[k]?u(k):l[w]?u(w):r.Ma,d=l[E]&&l[A]?u(A,1,E+A):l[E]?u(E,1):l[A]?u(A,1):l[C]?u(C,1):l[O]?u(O,1):r.Q,p=l[_]?u(_):r.Ma,m=l[S]?u(S):r.Ma,g=l[D]?u(D):r.Ma,v=l[F]?u(F):r.Ma;return function(t){c.setTime(+t);var e=f(c);return o(e,h(c),d(c,e),p(c),m(c),g(c),v(c));};}function J(t,e,n){return e+7*t-(n+6)%7;}var Q=(_Q2={},_defineProperty(_Q2,x,function(t){return t.getFullYear();}),_defineProperty(_Q2,w,function(t){return Math.floor(t.getMonth()/3);}),_defineProperty(_Q2,k,function(t){return t.getMonth();}),_defineProperty(_Q2,C,function(t){return t.getDate();}),_defineProperty(_Q2,_,function(t){return t.getHours();}),_defineProperty(_Q2,S,function(t){return t.getMinutes();}),_defineProperty(_Q2,D,function(t){return t.getSeconds();}),_defineProperty(_Q2,F,function(t){return t.getMilliseconds();}),_defineProperty(_Q2,O,function(t){return z(t);}),_defineProperty(_Q2,E,function(t){return U(t);}),_defineProperty(_Q2,E+A,function(t,e){return J(U(t),t.getDay(),W(e));}),_defineProperty(_Q2,A,function(t,e){return J(1,t.getDay(),W(e));}),_Q2),Z=(_Z={},_defineProperty(_Z,w,function(t){return 3*t;}),_defineProperty(_Z,E,function(t,e){return J(t,0,W(e));}),_Z);function tt(t,e){return Y(t,e||1,Q,Z,V);}var et=(_et={},_defineProperty(_et,x,function(t){return t.getUTCFullYear();}),_defineProperty(_et,w,function(t){return Math.floor(t.getUTCMonth()/3);}),_defineProperty(_et,k,function(t){return t.getUTCMonth();}),_defineProperty(_et,C,function(t){return t.getUTCDate();}),_defineProperty(_et,_,function(t){return t.getUTCHours();}),_defineProperty(_et,S,function(t){return t.getUTCMinutes();}),_defineProperty(_et,D,function(t){return t.getUTCSeconds();}),_defineProperty(_et,F,function(t){return t.getUTCMilliseconds();}),_defineProperty(_et,O,function(t){return H(t);}),_defineProperty(_et,E,function(t){return G(t);}),_defineProperty(_et,A,function(t,e){return J(1,t.getUTCDay(),K(e));}),_defineProperty(_et,E+A,function(t,e){return J(G(t),t.getUTCDay(),K(e));}),_et),nt=(_nt={},_defineProperty(_nt,w,function(t){return 3*t;}),_defineProperty(_nt,E,function(t,e){return J(t,0,K(e));}),_nt);function rt(t,e){return Y(t,e||1,et,nt,X);}var it=(_it={},_defineProperty(_it,x,u.a),_defineProperty(_it,w,c.a.every(3)),_defineProperty(_it,k,c.a),_defineProperty(_it,E,o.b),_defineProperty(_it,C,i.a),_defineProperty(_it,A,i.a),_defineProperty(_it,O,i.a),_defineProperty(_it,_,l.a),_defineProperty(_it,S,f.a),_defineProperty(_it,D,h.a),_defineProperty(_it,F,d.a),_it),ot=(_ot={},_defineProperty(_ot,x,p.a),_defineProperty(_ot,w,m.a.every(3)),_defineProperty(_ot,k,m.a),_defineProperty(_ot,E,s.b),_defineProperty(_ot,C,a.a),_defineProperty(_ot,A,a.a),_defineProperty(_ot,O,a.a),_defineProperty(_ot,_,g.a),_defineProperty(_ot,S,v.a),_defineProperty(_ot,D,h.a),_defineProperty(_ot,F,d.a),_ot);function at(t){return it[t];}function st(t){return ot[t];}function ut(t,e,n){return t?t.offset(e,n):void 0;}function ct(t,e,n){return ut(at(t),e,n);}function lt(t,e,n){return ut(st(t),e,n);}function ft(t,e,n,r){return t?t.range(e,n,r):void 0;}function ht(t,e,n,r){return ft(at(t),e,n,r);}function dt(t,e,n,r){return ft(st(t),e,n,r);}var pt=31536e6,mt=[x,k,C,_,S,D,F],gt=mt.slice(0,-1),vt=gt.slice(0,-1),yt=vt.slice(0,-1),bt=yt.slice(0,-1),xt=[x,k],wt=[x],kt=[[gt,1,1e3],[gt,5,5e3],[gt,15,15e3],[gt,30,3e4],[vt,1,6e4],[vt,5,3e5],[vt,15,9e5],[vt,30,18e5],[yt,1,36e5],[yt,3,108e5],[yt,6,216e5],[yt,12,432e5],[bt,1,864e5],[[x,E],1,6048e5],[xt,1,2592e6],[xt,3,7776e6],[wt,1,pt]];function Et(t){var e=t.extent,n=t.maxbins||40,i=Math.abs(Object(r.Z)(e))/n;var o,a,s=Object(y.a)(function(t){return t[2];}).right(kt,i);return s===kt.length?(o=wt,a=Object(b.c)(e[0]/pt,e[1]/pt,n)):s?(o=(s=kt[i/kt[s-1][2]<kt[s][2]/i?s-1:s])[0],a=s[1]):(o=mt,a=Math.max(Object(b.c)(e[0],e[1],n),1)),{units:o,step:a};}},function(t,e,n){n.d(e,"e",function(){return r;}),n.d(e,"c",function(){return i;}),n.d(e,"b",function(){return o;}),n.d(e,"a",function(){return a;}),n.d(e,"f",function(){return s;}),n.d(e,"d",function(){return u;}),n.d(e,"g",function(){return c;});var r=1e3,i=60*r,o=60*i,a=24*o,s=7*a,u=30*a,c=365*a;},function(t,e){t.exports=function(t){return "object"==_typeof$1(t)?null!==t:"function"==typeof t;};},function(t,e,n){var r=n(13);t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t;};},function(t,e){t.exports=function(t){try{return !!t();}catch(t){return !0;}};},function(t,e){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n);},function(t,e,n){t.exports=n(280);},function(t,e){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t;},t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e,n){var r=n(129)("wks"),i=n(84),o=n(16).Symbol,a="function"==typeof o;(t.exports=function(t){return r[t]||(r[t]=a&&o[t]||(a?o:i)("Symbol."+t));}).store=r;},function(t,e,n){n.r(e),function(t){n.d(e,"GraphModel",function(){return Et;}),n.d(e,"loadGraphModel",function(){return Ct;}),n.d(e,"deregisterOp",function(){return h;}),n.d(e,"registerOp",function(){return l;}),n.d(e,"version_converter",function(){return At;});var r,i,o=n(0),_a8=function a(){return (_a8=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){for(var i in e=arguments[n]){Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);}}return t;}).apply(this,arguments);};/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function s(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});}function u(t,e){var n,r,i,o,a={label:0,sent:function sent(){if(1&i[0])throw i[1];return i[1];},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this;}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;){try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue;}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break;}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break;}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break;}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(t,a);}catch(t){o=[6,t],r=0;}finally{n=i=0;}}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:!0};}([o,s]);};}}!function(t){t[t.DT_INVALID=0]="DT_INVALID",t[t.DT_FLOAT=1]="DT_FLOAT",t[t.DT_DOUBLE=2]="DT_DOUBLE",t[t.DT_INT32=3]="DT_INT32",t[t.DT_UINT8=4]="DT_UINT8",t[t.DT_INT16=5]="DT_INT16",t[t.DT_INT8=6]="DT_INT8",t[t.DT_STRING=7]="DT_STRING",t[t.DT_COMPLEX64=8]="DT_COMPLEX64",t[t.DT_INT64=9]="DT_INT64",t[t.DT_BOOL=10]="DT_BOOL",t[t.DT_QINT8=11]="DT_QINT8",t[t.DT_QUINT8=12]="DT_QUINT8",t[t.DT_QINT32=13]="DT_QINT32",t[t.DT_BFLOAT16=14]="DT_BFLOAT16",t[t.DT_FLOAT_REF=101]="DT_FLOAT_REF",t[t.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",t[t.DT_INT32_REF=103]="DT_INT32_REF",t[t.DT_UINT8_REF=104]="DT_UINT8_REF",t[t.DT_INT16_REF=105]="DT_INT16_REF",t[t.DT_INT8_REF=106]="DT_INT8_REF",t[t.DT_STRING_REF=107]="DT_STRING_REF",t[t.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",t[t.DT_INT64_REF=109]="DT_INT64_REF",t[t.DT_BOOL_REF=110]="DT_BOOL_REF",t[t.DT_QINT8_REF=111]="DT_QINT8_REF",t[t.DT_QUINT8_REF=112]="DT_QUINT8_REF",t[t.DT_QINT32_REF=113]="DT_QINT32_REF",t[t.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF";}(r||(r={})),function(t){!function(t){t[t.LEGACY=0]="LEGACY",t[t.V1=1]="V1",t[t.V2=2]="V2";}(t.CheckpointFormatVersion||(t.CheckpointFormatVersion={}));}(i||(i={}));var c={};function l(t,e){var n={tfOpName:t,category:"custom",inputs:[],attrs:[],customExecutor:e};c[t]=n;}function f(t){return c[t];}function h(t){delete c[t];}function d(t,e,n,r){var i=e.inputParams[t];if(i&&void 0!==i.inputIndexStart){var o=i.inputIndexStart,a=0===i.inputIndexEnd?void 0:void 0===i.inputIndexEnd?o+1:i.inputIndexEnd;if("tensor"===i.type)return p(e.inputNames[i.inputIndexStart],n,r);if("tensors"===i.type)return e.inputNames.slice(o,a).map(function(t){return p(t,n,r);});var s=Array.prototype.slice.call(p(e.inputNames.slice(o)[0],n,r).dataSync());return "number"===i.type?s[0]:s;}var u=e.attrParams[t];return u&&u.value;}function p(t,e,n){var r=v(t),i=r[0],o=r[1],a=n.currentContextIds.find(function(t){return !!e[g(i,t)];});return void 0!==a?e[g(i,a)][o]:void 0;}function m(t,e){var n=v(t),r=n[0],i=n[1];return [g(r,e&&e.currentContextId),i];}function g(t,e){return e?t+"-"+e:t;}function v(t){var e=t.lastIndexOf(":");return -1===e?[t,0]:[t.substring(0,e),Number(t.substring(e+1))];}function y(t,e){for(var n=[],r=0;r<t.length;r+=e){n.push(t.slice(r,r+e));}return n;}var b=Object.freeze({json:[{tfOpName:"Add",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddV2",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddN",category:"arithmetic",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"BiasAdd",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sub",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"RealDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Div",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"DivNoNan",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mul",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Maximum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}]},{tfOpName:"Pow",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SquaredDifference",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorMod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]}),x=Object.freeze({json:[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"clip_value_min",name:"clipValueMin",type:"number"},{tfName:"clip_value_max",name:"clipValueMax",type:"number"}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"clipValueMin",name:"clipValueMin",type:"number",defaultValue:0},{tfName:"clipValueMax",name:"clipValueMax",type:"number",defaultValue:6}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Prod",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axes",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]}),w=Object.freeze({json:[{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]},{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]},{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"number"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"number"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"number"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"number"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"number"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"number"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"number"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"number"}]}]}),k=Object.freeze({json:[{tfOpName:"AvgPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"DepthwiseConv2d",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"DepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"FusedDepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]}]},{tfOpName:"Conv3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]}]}),E=Object.freeze({json:[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}]}),C=Object.freeze({json:[{tfOpName:"NonMaxSuppressionV2",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV3",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV5",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"},{start:5,name:"softNmsSigma",type:"number"}]},{tfOpName:"Where",category:"dynamic",inputs:[{start:0,name:"condition",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ListDiff",category:"dynamic",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]}),A=Object.freeze({json:[{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]}]}),O=Object.freeze({json:[{tfOpName:"PlaceholderWithDefault",category:"graph",inputs:[{start:0,name:"default",type:"tensor"}],attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Placeholder",category:"graph",attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Const",category:"graph"},{tfOpName:"Identity",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IdentityN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Snapshot",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Rank",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Size",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Shape",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"ShapeN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Print",category:"graph",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"data",type:"tensors"}],attrs:[{tfName:"message",name:"message",type:"string"},{tfName:"first_n",name:"firstN",type:"number",notSupported:!0},{tfName:"summarize",name:"summarize",type:"number",defaultValue:3}]},{tfOpName:"NoOp",category:"graph",inputs:[]},{tfOpName:"StopGradient",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"FakeQuantWithMinMaxVars",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"min",name:"min",type:"number"},{tfName:"max",name:"max",type:"number"}]}]}),_=Object.freeze({json:[{tfOpName:"ResizeBilinear",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ResizeNearestNeighbor",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"CropAndResize",category:"image",inputs:[{start:0,name:"image",type:"tensor"},{start:1,name:"boxes",type:"tensor"},{start:2,name:"boxInd",type:"tensor"},{start:3,name:"cropSize",type:"number[]"}],attrs:[{tfName:"method",name:"method",type:"string"},{tfName:"extrapolation_value",name:"extrapolationValue",type:"number"}]}]}),S=Object.freeze({json:[{tfOpName:"Equal",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NotEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Greater",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"GreaterEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Less",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LessEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalAnd",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalNot",category:"logical",inputs:[{start:0,name:"a",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalOr",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]}),D=Object.freeze({json:[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]}),F=Object.freeze({json:[{tfOpName:"FusedBatchNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV2",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV3",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"LRN",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"depth_radius",name:"radius",type:"number",defaultValue:5},{tfName:"bias",name:"bias",type:"number",defaultValue:1},{tfName:"alpha",name:"alpha",type:"number",defaultValue:1},{tfName:"beta",name:"beta",type:"number",defaultValue:.5}]},{tfOpName:"Softmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"LogSoftmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"SparseToDense",category:"normalization",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!0,notSupported:!0}]}]}),T=Object.freeze({json:[{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]}]}),N=Object.freeze({json:[{tfOpName:"ConcatV2",category:"slice_join",inputs:[{start:0,end:-1,name:"tensors",type:"tensors"},{start:-1,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"Concat",category:"slice_join",inputs:[{start:1,end:0,name:"tensors",type:"tensors"},{start:0,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"GatherV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"validate_indices",name:"validateIndices",type:"bool",notSupported:!0}]},{tfOpName:"Reverse",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"dims",type:"bool",notSupported:!0}]},{tfOpName:"ReverseV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}]},{tfOpName:"Slice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"size",type:"number[]"}]},{tfOpName:"StridedSlice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"end",type:"number[]"},{start:3,name:"strides",type:"number[]"}],attrs:[{tfName:"begin_mask",name:"beginMask",type:"number",defaultValue:0},{tfName:"end_mask",name:"endMask",type:"number",defaultValue:0},{tfName:"new_axis_mask",name:"newAxisMask",type:"number",defaultValue:0},{tfName:"ellipsis_mask",name:"ellipsisMask",type:"number",defaultValue:0},{tfName:"shrink_axis_mask",name:"shrinkAxisMask",type:"number",defaultValue:0}]},{tfOpName:"Pack",category:"slice_join",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Unpack",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"num",name:"num",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Tile",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"reps",type:"number[]"}]},{tfOpName:"Split",category:"slice_join",inputs:[{start:0,name:"axis",type:"number",defaultValue:0},{start:1,name:"x",type:"tensor"}],attrs:[{tfName:"num_split",name:"numOrSizeSplits",type:"number",defaultValue:1}]},{tfOpName:"SplitV",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"numOrSizeSplits",type:"number[]"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"ScatterNd",category:"slice_join",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"shape",type:"number[]"}]},{tfOpName:"GatherNd",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}]},{tfOpName:"SparseToDense",category:"slice_join",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!1,notSupported:!0}]}]}),I=Object.freeze({json:[{tfOpName:"FFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"RFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]},{tfOpName:"IRFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]}]}),R=Object.freeze({json:[{tfOpName:"Cast",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"SrcT",name:"sdtype",type:"dtype",notSupported:!0},{tfName:"DstT",name:"dtype",type:"dtype"}]},{tfOpName:"ExpandDims",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]}]}),M=function(){function t(){var t=[b,x,w,k,E,C,A,S,_,O,D,F,T,N,I,R],e=[].concat.apply([],t.map(function(t){return t.json;}));this.opMappers=e.reduce(function(t,e){return t[e.tfOpName]=e,t;},{});}return Object.defineProperty(t,"Instance",{get:function get(){return this._instance||(this._instance=new this());},enumerable:!0,configurable:!0}),t.prototype.transformGraph=function(t,e){var n=this;void 0===e&&(e={});var r=[],i=[],o=t.node.reduce(function(t,e){return t[e.name]=n.mapNode(e),e.op.startsWith("Placeholder")&&r.push(t[e.name]),"Const"===e.op&&i.push(t[e.name]),t;},{}),a=[],s=[],u={},c={};null!=e&&(u=this.mapSignatureEntries(e.inputs),c=this.mapSignatureEntries(e.outputs));var l=Object.keys(o);return l.forEach(function(t){var e=o[t];e.inputNames.forEach(function(t){var n=m(t)[0];e.inputs.push(o[n]),o[n].children.push(e);});}),0===Object.keys(c).length?l.forEach(function(t){var e=o[t];0===e.children.length&&s.push(e);}):Object.keys(c).forEach(function(t){var e=m(t)[0],n=o[e];null!=n&&(n.signatureKey=c[t],s.push(n));}),Object.keys(u).length>0?Object.keys(u).forEach(function(t){var e=m(t)[0],n=o[e];n&&(n.signatureKey=u[t],a.push(n));}):a=r,{nodes:o,inputs:a,outputs:s,weights:i,placeholders:r,signature:e};},t.prototype.mapSignatureEntries=function(t){return Object.keys(t||{}).reduce(function(e,n){return e[t[n].name]=n,e;},{});},t.prototype.mapNode=function(t){var e=f(t.op)||this.opMappers[t.op]||{};null==t.attr&&(t.attr={});var n={name:t.name,op:t.op,category:e.category,inputNames:(t.input||[]).map(function(t){return t.startsWith("^")?t.substr(1):t;}),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:t.attr};return null!=e.inputs&&(n.inputParams=e.inputs.reduce(function(t,e){return t[e.name]={type:e.type,inputIndexStart:e.start,inputIndexEnd:e.end},t;},{})),null!=e.attrs&&(n.attrParams=e.attrs.reduce(function(e,n){var r=n.type,i=void 0;switch(n.type){case"string":void 0===(i=B(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(i=B(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"string[]":void 0===(i=H(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(i=H(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"number":void 0===(i=L(t.attr,n.tfName,n.defaultValue||0))&&n.tfDeprecatedName&&(i=L(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"number[]":void 0===(i=$(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(i=$(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool":void 0===(i=P(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(i=P(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool[]":void 0===(i=K(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(i=K(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape":void 0===(i=q(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(i=q(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape[]":void 0===(i=G(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(i=G(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype":void 0===(i=U(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(i=U(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype[]":void 0===(i=W(t.attr,n.tfName,n.defaultValue))&&n.tfDeprecatedName&&(i=W(t.attr,n.tfDeprecatedName,n.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error("Unsupported param type: "+n.type+" for op: "+t.op);}return e[n.name]={value:i,type:r},e;},{})),n;},t;}();function j(e,n){var r=Array.isArray(e)?String.fromCharCode.apply(null,e):function(e){var n=Object(o.env)().global;if(void 0!==n.atob)return n.atob(e);if(void 0!==t)return new t(e,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()");}(e);return n?r:r.toLowerCase();}function B(t,e,n,r){void 0===r&&(r=!1);var i=t[e];return null!=i?j(i.s,r):n;}function P(t,e,n){var r=t[e];return r?r.b:n;}function L(t,e,n){var r=t[e]||{},i=null!=r.i?r.i:null!=r.f?r.f:n;return "number"==typeof i?i:parseInt(i,10);}function z(t){switch("string"==typeof t&&(t=r[t]),t){case r.DT_FLOAT:return "float32";case r.DT_INT32:case r.DT_INT64:case r.DT_INT8:case r.DT_UINT8:return "int32";case r.DT_BOOL:return "bool";case r.DT_DOUBLE:return "float32";case r.DT_STRING:return "string";default:return null;}}function U(t,e,n){var r=t[e];return r&&r.type?z(r.type):n;}function W(t,e,n){var r=t[e];return r&&r.list&&r.list.type?r.list.type.map(function(t){return z(t);}):n;}function V(t){if(!t.unknownRank)return null!=t.dim?t.dim.map(function(t){return "number"==typeof t.size?t.size:parseInt(t.size,10);}):[];}function q(t,e,n){var r=t[e];return r&&r.shape?V(r.shape):n;}function $(t,e,n){var r=t[e];return r?((r.list.f&&r.list.f.length?r.list.f:r.list.i)||[]).map(function(t){return "number"==typeof t?t:parseInt(t,10);}):n;}function H(t,e,n,r){void 0===r&&(r=!1);var i=t[e];return i&&i.list&&i.list.s?i.list.s.map(function(t){return j(t,r);}):n;}function G(t,e,n){var r=t[e];return r&&r.list&&r.list.shape?r.list.shape.map(function(t){return V(t);}):n;}function K(t,e,n){var r=t[e];return r&&r.list&&r.list.b?r.list.b:n;}var X=function(){function t(t,e,n){var r=this;this.node=t,this.tensorMap=e,this.context=n,this.inputs=[],this.attrs={},this.inputs=t.inputNames.map(function(t){return r.getInput(t);}),null!=t.rawAttrs&&(this.attrs=Object.keys(t.rawAttrs).reduce(function(t,e){return t[e]=r.getAttr(e),t;},{}));}return t.prototype.getInput=function(t){return p(t,this.tensorMap,this.context);},t.prototype.getAttr=function(t,e){var n=this.node.rawAttrs[t];if(null!=n.tensor)return p(t,this.tensorMap,this.context);if(null!=n.i||null!=n.f)return L(this.node.rawAttrs,t,e);if(null!=n.s)return B(this.node.rawAttrs,t,e);if(null!=n.b)return P(this.node.rawAttrs,t,e);if(null!=n.shape)return q(this.node.rawAttrs,t,e);if(null!=n.type)return U(this.node.rawAttrs,t,e);if(null!=n.list){if(null!=n.list.i||null!=n.list.f)return $(this.node.rawAttrs,t,e);if(null!=n.list.s)return H(this.node.rawAttrs,t,e);if(null!=n.list.shape)return G(this.node.rawAttrs,t,e);if(null!=n.list.b)return K(this.node.rawAttrs,t,e);if(null!=n.list.type)return W(this.node.rawAttrs,t,e);}return e;},t;}(),Y=function Y(t,e,n){switch(t.op){case"BiasAdd":case"AddV2":case"Add":return [Object(o.add)(d("a",t,e,n),d("b",t,e,n))];case"AddN":return [Object(o.addN)(d("tensors",t,e,n))];case"FloorMod":case"Mod":return [Object(o.mod)(d("a",t,e,n),d("b",t,e,n))];case"Mul":return [Object(o.mul)(d("a",t,e,n),d("b",t,e,n))];case"RealDiv":case"Div":return [Object(o.div)(d("a",t,e,n),d("b",t,e,n))];case"DivNoNan":return [Object(o.divNoNan)(d("a",t,e,n),d("b",t,e,n))];case"FloorDiv":return [Object(o.floorDiv)(d("a",t,e,n),d("b",t,e,n))];case"Sub":return [Object(o.sub)(d("a",t,e,n),d("b",t,e,n))];case"Minimum":return [Object(o.minimum)(d("a",t,e,n),d("b",t,e,n))];case"Maximum":return [Object(o.maximum)(d("a",t,e,n),d("b",t,e,n))];case"Pow":return [Object(o.pow)(d("a",t,e,n),d("b",t,e,n))];case"SquaredDifference":return [Object(o.squaredDifference)(d("a",t,e,n),d("b",t,e,n))];default:throw TypeError("Node type "+t.op+" is not implemented");}},J=function J(t,e,n){switch(t.op){case"Abs":case"ComplexAbs":return [Object(o.abs)(d("x",t,e,n))];case"Acos":return [Object(o.acos)(d("x",t,e,n))];case"Acosh":return [Object(o.acosh)(d("x",t,e,n))];case"Asin":return [Object(o.asin)(d("x",t,e,n))];case"Asinh":return [Object(o.asinh)(d("x",t,e,n))];case"Atan":return [Object(o.atan)(d("x",t,e,n))];case"Atan2":return [Object(o.atan2)(d("x",t,e,n),d("y",t,e,n))];case"Atanh":return [Object(o.atanh)(d("x",t,e,n))];case"Ceil":return [Object(o.ceil)(d("x",t,e,n))];case"Complex":return [Object(o.complex)(d("real",t,e,n),d("imag",t,e,n))];case"Cos":return [Object(o.cos)(d("x",t,e,n))];case"Cosh":return [Object(o.cosh)(d("x",t,e,n))];case"Elu":return [Object(o.elu)(d("x",t,e,n))];case"Erf":return [Object(o.erf)(d("x",t,e,n))];case"Exp":return [Object(o.exp)(d("x",t,e,n))];case"Expm1":return [Object(o.expm1)(d("x",t,e,n))];case"Floor":return [Object(o.floor)(d("x",t,e,n))];case"Log":return [Object(o.log)(d("x",t,e,n))];case"Log1p":return [Object(o.log1p)(d("x",t,e,n))];case"Imag":return [Object(o.imag)(d("x",t,e,n))];case"Neg":return [Object(o.neg)(d("x",t,e,n))];case"Reciprocal":return [Object(o.reciprocal)(d("x",t,e,n))];case"Real":return [Object(o.real)(d("x",t,e,n))];case"Relu":return [Object(o.relu)(d("x",t,e,n))];case"Round":return [Object(o.round)(d("x",t,e,n))];case"Selu":return [Object(o.selu)(d("x",t,e,n))];case"Sigmoid":return [Object(o.sigmoid)(d("x",t,e,n))];case"Sin":return [Object(o.sin)(d("x",t,e,n))];case"Sign":return [Object(o.sign)(d("x",t,e,n))];case"Sinh":return [Object(o.sinh)(d("x",t,e,n))];case"Softplus":return [Object(o.softplus)(d("x",t,e,n))];case"Sqrt":return [Object(o.sqrt)(d("x",t,e,n))];case"Square":return [Object(o.square)(d("x",t,e,n))];case"Tanh":return [Object(o.tanh)(d("x",t,e,n))];case"Tan":return [Object(o.tan)(d("x",t,e,n))];case"Relu6":case"ClipByValue":return [Object(o.clipByValue)(d("x",t,e,n),d("clipValueMin",t,e,n),d("clipValueMax",t,e,n))];case"Rsqrt":return [Object(o.rsqrt)(p(t.inputNames[0],e,n))];case"Prod":return [Object(o.prod)(d("x",t,e,n),d("axes",t,e,n))];case"LeakyRelu":return [Object(o.leakyRelu)(d("x",t,e,n),d("alpha",t,e,n))];case"Prelu":return [Object(o.prelu)(d("x",t,e,n),d("alpha",t,e,n))];default:throw TypeError("Node type "+t.op+" is not implemented");}},Q=function(){function t(e,n,r,i,o,a,s){this.name=e,this.dtype=n,this.maxSize=r,this.elementShape=i,this.identicalElementShapes=o,this.dynamicSize=a,this.clearAfterRead=s,this.tensors=[],this.closed_=!1,this.id=t.nextId++;}return Object.defineProperty(t.prototype,"closed",{get:function get(){return this.closed_;},enumerable:!0,configurable:!0}),t.prototype.clearAndClose=function(){this.tensors.forEach(function(t){return t.tensor.dispose();}),this.tensors=[],this.closed_=!0;},t.prototype.size=function(){return this.tensors.length;},t.prototype.read=function(t){if(this.closed_)throw new Error("TensorArray "+this.name+" has already been closed.");if(t<0||t>=this.tensors.length)throw new Error("Tried to read from index "+t+", but array size is: "+this.tensors.length);var e=this.tensors[t];if(e.cleared)throw new Error("TensorArray "+this.name+": Could not read index "+t+" twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).");return this.clearAfterRead&&(e.cleared=!0),e.read=!0,e.tensor;},t.prototype.readMany=function(t){var e=this;return t.map(function(t){return e.read(t);});},t.prototype.write=function(t,e){if(this.closed_)throw new Error("TensorArray "+this.name+" has already been closed.");if(t<0||!this.dynamicSize&&t>=this.maxSize)throw new Error("Tried to write to index "+t+", but array is not resizeable and size is: "+this.maxSize);var n=this.tensors[t]||{};if(e.dtype!==this.dtype)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+t+",\n          because the value dtype is "+e.dtype+", but TensorArray dtype is "+this.dtype+".");if(0!==this.size()||null!=this.elementShape&&0!==this.elementShape.length||(this.elementShape=e.shape),this.assertShapesMatchAllowUndefinedSize(this.elementShape,e.shape,"TensorArray "+this.name+": Could not write to TensorArray index "+t+"."),n&&n.read)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+t+", because it has already been read.");if(n&&n.written)throw new Error("TensorArray "+this.name+": Could not write to TensorArray index "+t+", because it has already been written.");n.tensor=e,n.written=!0,this.tensors[t]=n;},t.prototype.writeMany=function(t,e){var n=this;if(t.length!==e.length)throw new Error("TensorArray "+this.name+": could not write multiple tensors,because the index size: "+t.length+" is not the same as tensors size: "+e.length+".");t.forEach(function(t,r){return n.write(t,e[r]);});},t.prototype.gather=function(t,e){if(e&&e!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but gather requested dtype "+e);if(!t){t=[];for(var n=0;n<this.size();n++){t.push(n);}}if(0===t.length)return Object(o.tensor)([],[0].concat(this.elementShape));var r=this.readMany(t);return this.assertShapesMatchAllowUndefinedSize(this.elementShape,r[0].shape,"TensorArray shape mismatch: "),Object(o.stack)(r,0);},t.prototype.concat=function(t){if(t&&t!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but concat requested dtype "+t);if(0===this.size())return Object(o.tensor)([],[0].concat(this.elementShape));for(var e=[],n=0;n<this.size();n++){e.push(n);}var r=this.readMany(e);return this.assertShapesMatchAllowUndefinedSize(this.elementShape,r[0].shape,"TensorArray shape mismatch: tensor array shape ("+this.elementShape+") vs first tensor shape ("+r[0].shape+")"),Object(o.concat)(r,0);},t.prototype.scatter=function(t,e){if(e.dtype!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but tensor has dtype "+e.dtype);if(t.length!==e.shape[0])throw new Error("Expected len(indices) == tensor.shape[0], but saw: "+t.length+" vs. "+e.shape[0]);var n=Math.max.apply(Math,t);if(!this.dynamicSize&&n>=this.maxSize)throw new Error("Max index must be < array size ("+n+"  vs. "+this.maxSize+")");this.writeMany(t,Object(o.unstack)(e,0));},t.prototype.split=function(t,e){var n=this;if(e.dtype!==this.dtype)throw new Error("TensorArray dtype is "+this.dtype+" but tensor has dtype "+e.dtype);var r=0,i=t.map(function(t){return r+=t;});if(r!==e.shape[0])throw new Error("Expected sum of lengths to be equal to\n          tensor.shape[0], but sum of lengths is\n        "+r+", and tensor's shape is: "+e.shape);if(!this.dynamicSize&&t.length!==this.maxSize)throw new Error("TensorArray's size is not equal to the size of lengths ("+this.maxSize+" vs. "+t.length+"), and the TensorArray is not marked as dynamically resizeable");var a=0===r?0:e.size/r,s=[];Object(o.tidy)(function(){e=e.reshape([1,r,a]);for(var u=0;u<t.length;++u){var c=[0,0===u?0:i[u-1],0],l=[1,t[u],a];s[u]=Object(o.slice)(e,c,l).reshape(n.elementShape);}return s;});for(var u=[],c=0;c<t.length;c++){u[c]=c;}this.writeMany(u,s);},t.prototype.assertShapesMatchAllowUndefinedSize=function(t,e,n){void 0===n&&(n=""),o.util.assert(this.shapesEqualAllowUndefinedSize(t,e),function(){return n+" Shapes "+t+" and "+e+" must match";});},t.prototype.shapesEqualAllowUndefinedSize=function(t,e){if(t.length!==e.length)return !1;for(var n=0;n<t.length;n++){if(-1!==t[n]&&-1!==e[n]&&t[n]!==e[n])return !1;}return !0;},t.nextId=0,t;}(),Z=function Z(t,e,n){return s(void 0,void 0,void 0,function(){var r,i,a,s,c,l,f,h,m,g,v,y,b,x,w,k,E,C,A,O,_,S,D,F,T,N,I,R,M,j,B,P,L,z,U;return u(this,function(u){switch(u.label){case 0:switch(t.op){case"LoopCond":return [3,1];case"Switch":return [3,2];case"Merge":return [3,4];case"Enter":return [3,5];case"Exit":return [3,6];case"NextIteration":return [3,7];case"TensorArrayV3":return [3,8];case"TensorArrayWriteV3":return [3,9];case"TensorArrayReadV3":return [3,10];case"TensorArrayGatherV3":return [3,11];case"TensorArrayScatterV3":return [3,12];case"TensorArrayConcatV3":return [3,13];case"TensorArraySplitV3":return [3,14];case"TensorArraySizeV3":return [3,15];case"TensorArrayCloseV3":return [3,16];}return [3,17];case 1:return [2,[d("pred",t,e,n).clone()]];case 2:return r=d("pred",t,e,n),i=d("data",t,e,n),[4,r.data()];case 3:return [2,u.sent()[0]?[void 0,i.clone()]:[i.clone(),void 0]];case 4:return [2,(a=t.inputNames.find(function(t){return void 0!==p(t,e,n);}))?[p(a,e,n).clone()]:void 0];case 5:return s=d("frameName",t,e,n),c=d("tensor",t,e,n),n.enterFrame(s),[2,[c.clone()]];case 6:return l=d("tensor",t,e,n),n.exitFrame(),[2,[l.clone()]];case 7:return f=d("tensor",t,e,n),n.nextIteration(),[2,[f.clone()]];case 8:return h=d("size",t,e,n),m=d("dtype",t,e,n),g=d("elementShape",t,e,n),v=d("dynamicSize",t,e,n),y=d("clearAfterRead",t,e,n),b=d("identicalElementShapes",t,e,n),x=d("name",t,e,n),w=new Q(x,m,h,g,b,v,y),n.addTensorArray(w),[2,[Object(o.scalar)(w.id),Object(o.scalar)(1)]];case 9:return k=d("tensorArrayId",t,e,n),E=d("index",t,e,n),C=d("tensor",t,e,n),n.getTensorArray(k).write(E,C),[2,[Object(o.scalar)(1)]];case 10:return A=d("tensorArrayId",t,e,n),O=d("index",t,e,n),[2,[n.getTensorArray(A).read(O)]];case 11:return _=d("tensorArrayId",t,e,n),S=d("indices",t,e,n),D=d("dtype",t,e,n),[2,[n.getTensorArray(_).gather(S,D)]];case 12:return F=d("tensorArrayId",t,e,n),T=d("indices",t,e,n),N=d("tensor",t,e,n),n.getTensorArray(F).scatter(T,N),[2,[Object(o.scalar)(1)]];case 13:return I=d("tensorArrayId",t,e,n),R=n.getTensorArray(I),M=d("dtype",t,e,n),[2,[R.concat(M)]];case 14:return j=d("tensorArrayId",t,e,n),B=d("tensor",t,e,n),P=d("lengths",t,e,n),n.getTensorArray(j).split(P,B),[2,[Object(o.scalar)(1)]];case 15:return L=d("tensorArrayId",t,e,n),z=n.getTensorArray(L),[2,[Object(o.scalar)(z.size(),"int32")]];case 16:return U=d("tensorArrayId",t,e,n),n.getTensorArray(U).clearAndClose(),[2,[Object(o.scalar)(0)]];case 17:throw TypeError("Node type "+t.op+" is not implemented");}});});},tt=function tt(t,e,n){switch(t.op){case"Conv1D":var r=d("stride",t,e,n),i=d("pad",t,e,n),a=d("dataFormat",t,e,n).toUpperCase(),s=d("dilation",t,e,n);return [Object(o.conv1d)(d("x",t,e,n),d("filter",t,e,n),r,i,a,s)];case"Conv2D":r=d("strides",t,e,n),i=d("pad",t,e,n),a=d("dataFormat",t,e,n).toUpperCase();var u=d("dilations",t,e,n);return [Object(o.conv2d)(d("x",t,e,n),d("filter",t,e,n),[r[1],r[2]],i,a,[u[1],u[2]])];case"_FusedConv2D":case"FusedDepthwiseConv2dNative":var c=d("fusedOps",t,e,n),l=c[0],f=c[1],h="biasadd"===l,p="prelu"===f,m="fusedbatchnorm"===l,g=d("numArgs",t,e,n);if(h){if(p&&2!==g)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!p&&1!==g)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.");}if(m)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported.");r=d("strides",t,e,n),i=d("pad",t,e,n),a=d("dataFormat",t,e,n).toUpperCase(),u=d("dilations",t,e,n);var v=d("args",t,e,n),y=v[0],b=v[1];return [("_FusedConv2D"===t.op?o.fused.conv2d:o.fused.depthwiseConv2d)({x:d("x",t,e,n),filter:d("filter",t,e,n),strides:[r[1],r[2]],pad:i,dataFormat:a,dilations:[u[1],u[2]],bias:y,activation:f,preluActivationWeights:b})];case"Conv2DBackpropInput":case"Conv2dTranspose":var x=d("outputShape",t,e,n);return r=d("strides",t,e,n),i=d("pad",t,e,n),[Object(o.conv2dTranspose)(d("x",t,e,n),d("filter",t,e,n),x,[r[1],r[2]],i)];case"DepthwiseConv2dNative":case"DepthwiseConv2d":return r=d("strides",t,e,n),i=d("pad",t,e,n),u=d("dilations",t,e,n),a=d("dataFormat",t,e,n).toUpperCase(),[Object(o.depthwiseConv2d)(d("input",t,e,n),d("filter",t,e,n),[r[1],r[2]],i,a,[u[1],u[2]])];case"Conv3D":return r=d("strides",t,e,n),i=d("pad",t,e,n),a=d("dataFormat",t,e,n).toUpperCase(),u=d("dilations",t,e,n),[Object(o.conv3d)(d("x",t,e,n),d("filter",t,e,n),[r[1],r[2],r[3]],i,a,[u[1],u[2],u[3]])];case"AvgPool":r=d("strides",t,e,n),i=d("pad",t,e,n);var w=d("kernelSize",t,e,n);return [Object(o.avgPool)(d("x",t,e,n),[w[1],w[2]],[r[1],r[2]],i)];case"MaxPool":return r=d("strides",t,e,n),i=d("pad",t,e,n),w=d("kernelSize",t,e,n),[Object(o.maxPool)(d("x",t,e,n),[w[1],w[2]],[r[1],r[2]],i)];case"MaxPoolWithArgmax":r=d("strides",t,e,n),i=d("pad",t,e,n),w=d("kernelSize",t,e,n);var k=d("includeBatchInIndex",t,e,n),E=Object(o.maxPoolWithArgmax)(d("x",t,e,n),[w[1],w[2]],[r[1],r[2]],i,k);return [E.result,E.indexes];case"AvgPool3D":return r=d("strides",t,e,n),i=d("pad",t,e,n),w=d("kernelSize",t,e,n),[Object(o.avgPool3d)(d("x",t,e,n),[w[1],w[2],w[3]],[r[1],r[2],r[3]],i)];case"MaxPool3D":return r=d("strides",t,e,n),i=d("pad",t,e,n),w=d("kernelSize",t,e,n),[Object(o.maxPool3d)(d("x",t,e,n),[w[1],w[2],w[3]],[r[1],r[2],r[3]],i)];default:throw TypeError("Node type "+t.op+" is not implemented");}},et=function et(t,e,n){switch(t.op){case"Fill":var r=d("shape",t,e,n),i=d("dtype",t,e,n),a=d("value",t,e,n);return [Object(o.fill)(r,a,i)];case"LinSpace":var s=d("start",t,e,n),u=d("stop",t,e,n),c=d("num",t,e,n);return [Object(o.linspace)(s,u,c)];case"Multinomial":var l=d("logits",t,e,n),f=d("numSamples",t,e,n),h=d("seed",t,e,n);return [Object(o.multinomial)(l,f,h)];case"OneHot":var p=d("indices",t,e,n),m=d("depth",t,e,n),g=d("onValue",t,e,n),v=d("offValue",t,e,n);return [Object(o.oneHot)(p,m,g,v)];case"Ones":return [Object(o.ones)(d("shape",t,e,n),d("dtype",t,e,n))];case"OnesLike":return [Object(o.onesLike)(d("x",t,e,n))];case"RandomUniform":return [Object(o.randomUniform)(d("shape",t,e,n),d("minval",t,e,n),d("maxval",t,e,n),d("dtype",t,e,n))];case"Range":s=d("start",t,e,n);var y=d("stop",t,e,n),b=d("step",t,e,n);return [Object(o.range)(s,y,b,d("dtype",t,e,n))];case"TruncatedNormal":r=d("shape",t,e,n);var x=d("mean",t,e,n),w=d("stdDev",t,e,n);return h=d("seed",t,e,n),[Object(o.truncatedNormal)(r,x,w,d("dtype",t,e,n),h)];case"Zeros":return [Object(o.zeros)(d("shape",t,e,n),d("dtype",t,e,n))];case"ZerosLike":return [Object(o.zerosLike)(d("x",t,e,n))];default:throw TypeError("Node type "+t.op+" is not implemented");}},nt=function nt(t,e,n){return s(void 0,void 0,void 0,function(){var r,i,a,s,c,l,f,h;return u(this,function(u){switch(u.label){case 0:switch(t.op){case"NonMaxSuppressionV5":case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":return [3,1];case"Where":return [3,5];case"ListDiff":return [3,7];}return [3,8];case 1:return r=d("boxes",t,e,n),i=d("scores",t,e,n),a=d("maxOutputSize",t,e,n),s=d("iouThreshold",t,e,n),c=d("scoreThreshold",t,e,n),"NonMaxSuppressionV5"!==t.op?[3,3]:(l=d("softNmsSigma",t,e,n),[4,o.image.nonMaxSuppressionWithScoreAsync(r,i,a,s,c,l)]);case 2:return [2,[(h=u.sent()).selectedIndices,h.selectedScores]];case 3:return [4,o.image.nonMaxSuppressionAsync(r,i,a,s,c)];case 4:return [2,[u.sent()]];case 5:return f=d("condition",t,e,n).asType("bool"),[4,Object(o.whereAsync)(f)];case 6:return h=[u.sent()],f.dispose(),[2,h];case 7:return [2,Object(o.setdiff1dAsync)(d("x",t,e,n),d("y",t,e,n))];case 8:throw TypeError("Node type "+t.op+" is not implemented");}});});},rt=function rt(t,e,n){switch(t.op){case"TopKV2":var r=d("x",t,e,n),i=d("k",t,e,n),a=d("sorted",t,e,n),s=Object(o.topk)(r,i,a);return [s.values,s.indices];default:throw TypeError("Node type "+t.op+" is not implemented");}},it=function it(t,e,n){switch(t.op){case"Const":return e[t.name];case"PlaceholderWithDefault":var r=d("default",t,e,n);return [p(t.name,e,n)||r];case"Placeholder":return [p(t.name,e,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":return [d("x",t,e,n).clone()];case"IdentityN":return d("x",t,e,n).map(function(t){return t.clone();});case"Snapshot":return [d("x",t,e,n).clone()];case"Shape":return [Object(o.tensor1d)(d("x",t,e,n).shape,"int32")];case"ShapeN":return d("x",t,e,n).map(function(t){return Object(o.tensor1d)(t.shape);});case"Size":return [Object(o.scalar)(d("x",t,e,n).size,"int32")];case"Rank":return [Object(o.scalar)(d("x",t,e,n).rank,"int32")];case"NoOp":return [Object(o.scalar)(1)];case"Print":var i=d("x",t,e,n),a=d("data",t,e,n),s=d("message",t,e,n),u=d("summarize",t,e,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(s);for(var c=0;c<a.length;c++){console.log(Array.prototype.slice.call(a[c].dataSync()).slice(0,u));}return [i];default:throw TypeError("Node type "+t.op+" is not implemented");}},ot=function ot(t,e,n){switch(t.op){case"ResizeBilinear":var r=d("images",t,e,n),i=d("size",t,e,n),a=d("alignCorners",t,e,n);return [o.image.resizeBilinear(r,[i[0],i[1]],a)];case"ResizeNearestNeighbor":return r=d("images",t,e,n),i=d("size",t,e,n),a=d("alignCorners",t,e,n),[o.image.resizeNearestNeighbor(r,[i[0],i[1]],a)];case"CropAndResize":var s=d("image",t,e,n),u=d("boxes",t,e,n),c=d("boxInd",t,e,n),l=d("cropSize",t,e,n),f=d("method",t,e,n),h=d("extrapolationValue",t,e,n);return [o.image.cropAndResize(s,u,c,l,f,h)];default:throw TypeError("Node type "+t.op+" is not implemented");}},at=function at(t,e,n){switch(t.op){case"Equal":return [Object(o.equal)(d("a",t,e,n),d("b",t,e,n))];case"NotEqual":return [Object(o.notEqual)(d("a",t,e,n),d("b",t,e,n))];case"Greater":return [Object(o.greater)(d("a",t,e,n),d("b",t,e,n))];case"GreaterEqual":return [Object(o.greaterEqual)(d("a",t,e,n),d("b",t,e,n))];case"Less":return [Object(o.less)(d("a",t,e,n),d("b",t,e,n))];case"LessEqual":return [Object(o.lessEqual)(d("a",t,e,n),d("b",t,e,n))];case"LogicalAnd":return [Object(o.logicalAnd)(d("a",t,e,n),d("b",t,e,n))];case"LogicalNot":return [Object(o.logicalNot)(d("a",t,e,n))];case"LogicalOr":return [Object(o.logicalOr)(d("a",t,e,n),d("b",t,e,n))];case"Select":case"SelectV2":return [Object(o.where)(d("condition",t,e,n),d("a",t,e,n),d("b",t,e,n))];default:throw TypeError("Node type "+t.op+" is not implemented");}},st=function st(t,e,n){switch(t.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return [Object(o.matMul)(d("a",t,e,n),d("b",t,e,n),d("transposeA",t,e,n),d("transposeB",t,e,n))];case"Transpose":return [Object(o.transpose)(d("x",t,e,n),d("perm",t,e,n))];case"_FusedMatMul":var r=d("fusedOps",t,e,n),i=r[0],a=r[1],s="biasadd"===i,u="prelu"===a,c=d("numArgs",t,e,n);if(s){if(u&&2!==c)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!u&&1!==c)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.");}var l=d("args",t,e,n),f=l[0],h=l[1];return [o.fused.matMul({a:d("a",t,e,n),b:d("b",t,e,n),transposeA:d("transposeA",t,e,n),transposeB:d("transposeB",t,e,n),bias:f,activation:a,preluActivationWeights:h})];default:throw TypeError("Node type "+t.op+" is not implemented");}},ut=function ut(t,e,n){switch(t.op){case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return [Object(o.batchNorm)(d("x",t,e,n),d("mean",t,e,n),d("variance",t,e,n),d("offset",t,e,n),d("scale",t,e,n),d("epsilon",t,e,n))];case"LRN":return [Object(o.localResponseNormalization)(d("x",t,e,n),d("radius",t,e,n),d("bias",t,e,n),d("alpha",t,e,n),d("beta",t,e,n))];case"Softmax":return [Object(o.softmax)(d("x",t,e,n))];case"LogSoftmax":return [Object(o.logSoftmax)(d("x",t,e,n))];case"SparseToDense":return [Object(o.sparseToDense)(d("sparseIndices",t,e,n),d("outputShape",t,e,n),d("sparseValues",t,e,n),d("defaultValue",t,e,n))];default:throw TypeError("Node type "+t.op+" is not implemented");}},ct=function ct(t,e,n){switch(t.op){case"Max":var r=d("axis",t,e,n),i=d("keepDims",t,e,n);return [Object(o.max)(d("x",t,e,n),r,i)];case"Mean":return r=d("axis",t,e,n),i=d("keepDims",t,e,n),[Object(o.mean)(d("x",t,e,n),r,i)];case"Min":return r=d("axis",t,e,n),i=d("keepDims",t,e,n),[Object(o.min)(d("x",t,e,n),r,i)];case"Sum":return r=d("axis",t,e,n),i=d("keepDims",t,e,n),[Object(o.sum)(d("x",t,e,n),r,i)];case"All":return r=d("axis",t,e,n),i=d("keepDims",t,e,n),[Object(o.all)(d("x",t,e,n),r,i)];case"Any":return r=d("axis",t,e,n),i=d("keepDims",t,e,n),[Object(o.any)(d("x",t,e,n),r,i)];case"ArgMax":return r=d("axis",t,e,n),[Object(o.argMax)(d("x",t,e,n),r)];case"ArgMin":return r=d("axis",t,e,n),[Object(o.argMin)(d("x",t,e,n),r)];case"Prod":return r=d("axis",t,e,n),i=d("keepDims",t,e,n),[Object(o.prod)(d("x",t,e,n),r,i)];default:throw TypeError("Node type "+t.op+" is not implemented");}},lt=function lt(t,e,n){switch(t.op){case"ConcatV2":case"Concat":var r=d("n",t,e,n),i=d("axis",t,e,n),a=d("tensors",t,e,n);return a=a.slice(0,r),[Object(o.concat)(a,i)];case"GatherV2":case"Gather":i=d("axis",t,e,n);var s=d("x",t,e,n),u=d("indices",t,e,n);return [Object(o.gather)(s,u.asType("int32"),i)];case"ReverseV2":case"Reverse":return i=d("axis",t,e,n),s=d("x",t,e,n),[Object(o.reverse)(s,i)];case"Slice":var c=d("begin",t,e,n),l=d("size",t,e,n);return [Object(o.slice)(d("x",t,e,n),c,l)];case"StridedSlice":c=d("begin",t,e,n);var f=d("end",t,e,n),h=d("strides",t,e,n),p=d("beginMask",t,e,n),m=d("endMask",t,e,n),g=d("ellipsisMask",t,e,n),v=d("newAxisMask",t,e,n),y=d("shrinkAxisMask",t,e,n),b=d("x",t,e,n);if(1===c.length&&b.shape.length>1)for(var x=1;x<b.shape.length;x++){c.push(0),f.push(b.shape[x]),h.push(h[0]);}return [Object(o.stridedSlice)(b,c,f,h,p,m,g,v,y)];case"Pack":return Object(o.tidy)(function(){var r=d("axis",t,e,n),i=d("tensors",t,e,n),a=i[0].shape,s=i[0].squeeze().shape,u=i.map(function(t){var e=o.util.arraysEqual(t.shape,a);if(!e&&!o.util.arraysEqual(t.squeeze().shape,s))throw new Error("the input tensors shape does not match");return e?t:t.reshape(a);});return [Object(o.stack)(u,r)];});case"Unpack":return Object(o.tidy)(function(){var r=d("axis",t,e,n),i=d("tensor",t,e,n);return Object(o.unstack)(i,r);});case"Tile":var w=d("reps",t,e,n);return [Object(o.tile)(d("x",t,e,n),w)];case"Split":case"SplitV":i=d("axis",t,e,n);var k=d("numOrSizeSplits",t,e,n);return Object(o.split)(d("x",t,e,n),k,i);case"ScatterNd":u=d("indices",t,e,n);var E=d("values",t,e,n),C=d("shape",t,e,n);return [Object(o.scatterND)(u,E,C)];case"GatherNd":var A=d("x",t,e,n);return u=d("indices",t,e,n),[Object(o.gatherND)(A,u)];case"SparseToDense":u=d("sparseIndices",t,e,n),C=d("outputShape",t,e,n);var O=d("sparseValues",t,e,n),_=d("defaultValue",t,e,n);return [Object(o.sparseToDense)(u,O,C,O.dtype===_.dtype?_:_.asType(O.dtype))];default:throw TypeError("Node type "+t.op+" is not implemented");}},ft=function ft(t,e,n){switch(t.op){case"FFT":return [Object(o.fft)(d("x",t,e,n))];case"IFFT":return [Object(o.ifft)(d("x",t,e,n))];case"RFFT":return [Object(o.rfft)(d("x",t,e,n))];case"IRFFT":return [Object(o.irfft)(d("x",t,e,n))];default:throw TypeError("Node type "+t.op+" is not implemented");}},ht=function ht(t,e,n){switch(t.op){case"Cast":return [Object(o.cast)(d("x",t,e,n),d("dtype",t,e,n))];case"ExpandDims":var r=d("axis",t,e,n);return [Object(o.expandDims)(d("x",t,e,n),r)];case"Squeeze":return r=d("axis",t,e,n),[Object(o.squeeze)(d("x",t,e,n),r)];case"Reshape":return [Object(o.reshape)(d("x",t,e,n),d("shape",t,e,n))];case"PadV2":case"Pad":return [Object(o.pad)(d("x",t,e,n),y(d("padding",t,e,n),2),d("constantValue",t,e,n))];case"SpaceToBatchND":var i=d("blockShape",t,e,n),a=y(d("paddings",t,e,n),2);return [Object(o.spaceToBatchND)(d("x",t,e,n),i,a)];case"BatchToSpaceND":i=d("blockShape",t,e,n);var s=y(d("crops",t,e,n),2);return [Object(o.batchToSpaceND)(d("x",t,e,n),i,s)];case"DepthToSpace":var u=d("blockSize",t,e,n),c=d("dataFormat",t,e,n).toUpperCase();return [Object(o.depthToSpace)(d("x",t,e,n),u,c)];default:throw TypeError("Node type "+t.op+" is not implemented");}};function dt(t,e,n){var r=function(t,e,n){switch(t.category){case"arithmetic":return Object(o.tidy)(function(){return Y(t,e,n);});case"basic_math":return Object(o.tidy)(function(){return J(t,e,n);});case"control":return Z(t,e,n);case"convolution":return Object(o.tidy)(function(){return tt(t,e,n);});case"creation":return Object(o.tidy)(function(){return et(t,e,n);});case"dynamic":return nt(t,e,n);case"evaluation":return Object(o.tidy)(function(){return rt(t,e,n);});case"image":return Object(o.tidy)(function(){return ot(t,e,n);});case"graph":return Object(o.tidy)(function(){return it(t,e,n);});case"logical":return Object(o.tidy)(function(){return at(t,e,n);});case"matrices":return Object(o.tidy)(function(){return st(t,e,n);});case"normalization":return Object(o.tidy)(function(){return ut(t,e,n);});case"reduction":return Object(o.tidy)(function(){return ct(t,e,n);});case"slice_join":return Object(o.tidy)(function(){return lt(t,e,n);});case"spectral":return Object(o.tidy)(function(){return ft(t,e,n);});case"transformation":return Object(o.tidy)(function(){return ht(t,e,n);});case"custom":var r=f(t.op);if(r&&r.customExecutor)return r.customExecutor(new X(t,e,n));throw TypeError("Custom op "+t.op+" is not registered.");default:throw TypeError("Unknown op '"+t.op+"'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()");}}(t,e,n);return r instanceof Promise?r.then(function(t){return [].concat(t);}):[].concat(r);}var pt=function(){function t(t,e){this.weightMap=t,this.tensorArrayMap=e,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds();}return t.prototype.newFrame=function(t,e){return {id:t,frameName:e,iterationId:0};},Object.defineProperty(t.prototype,"currentContext",{get:function get(){return this.contexts;},set:function set(t){this.contexts!==t&&(this.contexts=t,this.generateCurrentContextIds());},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"currentContextId",{get:function get(){return this._currentContextIds[0];},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"currentContextIds",{get:function get(){return this._currentContextIds;},enumerable:!0,configurable:!0}),t.prototype.generateCurrentContextIds=function(){for(var t=[],e=0;e<this.contexts.length-1;e++){var n=this.contexts.slice(0,this.contexts.length-e);t.push(this.contextIdforContexts(n));}t.push(""),this._currentContextIds=t;},t.prototype.contextIdforContexts=function(t){return t?t.map(function(t){return 0===t.id&&0===t.iterationId?"":t.frameName+"-"+t.iterationId;}).join("/"):"";},t.prototype.enterFrame=function(t){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,t)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)));},t.prototype.exitFrame=function(){if(!(this.contexts&&this.contexts.length>1))throw new Error("Cannot exit frame, the context is empty");this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift();},t.prototype.nextIteration=function(){if(!(this.contexts&&this.contexts.length>0))throw new Error("Cannot increase frame iteration, the context is empty");this.contexts=this.contexts.slice(),this.lastId++;var t=Object.assign({},this.contexts[this.contexts.length-1]);t.iterationId+=1,t.id=this.lastId,this.contexts.splice(-1,1,t),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts));},t.prototype.getWeight=function(t){return this.weightMap[t];},t.prototype.addTensorArray=function(t){this.tensorArrayMap[t.id]=t;},t.prototype.getTensorArray=function(t){return this.tensorArrayMap[t];},t;}();function mt(t,e,n){for(var r=new Set(),i=[],o=null,a=null,s=new Set(),u=Object.keys(t).map(function(t){return v(t)[0];}),c=e.slice();c.length>0;){var l=c.pop();(yt(l)||bt(l))&&null==o&&(a=(o=l).children.map(function(t){return t.name;}).filter(function(t){return r.has(t);})),r.add(l.name),null==n[l.name]&&-1===u.indexOf(l.name)&&(0!==l.inputs.length?l.inputs.forEach(function(t){s.has(t.name)||(s.add(t.name),c.push(t));}):i.push(l.name));}return {inputs:t,outputs:e,usedNodes:r,missingInputs:i,dynamicNode:o,syncInputs:a};}var gt=["Switch","Merge","Enter","Exit","NextIteration"],vt=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"];function yt(t){return gt.indexOf(t.op)>=0;}function bt(t){return vt.indexOf(t.op)>=0;}var xt=function(){function t(t){this.graph=t,this.compiledMap=new Map(),this._weightMap={},this.SEPERATOR=",",this._outputs=t.outputs,this._inputs=t.inputs,this._signature=t.signature;}return Object.defineProperty(t.prototype,"weightMap",{get:function get(){return this._weightMap;},set:function set(t){var e=Object.keys(t).map(function(e){return t[e].map(function(t){return t.id;});});this.weightIds=[].concat.apply([],e),this._weightMap=t;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"inputs",{get:function get(){return this._inputs.map(function(t){return {name:t.name,shape:t.attrParams.shape?t.attrParams.shape.value:void 0,dtype:t.attrParams.dtype?t.attrParams.dtype.value:void 0};});},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"outputs",{get:function get(){return this._outputs.map(function(t){return {name:t.name,shape:t.attrParams.shape?t.attrParams.shape.value:void 0,dtype:t.attrParams.dtype?t.attrParams.dtype.value:void 0};});},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"inputNodes",{get:function get(){return this._inputs.map(function(t){return t.signatureKey||t.name;});},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"outputNodes",{get:function get(){return this._outputs.map(function(t){return t.signatureKey||t.name;});},enumerable:!0,configurable:!0}),t.prototype.getCompilationKey=function(t,e){var n=t.map(function(t){return t.name;}).sort(),r=e.map(function(t){return t.name;}).sort();return n.join(this.SEPERATOR)+"--"+r.join(this.SEPERATOR);},t.prototype.compile=function(t,e){var n=mt(t,e,this.weightMap),r=n.missingInputs,i=n.dynamicNode,o=n.syncInputs;if(null!=i)throw new Error("This execution contains the node '"+i.name+"', which has the dynamic op '"+i.op+"'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs ["+o+"]");if(r.length>0){var a=e.map(function(t){return t.name;}),s=Object.keys(t);throw new Error("Cannot compute the outputs ["+a+"] from the provided inputs ["+s+"]. Missing the following inputs: ["+r+"]");}return function(t,e,n){var r=n.usedNodes,i=n.inputs,o=[];Object.keys(i).map(function(t){return v(t)[0];}).map(function(e){return t.nodes[e];}).forEach(function(t){r.has(t.name)&&o.push(t);}),t.weights.forEach(function(t){r.has(t.name)&&o.push(t);});for(var a=new Set(),s=[];o.length>0;){var u=o.pop();a.add(u.name),e[u.name]||s.push(u),u.children.forEach(function(t){!a.has(t.name)&&r.has(t.name)&&t.inputs.every(function(t){return a.has(t.name);})&&o.push(t);});}return s;}(this.graph,this.weightMap,n);},t.prototype.execute=function(t,e){var n=this;t=this.mapInputs(t);var r=Object.keys(t).sort();this.checkInputs(t),this.checkInputShapeAndType(t),e=this.mapOutputs(e),this.checkOutputs(e);var i=r.map(function(t){return n.graph.nodes[v(t)[0]];}),s=e.map(function(t){return n.graph.nodes[v(t)[0]];}),u=this.getCompilationKey(i,s),c=this.compiledMap.get(u);null==c&&(c=this.compile(t,s),this.compiledMap.set(u,c));var l={};return Object(o.tidy)(function(){var r=new pt(n._weightMap,l),i=_a8({},n.weightMap);Object.keys(t).forEach(function(e){var n=v(e),r=n[0],o=[];o[n[1]]=t[e],i[r]=o;});for(var o=n.getFrozenTensorIds(i),s={},u=0;u<c.length;u++){var f=c[u];if(!i[f.name]){var h=dt(f,i,r);if(h instanceof Promise)throw new Error("The execution of the op '"+f.op+"' returned a promise. Please use model.executeAsync() instead.");i[f.name]=h,n.checkTensorForDisposal(f.name,f,i,r,o,e,s);}}return e.map(function(t){return p(t,i,r);});});},t.prototype.getFrozenTensorIds=function(t){var e=[].concat.apply([],Object.keys(t).map(function(e){return t[e];}).map(function(t){return t.map(function(t){return t.id;});}));return new Set(e);},t.prototype.checkTensorForDisposal=function(t,e,n,r,i,o,a){"control"!==e.category&&-1===o.indexOf(t)&&(n[t].forEach(function(t){null!=t&&(a[t.id]=(a[t.id]||0)+e.children.length);}),e.inputs.forEach(function(t){if("control"!==t.category){var e=function(t,e,n){return e[g(t,n.currentContextId)];}(t.name,n,r);null!=e&&e.forEach(function(t){if(t&&!i.has(t.id)){var e=a[t.id];1===e?(t.dispose(),delete a[t.id]):null!=e&&a[t.id]--;}});}}));},t.prototype.executeAsync=function(t,e){return s(this,void 0,void 0,function(){var n,r,i,o,a,s,c=this;return u(this,function(u){switch(u.label){case 0:return t=this.mapInputs(t),this.checkInputs(t),this.checkInputShapeAndType(t),e=this.mapOutputs(e),this.checkOutputs(e),n={},r=new pt(this._weightMap,n),[4,this.executeWithControlFlow(t,r,e)];case 1:return i=u.sent(),o=e.map(function(t){return p(t,i,r);}),a=new Set(o.map(function(t){return t.id;})),s=new Set(Object.keys(t).map(function(e){return t[e].id;})),Object.keys(i).forEach(function(t){i[t].forEach(function(t){!t||t.isDisposed||a.has(t.id)||s.has(t.id)||-1!==c.weightIds.indexOf(t.id)||t.dispose();});}),[2,o];}});});},t.prototype.executeWithControlFlow=function(t,e,n){return s(this,void 0,void 0,function(){var r,i,o,s,c,l,f,h,d,m,g,y,b,x,w,k,E=this;return u(this,function(u){switch(u.label){case 0:r=Object.keys(t),i=r.map(function(t){return E.graph.nodes[v(t)[0]];}),o=n.map(function(t){return E.graph.nodes[v(t)[0]];}),s=mt(t,o,this.weightMap),c=s.usedNodes,l=s.missingInputs,f=s.dynamicNode,h=s.syncInputs,d=i.concat(this.graph.weights).map(function(t){return {node:t,contexts:e.currentContext};}),m=_a8({},this.weightMap),Object.keys(t).forEach(function(e){var n=v(e),r=n[0],i=[];i[n[1]]=t[e],m[r]=i;}),g={},y=this.getFrozenTensorIds(m),b={},u.label=1;case 1:return d.length>0?(x=this.processStack(i,d,e,m,b,y,n,g,c),[4,Promise.all(x)]):[3,3];case 2:return u.sent(),[3,1];case 3:if(null==f&&console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead."),(w=o.filter(function(t){return !yt(t)&&!p(t.name,m,e);}).map(function(t){return t.name;})).length>0)throw k="",null!=f&&(k="Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs ["+h+"]"),new Error("Cannot compute the outputs ["+w+"] from the provided inputs ["+r+"]. Consider providing the following inputs: ["+l+"]. "+k);return [2,m];}});});},t.prototype.processStack=function(t,e,n,r,i,o,a,s,u){for(var c=this,l=[],f=function f(){var f=e.pop();n.currentContext=f.contexts;var p="";if("Enter"===f.node.op&&d("isConstant",f.node,r,n)&&(p=m(f.node.name,n)[0]),-1===t.indexOf(f.node)){var g=dt(f.node,r,n);p||(p=m(f.node.name,n)[0]);var v=n.currentContext;g instanceof Promise?l.push(g.then(function(t){return r[p]=t,n.currentContext=v,c.checkTensorForDisposal(p,f.node,r,n,o,a,s),c.processChildNodes(f.node,e,n,r,i,u),t;})):(r[p]=g,h.checkTensorForDisposal(p,f.node,r,n,o,a,s),h.processChildNodes(f.node,e,n,r,i,u));}else h.processChildNodes(f.node,e,n,r,i,u);},h=this;e.length>0;){f();}return l;},t.prototype.processChildNodes=function(t,e,n,r,i,o){t.children.forEach(function(t){var a=m(t.name,n)[0];!i[a]&&o.has(t.name)&&("Merge"===t.op?t.inputNames.some(function(t){return !!p(t,r,n);})&&(i[a]=!0,e.push({contexts:n.currentContext,node:t})):t.inputNames.every(function(t){return !!p(t,r,n);})&&(i[a]=!0,e.push({contexts:n.currentContext,node:t})));});},t.prototype.dispose=function(){var t=this;Object.keys(this.weightMap).forEach(function(e){return t.weightMap[e].forEach(function(t){return t.dispose();});});},t.prototype.checkInputShapeAndType=function(t){var e=this;Object.keys(t).forEach(function(n){var r=t[n],i=v(n)[0],a=e.graph.nodes[i];if(a.attrParams.shape&&a.attrParams.shape.value){var s=a.attrParams.shape.value,u=s.length===r.shape.length&&r.shape.every(function(t,e){return -1===s[e]||s[e]===t;});o.util.assert(u,function(){return "The shape of dict['"+a.name+"'] provided in model.execute(dict) must be ["+s+"], but was ["+r.shape+"]";});}a.attrParams.dtype&&a.attrParams.dtype.value&&o.util.assert(r.dtype===a.attrParams.dtype.value,function(){return "The dtype of dict['"+a.name+"'] provided in model.execute(dict) must be "+a.attrParams.dtype.value+", but was "+r.dtype;});});},t.prototype.mapInputs=function(t){var e={};for(var n in t){null!=this._signature&&null!=this._signature.inputs&&null!=this._signature.inputs[n]?e[this._signature.inputs[n].name]=t[n]:e[n]=t[n];}return e;},t.prototype.checkInputs=function(t){var e=this,n=Object.keys(t).filter(function(t){var n=v(t)[0];return null==e.graph.nodes[n];});if(n.length>0)throw new Error("The dict provided in model.execute(dict) has keys: ["+n+"] that are not part of graph");},t.prototype.mapOutputs=function(t){var e=this;return t.map(function(t){return null!=e._signature&&null!=e._signature.outputs&&null!=e._signature.outputs[t]?e._signature.outputs[t].name:t;},{});},t.prototype.checkOutputs=function(t){var e=this;t.forEach(function(t){var n=v(t)[0];if(!e.graph.nodes[n])throw new Error("The output '"+t+"' is not found in the graph");});},t;}(),wt="?tfjs-format=file",kt="model.json",Et=function(){function t(t,e){void 0===e&&(e={}),this.modelUrl=t,this.loadOptions=e,this.version="n/a",null==e&&(this.loadOptions={});}return Object.defineProperty(t.prototype,"modelVersion",{get:function get(){return this.version;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"inputNodes",{get:function get(){return this.executor.inputNodes;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"outputNodes",{get:function get(){return this.executor.outputNodes;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"inputs",{get:function get(){return this.executor.inputs;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"outputs",{get:function get(){return this.executor.outputs;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"weights",{get:function get(){return this.executor.weightMap;},enumerable:!0,configurable:!0}),t.prototype.findIOHandler=function(){var t=this.modelUrl;if(null!=t.load)this.handler=t;else if(null!=this.loadOptions.requestInit)this.handler=o.io.browserHTTPRequest(t,this.loadOptions);else {var e=o.io.getLoadHandlers(t,this.loadOptions.onProgress);if(0===e.length)e.push(o.io.browserHTTPRequest(t,this.loadOptions));else if(e.length>1)throw new Error("Found more than one ("+e.length+") load handlers for URL '"+[t]+"'");this.handler=e[0];}},t.prototype.load=function(){return s(this,void 0,void 0,function(){var t,e,n,r;return u(this,function(i){switch(i.label){case 0: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.");return t=this,[4,this.handler.load()];case 1:return t.artifacts=i.sent(),e=this.artifacts.modelTopology,n={},null!=this.artifacts.userDefinedMetadata&&(n=this.artifacts.userDefinedMetadata.signature),this.version=e.versions.producer+"."+e.versions.minConsumer,r=o.io.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs),this.executor=new xt(M.Instance.transformGraph(e,n)),this.executor.weightMap=this.convertTensorMapToTensorsMap(r),[2,!0];}});});},t.prototype.save=function(t,e){return s(this,void 0,void 0,function(){var e;return u(this,function(n){if("string"==typeof t){if(0===(e=o.io.getSaveHandlers(t)).length)throw new Error("Cannot find any save handlers for URL '"+t+"'");if(e.length>1)throw new Error("Found more than one ("+e.length+") save handlers for URL '"+t+"'");t=e[0];}if(null==t.save)throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return [2,t.save(this.artifacts)];});});},t.prototype.predict=function(t,e){return this.execute(t,this.outputNodes);},t.prototype.normalizeInputs=function(t){if(!(t instanceof o.Tensor||Array.isArray(t)))return t;if((t=Array.isArray(t)?t:[t]).length!==this.inputNodes.length)throw new Error("Input tensor count mismatch,the graph model has "+this.inputNodes.length+" placeholders, while there are "+t.length+" input tensors.");return this.inputNodes.reduce(function(e,n,r){return e[n]=t[r],e;},{});},t.prototype.normalizeOutputs=function(t){return t=t||this.outputNodes,Array.isArray(t)?t:[t];},t.prototype.execute=function(t,e){t=this.normalizeInputs(t),e=this.normalizeOutputs(e);var n=this.executor.execute(t,e);return n.length>1?n:n[0];},t.prototype.executeAsync=function(t,e){return s(this,void 0,void 0,function(){var n;return u(this,function(r){switch(r.label){case 0:return t=this.normalizeInputs(t),e=this.normalizeOutputs(e),[4,this.executor.executeAsync(t,e)];case 1:return [2,(n=r.sent()).length>1?n:n[0]];}});});},t.prototype.convertTensorMapToTensorsMap=function(t){return Object.keys(t).reduce(function(e,n){return e[n]=[t[n]],e;},{});},t.prototype.dispose=function(){this.executor.dispose();},t;}();function Ct(t,e){return void 0===e&&(e={}),s(this,void 0,void 0,function(){var n;return u(this,function(r){switch(r.label){case 0:if(null==t)throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");return null==e&&(e={}),e.fromTFHub&&null==t.load&&(t.endsWith("/")||(t+="/"),t=""+t+kt+wt),[4,(n=new Et(t,e)).load()];case 1:return r.sent(),[2,n];}});});}var At="1.7.4";}.call(this,n(92).Buffer);},function(t,e,n){/**
 * @license
 * Copyright 2017 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(103);function i(t){for(var e=t.length,n=0,r=0;e>0;){r=Math.random()*e|0,n=t[--e],t[e]=t[r],t[r]=n;}}function o(t,e){if(!t)throw new Error("string"==typeof e?e:e());}function a(t,e,n){if(void 0===e&&(e=[]),void 0===n&&(n=!1),null==e&&(e=[]),Array.isArray(t)||f(t)&&!n)for(var r=0;r<t.length;++r){a(t[r],e,n);}else e.push(t);return e;}function s(t,e){if(t===e)return !0;if(null==t||null==e)return !1;if(t.length!==e.length)return !1;for(var n=0;n<t.length;n++){if(t[n]!==e[n])return !1;}return !0;}function u(t){return t%1==0;}function c(t,e){var n=e.length;return o((t=null==t?e.map(function(t,e){return e;}):[].concat(t)).every(function(t){return t>=-n&&t<n;}),function(){return "All values in axis param must be in range [-"+n+", "+n+") but got axis "+t;}),o(t.every(function(t){return u(t);}),function(){return "All values in axis param must be integers but got axis "+t;}),t.map(function(t){return t<0?n+t:t;});}function l(t,e){for(var n=0;n<t.length;n++){var r=t[n];if(isNaN(r)||!isFinite(r))throw Error("A tensor of type "+e+" being uploaded contains "+r+".");}}function f(t){return t instanceof Float32Array||t instanceof Int32Array||t instanceof Uint8Array;}function h(t){return "string"==typeof t||t instanceof String;}function d(t){return "boolean"==typeof t;}function p(t){return "number"==typeof t;}function m(t,e){if(null==e||"float32"===e||"complex64"===e)return new Float32Array(t);if("int32"===e)return new Int32Array(t);if("bool"===e)return new Uint8Array(t);throw new Error("Unknown data type "+e);}e.shuffle=i,e.clamp=function(t,e,n){return Math.max(t,Math.min(e,n));},e.nearestLargerEven=function(t){return t%2==0?t:t+1;},e.sum=function(t){for(var e=0,n=0;n<t.length;n++){e+=t[n];}return e;},e.randUniform=function(t,e){var n=Math.random();return e*n+(1-n)*t;},e.distSquared=function(t,e){for(var n=0,r=0;r<t.length;r++){var i=Number(t[r])-Number(e[r]);n+=i*i;}return n;},e.assert=o,e.assertShapesMatch=function(t,e,n){void 0===n&&(n=""),o(s(t,e),function(){return n+" Shapes "+t+" and "+e+" must match";});},e.assertNonNull=function(t){o(null!=t,function(){return "The input to the tensor constructor must be a non-null value.";});},e.flatten=a,e.sizeFromShape=function(t){if(0===t.length)return 1;for(var e=t[0],n=1;n<t.length;n++){e*=t[n];}return e;},e.isScalarShape=function(t){return 0===t.length;},e.arraysEqual=s,e.isInt=u,e.tanh=function(t){if(null!=Math.tanh)return Math.tanh(t);if(t===1/0)return 1;if(t===-1/0)return -1;var e=Math.exp(2*t);return (e-1)/(e+1);},e.sizeToSquarishShape=function(t){var e=Math.ceil(Math.sqrt(t));return [e,Math.ceil(t/e)];},e.createShuffledIndices=function(t){for(var e=new Uint32Array(t),n=0;n<t;++n){e[n]=n;}return i(e),e;},e.rightPad=function(t,e){return e<=t.length?t:t+" ".repeat(e-t.length);},e.repeatedTry=function(t,e,n){return void 0===e&&(e=function e(t){return 0;}),new Promise(function(r,i){var o=0,a=function a(){if(t())r();else {var s=e(++o);null!=n&&o>=n?i():setTimeout(a,s);}};a();});},e.inferFromImplicitShape=function(t,e){for(var n=1,r=-1,i=0;i<t.length;++i){if(t[i]>=0)n*=t[i];else if(-1===t[i]){if(-1!==r)throw Error("Shapes can only have 1 implicit size. Found -1 at dim "+r+" and dim "+i);r=i;}else if(t[i]<0)throw Error("Shapes can not be < 0. Found "+t[i]+" at dim "+i);}if(-1===r){if(e>0&&e!==n)throw Error("Size("+e+") must match the product of shape "+t);return t;}if(0===n)throw Error("Cannot infer the missing size in ["+t+"] when there are 0 elements");if(e%n!=0)throw Error("The implicit shape can't be a fractional number. Got "+e+" / "+n);var o=t.slice();return o[r]=e/n,o;},e.parseAxisParam=c,e.squeezeShape=function(t,e){for(var n=[],r=[],i=null!=e&&Array.isArray(e)&&0===e.length,o=null==e||i?null:c(e,t).sort(),a=0,s=0;s<t.length;++s){if(null!=o){if(o[a]===s&&1!==t[s])throw new Error("Can't squeeze axis "+s+" since its dim '"+t[s]+"' is not 1");(null==o[a]||o[a]>s)&&1===t[s]&&(n.push(t[s]),r.push(s)),o[a]<=s&&a++;}1!==t[s]&&(n.push(t[s]),r.push(s));}return {newShape:n,keptDims:r};},e.getTypedArrayFromDType=function(t,e){var n=null;if(null==t||"float32"===t)n=new Float32Array(e);else if("int32"===t)n=new Int32Array(e);else {if("bool"!==t)throw new Error("Unknown data type "+t);n=new Uint8Array(e);}return n;},e.getArrayFromDType=function(t,e){var n=null;if(null==t||"float32"===t)n=new Float32Array(e);else if("int32"===t)n=new Int32Array(e);else if("bool"===t)n=new Uint8Array(e);else {if("string"!==t)throw new Error("Unknown data type "+t);n=new Array(e);}return n;},e.checkConversionForErrors=l,e.isValidDtype=function(t){return "bool"===t||"complex64"===t||"float32"===t||"int32"===t||"string"===t;},e.hasEncodingLoss=function(t,e){return !("complex64"===e||"float32"===e&&"complex64"!==t||"int32"===e&&"float32"!==t&&"complex64"!==t||"bool"===e&&"bool"===t);},e.isTypedArray=f,e.bytesPerElement=function(t){if("float32"===t||"int32"===t)return 4;if("complex64"===t)return 8;if("bool"===t)return 1;throw new Error("Unknown dtype "+t);},e.bytesFromStringArray=function(t){if(null==t)return 0;var e=0;return t.forEach(function(t){return e+=t.length;}),e;},e.isString=h,e.isBoolean=d,e.isNumber=p,e.inferDtype=function t(e){return Array.isArray(e)?t(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array?"int32":p(e)?"float32":h(e)?"string":d(e)?"bool":"float32";},e.isFunction=function(t){return !!(t&&t.constructor&&t.call&&t.apply);},e.nearestDivisor=function(t,e){for(var n=e;n<t;++n){if(t%n==0)return n;}return t;},e.computeStrides=function(t){var e=t.length;if(e<2)return [];var n=new Array(e-1);n[e-2]=t[e-1];for(var r=e-3;r>=0;--r){n[r]=n[r+1]*t[r+1];}return n;},e.toTypedArray=function(t,e,n){if("string"===e)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(t)&&(t=a(t)),n&&l(t,e),function(t,e){return t instanceof Float32Array&&"float32"===e||t instanceof Int32Array&&"int32"===e||t instanceof Uint8Array&&"bool"===e;}(t,e))return t;if(null==e||"float32"===e||"complex64"===e)return new Float32Array(t);if("int32"===e)return new Int32Array(t);if("bool"===e){for(var r=new Uint8Array(t.length),i=0;i<r.length;++i){0!==Math.round(t[i])&&(r[i]=1);}return r;}throw new Error("Unknown data type "+e);},e.toNestedArray=function(t,e){if(0===t.length)return e[0];var n=t.reduce(function(t,e){return t*e;});if(0===n)return [];if(n!==e.length)throw new Error("["+t+"] does not match the input size.");return function t(e,n,r){var i=new Array();if(1===n.length)for(var o=n[0],a=0;a<o;a++){i[a]=r[e+a];}else {o=n[0];var s=n.slice(1),u=s.reduce(function(t,e){return t*e;});for(a=0;a<o;a++){i[a]=t(e+a*u,s,r);}}return i;}(0,t,e);},e.makeOnesTypedArray=function(t,e){for(var n=m(t,e),r=0;r<n.length;r++){n[r]=1;}return n;},e.makeZerosTypedArray=m,e.now=function(){return r.env().platform.now();},e.assertNonNegativeIntegerDimensions=function(t){t.forEach(function(e){o(Number.isInteger(e)&&e>=0,function(){return "Tensor must have a shape comprised of positive integers but got shape ["+t+"].";});});},e.fetch=function(t,e){return r.env().platform.fetch(t,e);},e.encodeString=function(t,e){return void 0===e&&(e="utf-8"),e=e||"utf-8",r.env().platform.encode(t,e);},e.decodeString=function(t,e){return void 0===e&&(e="utf-8"),e=e||"utf-8",r.env().platform.decode(t,e);},e.locToIndex=function(t,e,n){if(0===e)return 0;if(1===e)return t[0];for(var r=t[t.length-1],i=0;i<t.length-1;++i){r+=n[i]*t[i];}return r;},e.indexToLoc=function(t,e,n){if(0===e)return [];if(1===e)return [t];for(var r=new Array(e),i=0;i<r.length-1;++i){r[i]=Math.floor(t/n[i]),t-=r[i]*n[i];}return r[r.length-1]=t,r;};},function(t,e,n){var r=n(54),i=Math.min;t.exports=function(t){return t>0?i(r(t),9007199254740991):0;};},function(t,e,n){var r=n(262),i=n(261),o=n(187),a=n(260);t.exports=function(t,e){return r(t)||i(t,e)||o(t,e)||a();},t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e){var n=t.exports={version:"2.6.12"};"number"==typeof __e&&(__e=n);},function(t,e,n){(function(t,r){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var i=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});},o=this&&this.__generator||function(t,e){var n,r,i,o,a={label:0,sent:function sent(){if(1&i[0])throw i[1];return i[1];},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this;}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;){try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue;}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break;}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break;}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break;}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(t,a);}catch(t){o=[6,t],r=0;}finally{n=i=0;}}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:!0};}([o,s]);};}};Object.defineProperty(e,"__esModule",{value:!0});var a,s=n(103),u=n(382),c=n(381),l=n(380),f=n(33),h=n(74),d=n(21),p=n(21),m=function(){function t(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap(),this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null};}return t.prototype.dispose=function(){for(var t in this.registeredVariables){this.registeredVariables[t].dispose();}},t;}(),g=function(){function t(t){this.ENV=t,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new m();}return t.prototype.ready=function(){return i(this,void 0,void 0,function(){var t,e,n;return o(this,function(r){switch(r.label){case 0:if(null!=this.pendingBackendInit)return [2,this.pendingBackendInit.then(function(){})];if(null!=this.backendInstance)return [2];t=this.getSortedBackends(),e=0,r.label=1;case 1:return e<t.length?(n=t[e],[4,this.initializeBackend(n).success]):[3,5];case 2:return r.sent()?[4,this.setBackend(n)]:[3,4];case 3:return r.sent(),[2];case 4:return e++,[3,1];case 5:throw new Error("Could not initialize any backends, all backend initializations failed.");}});});},Object.defineProperty(t.prototype,"backend",{get:function get(){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");if(null==this.backendInstance){var t=this.initializeBackendsAndReturnBest(),e=t.name;if(t.asyncInit)throw new Error("The highest priority backend '"+e+"' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods");this.setBackend(e);}return this.backendInstance;},enumerable:!0,configurable:!0}),t.prototype.backendNames=function(){return Object.keys(this.registryFactory);},t.prototype.findBackend=function(t){if(!(t in this.registry)){if(!(t in this.registryFactory))return null;if(this.initializeBackend(t).asyncInit)return null;}return this.registry[t];},t.prototype.findBackendFactory=function(t){return t in this.registryFactory?this.registryFactory[t].factory:null;},t.prototype.registerBackend=function(t,e,n){return void 0===n&&(n=1),t in this.registryFactory?(console.warn(t+" backend was already registered. Reusing existing backend factory."),!1):(this.registryFactory[t]={factory:e,priority:n},!0);},t.prototype.setBackend=function(t){return i(this,void 0,void 0,function(){var e,n,r;return o(this,function(i){switch(i.label){case 0:if(null==this.registryFactory[t])throw new Error("Backend name '"+t+"' not found in registry");return this.backendName=t,null!=this.registry[t]?[3,4]:(this.backendInstance=null,e=this.initializeBackend(t),n=e.success,e.asyncInit?[4,n]:[3,2]);case 1:return r=i.sent(),[3,3];case 2:r=n,i.label=3;case 3:if(!r)return [2,!1];i.label=4;case 4:return this.backendInstance=this.registry[t],this.setupRegisteredKernels(),this.profiler=new c.Profiler(this.backendInstance),[2,!0];}});});},t.prototype.setupRegisteredKernels=function(){var t=this;u.getKernelsForBackend(this.backendName).forEach(function(e){null!=e.setupFunc&&e.setupFunc(t.backendInstance);});},t.prototype.disposeRegisteredKernels=function(t){var e=this;u.getKernelsForBackend(t).forEach(function(n){null!=n.disposeFunc&&n.disposeFunc(e.registry[t]);});},t.prototype.initializeBackend=function(t){var e=this,n=this.registryFactory[t];if(null==n)throw new Error("Cannot initialize backend "+t+", no registration found.");try{var r=n.factory();if(Promise.resolve(r)===r){var i=++this.pendingBackendInitId,o=r.then(function(n){return !(i<e.pendingBackendInitId)&&(e.registry[t]=n,e.pendingBackendInit=null,!0);}).catch(function(n){return !(i<e.pendingBackendInitId)&&(e.pendingBackendInit=null,console.warn("Initialization of backend "+t+" failed"),console.warn(n.stack||n.message),!1);});return this.pendingBackendInit=o,{success:o,asyncInit:!0};}return this.registry[t]=r,{success:!0,asyncInit:!1};}catch(e){return console.warn("Initialization of backend "+t+" failed"),console.warn(e.stack||e.message),{success:!1,asyncInit:!1};}},t.prototype.removeBackend=function(t){if(!(t in this.registryFactory))throw new Error(t+" backend not found in registry");this.backendName===t&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,t in this.registry&&(this.disposeRegisteredKernels(t),this.registry[t].dispose(),delete this.registry[t]),delete this.registryFactory[t],this.backendName===t&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null);},t.prototype.getSortedBackends=function(){var t=this;if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort(function(e,n){return t.registryFactory[n].priority-t.registryFactory[e].priority;});},t.prototype.initializeBackendsAndReturnBest=function(){for(var t=this.getSortedBackends(),e=0;e<t.length;e++){var n=t[e],r=this.initializeBackend(n),i=r.success,o=r.asyncInit;if(o||i)return {name:n,asyncInit:o};}throw new Error("Could not initialize any backends, all backend initializations failed.");},t.prototype.moveData=function(t,e){var n=this.state.tensorInfo.get(e),r=n.backend,i=this.readSync(e);r.disposeData(e),n.backend=t,t.move(e,i,n.shape,n.dtype),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++;},t.prototype.tidy=function(t,e){var n,r=this,i=null;if(null==e){if("function"!=typeof t)throw new Error("Please provide a function to tidy()");e=t;}else {if("string"!=typeof t&&!(t instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof e)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");i=t;}return this.scopedRun(function(){return r.startScope(i);},function(){return r.endScope(n);},function(){return (n=e())instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n;});},t.prototype.scopedRun=function(t,e,n){t();try{var r=n();return e(),r;}catch(t){throw e(),t;}},t.prototype.nextTensorId=function(){return t.nextTensorId++;},t.prototype.nextVariableId=function(){return t.nextVariableId++;},t.prototype.clone=function(t){var e=this.makeTensorFromDataId(t.dataId,t.shape,t.dtype),n={x:t};return this.addTapeNode(this.state.activeScope.name,n,[e],function(t){return {x:function x(){return t.toFloat();}};},[],{}),e;},t.prototype.runKernel=function(t,e,n,r,i){return this.runKernelFunc(null,e,null,t,n,r,i);},t.prototype.shouldCheckForMemLeaks=function(){return this.ENV.getBool("IS_TEST");},t.prototype.checkKernelForMemLeak=function(t,e,n){var r=this.backend.numDataIds(),i=0;n.forEach(function(t){i+="complex64"===t.dtype?3:1;});var o=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],a=r-e-i-o;if(a>0)throw new Error("Backend '"+this.backendName+"' has an internal memory leak ("+a+" data ids) after running '"+t+"'");},t.prototype.runKernelFunc=function(t,e,n,r,i,o,a){var s,c=this,l=[],f=this.isTapeOn();null==r&&(r=null!=this.state.activeScope?this.state.activeScope.name:"");var h,d=this.state.numBytes,p=this.state.numTensors;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0);var m,g=u.getKernel(r,this.backendName);if(null!=g)h=function h(){var t=c.backend.numDataIds();m=g.kernelFunc({inputs:e,attrs:i,backend:c.backend});var n=Array.isArray(m)?m:[m];c.shouldCheckForMemLeaks()&&c.checkKernelForMemLeak(r,t,n);var s=n.map(function(t){var e=t.dataId,n=t.shape,r=t.dtype;return c.makeTensorFromDataId(e,n,r);});if(f){var u=c.getTensorsForGradient(r,e,s);if(null==u){null==a&&(a=[]);var h=s.filter(function(t,e){return a[e];});u=(o||[]).slice().concat(h);}l=c.saveTensorsForBackwardMode(u);}return s;};else {var v=function v(t){f&&(l=t.map(function(t){return c.keep(c.clone(t));}));};h=function h(){var e=c.backend.numDataIds();m=c.tidy(function(){return t(c.backend,v);});var n=Array.isArray(m)?m:[m];return c.shouldCheckForMemLeaks()&&c.checkKernelForMemLeak(r,e,n),n;};}return this.scopedRun(function(){return c.state.kernelDepth++;},function(){return c.state.kernelDepth--;},function(){s=c.ENV.getBool("DEBUG")?c.profiler.profileKernel(r,e,function(){return h();}):h();}),f&&this.addTapeNode(r,e,s,n,l,i),this.state.profiling&&this.state.activeProfile.kernels.push({name:r,bytesAdded:this.state.numBytes-d,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-p,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(e).map(function(t){return e[t].shape;}),outputShapes:s.map(function(t){return t.shape;})}),Array.isArray(m)?s:s[0];},t.prototype.saveTensorsForBackwardMode=function(t){var e=this;return t.map(function(t){return e.keep(e.clone(t));});},t.prototype.getTensorsForGradient=function(t,e,n){var r=u.getGradient(t);if(null!=r){var i=r.inputsToSave||[],o=r.outputsToSave||[],a=void 0;r.saveAllInputs?(d.assert(Array.isArray(e),function(){return "saveAllInputs is true, expected inputs to be an array.";}),a=Object.keys(e).map(function(t){return e[t];})):a=i.map(function(t){return e[t];});var s=n.filter(function(t,e){return o[e];});return a.concat(s);}return null;},t.prototype.makeTensor=function(t,e,n,r){if(null==t)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;var i=t;"string"===n&&d.isString(t[0])&&(i=t.map(function(t){return d.encodeString(t);}));var o=r.write(i,e,n),a=new f.Tensor(e,n,o,this.nextTensorId());if(this.incRef(a,r),"string"===n){var s=this.state.tensorInfo.get(o),u=p.bytesFromStringArray(i);this.state.numBytes+=u-s.bytes,s.bytes=u;}return a;},t.prototype.makeTensorFromDataId=function(t,e,n,r){n=n||"float32";var i=new f.Tensor(e,n,t,this.nextTensorId());return this.incRef(i,r),i;},t.prototype.makeVariable=function(t,e,n,r){void 0===e&&(e=!0),n=n||this.nextVariableId().toString(),null!=r&&r!==t.dtype&&(t=t.asType(r));var i=new f.Variable(t,e,n,this.nextTensorId());if(null!=this.state.registeredVariables[i.name])throw new Error("Variable with name "+i.name+" was already registered");return this.state.registeredVariables[i.name]=i,this.incRef(i,this.backend),i;},t.prototype.incRef=function(t,e){var n=this.state.tensorInfo.has(t.dataId)?this.state.tensorInfo.get(t.dataId).refCount:0;if(this.state.numTensors++,"string"===t.dtype&&this.state.numStringTensors++,0===n){this.state.numDataBuffers++;var r=0;"complex64"!==t.dtype&&"string"!==t.dtype&&(r=t.size*d.bytesPerElement(t.dtype)),this.state.tensorInfo.set(t.dataId,{backend:e||this.backend,dtype:t.dtype,shape:t.shape,bytes:r,refCount:0}),this.state.numBytes+=r;}this.state.tensorInfo.get(t.dataId).refCount++,t instanceof f.Variable||this.track(t);},t.prototype.disposeTensor=function(t){if(this.state.tensorInfo.has(t.dataId)){this.state.numTensors--,"string"===t.dtype&&this.state.numStringTensors--;var e=this.state.tensorInfo.get(t.dataId);e.refCount<=1?("complex64"!==t.dtype&&(this.state.numBytes-=e.bytes),this.state.numDataBuffers--,e.backend.disposeData(t.dataId),this.state.tensorInfo.delete(t.dataId)):this.state.tensorInfo.get(t.dataId).refCount--;}},t.prototype.disposeVariables=function(){for(var t in this.state.registeredVariables){var e=this.state.registeredVariables[t];this.disposeVariable(e);}},t.prototype.disposeVariable=function(t){this.disposeTensor(t),null!=this.state.registeredVariables[t.name]&&delete this.state.registeredVariables[t.name];},t.prototype.memory=function(){var t=this.backend.memory();return t.numTensors=this.state.numTensors,t.numDataBuffers=this.state.numDataBuffers,t.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(t.unreliable=!0,null==t.reasons&&(t.reasons=[]),t.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),t;},t.prototype.profile=function(t){return i(this,void 0,void 0,function(){var e,n;return o(this,function(r){return this.state.profiling=!0,e=this.state.numBytes,n=this.state.numTensors,this.state.activeProfile.kernels=[],this.state.activeProfile.result=t(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max.apply(Math,this.state.activeProfile.kernels.map(function(t){return t.totalBytesSnapshot;})),this.state.activeProfile.newBytes=this.state.numBytes-e,this.state.activeProfile.newTensors=this.state.numTensors-n,[2,this.state.activeProfile];});});},t.prototype.isTapeOn=function(){return this.state.gradientDepth>0&&0===this.state.kernelDepth;},t.prototype.addTapeNode=function(t,e,n,r,i,o){var a=this,s={id:this.state.nextTapeNodeId++,kernelName:t,inputs:e,outputs:n,saved:i},c=u.getGradient(t);null!=c&&(r=c.gradFunc),null!=r&&(s.gradient=function(t){return t=t.map(function(t,e){if(null==t){var r=n[e],i=d.makeZerosTypedArray(r.size,r.dtype);return a.makeTensor(i,r.shape,r.dtype);}return t;}),r(t.length>1?t:t[0],i,o);}),this.state.activeTape.push(s);},t.prototype.keep=function(t){return t.kept=!0,t;},t.prototype.startTape=function(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++;},t.prototype.endTape=function(){this.state.gradientDepth--;},t.prototype.startScope=function(t){var e={track:[],name:"unnamed scope",id:this.state.nextScopeId++};t&&(e.name=t),this.state.scopeStack.push(e),this.state.activeScope=e;},t.prototype.endScope=function(t){for(var e=this,n=h.getTensorsInContainer(t),r=new Set(n.map(function(t){return t.id;})),i=0;i<this.state.activeScope.track.length;i++){var o=this.state.activeScope.track[i];o.kept||r.has(o.id)||o.dispose();}var a=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],n.forEach(function(t){t.kept||t.scopeId!==a.id||e.track(t);});},t.prototype.gradients=function(t,n,r,i){var o=this;if(void 0===i&&(i=!1),d.assert(n.length>0,function(){return "gradients() received an empty list of xs.";}),null!=r&&"float32"!==r.dtype)throw new Error("dy must have 'float32' dtype, but has '"+r.dtype+"'");var a=this.scopedRun(function(){return o.startTape();},function(){return o.endTape();},function(){return o.tidy("forward",t);});d.assert(a instanceof f.Tensor,function(){return "The result y returned by f() must be a tensor.";});var s=l.getFilteredNodesXToY(this.state.activeTape,n,a);if(!i&&0===s.length&&n.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",function(){var t={};t[a.id]=null==r?function(t){var n=p.makeOnesTypedArray(p.sizeFromShape(t),"float32");return e.ENGINE.makeTensor(n,t,"float32");}(a.shape):r,l.backpropagateGradients(t,s,function(t){return o.tidy(t);});var i=n.map(function(e){return t[e.id];});return 0===o.state.gradientDepth&&(o.state.activeTape.forEach(function(t){for(var e=0,n=t.saved;e<n.length;e++){n[e].dispose();}}),o.state.activeTape=null),{value:a,grads:i};});},t.prototype.customGrad=function(t){var e=this;return d.assert(d.isFunction(t),function(){return "The f passed in customGrad(f) must be a function.";}),function(){for(var n,r=[],i=0;i<arguments.length;i++){r[i]=arguments[i];}d.assert(r.every(function(t){return t instanceof f.Tensor;}),function(){return "The args passed in customGrad(f)(x1, x2,...) must all be tensors";});var o={};return r.forEach(function(t,e){o[e]=t;}),e.runKernelFunc(function(e,i){return n=t.apply(void 0,r.concat([i])),d.assert(n.value instanceof f.Tensor,function(){return "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor";}),d.assert(d.isFunction(n.gradFunc),function(){return "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.";}),n.value;},o,function(t,e){var i=n.gradFunc(t,e),o=Array.isArray(i)?i:[i];d.assert(o.length===r.length,function(){return "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...).";}),d.assert(o.every(function(t){return t instanceof f.Tensor;}),function(){return "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.";});var a={};return o.forEach(function(t,e){a[e]=function(){return t;};}),a;});};},t.prototype.readSync=function(t){return this.state.tensorInfo.get(t).backend.readSync(t);},t.prototype.read=function(t){return this.state.tensorInfo.get(t).backend.read(t);},t.prototype.time=function(t){return i(this,void 0,void 0,function(){var e,n;return o(this,function(r){switch(r.label){case 0:return e=p.now(),[4,this.backend.time(t)];case 1:return (n=r.sent()).wallMs=p.now()-e,[2,n];}});});},t.prototype.track=function(t){return null!=this.state.activeScope&&(t.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(t)),t;},Object.defineProperty(t.prototype,"registeredVariables",{get:function get(){return this.state.registeredVariables;},enumerable:!0,configurable:!0}),t.prototype.reset=function(){for(var t in this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new m(),this.registry){this.disposeRegisteredKernels(t),this.registry[t].dispose(),delete this.registry[t];}this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null;},t.nextTensorId=0,t.nextVariableId=0,t;}();e.Engine=g,e.ENGINE=function(){var e=function(){if(null==a){var e=void 0;if("undefined"!=typeof window)e=window;else if(void 0!==t)e=t;else if(void 0!==r)e=r;else {if("undefined"==typeof self)throw new Error("Could not find a global object");e=self;}a=e;}return a;}();if(null==e._tfengine){var n=new s.Environment(e);e._tfengine=new g(n);}return s.setEnvironmentGlobal(e._tfengine.ENV),f.setTensorTracker(function(){return e._tfengine;}),e._tfengine;}();}).call(this,n(59),n(75));},function(t,e,n){var r=n(14),i=n(240),o=n(66),a=Object.defineProperty;e.f=n(27)?Object.defineProperty:function(t,e,n){if(r(t),e=o(e,!0),r(n),i)try{return a(t,e,n);}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return "value"in n&&(t[e]=n.value),t;};},function(t,e,n){t.exports=!n(15)(function(){return 7!=Object.defineProperty({},"a",{get:function get(){return 7;}}).a;});},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0});/**
 * @license
 * Copyright 2018 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=n(25);e.op=function(t){var e=Object.keys(t);if(1!==e.length)throw new Error("Please provide an object with a single key (operation name) mapping to a function. Got an object with "+e.length+" keys.");var n=e[0],i=t[n];n.endsWith("_")&&(n=n.substring(0,n.length-1));var o=function o(){for(var t=[],e=0;e<arguments.length;e++){t[e]=arguments[e];}r.ENGINE.startScope(n);try{var o=i.apply(void 0,t);return o instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),r.ENGINE.endScope(o),o;}catch(t){throw r.ENGINE.endScope(null),t;}};return Object.defineProperty(o,"name",{value:n,configurable:!0}),o;};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(25),i=n(103),o=n(33),a=n(21);function s(t,e){var n=t;if(a.isTypedArray(t))return "string"===e?[]:[t.length];if(!Array.isArray(t))return [];for(var r=[];Array.isArray(n)||a.isTypedArray(n)&&"string"!==e;){r.push(n.length),n=n[0];}return Array.isArray(t)&&i.env().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&function t(e,n,r){r=r||[];if(!Array.isArray(e)&&!a.isTypedArray(e))return void a.assert(0===n.length,function(){return "Element arr["+r.join("][")+"] is a primitive, but should be an array/TypedArray of "+n[0]+" elements";});a.assert(n.length>0,function(){return "Element arr["+r.join("][")+"] should be a primitive, but is an array of "+e.length+" elements";});a.assert(e.length===n[0],function(){return "Element arr["+r.join("][")+"] should have "+n[0]+" elements, but has "+e.length+" elements";});var i=n.slice(1);for(var o=0;o<e.length;++o){t(e[o],i,r.concat(o));}}(t,r,[]),r;}function u(t,e,n,r){if(null!=t&&("numeric"!==t&&t!==e||"numeric"===t&&"string"===e))throw new Error("Argument '"+n+"' passed to '"+r+"' must be "+t+" tensor, but got "+e+" tensor");}function c(t,e,n,c){if(void 0===c&&(c="numeric"),t instanceof o.Tensor)return u(c,t.dtype,e,n),t;var l=a.inferDtype(t);if("string"!==l&&["bool","int32","float32"].indexOf(c)>=0&&(l=c),u(c,l,e,n),null==t||!a.isTypedArray(t)&&!Array.isArray(t)&&"number"!=typeof t&&"boolean"!=typeof t&&"string"!=typeof t){var f=null==t?"null":t.constructor.name;throw new Error("Argument '"+e+"' passed to '"+n+"' must be a Tensor or TensorLike, but got '"+f+"'");}var h=s(t,l);a.isTypedArray(t)||Array.isArray(t)||(t=[t]);var d="string"!==l?a.toTypedArray(t,l,i.env().getBool("DEBUG")):a.flatten(t,[],!0);return r.ENGINE.makeTensor(d,h,l);}e.inferShape=s,e.convertToTensor=c,e.convertToTensorArray=function(t,e,n,r){if(void 0===r&&(r="numeric"),!Array.isArray(t))throw new Error("Argument "+e+" passed to "+n+" must be a `Tensor[]` or `TensorLike[]`");return t.map(function(t,r){return c(t,e+"["+r+"]",n);},r);};},function(t,e,n){var r=n(254),i=n(253),o=n(187),a=n(252);t.exports=function(t){return r(t)||i(t)||o(t)||a();},t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e,n){n.d(e,"a",function(){return o;});var r=new Date(),i=new Date();function o(t,e,n,a){function s(e){return t(e=0===arguments.length?new Date():new Date(+e)),e;}return s.floor=function(e){return t(e=new Date(+e)),e;},s.ceil=function(n){return t(n=new Date(n-1)),e(n,1),t(n),n;},s.round=function(t){var e=s(t),n=s.ceil(t);return t-e<n-t?e:n;},s.offset=function(t,n){return e(t=new Date(+t),null==n?1:Math.floor(n)),t;},s.range=function(n,r,i){var o,a=[];if(n=s.ceil(n),i=null==i?1:Math.floor(i),!(n<r&&i>0))return a;do{a.push(o=new Date(+n)),e(n,i),t(n);}while(o<n&&n<r);return a;},s.filter=function(n){return o(function(e){if(e>=e)for(;t(e),!n(e);){e.setTime(e-1);}},function(t,r){if(t>=t)if(r<0)for(;++r<=0;){for(;e(t,-1),!n(t);){}}else for(;--r>=0;){for(;e(t,1),!n(t);){}}});},n&&(s.count=function(e,o){return r.setTime(+e),i.setTime(+o),t(r),t(i),Math.floor(n(r,i));},s.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?s.filter(a?function(e){return a(e)%t==0;}:function(e){return s.count(0,e)%t==0;}):s:null;}),s;}},function(t,e,n){var r=n(116),_n5=n(117),i=_n5.MAX_LENGTH,o=_n5.MAX_SAFE_INTEGER,_n6=n(90),a=_n6.re,s=_n6.t,u=n(115),_n7=n(146),c=_n7.compareIdentifiers;var l=/*#__PURE__*/function(){function l(t,e){_classCallCheck(this,l);if(e=u(e),t instanceof l){if(t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease)return t;t=t.version;}else if("string"!=typeof t)throw new TypeError("Invalid Version: ".concat(t));if(t.length>i)throw new TypeError("version is longer than ".concat(i," characters"));r("SemVer",t,e),this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease;var n=t.trim().match(e.loose?a[s.LOOSE]:a[s.FULL]);if(!n)throw new TypeError("Invalid Version: ".concat(t));if(this.raw=t,this.major=+n[1],this.minor=+n[2],this.patch=+n[3],this.major>o||this.major<0)throw new TypeError("Invalid major version");if(this.minor>o||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>o||this.patch<0)throw new TypeError("Invalid patch version");n[4]?this.prerelease=n[4].split(".").map(function(t){if(/^[0-9]+$/.test(t)){var _e5=+t;if(_e5>=0&&_e5<o)return _e5;}return t;}):this.prerelease=[],this.build=n[5]?n[5].split("."):[],this.format();}_createClass(l,[{key:"format",value:function format(){return this.version="".concat(this.major,".").concat(this.minor,".").concat(this.patch),this.prerelease.length&&(this.version+="-".concat(this.prerelease.join("."))),this.version;}},{key:"toString",value:function toString(){return this.version;}},{key:"compare",value:function compare(t){if(r("SemVer.compare",this.version,this.options,t),!(t instanceof l)){if("string"==typeof t&&t===this.version)return 0;t=new l(t,this.options);}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t);}},{key:"compareMain",value:function compareMain(t){return t instanceof l||(t=new l(t,this.options)),c(this.major,t.major)||c(this.minor,t.minor)||c(this.patch,t.patch);}},{key:"comparePre",value:function comparePre(t){if(t instanceof l||(t=new l(t,this.options)),this.prerelease.length&&!t.prerelease.length)return -1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;var e=0;do{var _n8=this.prerelease[e],_i8=t.prerelease[e];if(r("prerelease compare",e,_n8,_i8),void 0===_n8&&void 0===_i8)return 0;if(void 0===_i8)return 1;if(void 0===_n8)return -1;if(_n8!==_i8)return c(_n8,_i8);}while(++e);}},{key:"compareBuild",value:function compareBuild(t){t instanceof l||(t=new l(t,this.options));var e=0;do{var _n9=this.build[e],_i9=t.build[e];if(r("prerelease compare",e,_n9,_i9),void 0===_n9&&void 0===_i9)return 0;if(void 0===_i9)return 1;if(void 0===_n9)return -1;if(_n9!==_i9)return c(_n9,_i9);}while(++e);}},{key:"inc",value:function inc(t,e){switch(t){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",e);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",e);break;case"prepatch":this.prerelease.length=0,this.inc("patch",e),this.inc("pre",e);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",e),this.inc("pre",e);break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":if(0===this.prerelease.length)this.prerelease=[0];else {var _t5=this.prerelease.length;for(;--_t5>=0;){"number"==typeof this.prerelease[_t5]&&(this.prerelease[_t5]++,_t5=-2);}-1===_t5&&this.prerelease.push(0);}e&&(this.prerelease[0]===e?isNaN(this.prerelease[1])&&(this.prerelease=[e,0]):this.prerelease=[e,0]);break;default:throw new Error("invalid increment argument: ".concat(t));}return this.format(),this.raw=this.version,this;}}]);return l;}();t.exports=l;},function(t,e,n){/**
 * @license
 * Copyright 2017 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=this&&this.__extends||function(){var _t6=function t(e,n){return (_t6=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e;}||function(t,e){for(var n in e){e.hasOwnProperty(n)&&(t[n]=e[n]);}})(e,n);};return function(e,n){function r(){this.constructor=e;}_t6(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r());};}(),i=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});},o=this&&this.__generator||function(t,e){var n,r,i,o,a={label:0,sent:function sent(){if(1&i[0])throw i[1];return i[1];},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this;}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;){try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue;}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break;}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break;}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break;}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(t,a);}catch(t){o=[6,t],r=0;}finally{n=i=0;}}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:!0};}([o,s]);};}};Object.defineProperty(e,"__esModule",{value:!0});var a=n(379),s=n(21),u=n(21),c=function(){function t(t,e,n){var r=this;if(this.dtype=e,this.shape=t.slice(),this.size=s.sizeFromShape(t),null!=n){var i=n.length;s.assert(i===this.size,function(){return "Length of values '"+i+"' does not match the size inferred by the shape '"+r.size+"'.";});}if("complex64"===e)throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||s.getArrayFromDType(e,this.size),this.strides=u.computeStrides(t);}return t.prototype.set=function(t){for(var e=this,n=[],r=1;r<arguments.length;r++){n[r-1]=arguments[r];}0===n.length&&(n=[0]),s.assert(n.length===this.rank,function(){return "The number of provided coordinates ("+n.length+") must match the rank ("+e.rank+")";});var i=this.locToIndex(n);this.values[i]=t;},t.prototype.get=function(){for(var t=[],e=0;e<arguments.length;e++){t[e]=arguments[e];}0===t.length&&(t=[0]);for(var n=0,r=0,i=t;r<i.length;r++){var o=i[r];if(o<0||o>=this.shape[n]){var a="Requested out of range element at "+t+".   Buffer shape="+this.shape;throw new Error(a);}n++;}for(var s=t[t.length-1],u=0;u<t.length-1;++u){s+=this.strides[u]*t[u];}return this.values[s];},t.prototype.locToIndex=function(t){if(0===this.rank)return 0;if(1===this.rank)return t[0];for(var e=t[t.length-1],n=0;n<t.length-1;++n){e+=this.strides[n]*t[n];}return e;},t.prototype.indexToLoc=function(t){if(0===this.rank)return [];if(1===this.rank)return [t];for(var e=new Array(this.shape.length),n=0;n<e.length-1;++n){e[n]=Math.floor(t/this.strides[n]),t-=e[n]*this.strides[n];}return e[e.length-1]=t,e;},Object.defineProperty(t.prototype,"rank",{get:function get(){return this.shape.length;},enumerable:!0,configurable:!0}),t.prototype.toTensor=function(){return l().makeTensor(this.values,this.shape,this.dtype);},t;}();e.TensorBuffer=c;var l=null,f=null,h=null;e.setTensorTracker=function(t){l=t;},e.setOpHandler=function(t){f=t;},e.setDeprecationWarningFn=function(t){h=t;};var d=function(){function t(t,e,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=t.slice(),this.dtype=e||"float32",this.size=s.sizeFromShape(t),this.strides=u.computeStrides(t),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher";}return t.prototype.flatten=function(){return this.throwIfDisposed(),this.as1D();},t.prototype.asScalar=function(){return this.throwIfDisposed(),s.assert(1===this.size,function(){return "The array must have only 1 element.";}),this.reshape([]);},t.prototype.as1D=function(){return this.throwIfDisposed(),this.reshape([this.size]);},t.prototype.as2D=function(t,e){return this.throwIfDisposed(),this.reshape([t,e]);},t.prototype.as3D=function(t,e,n){return this.throwIfDisposed(),this.reshape([t,e,n]);},t.prototype.as4D=function(t,e,n,r){return this.throwIfDisposed(),this.reshape([t,e,n,r]);},t.prototype.as5D=function(t,e,n,r,i){return this.throwIfDisposed(),this.reshape([t,e,n,r,i]);},t.prototype.asType=function(t){return this.throwIfDisposed(),f.cast(this,t);},Object.defineProperty(t.prototype,"rank",{get:function get(){return this.shape.length;},enumerable:!0,configurable:!0}),t.prototype.buffer=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return [4,this.data()];case 1:return t=e.sent(),[2,f.buffer(this.shape,this.dtype,t)];}});});},t.prototype.bufferSync=function(){return f.buffer(this.shape,this.dtype,this.dataSync());},t.prototype.array=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return [4,this.data()];case 1:return t=e.sent(),[2,u.toNestedArray(this.shape,t)];}});});},t.prototype.arraySync=function(){return u.toNestedArray(this.shape,this.dataSync());},t.prototype.data=function(){return i(this,void 0,void 0,function(){var t,e;return o(this,function(n){switch(n.label){case 0:return this.throwIfDisposed(),t=l().read(this.dataId),"string"!==this.dtype?[3,2]:[4,t];case 1:e=n.sent();try{return [2,e.map(function(t){return s.decodeString(t);})];}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().");}n.label=2;case 2:return [2,t];}});});},t.prototype.dataSync=function(){this.throwIfDisposed();var t=l().readSync(this.dataId);if("string"===this.dtype)try{return t.map(function(t){return s.decodeString(t);});}catch(t){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().");}return t;},t.prototype.bytes=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return this.throwIfDisposed(),[4,l().read(this.dataId)];case 1:return t=e.sent(),"string"===this.dtype?[2,t]:[2,new Uint8Array(t.buffer)];}});});},t.prototype.dispose=function(){this.isDisposed||(l().disposeTensor(this),this.isDisposedInternal=!0);},Object.defineProperty(t.prototype,"isDisposed",{get:function get(){return this.isDisposedInternal;},enumerable:!0,configurable:!0}),t.prototype.throwIfDisposed=function(){if(this.isDisposed)throw new Error("Tensor is disposed.");},t.prototype.toFloat=function(){return this.asType("float32");},t.prototype.toInt=function(){return this.asType("int32");},t.prototype.toBool=function(){return this.asType("bool");},t.prototype.print=function(t){return void 0===t&&(t=!1),f.print(this,t);},t.prototype.reshape=function(t){return this.throwIfDisposed(),f.reshape(this,t);},t.prototype.reshapeAs=function(t){return this.throwIfDisposed(),this.reshape(t.shape);},t.prototype.expandDims=function(t){return void 0===t&&(t=0),f.expandDims(this,t);},t.prototype.cumsum=function(t,e,n){return void 0===t&&(t=0),void 0===e&&(e=!1),void 0===n&&(n=!1),f.cumsum(this,t,e,n);},t.prototype.squeeze=function(t){return this.throwIfDisposed(),f.squeeze(this,t);},t.prototype.clone=function(){return this.throwIfDisposed(),f.clone(this);},t.prototype.toString=function(t){void 0===t&&(t=!1);var e=this.dataSync();return a.tensorToString(e,this.shape,this.dtype,t);},t.prototype.gather=function(t,e){return void 0===e&&(e=0),this.throwIfDisposed(),f.gather(this,t,e);},t.prototype.matMul=function(t,e,n){return void 0===e&&(e=!1),void 0===n&&(n=!1),this.throwIfDisposed(),f.matMul(this,t,e,n);},t.prototype.dot=function(t){return this.throwIfDisposed(),f.dot(this,t);},t.prototype.norm=function(t,e,n){return void 0===t&&(t="euclidean"),void 0===e&&(e=null),void 0===n&&(n=!1),this.throwIfDisposed(),f.norm(this,t,e,n);},t.prototype.slice=function(t,e){return this.throwIfDisposed(),f.slice(this,t,e);},t.prototype.reverse=function(t){return this.throwIfDisposed(),f.reverse(this,t);},t.prototype.concat=function(e,n){return void 0===n&&(n=0),this.throwIfDisposed(),e instanceof t&&(e=[e]),f.concat([this].concat(e),n);},t.prototype.split=function(t,e){return void 0===e&&(e=0),this.throwIfDisposed(),f.split(this,t,e);},t.prototype.stack=function(t,e){return void 0===e&&(e=0),f.stack([this,t],e);},t.prototype.unstack=function(t){return void 0===t&&(t=0),f.unstack(this,t);},t.prototype.batchNormalization=function(t,e,n,r,i){return void 0===n&&(n=.001),h("tf.batchNormalization() is going away. Use tf.batchNorm() instead, and note the positional argument change of scale, offset, and varianceEpsilon"),this.batchNorm(t,e,i,r,n);},t.prototype.all=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),f.all(this,t,e);},t.prototype.any=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),f.any(this,t,e);},t.prototype.logSumExp=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),f.logSumExp(this,t,e);},t.prototype.sum=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),f.sum(this,t,e);},t.prototype.prod=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),f.prod(this,t,e);},t.prototype.mean=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),f.mean(this,t,e);},t.prototype.min=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),f.min(this,t,e);},t.prototype.max=function(t,e){return void 0===t&&(t=null),void 0===e&&(e=!1),this.throwIfDisposed(),f.max(this,t,e);},t.prototype.argMin=function(t){return void 0===t&&(t=null),this.throwIfDisposed(),f.argMin(this,t);},t.prototype.argMax=function(t){return void 0===t&&(t=null),this.throwIfDisposed(),f.argMax(this,t);},t.prototype.cast=function(t){return this.throwIfDisposed(),f.cast(this,t);},t.prototype.addStrict=function(t){return this.throwIfDisposed(),f.addStrict(this,t);},t.prototype.atan2=function(t){return this.throwIfDisposed(),f.atan2(this,t);},t.prototype.sub=function(t){return this.throwIfDisposed(),f.sub(this,t);},t.prototype.subStrict=function(t){return this.throwIfDisposed(),f.subStrict(this,t);},t.prototype.pow=function(t){return this.throwIfDisposed(),f.pow(this,t);},t.prototype.powStrict=function(t){return this.throwIfDisposed(),f.powStrict(this,t);},t.prototype.mul=function(t){return this.throwIfDisposed(),f.mul(this,t);},t.prototype.mulStrict=function(t){return this.throwIfDisposed(),f.mulStrict(this,t);},t.prototype.floorDiv=function(t){return this.throwIfDisposed(),f.floorDiv(this,t);},t.prototype.divStrict=function(t){return this.throwIfDisposed(),f.divStrict(this,t);},t.prototype.minimum=function(t){return this.throwIfDisposed(),f.minimum(this,t);},t.prototype.minimumStrict=function(t){return this.throwIfDisposed(),f.minimumStrict(this,t);},t.prototype.maximum=function(t){return this.throwIfDisposed(),f.maximum(this,t);},t.prototype.maximumStrict=function(t){return this.throwIfDisposed(),f.maximumStrict(this,t);},t.prototype.mod=function(t){return this.throwIfDisposed(),f.mod(this,t);},t.prototype.modStrict=function(t){return this.throwIfDisposed(),f.modStrict(this,t);},t.prototype.squaredDifferenceStrict=function(t){return this.throwIfDisposed(),f.squaredDifferenceStrict(this,t);},t.prototype.notEqual=function(t){return this.throwIfDisposed(),f.notEqual(this,t);},t.prototype.notEqualStrict=function(t){return this.throwIfDisposed(),f.notEqualStrict(this,t);},t.prototype.less=function(t){return this.throwIfDisposed(),f.less(this,t);},t.prototype.lessStrict=function(t){return this.throwIfDisposed(),f.lessStrict(this,t);},t.prototype.equal=function(t){return this.throwIfDisposed(),f.equal(this,t);},t.prototype.equalStrict=function(t){return this.throwIfDisposed(),f.equalStrict(this,t);},t.prototype.lessEqual=function(t){return this.throwIfDisposed(),f.lessEqual(this,t);},t.prototype.lessEqualStrict=function(t){return this.throwIfDisposed(),f.lessEqualStrict(this,t);},t.prototype.greater=function(t){return this.throwIfDisposed(),f.greater(this,t);},t.prototype.greaterStrict=function(t){return this.throwIfDisposed(),f.greaterStrict(this,t);},t.prototype.greaterEqual=function(t){return this.throwIfDisposed(),f.greaterEqual(this,t);},t.prototype.greaterEqualStrict=function(t){return this.throwIfDisposed(),f.greaterEqualStrict(this,t);},t.prototype.logicalAnd=function(t){return this.throwIfDisposed(),f.logicalAnd(this,t);},t.prototype.logicalOr=function(t){return this.throwIfDisposed(),f.logicalOr(this,t);},t.prototype.logicalNot=function(){return this.throwIfDisposed(),f.logicalNot(this);},t.prototype.logicalXor=function(t){return this.throwIfDisposed(),f.logicalXor(this,t);},t.prototype.where=function(t,e){return this.throwIfDisposed(),f.where(t,this,e);},t.prototype.neg=function(){return this.throwIfDisposed(),f.neg(this);},t.prototype.ceil=function(){return this.throwIfDisposed(),f.ceil(this);},t.prototype.floor=function(){return this.throwIfDisposed(),f.floor(this);},t.prototype.sign=function(){return this.throwIfDisposed(),f.sign(this);},t.prototype.isNaN=function(){return this.throwIfDisposed(),f.isNaN(this);},t.prototype.isInf=function(){return this.throwIfDisposed(),f.isInf(this);},t.prototype.isFinite=function(){return this.throwIfDisposed(),f.isFinite(this);},t.prototype.exp=function(){return this.throwIfDisposed(),f.exp(this);},t.prototype.expm1=function(){return this.throwIfDisposed(),f.expm1(this);},t.prototype.log=function(){return this.throwIfDisposed(),f.log(this);},t.prototype.log1p=function(){return this.throwIfDisposed(),f.log1p(this);},t.prototype.sqrt=function(){return this.throwIfDisposed(),f.sqrt(this);},t.prototype.rsqrt=function(){return this.throwIfDisposed(),f.rsqrt(this);},t.prototype.square=function(){return this.throwIfDisposed(),f.square(this);},t.prototype.reciprocal=function(){return this.throwIfDisposed(),f.reciprocal(this);},t.prototype.abs=function(){return this.throwIfDisposed(),f.abs(this);},t.prototype.clipByValue=function(t,e){return this.throwIfDisposed(),f.clipByValue(this,t,e);},t.prototype.relu=function(){return this.throwIfDisposed(),f.relu(this);},t.prototype.relu6=function(){return this.throwIfDisposed(),f.relu6(this);},t.prototype.elu=function(){return this.throwIfDisposed(),f.elu(this);},t.prototype.selu=function(){return this.throwIfDisposed(),f.selu(this);},t.prototype.leakyRelu=function(t){return void 0===t&&(t=.2),this.throwIfDisposed(),f.leakyRelu(this,t);},t.prototype.prelu=function(t){return this.throwIfDisposed(),f.prelu(this,t);},t.prototype.sigmoid=function(){return this.throwIfDisposed(),f.sigmoid(this);},t.prototype.logSigmoid=function(){return this.throwIfDisposed(),f.logSigmoid(this);},t.prototype.softplus=function(){return this.throwIfDisposed(),f.softplus(this);},t.prototype.zerosLike=function(){return this.throwIfDisposed(),f.zerosLike(this);},t.prototype.onesLike=function(){return this.throwIfDisposed(),f.onesLike(this);},t.prototype.sin=function(){return this.throwIfDisposed(),f.sin(this);},t.prototype.cos=function(){return this.throwIfDisposed(),f.cos(this);},t.prototype.tan=function(){return this.throwIfDisposed(),f.tan(this);},t.prototype.asin=function(){return this.throwIfDisposed(),f.asin(this);},t.prototype.acos=function(){return this.throwIfDisposed(),f.acos(this);},t.prototype.atan=function(){return this.throwIfDisposed(),f.atan(this);},t.prototype.sinh=function(){return this.throwIfDisposed(),f.sinh(this);},t.prototype.cosh=function(){return this.throwIfDisposed(),f.cosh(this);},t.prototype.tanh=function(){return this.throwIfDisposed(),f.tanh(this);},t.prototype.asinh=function(){return this.throwIfDisposed(),f.asinh(this);},t.prototype.acosh=function(){return this.throwIfDisposed(),f.acosh(this);},t.prototype.atanh=function(){return this.throwIfDisposed(),f.atanh(this);},t.prototype.erf=function(){return this.throwIfDisposed(),f.erf(this);},t.prototype.round=function(){return this.throwIfDisposed(),f.round(this);},t.prototype.step=function(t){return void 0===t&&(t=0),this.throwIfDisposed(),f.step(this,t);},t.prototype.softmax=function(t){return void 0===t&&(t=-1),this.throwIfDisposed(),f.softmax(this,t);},t.prototype.logSoftmax=function(t){return void 0===t&&(t=-1),this.throwIfDisposed(),f.logSoftmax(this,t);},t.prototype.resizeBilinear=function(t,e){return void 0===e&&(e=!1),this.throwIfDisposed(),f.image.resizeBilinear(this,t,e);},t.prototype.resizeNearestNeighbor=function(t,e){return void 0===e&&(e=!1),this.throwIfDisposed(),f.image.resizeNearestNeighbor(this,t,e);},t.prototype.conv1d=function(t,e,n,r,i,o){return void 0===r&&(r="NWC"),void 0===i&&(i=1),this.throwIfDisposed(),f.conv1d(this,t,e,n,r,i,o);},t.prototype.conv2d=function(t,e,n,r,i,o){return void 0===r&&(r="NHWC"),void 0===i&&(i=[1,1]),this.throwIfDisposed(),f.conv2d(this,t,e,n,r,i,o);},t.prototype.conv2dTranspose=function(t,e,n,r,i){return this.throwIfDisposed(),f.conv2dTranspose(this,t,e,n,r,i);},t.prototype.depthwiseConv2D=function(t,e,n,r,i,o){return void 0===r&&(r="NHWC"),void 0===i&&(i=[1,1]),this.throwIfDisposed(),f.depthwiseConv2d(this,t,e,n,r,i,o);},t.prototype.separableConv2d=function(t,e,n,r,i,o){return void 0===i&&(i=[1,1]),void 0===o&&(o="NHWC"),this.throwIfDisposed(),f.separableConv2d(this,t,e,n,r,i,o);},t.prototype.avgPool=function(t,e,n,r){return this.throwIfDisposed(),f.avgPool(this,t,e,n,r);},t.prototype.maxPool=function(t,e,n,r){return this.throwIfDisposed(),f.maxPool(this,t,e,n,r);},t.prototype.localResponseNormalization=function(t,e,n,r){return void 0===t&&(t=5),void 0===e&&(e=1),void 0===n&&(n=1),void 0===r&&(r=.5),f.localResponseNormalization(this,t,e,n,r);},t.prototype.pool=function(t,e,n,r,i){return this.throwIfDisposed(),f.pool(this,t,e,n,r,i);},t.prototype.variable=function(t,e,n){return void 0===t&&(t=!0),this.throwIfDisposed(),l().makeVariable(this,t,e,n);},t.prototype.unsortedSegmentSum=function(t,e){return this.throwIfDisposed(),f.unsortedSegmentSum(this,t,e);},t.prototype.batchToSpaceND=function(t,e){return this.throwIfDisposed(),f.batchToSpaceND(this,t,e);},t.prototype.spaceToBatchND=function(t,e){return this.throwIfDisposed(),f.spaceToBatchND(this,t,e);},t.prototype.topk=function(t,e){return void 0===t&&(t=1),void 0===e&&(e=!0),this.throwIfDisposed(),f.topk(this,t,e);},t.prototype.stridedSlice=function(t,e,n,r,i,o,a,s){return void 0===r&&(r=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===a&&(a=0),void 0===s&&(s=0),this.throwIfDisposed(),f.stridedSlice(this,t,e,n,r,i,o,a,s);},t.prototype.depthToSpace=function(t,e){return this.throwIfDisposed(),f.depthToSpace(this,t,e);},t.prototype.fft=function(){return this.throwIfDisposed(),f.spectral.fft(this);},t.prototype.ifft=function(){return this.throwIfDisposed(),f.spectral.ifft(this);},t.prototype.rfft=function(){return this.throwIfDisposed(),f.spectral.rfft(this);},t.prototype.irfft=function(){return this.throwIfDisposed(),f.spectral.irfft(this);},t;}();e.Tensor=d,Object.defineProperty(d,Symbol.hasInstance,{value:function value(t){return !!t&&null!=t.dataId&&null!=t.shape&&null!=t.dtype;}});var p=function(t){function e(e,n,r,i){var o=t.call(this,e.shape,e.dtype,e.dataId,i)||this;return o.trainable=n,o.name=r,o;}return r(e,t),e.prototype.assign=function(t){if(t.dtype!==this.dtype)throw new Error("dtype of the new value ("+t.dtype+") and previous value ("+this.dtype+") must match");if(!s.arraysEqual(t.shape,this.shape))throw new Error("shape of the new value ("+t.shape+") and previous value ("+this.shape+") must match");l().disposeTensor(this),this.dataId=t.dataId,l().incRef(this,null);},e.prototype.dispose=function(){l().disposeVariable(this),this.isDisposedInternal=!0;},e;}(d);e.Variable=p,Object.defineProperty(p,Symbol.hasInstance,{value:function value(t){return t instanceof d&&null!=t.assign&&t.assign instanceof Function;}});},function(t,e,n){var r=n(61);t.exports=function(t){return Object(r(t));};},function(t,e){function n(e){return t.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t);},t.exports.__esModule=!0,t.exports.default=t.exports,n(e);}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e,n){var r=n(195),i=Object.prototype.toString;function o(t){return "[object Array]"===i.call(t);}function a(t){return void 0===t;}function s(t){return null!==t&&"object"==_typeof$1(t);}function u(t){if("[object Object]"!==i.call(t))return !1;var e=Object.getPrototypeOf(t);return null===e||e===Object.prototype;}function c(t){return "[object Function]"===i.call(t);}function l(t,e){if(null!==t&&void 0!==t)if("object"!=_typeof$1(t)&&(t=[t]),o(t))for(var n=0,r=t.length;n<r;n++){e.call(null,t[n],n,t);}else for(var i in t){Object.prototype.hasOwnProperty.call(t,i)&&e.call(null,t[i],i,t);}}t.exports={isArray:o,isArrayBuffer:function isArrayBuffer(t){return "[object ArrayBuffer]"===i.call(t);},isBuffer:function isBuffer(t){return null!==t&&!a(t)&&null!==t.constructor&&!a(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t);},isFormData:function isFormData(t){return "undefined"!=typeof FormData&&t instanceof FormData;},isArrayBufferView:function isArrayBufferView(t){return "undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer;},isString:function isString(t){return "string"==typeof t;},isNumber:function isNumber(t){return "number"==typeof t;},isObject:s,isPlainObject:u,isUndefined:a,isDate:function isDate(t){return "[object Date]"===i.call(t);},isFile:function isFile(t){return "[object File]"===i.call(t);},isBlob:function isBlob(t){return "[object Blob]"===i.call(t);},isFunction:c,isStream:function isStream(t){return s(t)&&c(t.pipe);},isURLSearchParams:function isURLSearchParams(t){return "undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams;},isStandardBrowserEnv:function isStandardBrowserEnv(){return ("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document;},forEach:l,merge:function t(){var e={};function n(n,r){u(e[r])&&u(n)?e[r]=t(e[r],n):u(n)?e[r]=t({},n):o(n)?e[r]=n.slice():e[r]=n;}for(var r=0,i=arguments.length;r<i;r++){l(arguments[r],n);}return e;},extend:function extend(t,e,n){return l(e,function(e,i){t[i]=n&&"function"==typeof e?r(e,n):e;}),t;},trim:function trim(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"");},stripBOM:function stripBOM(t){return 65279===t.charCodeAt(0)&&(t=t.slice(1)),t;}};},function(t,e,n){var r=n(8),i=n(15),o=n(61),a=/"/g,s=function s(t,e,n,r){var i=String(o(t)),s="<"+e;return ""!==n&&(s+=" "+n+'="'+String(r).replace(a,"&quot;")+'"'),s+">"+i+"</"+e+">";};t.exports=function(t,e){var n={};n[t]=e(s),r(r.P+r.F*i(function(){var e=""[t]('"');return e!==e.toLowerCase()||e.split('"').length>3;}),"String",n);};},function(t,e,n){var r=n(16),i=n(42),o=n(43),a=n(84)("src"),s=n(576),u=(""+s).split("toString");n(24).inspectSource=function(t){return s.call(t);},(t.exports=function(t,e,n,s){var c="function"==typeof n;c&&(o(n,"name")||i(n,"name",e)),t[e]!==n&&(c&&(o(n,a)||i(n,a,t[e]?""+t[e]:u.join(String(e)))),t===r?t[e]=n:s?t[e]?t[e]=n:i(t,e,n):(delete t[e],i(t,e,n)));})(Function.prototype,"toString",function(){return "function"==typeof this&&this[a]||s.call(this);});},function(t,e,n){n.d(e,"b",function(){return a;}),n.d(e,"a",function(){return s;}),n.d(e,"c",function(){return l;});var r=n(31),i=n(12);function o(t){return Object(r.a)(function(e){e.setUTCDate(e.getUTCDate()-(e.getUTCDay()+7-t)%7),e.setUTCHours(0,0,0,0);},function(t,e){t.setUTCDate(t.getUTCDate()+7*e);},function(t,e){return (e-t)/i.f;});}var a=o(0),s=o(1),u=o(2),c=o(3),l=o(4),f=o(5),h=o(6);a.range,s.range,u.range,c.range,l.range,f.range,h.range;},function(t,e,n){n.d(e,"b",function(){return a;}),n.d(e,"a",function(){return s;}),n.d(e,"c",function(){return l;});var r=n(31),i=n(12);function o(t){return Object(r.a)(function(e){e.setDate(e.getDate()-(e.getDay()+7-t)%7),e.setHours(0,0,0,0);},function(t,e){t.setDate(t.getDate()+7*e);},function(t,e){return (e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*i.c)/i.f;});}var a=o(0),s=o(1),u=o(2),c=o(3),l=o(4),f=o(5),h=o(6);a.range,s.range,u.range,c.range,l.range,f.range,h.range;},function(t,e,n){var r=n(107),i=n(61);t.exports=function(t){return r(i(t));};},function(t,e,n){var r=n(26),i=n(85);t.exports=n(27)?function(t,e,n){return r.f(t,e,i(1,n));}:function(t,e,n){return t[e]=n,t;};},function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e);};},function(t,e,n){var r=n(45),i=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function o(t){if(!(e=i.exec(t)))throw new Error("invalid format: "+t);var e;return new a({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]});}function a(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+"";}o.prototype=a.prototype,a.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type;};function _s4(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return [r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)];}var u,c,l,f,h=function h(t){return (t=_s4(Math.abs(t)))?t[1]:NaN;},d=function d(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(h(e)/3)))-h(Math.abs(t)));},p=function p(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,h(e)-h(t))+1;},m=function m(t){return Math.max(0,-h(Math.abs(t)));},g=function g(t){t:for(var e,n=t.length,r=1,i=-1;r<n;++r){switch(t[r]){case".":i=e=r;break;case"0":0===i&&(i=r),e=r;break;default:if(!+t[r])break t;i>0&&(i=0);}}return i>0?t.slice(0,i)+t.slice(e+1):t;},v=function v(t,e){var n=_s4(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0");},y={"%":function _(t,e){return (100*t).toFixed(e);},b:function b(t){return Math.round(t).toString(2);},c:function c(t){return t+"";},d:function d(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10);},e:function e(t,_e6){return t.toExponential(_e6);},f:function f(t,e){return t.toFixed(e);},g:function g(t,e){return t.toPrecision(e);},o:function o(t){return Math.round(t).toString(8);},p:function p(t,e){return v(100*t,e);},r:v,s:function s(t,e){var n=_s4(t,e);if(!n)return t+"";var r=n[0],i=n[1],o=i-(u=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,a=r.length;return o===a?r:o>a?r+new Array(o-a+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+_s4(t,Math.max(0,e+o-1))[0];},X:function X(t){return Math.round(t).toString(16).toUpperCase();},x:function x(t){return Math.round(t).toString(16);}},b=function b(t){return t;},x=Array.prototype.map,w=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"],k=function k(t){var e=void 0===t.grouping||void 0===t.thousands?b:function(t,e){return function(n,r){for(var i=n.length,o=[],a=0,s=t[0],u=0;i>0&&s>0&&(u+s+1>r&&(s=Math.max(1,r-u)),o.push(n.substring(i-=s,i+s)),!((u+=s+1)>r));){s=t[a=(a+1)%t.length];}return o.reverse().join(e);};}(x.call(t.grouping,Number),t.thousands+""),n=void 0===t.currency?"":t.currency[0]+"",r=void 0===t.currency?"":t.currency[1]+"",i=void 0===t.decimal?".":t.decimal+"",a=void 0===t.numerals?b:function(t){return function(e){return e.replace(/[0-9]/g,function(e){return t[+e];});};}(x.call(t.numerals,String)),s=void 0===t.percent?"%":t.percent+"",c=void 0===t.minus?"−":t.minus+"",l=void 0===t.nan?"NaN":t.nan+"";function f(t){var f=(t=o(t)).fill,h=t.align,d=t.sign,p=t.symbol,m=t.zero,v=t.width,b=t.comma,x=t.precision,k=t.trim,E=t.type;"n"===E?(b=!0,E="g"):y[E]||(void 0===x&&(x=12),k=!0,E="g"),(m||"0"===f&&"="===h)&&(m=!0,f="0",h="=");var C="$"===p?n:"#"===p&&/[boxX]/.test(E)?"0"+E.toLowerCase():"",A="$"===p?r:/[%p]/.test(E)?s:"",O=y[E],_=/[defgprs%]/.test(E);function S(t){var n,r,o,s=C,p=A;if("c"===E)p=O(t)+p,t="";else {var y=(t=+t)<0||1/t<0;if(t=isNaN(t)?l:O(Math.abs(t),x),k&&(t=g(t)),y&&0==+t&&"+"!==d&&(y=!1),s=(y?"("===d?d:c:"-"===d||"("===d?"":d)+s,p=("s"===E?w[8+u/3]:"")+p+(y&&"("===d?")":""),_)for(n=-1,r=t.length;++n<r;){if(48>(o=t.charCodeAt(n))||o>57){p=(46===o?i+t.slice(n+1):t.slice(n))+p,t=t.slice(0,n);break;}}}b&&!m&&(t=e(t,1/0));var S=s.length+t.length+p.length,D=S<v?new Array(v-S+1).join(f):"";switch(b&&m&&(t=e(D+t,D.length?v-p.length:1/0),D=""),h){case"<":t=s+t+p+D;break;case"=":t=s+D+t+p;break;case"^":t=D.slice(0,S=D.length>>1)+s+t+p+D.slice(S);break;default:t=D+s+t+p;}return a(t);}return x=void 0===x?6:/[gprs]/.test(E)?Math.max(1,Math.min(21,x)):Math.max(0,Math.min(20,x)),S.toString=function(){return t+"";},S;}return {format:f,formatPrefix:function formatPrefix(t,e){var n=f(((t=o(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(h(e)/3))),i=Math.pow(10,-r),a=w[8+r/3];return function(t){return n(i*t)+a;};}};};!function(t){c=k(t),l=c.format,f=c.formatPrefix;}({thousands:",",grouping:[3],currency:["$",""]});var E=n(11),C=n(1),A=n(100),O=n(246);function _(t){var e={};return function(n){return e[n]||(e[n]=t(n));};}function S(t){var e=_(t.format),n=t.formatPrefix;return {format:e,formatPrefix:n,formatFloat:function formatFloat(t){var n=o(t||",");if(null==n.precision){switch(n.precision=12,n.type){case"%":n.precision-=2;break;case"e":n.precision-=1;}return function(t,e){return function(n){var r=t(n),i=r.indexOf(e);if(i<0)return r;var o=function(t,e){var n,r=t.lastIndexOf("e");if(r>0)return r;for(r=t.length;--r>e;){if((n=t.charCodeAt(r))>=48&&n<=57)return r+1;}}(r,i);var a=o<r.length?r.slice(o):"";for(;--o>i;){if("0"!==r[o]){++o;break;}}return r.slice(0,o)+a;};}(e(n),e(".1f")(1)[1]);}return e(n);},formatSpan:function formatSpan(t,i,a,s){s=o(null==s?",f":s);var u=Object(r.c)(t,i,a),c=Math.max(Math.abs(t),Math.abs(i));var l;if(null==s.precision)switch(s.type){case"s":return isNaN(l=d(u,c))||(s.precision=l),n(s,c);case"":case"e":case"g":case"p":case"r":isNaN(l=p(u,c))||(s.precision=l-("e"===s.type));break;case"f":case"%":isNaN(l=m(u))||(s.precision=l-2*("%"===s.type));}return e(s);}};}var D,F;function T(){return D=S({format:l,formatPrefix:f});}function N(t){return S(k(t));}function I(t){return arguments.length?D=N(t):D;}function R(t,e,n){n=n||{},Object(C.H)(n)||Object(C.o)("Invalid time multi-format specifier: ".concat(n));var r=e(E.i),i=e(E.f),o=e(E.d),a=e(E.a),s=e(E.k),u=e(E.g),c=e(E.h),l=e(E.l),f=t(n[E.e]||".%L"),h=t(n[E.i]||":%S"),d=t(n[E.f]||"%I:%M"),p=t(n[E.d]||"%I %p"),m=t(n[E.a]||n[E.b]||"%a %d"),g=t(n[E.k]||"%b %d"),v=t(n[E.g]||"%B"),y=t(n[E.h]||"%B"),b=t(n[E.l]||"%Y");return function(t){return (r(t)<t?f:i(t)<t?h:o(t)<t?d:a(t)<t?p:u(t)<t?s(t)<t?m:g:l(t)<t?c(t)<t?v:y:b)(t);};}function M(t){var e=_(t.format),n=_(t.utcFormat);return {timeFormat:function timeFormat(t){return Object(C.J)(t)?e(t):R(e,E.p,t);},utcFormat:function utcFormat(t){return Object(C.J)(t)?n(t):R(n,E.v,t);},timeParse:_(t.parse),utcParse:_(t.utcParse)};}function j(){return F=M({format:A.a,parse:A.b,utcFormat:A.c,utcParse:A.d});}function B(t){return M(Object(O.a)(t));}function P(t){return arguments.length?F=B(t):F;}n.d(e,"a",function(){return U;}),n.d(e,"b",function(){return z;}),n.d(e,"c",function(){return I;}),n.d(e,"d",function(){return W;}),n.d(e,"e",function(){return P;}),T(),j();var L=function L(t,e){return Object(C.p)({},t,e);};function z(t,e){var n=t?N(t):I(),r=e?B(e):P();return L(n,r);}function U(t,e){var n=arguments.length;return n&&2!==n&&Object(C.o)("defaultLocale expects either zero or two arguments."),n?L(I(t),P(e)):L(I(),P());}function W(){return T(),j(),U();}},function(t,e,n){n.d(e,"b",function(){return a;}),n.d(e,"c",function(){return s;});var r=Math.sqrt(50),i=Math.sqrt(10),o=Math.sqrt(2);function a(t,e,n){var a=(e-t)/Math.max(0,n),s=Math.floor(Math.log(a)/Math.LN10),u=a/Math.pow(10,s);return s>=0?(u>=r?10:u>=i?5:u>=o?2:1)*Math.pow(10,s):-Math.pow(10,-s)/(u>=r?10:u>=i?5:u>=o?2:1);}function s(t,e,n){var a=Math.abs(e-t)/Math.max(0,n),s=Math.pow(10,Math.floor(Math.log(a)/Math.LN10)),u=a/s;return u>=r?s*=10:u>=i?s*=5:u>=o&&(s*=2),e<t?-s:s;}e.a=function(t,e,n){var r,i,o,s,u=-1;if(n=+n,(t=+t)===(e=+e)&&n>0)return [t];if((r=e<t)&&(i=t,t=e,e=i),0===(s=a(t,e,n))||!isFinite(s))return [];if(s>0){var _n10=Math.round(t/s),_r13=Math.round(e/s);for(_n10*s<t&&++_n10,_r13*s>e&&--_r13,o=new Array(i=_r13-_n10+1);++u<i;){o[u]=(_n10+u)*s;}}else {s=-s;var _n11=Math.round(t*s),_r14=Math.round(e*s);for(_n11/s<t&&++_n11,_r14/s>e&&--_r14,o=new Array(i=_r14-_n11+1);++u<i;){o[u]=(_n11+u)/s;}}return r&&o.reverse(),o;};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});};Object.defineProperty(e,"__esModule",{value:!0});var i=n(198),o=n(197);e.getDrawArea=function(t){if(t instanceof HTMLElement)return t;if(i.isSurface(t))return t.drawArea;if(i.isSurfaceInfo(t))return o.visor().surface({name:t.name,tab:t.tab,styles:t.styles}).drawArea;throw new Error("Not a drawable");},e.shallowEquals=function(t,e){var n=Object.getOwnPropertyNames(t),r=Object.getOwnPropertyNames(e);if(n.length!==r.length)return !1;for(var _r15=0;_r15<n.length;_r15++){var _i10=n[_r15];if(t[_i10]!==e[_i10])return !1;}return !0;},e.nextFrame=function(){return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee(){return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.next=2;return new Promise(function(t){return requestAnimationFrame(t);});case 2:case"end":return _context.stop();}}},_callee);}));};},function(t,e,n){var r=/*#__PURE__*/function(){function r(t,e){var _this=this;_classCallCheck(this,r);if(e=o(e),t instanceof r)return t.loose===!!e.loose&&t.includePrerelease===!!e.includePrerelease?t:new r(t.raw,e);if(t instanceof a)return this.raw=t.value,this.set=[[t]],this.format(),this;if(this.options=e,this.loose=!!e.loose,this.includePrerelease=!!e.includePrerelease,this.raw=t,this.set=t.split(/\s*\|\|\s*/).map(function(t){return _this.parseRange(t.trim());}).filter(function(t){return t.length;}),!this.set.length)throw new TypeError("Invalid SemVer Range: ".concat(t));if(this.set.length>1){var _t7=this.set[0];if(this.set=this.set.filter(function(t){return !p(t[0]);}),0===this.set.length)this.set=[_t7];else if(this.set.length>1){var _iterator=_createForOfIteratorHelper(this.set),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var _t8=_step.value;if(1===_t8.length&&m(_t8[0])){this.set=[_t8];break;}}}catch(err){_iterator.e(err);}finally{_iterator.f();}}}this.format();}_createClass(r,[{key:"format",value:function format(){return this.range=this.set.map(function(t){return t.join(" ").trim();}).join("||").trim(),this.range;}},{key:"toString",value:function toString(){return this.range;}},{key:"parseRange",value:function parseRange(t){var _this2=this;t=t.trim();var e="parseRange:".concat(Object.keys(this.options).join(","),":").concat(t),n=i.get(e);if(n)return n;var _r16=this.options.loose,o=_r16?c[l.HYPHENRANGELOOSE]:c[l.HYPHENRANGE];t=t.replace(o,_(this.options.includePrerelease)),s("hyphen replace",t),t=t.replace(c[l.COMPARATORTRIM],f),s("comparator trim",t,c[l.COMPARATORTRIM]),t=(t=(t=t.replace(c[l.TILDETRIM],h)).replace(c[l.CARETTRIM],d)).split(/\s+/).join(" ");var u=_r16?c[l.COMPARATORLOOSE]:c[l.COMPARATOR],m=t.split(" ").map(function(t){return v(t,_this2.options);}).join(" ").split(/\s+/).map(function(t){return O(t,_this2.options);}).filter(this.options.loose?function(t){return !!t.match(u);}:function(){return !0;}).map(function(t){return new a(t,_this2.options);}),g=(m.length,new Map());var _iterator2=_createForOfIteratorHelper(m),_step2;try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){var _t9=_step2.value;if(p(_t9))return [_t9];g.set(_t9.value,_t9);}}catch(err){_iterator2.e(err);}finally{_iterator2.f();}g.size>1&&g.has("")&&g.delete("");var y=_toConsumableArray(g.values());return i.set(e,y),y;}},{key:"intersects",value:function intersects(t,e){if(!(t instanceof r))throw new TypeError("a Range is required");return this.set.some(function(n){return g(n,e)&&t.set.some(function(t){return g(t,e)&&n.every(function(n){return t.every(function(t){return n.intersects(t,e);});});});});}},{key:"test",value:function test(t){if(!t)return !1;if("string"==typeof t)try{t=new u(t,this.options);}catch(t){return !1;}for(var _e7=0;_e7<this.set.length;_e7++){if(S(this.set[_e7],t,this.options))return !0;}return !1;}}]);return r;}();t.exports=r;var i=new(n(335))({max:1e3}),o=n(115),a=n(113),s=n(116),u=n(32),_n12=n(90),c=_n12.re,l=_n12.t,f=_n12.comparatorTrimReplace,h=_n12.tildeTrimReplace,d=_n12.caretTrimReplace,p=function p(t){return "<0.0.0-0"===t.value;},m=function m(t){return ""===t.value;},g=function g(t,e){var n=!0;var r=t.slice();var i=r.pop();for(;n&&r.length;){n=r.every(function(t){return i.intersects(t,e);}),i=r.pop();}return n;},v=function v(t,e){return s("comp",t,e),t=w(t,e),s("caret",t),t=b(t,e),s("tildes",t),t=E(t,e),s("xrange",t),t=A(t,e),s("stars",t),t;},y=function y(t){return !t||"x"===t.toLowerCase()||"*"===t;},b=function b(t,e){return t.trim().split(/\s+/).map(function(t){return x(t,e);}).join(" ");},x=function x(t,e){var n=e.loose?c[l.TILDELOOSE]:c[l.TILDE];return t.replace(n,function(e,n,r,i,o){var a;return s("tilde",t,e,n,r,i,o),y(n)?a="":y(r)?a=">=".concat(n,".0.0 <").concat(+n+1,".0.0-0"):y(i)?a=">=".concat(n,".").concat(r,".0 <").concat(n,".").concat(+r+1,".0-0"):o?(s("replaceTilde pr",o),a=">=".concat(n,".").concat(r,".").concat(i,"-").concat(o," <").concat(n,".").concat(+r+1,".0-0")):a=">=".concat(n,".").concat(r,".").concat(i," <").concat(n,".").concat(+r+1,".0-0"),s("tilde return",a),a;});},w=function w(t,e){return t.trim().split(/\s+/).map(function(t){return k(t,e);}).join(" ");},k=function k(t,e){s("caret",t,e);var n=e.loose?c[l.CARETLOOSE]:c[l.CARET],r=e.includePrerelease?"-0":"";return t.replace(n,function(e,n,i,o,a){var u;return s("caret",t,e,n,i,o,a),y(n)?u="":y(i)?u=">=".concat(n,".0.0").concat(r," <").concat(+n+1,".0.0-0"):y(o)?u="0"===n?">=".concat(n,".").concat(i,".0").concat(r," <").concat(n,".").concat(+i+1,".0-0"):">=".concat(n,".").concat(i,".0").concat(r," <").concat(+n+1,".0.0-0"):a?(s("replaceCaret pr",a),u="0"===n?"0"===i?">=".concat(n,".").concat(i,".").concat(o,"-").concat(a," <").concat(n,".").concat(i,".").concat(+o+1,"-0"):">=".concat(n,".").concat(i,".").concat(o,"-").concat(a," <").concat(n,".").concat(+i+1,".0-0"):">=".concat(n,".").concat(i,".").concat(o,"-").concat(a," <").concat(+n+1,".0.0-0")):(s("no pr"),u="0"===n?"0"===i?">=".concat(n,".").concat(i,".").concat(o).concat(r," <").concat(n,".").concat(i,".").concat(+o+1,"-0"):">=".concat(n,".").concat(i,".").concat(o).concat(r," <").concat(n,".").concat(+i+1,".0-0"):">=".concat(n,".").concat(i,".").concat(o," <").concat(+n+1,".0.0-0")),s("caret return",u),u;});},E=function E(t,e){return s("replaceXRanges",t,e),t.split(/\s+/).map(function(t){return C(t,e);}).join(" ");},C=function C(t,e){t=t.trim();var n=e.loose?c[l.XRANGELOOSE]:c[l.XRANGE];return t.replace(n,function(n,r,i,o,a,u){s("xRange",t,n,r,i,o,a,u);var c=y(i),l=c||y(o),f=l||y(a),h=f;return "="===r&&h&&(r=""),u=e.includePrerelease?"-0":"",c?n=">"===r||"<"===r?"<0.0.0-0":"*":r&&h?(l&&(o=0),a=0,">"===r?(r=">=",l?(i=+i+1,o=0,a=0):(o=+o+1,a=0)):"<="===r&&(r="<",l?i=+i+1:o=+o+1),"<"===r&&(u="-0"),n="".concat(r+i,".").concat(o,".").concat(a).concat(u)):l?n=">=".concat(i,".0.0").concat(u," <").concat(+i+1,".0.0-0"):f&&(n=">=".concat(i,".").concat(o,".0").concat(u," <").concat(i,".").concat(+o+1,".0-0")),s("xRange return",n),n;});},A=function A(t,e){return s("replaceStars",t,e),t.trim().replace(c[l.STAR],"");},O=function O(t,e){return s("replaceGTE0",t,e),t.trim().replace(c[e.includePrerelease?l.GTE0PRE:l.GTE0],"");},_=function _(t){return function(e,n,r,i,o,a,s,u,c,l,f,h,d){return "".concat(n=y(r)?"":y(i)?">=".concat(r,".0.0").concat(t?"-0":""):y(o)?">=".concat(r,".").concat(i,".0").concat(t?"-0":""):a?">=".concat(n):">=".concat(n).concat(t?"-0":"")," ").concat(u=y(c)?"":y(l)?"<".concat(+c+1,".0.0-0"):y(f)?"<".concat(c,".").concat(+l+1,".0-0"):h?"<=".concat(c,".").concat(l,".").concat(f,"-").concat(h):t?"<".concat(c,".").concat(l,".").concat(+f+1,"-0"):"<=".concat(u)).trim();};},S=function S(t,e,n){for(var _n13=0;_n13<t.length;_n13++){if(!t[_n13].test(e))return !1;}if(e.prerelease.length&&!n.includePrerelease){for(var _n14=0;_n14<t.length;_n14++){if(s(t[_n14].semver),t[_n14].semver!==a.ANY&&t[_n14].semver.prerelease.length>0){var _r17=t[_n14].semver;if(_r17.major===e.major&&_r17.minor===e.minor&&_r17.patch===e.patch)return !0;}}return !1;}return !0;};},function(t,e,n){var r=n(32);t.exports=function(t,e,n){return new r(t,n).compare(new r(e,n));};},function(t,e,n){var r=n(15);t.exports=function(t,e){return !!t&&r(function(){e?t.call(null,function(){},1):t.call(null);});};},function(t,e,n){n.r(e);var r=function r(t,e){if((n=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var n,r=t.slice(0,n);return [r.length>1?r[0]+r.slice(2):r,+t.slice(n+1)];},i=function i(t){return (t=r(Math.abs(t)))?t[1]:NaN;},o=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function a(t){return new s(t);}function s(t){if(!(e=o.exec(t)))throw new Error("invalid format: "+t);var e;this.fill=e[1]||" ",this.align=e[2]||">",this.sign=e[3]||"-",this.symbol=e[4]||"",this.zero=!!e[5],this.width=e[6]&&+e[6],this.comma=!!e[7],this.precision=e[8]&&+e[8].slice(1),this.trim=!!e[9],this.type=e[10]||"";}a.prototype=s.prototype,s.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(null==this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(null==this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type;};var u,c,l,f,h=function h(t){t:for(var e,n=t.length,r=1,i=-1;r<n;++r){switch(t[r]){case".":i=e=r;break;case"0":0===i&&(i=r),e=r;break;default:if(i>0){if(!+t[r])break t;i=0;}}}return i>0?t.slice(0,i)+t.slice(e+1):t;},d=function d(t,e){var n=r(t,e);if(!n)return t+"";var i=n[0],o=n[1];return o<0?"0."+new Array(-o).join("0")+i:i.length>o+1?i.slice(0,o+1)+"."+i.slice(o+1):i+new Array(o-i.length+2).join("0");},p={"%":function _(t,e){return (100*t).toFixed(e);},b:function b(t){return Math.round(t).toString(2);},c:function c(t){return t+"";},d:function d(t){return Math.round(t).toString(10);},e:function e(t,_e8){return t.toExponential(_e8);},f:function f(t,e){return t.toFixed(e);},g:function g(t,e){return t.toPrecision(e);},o:function o(t){return Math.round(t).toString(8);},p:function p(t,e){return d(100*t,e);},r:d,s:function s(t,e){var n=r(t,e);if(!n)return t+"";var i=n[0],o=n[1],a=o-(u=3*Math.max(-8,Math.min(8,Math.floor(o/3))))+1,s=i.length;return a===s?i:a>s?i+new Array(a-s+1).join("0"):a>0?i.slice(0,a)+"."+i.slice(a):"0."+new Array(1-a).join("0")+r(t,Math.max(0,e+a-1))[0];},X:function X(t){return Math.round(t).toString(16).toUpperCase();},x:function x(t){return Math.round(t).toString(16);}},m=function m(t){return t;},g=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"],v=function v(t){var e=t.grouping&&t.thousands?function(t,e){return function(n,r){for(var i=n.length,o=[],a=0,s=t[0],u=0;i>0&&s>0&&(u+s+1>r&&(s=Math.max(1,r-u)),o.push(n.substring(i-=s,i+s)),!((u+=s+1)>r));){s=t[a=(a+1)%t.length];}return o.reverse().join(e);};}(t.grouping,t.thousands):m,n=t.currency,r=t.decimal,o=t.numerals?function(t){return function(e){return e.replace(/[0-9]/g,function(e){return t[+e];});};}(t.numerals):m,s=t.percent||"%";function c(t){var i=(t=a(t)).fill,c=t.align,l=t.sign,f=t.symbol,d=t.zero,m=t.width,v=t.comma,y=t.precision,b=t.trim,x=t.type;"n"===x?(v=!0,x="g"):p[x]||(null==y&&(y=12),b=!0,x="g"),(d||"0"===i&&"="===c)&&(d=!0,i="0",c="=");var w="$"===f?n[0]:"#"===f&&/[boxX]/.test(x)?"0"+x.toLowerCase():"",k="$"===f?n[1]:/[%p]/.test(x)?s:"",E=p[x],C=/[defgprs%]/.test(x);function A(t){var n,a,s,f=w,p=k;if("c"===x)p=E(t)+p,t="";else {var A=(t=+t)<0;if(t=E(Math.abs(t),y),b&&(t=h(t)),A&&0==+t&&(A=!1),f=(A?"("===l?l:"-":"-"===l||"("===l?"":l)+f,p=("s"===x?g[8+u/3]:"")+p+(A&&"("===l?")":""),C)for(n=-1,a=t.length;++n<a;){if(48>(s=t.charCodeAt(n))||s>57){p=(46===s?r+t.slice(n+1):t.slice(n))+p,t=t.slice(0,n);break;}}}v&&!d&&(t=e(t,1/0));var O=f.length+t.length+p.length,_=O<m?new Array(m-O+1).join(i):"";switch(v&&d&&(t=e(_+t,_.length?m-p.length:1/0),_=""),c){case"<":t=f+t+p+_;break;case"=":t=f+_+t+p;break;case"^":t=_.slice(0,O=_.length>>1)+f+t+p+_.slice(O);break;default:t=_+f+t+p;}return o(t);}return y=null==y?6:/[gprs]/.test(x)?Math.max(1,Math.min(21,y)):Math.max(0,Math.min(20,y)),A.toString=function(){return t+"";},A;}return {format:c,formatPrefix:function formatPrefix(t,e){var n=c(((t=a(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(i(e)/3))),o=Math.pow(10,-r),s=g[8+r/3];return function(t){return n(o*t)+s;};}};};function y(t){return c=v(t),l=c.format,f=c.formatPrefix,c;}y({decimal:".",thousands:",",grouping:[3],currency:["$",""]});var b=function b(t){return Math.max(0,-i(Math.abs(t)));},x=function x(t,e){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(i(e)/3)))-i(Math.abs(t)));},w=function w(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,i(e)-i(t))+1;};n.d(e,"formatDefaultLocale",function(){return y;}),n.d(e,"format",function(){return l;}),n.d(e,"formatPrefix",function(){return f;}),n.d(e,"formatLocale",function(){return v;}),n.d(e,"formatSpecifier",function(){return a;}),n.d(e,"precisionFixed",function(){return b;}),n.d(e,"precisionPrefix",function(){return x;}),n.d(e,"precisionRound",function(){return w;});},function(t,e,n){var r=n(56),i=n(107),o=n(34),a=n(22),s=n(224);t.exports=function(t,e){var n=1==t,u=2==t,c=3==t,l=4==t,f=6==t,h=5==t||f,d=e||s;return function(e,s,p){for(var m,g,v=o(e),y=i(v),b=r(s,p,3),x=a(y.length),w=0,k=n?d(e,x):u?d(e,0):void 0;x>w;w++){if((h||w in y)&&(g=b(m=y[w],w,v),t))if(n)k[w]=g;else if(g)switch(t){case 3:return !0;case 5:return m;case 6:return w;case 2:k.push(m);}else if(l)return !1;}return f?-1:c||l?l:k;};};},function(t,e,n){var r=n(8),i=n(24),o=n(15);t.exports=function(t,e){var n=(i.Object||{})[t]||Object[t],a={};a[t]=e(n),r(r.S+r.F*o(function(){n(1);}),"Object",a);};},function(t,e,n){var r=n(106),i=n(85),o=n(41),a=n(66),s=n(43),u=n(240),c=Object.getOwnPropertyDescriptor;e.f=n(27)?c:function(t,e){if(t=o(t),e=a(e,!0),u)try{return c(t,e);}catch(t){}if(s(t,e))return i(!r.f.call(t,e),t[e]);};},function(t,e){var n=Math.ceil,r=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?r:n)(t);};},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t;};},function(t,e,n){var r=n(55);t.exports=function(t,e,n){if(r(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n);};case 2:return function(n,r){return t.call(e,n,r);};case 3:return function(n,r,i){return t.call(e,n,r,i);};}return function(){return t.apply(e,arguments);};};},function(t,e,n){var r=n(7).default,i=n(258);t.exports=function(t,e){if(e&&("object"===r(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return i(t);},t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e,n){var r=n(259);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&r(t,e);},t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e){var n;n=function(){return this;}();try{n=n||Function("return this")()||(0,eval)("this");}catch(t){"object"==(typeof window==="undefined"?"undefined":_typeof$1(window))&&(n=window);}t.exports=n;},function(t,e,n){if(n(27)){var r=n(83),i=n(16),o=n(15),a=n(8),s=n(118),u=n(151),c=n(56),l=n(94),f=n(85),h=n(42),d=n(93),p=n(54),m=n(22),g=n(213),v=n(81),y=n(66),b=n(43),x=n(105),w=n(13),k=n(34),E=n(159),C=n(80),A=n(78),O=n(79).f,_=n(157),S=n(84),D=n(19),F=n(51),T=n(128),N=n(104),I=n(155),R=n(96),M=n(125),j=n(95),B=n(156),P=n(222),L=n(26),z=n(53),U=L.f,W=z.f,V=i.RangeError,q=i.TypeError,$=i.Uint8Array,H=Array.prototype,G=u.ArrayBuffer,K=u.DataView,X=F(0),Y=F(2),J=F(3),Q=F(4),Z=F(5),tt=F(6),et=T(!0),nt=T(!1),rt=I.values,it=I.keys,ot=I.entries,at=H.lastIndexOf,st=H.reduce,ut=H.reduceRight,ct=H.join,lt=H.sort,ft=H.slice,ht=H.toString,dt=H.toLocaleString,pt=D("iterator"),mt=D("toStringTag"),gt=S("typed_constructor"),vt=S("def_constructor"),yt=s.CONSTR,bt=s.TYPED,xt=s.VIEW,wt=F(1,function(t,e){return Ot(N(t,t[vt]),e);}),kt=o(function(){return 1===new $(new Uint16Array([1]).buffer)[0];}),Et=!!$&&!!$.prototype.set&&o(function(){new $(1).set({});}),Ct=function Ct(t,e){var n=p(t);if(n<0||n%e)throw V("Wrong offset!");return n;},At=function At(t){if(w(t)&&bt in t)return t;throw q(t+" is not a typed array!");},Ot=function Ot(t,e){if(!(w(t)&&gt in t))throw q("It is not a typed array constructor!");return new t(e);},_t=function _t(t,e){return St(N(t,t[vt]),e);},St=function St(t,e){for(var n=0,r=e.length,i=Ot(t,r);r>n;){i[n]=e[n++];}return i;},Dt=function Dt(t,e,n){U(t,e,{get:function get(){return this._d[n];}});},Ft=function Ft(t){var e,n,r,i,o,a,s=k(t),u=arguments.length,l=u>1?arguments[1]:void 0,f=void 0!==l,h=_(s);if(void 0!=h&&!E(h)){for(a=h.call(s),r=[],e=0;!(o=a.next()).done;e++){r.push(o.value);}s=r;}for(f&&u>2&&(l=c(l,arguments[2],2)),e=0,n=m(s.length),i=Ot(this,n);n>e;e++){i[e]=f?l(s[e],e):s[e];}return i;},Tt=function Tt(){for(var t=0,e=arguments.length,n=Ot(this,e);e>t;){n[t]=arguments[t++];}return n;},Nt=!!$&&o(function(){dt.call(new $(1));}),It=function It(){return dt.apply(Nt?ft.call(At(this)):At(this),arguments);},Rt={copyWithin:function copyWithin(t,e){return P.call(At(this),t,e,arguments.length>2?arguments[2]:void 0);},every:function every(t){return Q(At(this),t,arguments.length>1?arguments[1]:void 0);},fill:function fill(t){return B.apply(At(this),arguments);},filter:function filter(t){return _t(this,Y(At(this),t,arguments.length>1?arguments[1]:void 0));},find:function find(t){return Z(At(this),t,arguments.length>1?arguments[1]:void 0);},findIndex:function findIndex(t){return tt(At(this),t,arguments.length>1?arguments[1]:void 0);},forEach:function forEach(t){X(At(this),t,arguments.length>1?arguments[1]:void 0);},indexOf:function indexOf(t){return nt(At(this),t,arguments.length>1?arguments[1]:void 0);},includes:function includes(t){return et(At(this),t,arguments.length>1?arguments[1]:void 0);},join:function join(t){return ct.apply(At(this),arguments);},lastIndexOf:function lastIndexOf(t){return at.apply(At(this),arguments);},map:function map(t){return wt(At(this),t,arguments.length>1?arguments[1]:void 0);},reduce:function reduce(t){return st.apply(At(this),arguments);},reduceRight:function reduceRight(t){return ut.apply(At(this),arguments);},reverse:function reverse(){for(var t,e=At(this).length,n=Math.floor(e/2),r=0;r<n;){t=this[r],this[r++]=this[--e],this[e]=t;}return this;},some:function some(t){return J(At(this),t,arguments.length>1?arguments[1]:void 0);},sort:function sort(t){return lt.call(At(this),t);},subarray:function subarray(t,e){var n=At(this),r=n.length,i=v(t,r);return new(N(n,n[vt]))(n.buffer,n.byteOffset+i*n.BYTES_PER_ELEMENT,m((void 0===e?r:v(e,r))-i));}},Mt=function Mt(t,e){return _t(this,ft.call(At(this),t,e));},jt=function jt(t){At(this);var e=Ct(arguments[1],1),n=this.length,r=k(t),i=m(r.length),o=0;if(i+e>n)throw V("Wrong length!");for(;o<i;){this[e+o]=r[o++];}},Bt={entries:function entries(){return ot.call(At(this));},keys:function keys(){return it.call(At(this));},values:function values(){return rt.call(At(this));}},Pt=function Pt(t,e){return w(t)&&t[bt]&&"symbol"!=_typeof$1(e)&&e in t&&String(+e)==String(e);},Lt=function Lt(t,e){return Pt(t,e=y(e,!0))?f(2,t[e]):W(t,e);},zt=function zt(t,e,n){return !(Pt(t,e=y(e,!0))&&w(n)&&b(n,"value"))||b(n,"get")||b(n,"set")||n.configurable||b(n,"writable")&&!n.writable||b(n,"enumerable")&&!n.enumerable?U(t,e,n):(t[e]=n.value,t);};yt||(z.f=Lt,L.f=zt),a(a.S+a.F*!yt,"Object",{getOwnPropertyDescriptor:Lt,defineProperty:zt}),o(function(){ht.call({});})&&(ht=dt=function dt(){return ct.call(this);});var Ut=d({},Rt);d(Ut,Bt),h(Ut,pt,Bt.values),d(Ut,{slice:Mt,set:jt,constructor:function constructor(){},toString:ht,toLocaleString:It}),Dt(Ut,"buffer","b"),Dt(Ut,"byteOffset","o"),Dt(Ut,"byteLength","l"),Dt(Ut,"length","e"),U(Ut,mt,{get:function get(){return this[bt];}}),t.exports=function(t,e,n,u){var c=t+((u=!!u)?"Clamped":"")+"Array",f="get"+t,d="set"+t,p=i[c],v=p||{},y=p&&A(p),b=!p||!s.ABV,k={},E=p&&p.prototype,_=function _(t,n){U(t,n,{get:function get(){return function(t,n){var r=t._d;return r.v[f](n*e+r.o,kt);}(this,n);},set:function set(t){return function(t,n,r){var i=t._d;u&&(r=(r=Math.round(r))<0?0:r>255?255:255&r),i.v[d](n*e+i.o,r,kt);}(this,n,t);},enumerable:!0});};b?(p=n(function(t,n,r,i){l(t,p,c,"_d");var o,a,s,u,f=0,d=0;if(w(n)){if(!(n instanceof G||"ArrayBuffer"==(u=x(n))||"SharedArrayBuffer"==u))return bt in n?St(p,n):Ft.call(p,n);o=n,d=Ct(r,e);var v=n.byteLength;if(void 0===i){if(v%e)throw V("Wrong length!");if((a=v-d)<0)throw V("Wrong length!");}else if((a=m(i)*e)+d>v)throw V("Wrong length!");s=a/e;}else s=g(n),o=new G(a=s*e);for(h(t,"_d",{b:o,o:d,l:a,e:s,v:new K(o)});f<s;){_(t,f++);}}),E=p.prototype=C(Ut),h(E,"constructor",p)):o(function(){p(1);})&&o(function(){new p(-1);})&&M(function(t){new p(),new p(null),new p(1.5),new p(t);},!0)||(p=n(function(t,n,r,i){var o;return l(t,p,c),w(n)?n instanceof G||"ArrayBuffer"==(o=x(n))||"SharedArrayBuffer"==o?void 0!==i?new v(n,Ct(r,e),i):void 0!==r?new v(n,Ct(r,e)):new v(n):bt in n?St(p,n):Ft.call(p,n):new v(g(n));}),X(y!==Function.prototype?O(v).concat(O(y)):O(v),function(t){t in p||h(p,t,v[t]);}),p.prototype=E,r||(E.constructor=p));var S=E[pt],D=!!S&&("values"==S.name||void 0==S.name),F=Bt.values;h(p,gt,!0),h(E,bt,c),h(E,xt,!0),h(E,vt,p),(u?new p(1)[mt]==c:mt in E)||U(E,mt,{get:function get(){return c;}}),k[c]=p,a(a.G+a.W+a.F*(p!=v),k),a(a.S,c,{BYTES_PER_ELEMENT:e}),a(a.S+a.F*o(function(){v.of.call(p,1);}),c,{from:Ft,of:Tt}),"BYTES_PER_ELEMENT"in E||h(E,"BYTES_PER_ELEMENT",e),a(a.P,c,Rt),j(c),a(a.P+a.F*Et,c,{set:jt}),a(a.P+a.F*!D,c,Bt),r||E.toString==ht||(E.toString=ht),a(a.P+a.F*o(function(){new p(1).slice();}),c,{slice:Mt}),a(a.P+a.F*(o(function(){return [1,2].toLocaleString()!=new p([1,2]).toLocaleString();})||!o(function(){E.toLocaleString.call([1,2]);})),c,{toLocaleString:It}),R[c]=D?S:F,r||D||h(E,pt,F);};}else t.exports=function(){};},function(t,e){t.exports=function(t){if(void 0==t)throw TypeError("Can't call method on  "+t);return t;};},function(t,e){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1);};},function(t,e,n){(function(t){n.d(e,"a",function(){return A;}),n.d(e,"b",function(){return O;}),n.d(e,"c",function(){return y;}),n.d(e,"d",function(){return b;}),n.d(e,"e",function(){return D;}),n.d(e,"f",function(){return S;}),n.d(e,"g",function(){return _;}),n.d(e,"h",function(){return m;});var r=n(1),i=n(582),o=n(176),a=n(44);var s=/^(data:|([A-Za-z]+:)?\/\/)/,u=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file|data):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,c=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,l="file://";function f(){return _f2.apply(this,arguments);}function _f2(){_f2=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee5(){return regeneratorRuntime.wrap(function _callee5$(_context5){while(1){switch(_context5.prev=_context5.next){case 0:Object(r.o)("No file system access.");case 1:case"end":return _context5.stop();}}},_callee5);}));return _f2.apply(this,arguments);}function h(){return _h2.apply(this,arguments);}function _h2(){_h2=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee6(){return regeneratorRuntime.wrap(function _callee6$(_context6){while(1){switch(_context6.prev=_context6.next){case 0:Object(r.o)("No HTTP fetch method available.");case 1:case"end":return _context6.stop();}}},_callee6);}));return _h2.apply(this,arguments);}var d=function d(t){return null!=t&&t==t;},p=function p(t){return !(Number.isNaN(+t)||t instanceof Date);},m={boolean:r.Ca,integer:r.Ea,number:r.Ea,date:r.Da,string:r.Ga,unknown:r.y},g=[function(t){return "true"===t||"false"===t||!0===t||!1===t;},function(t){return p(t)&&Number.isInteger(+t);},p,function(t){return !Number.isNaN(Date.parse(t));}],v=["boolean","integer","number","date"];function y(t,e){if(!t||!t.length)return "unknown";var n=t.length,r=g.length,i=g.map(function(t,e){return e+1;});for(var _o7,_a9,_s5=0,_u2=0;_s5<n;++_s5){for(_a9=e?t[_s5][e]:t[_s5],_o7=0;_o7<r;++_o7){if(i[_o7]&&d(_a9)&&!g[_o7](_a9)&&(i[_o7]=0,++_u2===g.length))return "string";}}return v[i.reduce(function(t,e){return 0===t?e:t;},0)-1];}function b(t,e){return e.reduce(function(e,n){return e[n]=y(t,n),e;},{});}function x(t){var e=function e(_e9,n){var i={delimiter:t};return w(_e9,n?Object(r.p)(n,i):i);};return e.responseType="text",e;}function w(t,e){return e.header&&(t=e.header.map(r.Ba).join(e.delimiter)+"\n"+t),Object(i.a)(e.delimiter).parse(t+"");}function k(e,n){var i=n&&n.property?Object(r.u)(n.property):r.y;return Object(r.H)(e)&&!function(e){return !("function"!=typeof t||!Object(r.E)(t.isBuffer))&&t.isBuffer(e);}(e)?function(t,e){!Object(r.B)(t)&&Object(r.F)(t)&&(t=_toConsumableArray(t));return e&&e.copy?JSON.parse(JSON.stringify(t)):t;}(i(e),n):i(JSON.parse(e));}w.responseType="text",k.responseType="json";var E={interior:function interior(t,e){return t!==e;},exterior:function exterior(t,e){return t===e;}};function C(t,e){var n,i,a,s;return t=k(t,e),e&&e.feature?(n=o.a,a=e.feature):e&&e.mesh?(n=o.b,a=e.mesh,s=E[e.filter]):Object(r.o)("Missing TopoJSON feature or mesh parameter."),(i=(i=t.objects[a])?n(t,i,s):Object(r.o)("Invalid TopoJSON object: "+a))&&i.features||[i];}C.responseType="json";var A={dsv:w,csv:x(","),tsv:x("\t"),json:k,topojson:C};function O(t,e){return arguments.length>1?(A[t]=e,this):Object(r.w)(A,t)?A[t]:null;}function _(t){var e=O(t);return e&&e.responseType||"text";}function S(t,e,n,i){var o=O((e=e||{}).type||"json");return o||Object(r.o)("Unknown data format type: "+e.type),t=o(t,e),e.parse&&function(t,e,n,r){if(!t.length)return;var i=Object(a.e)();n=n||i.timeParse,r=r||i.utcParse;var o,s,u,c,l,f,h=t.columns||Object.keys(t[0]);"auto"===e&&(e=b(t,h));var d=(h=Object.keys(e)).map(function(t){var i=e[t];var o,a;if(i&&(i.startsWith("date:")||i.startsWith("utc:"))){o=i.split(/:(.+)?/,2),("'"===(a=o[1])[0]&&"'"===a[a.length-1]||'"'===a[0]&&'"'===a[a.length-1])&&(a=a.slice(1,-1));var _t10="utc"===o[0]?r:n;return _t10(a);}if(!m[i])throw Error("Illegal format pattern: "+t+":"+i);return m[i];});for(u=0,l=t.length,f=h.length;u<l;++u){for(o=t[u],c=0;c<f;++c){s=h[c],o[s]=d[c](o[s]);}}}(t,e.parse,n,i),Object(r.w)(t,"columns")&&delete t.columns,t;}var D=function(t,e){return function(n){return {options:n||{},sanitize:function(){var _sanitize=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee2(t,e){var n,i,o,a,f,h,d;return regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:e=Object(r.p)({},this.options,e);n=this.fileAccess,i={href:null};h=u.test(t.replace(c,""));null!=t&&"string"==typeof t&&h||Object(r.o)("Sanitize failure, invalid URI: "+Object(r.Ba)(t));d=s.test(t);return _context2.abrupt("return",((f=e.baseURL)&&!d&&(t.startsWith("/")||f.endsWith("/")||(t="/"+t),t=f+t),a=(o=t.startsWith(l))||"file"===e.mode||"http"!==e.mode&&!d&&n,o?t=t.slice(l.length):t.startsWith("//")&&("file"===e.defaultProtocol?(t=t.slice(2),a=!0):t=(e.defaultProtocol||"http")+":"+t),Object.defineProperty(i,"localFile",{value:!!a}),i.href=t,e.target&&(i.target=e.target+""),e.rel&&(i.rel=e.rel+""),"image"===e.context&&e.crossOrigin&&(i.crossOrigin=e.crossOrigin+""),i));case 6:case"end":return _context2.stop();}}},_callee2,this);}));function sanitize(_x2,_x3){return _sanitize.apply(this,arguments);}return sanitize;}(),load:function(){var _load=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee3(t,e){var n,r;return regeneratorRuntime.wrap(function _callee3$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:_context3.next=2;return this.sanitize(t,e);case 2:n=_context3.sent;r=n.href;return _context3.abrupt("return",n.localFile?this.file(r):this.http(r,e));case 5:case"end":return _context3.stop();}}},_callee3,this);}));function load(_x4,_x5){return _load.apply(this,arguments);}return load;}(),fileAccess:!!e,file:function(t){return t?function(e){return new Promise(function(n,r){t.readFile(e,function(t,e){t?r(t):n(e);});});}:f;}(e),http:function(t){return t?/*#__PURE__*/function(){var _ref=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee4(e,n){var i,o,a;return regeneratorRuntime.wrap(function _callee4$(_context4){while(1){switch(_context4.prev=_context4.next){case 0:i=Object(r.p)({},this.options.http,n);o=n&&n.response;_context4.next=4;return t(e,i);case 4:a=_context4.sent;return _context4.abrupt("return",a.ok?Object(r.E)(a[o])?a[o]():a.text():Object(r.o)(a.status+""+a.statusText));case 6:case"end":return _context4.stop();}}},_callee4,this);}));return function(_x6,_x7){return _ref.apply(this,arguments);};}():h;}(t)};};}("undefined"!=typeof fetch&&fetch,null);}).call(this,n(92).Buffer);},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(102),i=n(46),o={prepend:!1};e.subSurface=function(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var a=i.getDrawArea(t),s=r.css({"& canvas":{display:"block"},marginTop:".5rem",marginBottom:".5rem"}),u=r.css({backgroundColor:"white",display:"inline-block",boxSizing:"border-box",borderBottom:"1px solid #357EDD",lineHeight:"2em",padding:"0 10px 0 10px",marginBottom:"20px",fontWeight:"600",textAlign:"left"}),c=Object.assign({},o,n);var l=a.querySelector("div[data-name=".concat(e,"]"));if(!l){if((l=document.createElement("div")).setAttribute("class","".concat(s)),l.dataset.name=e,c.title){var _t11=document.createElement("div");_t11.setAttribute("class","subsurface-title ".concat(u)),_t11.innerText=c.title,l.appendChild(_t11);}c.prepend?a.insertBefore(l,a.firstChild):a.appendChild(l);}return l;},e.getDefaultWidth=function(t){var e=0,n=t;for(;n&&0===n.clientWidth;){n=n.parentElement,e=50;}return n.clientWidth-e;},e.getDefaultHeight=function(t){return 0===t.clientHeight?200:t.clientHeight;};},function(t,e,n){var r=n(84)("meta"),i=n(13),o=n(43),a=n(26).f,s=0,u=Object.isExtensible||function(){return !0;},c=!n(15)(function(){return u(Object.preventExtensions({}));}),l=function l(t){a(t,r,{value:{i:"O"+ ++s,w:{}}});},f=t.exports={KEY:r,NEED:!1,fastKey:function fastKey(t,e){if(!i(t))return "symbol"==_typeof$1(t)?t:("string"==typeof t?"S":"P")+t;if(!o(t,r)){if(!u(t))return "F";if(!e)return "E";l(t);}return t[r].i;},getWeak:function getWeak(t,e){if(!o(t,r)){if(!u(t))return !0;if(!e)return !1;l(t);}return t[r].w;},onFreeze:function onFreeze(t){return c&&f.NEED&&u(t)&&!o(t,r)&&l(t),t;}};},function(t,e,n){var r=n(13);t.exports=function(t,e){if(!r(t))return t;var n,i;if(e&&"function"==typeof(n=t.toString)&&!r(i=n.call(t)))return i;if("function"==typeof(n=t.valueOf)&&!r(i=n.call(t)))return i;if(!e&&"function"==typeof(n=t.toString)&&!r(i=n.call(t)))return i;throw TypeError("Can't convert object to primitive value");};},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */n(0),n(384);var r=n(349),i=n(289),o=n(288),a=n(137),s=n(196),u=n(287),c=n(109),l=n(286),f=n(285),h=n(284),d=n(283),p=n(110),m=n(282);e.version_vis=m.version;var g={barchart:r.barchart,table:c.table,histogram:a.histogram,linechart:s.linechart,scatterplot:u.scatterplot,confusionMatrix:i.confusionMatrix,heatmap:o.heatmap};e.render=g;var v={accuracy:p.accuracy,perClassAccuracy:p.perClassAccuracy,confusionMatrix:p.confusionMatrix};e.metrics=v;var y={history:l.history,fitCallbacks:l.fitCallbacks,perClassAccuracy:h.perClassAccuracy,valuesDistribution:d.valuesDistribution,layer:f.layer,modelSummary:f.modelSummary};e.show=y;var b=n(197);e.visor=b.visor,function(t){for(var n in t){e.hasOwnProperty(n)||(e[n]=t[n]);}}(n(198));},function(t,e,n){var r=n(31),i=Object(r.a)(function(t){t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0);},function(t,e){t.setUTCFullYear(t.getUTCFullYear()+e);},function(t,e){return e.getUTCFullYear()-t.getUTCFullYear();},function(t){return t.getUTCFullYear();});i.every=function(t){return isFinite(t=Math.floor(t))&&t>0?Object(r.a)(function(e){e.setUTCFullYear(Math.floor(e.getUTCFullYear()/t)*t),e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0);},function(e,n){e.setUTCFullYear(e.getUTCFullYear()+n*t);}):null;},e.a=i;i.range;},function(t,e,n){var r=n(31),i=n(12),o=Object(r.a)(function(t){t.setTime(t-t.getMilliseconds());},function(t,e){t.setTime(+t+e*i.e);},function(t,e){return (e-t)/i.e;},function(t){return t.getUTCSeconds();});e.a=o;o.range;},function(t,e,n){var r=n(31),i=Object(r.a)(function(t){t.setMonth(0,1),t.setHours(0,0,0,0);},function(t,e){t.setFullYear(t.getFullYear()+e);},function(t,e){return e.getFullYear()-t.getFullYear();},function(t){return t.getFullYear();});i.every=function(t){return isFinite(t=Math.floor(t))&&t>0?Object(r.a)(function(e){e.setFullYear(Math.floor(e.getFullYear()/t)*t),e.setMonth(0,1),e.setHours(0,0,0,0);},function(e,n){e.setFullYear(e.getFullYear()+n*t);}):null;},e.a=i;i.range;},function(t,e,n){var r=n(31),i=n(12),o=Object(r.a)(function(t){t.setUTCHours(0,0,0,0);},function(t,e){t.setUTCDate(t.getUTCDate()+e);},function(t,e){return (e-t)/i.a;},function(t){return t.getUTCDate()-1;});e.a=o;o.range;},function(t,e,n){var r=n(31),i=n(12),o=Object(r.a)(function(t){return t.setHours(0,0,0,0);},function(t,e){return t.setDate(t.getDate()+e);},function(t,e){return (e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*i.c)/i.a;},function(t){return t.getDate()-1;});e.a=o;o.range;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.Add="Add",e.AddN="AddN",e.Div="Div",e.FusedBatchNorm="FusedBatchNorm",e.SquaredDifference="SquaredDifference",e.Square="Square",e.Transpose="Transpose",e.NonMaxSuppressionV5="NonMaxSuppressionV5",e.BroadcastTo="BroadcastTo",e.OneHot="OneHot",e.Identity="Identity",e.Tile="Tile",e.PadV2="PadV2",e.FromPixels="FromPixels",e.MaxPoolWithArgmax="MaxPoolWithArgmax";},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(33),i=n(378),o=n(21);e.makeTypesMatch=function(t,e){if(t.dtype===e.dtype)return [t,e];var n=i.upcastType(t.dtype,e.dtype);return [t.cast(n),e.cast(n)];},e.assertTypesMatch=function(t,e){o.assert(t.dtype===e.dtype,function(){return "The dtypes of the first("+t.dtype+") and second("+e.dtype+") input must match";});},e.isTensorInList=function(t,e){return e.some(function(e){return e.id===t.id;});},e.getTensorsInContainer=function(t){var e=[];return function t(e,n,i){if(null!=e)if(e instanceof r.Tensor)n.push(e);else if(function(t){return Array.isArray(t)||"object"==_typeof$1(t);}(e)){var o=e;for(var a in o){var s=o[a];i.has(s)||(i.add(s),t(s,n,i));}}}(t,e,new Set()),e;};},function(t,e){var n,r,i=t.exports={};function o(){throw new Error("setTimeout has not been defined");}function a(){throw new Error("clearTimeout has not been defined");}function s(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0);}catch(e){try{return n.call(null,t,0);}catch(e){return n.call(this,t,0);}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o;}catch(t){n=o;}try{r="function"==typeof clearTimeout?clearTimeout:a;}catch(t){r=a;}}();var u,c=[],l=!1,f=-1;function h(){l&&u&&(l=!1,u.length?c=u.concat(c):f=-1,c.length&&d());}function d(){if(!l){var t=s(h);l=!0;for(var e=c.length;e;){for(u=c,c=[];++f<e;){u&&u[f].run();}f=-1,e=c.length;}u=null,l=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t);}catch(e){try{return r.call(null,t);}catch(e){return r.call(this,t);}}}(t);}}function p(t,e){this.fun=t,this.array=e;}function m(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++){e[n-1]=arguments[n];}c.push(new p(t,e)),1!==c.length||l||s(d);},p.prototype.run=function(){this.fun.apply(null,this.array);},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(t){return [];},i.binding=function(t){throw new Error("process.binding is not supported");},i.cwd=function(){return "/";},i.chdir=function(t){throw new Error("process.chdir is not supported");},i.umask=function(){return 0;};},function(t,e,n){var r=n(13);t.exports=function(t,e){if(!r(t)||t._t!==e)throw TypeError("Incompatible receiver, "+e+" required!");return t;};},function(t,e,n){var r=n(19)("unscopables"),i=Array.prototype;void 0==i[r]&&n(42)(i,r,{}),t.exports=function(t){i[r][t]=!0;};},function(t,e,n){var r=n(43),i=n(34),o=n(173)("IE_PROTO"),a=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=i(t),r(t,o)?t[o]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?a:null;};},function(t,e,n){var r=n(238),i=n(172).concat("length","prototype");e.f=Object.getOwnPropertyNames||function(t){return r(t,i);};},function(t,e,n){var r=n(14),i=n(237),o=n(172),a=n(173)("IE_PROTO"),s=function s(){},_u3=function u(){var t,e=n(175)("iframe"),r=o.length;for(e.style.display="none",n(171).appendChild(e),e.src="javascript:",(t=e.contentWindow.document).open(),t.write("<script>document.F=Object<\/script>"),t.close(),_u3=t.F;r--;){delete _u3.prototype[o[r]];}return _u3();};t.exports=Object.create||function(t,e){var n;return null!==t?(s.prototype=r(t),n=new s(),s.prototype=null,n[a]=t):n=_u3(),void 0===e?n:i(n,e);};},function(t,e,n){var r=n(54),i=Math.max,o=Math.min;t.exports=function(t,e){return (t=r(t))<0?i(t+e,0):o(t,e);};},function(t,e,n){var r=n(238),i=n(172);t.exports=Object.keys||function(t){return r(t,i);};},function(t,e){t.exports=!1;},function(t,e){var n=0,r=Math.random();t.exports=function(t){return "Symbol(".concat(void 0===t?"":t,")_",(++n+r).toString(36));};},function(t,e){t.exports=function(t,e){return {enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e};};},function(t,e,n){t.exports=function(t,e){e||(e={}),"function"==typeof e&&(e={cmp:e});var n="boolean"==typeof e.cycles&&e.cycles,r=e.cmp&&function(t){return function(e){return function(n,r){var i={key:n,value:e[n]},o={key:r,value:e[r]};return t(i,o);};};}(e.cmp),i=[];return function t(e){if(e&&e.toJSON&&"function"==typeof e.toJSON&&(e=e.toJSON()),void 0!==e){if("number"==typeof e)return isFinite(e)?""+e:"null";if("object"!=_typeof$1(e))return JSON.stringify(e);var o,a;if(Array.isArray(e)){for(a="[",o=0;o<e.length;o++){o&&(a+=","),a+=t(e[o])||"null";}return a+"]";}if(null===e)return "null";if(-1!==i.indexOf(e)){if(n)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON");}var s=i.push(e)-1,u=Object.keys(e).sort(r&&r(e));for(a="",o=0;o<u.length;o++){var c=u[o],l=t(e[c]);l&&(a&&(a+=","),a+=JSON.stringify(c)+":"+l);}return i.splice(s,1),"{"+a+"}";}}(t);};},function(t,e,n){e.a=function(t,e){return t<e?-1:t>e?1:t>=e?0:NaN;};},function(t,e,n){var _Ju,_Qu;var _marked=/*#__PURE__*/regeneratorRuntime.mark(Qt);n.r(e);var r={};n.d(r,"JsonPatchError",function(){return T;}),n.d(r,"deepClone",function(){return N;}),n.d(r,"getValueByPointer",function(){return M;}),n.d(r,"applyOperation",function(){return j;}),n.d(r,"applyPatch",function(){return B;}),n.d(r,"applyReducer",function(){return P;}),n.d(r,"validator",function(){return L;}),n.d(r,"validate",function(){return z;}),n.d(r,"_areEquals",function(){return U;});var i={};n.d(i,"unobserve",function(){return $;}),n.d(i,"observe",function(){return H;}),n.d(i,"generate",function(){return G;}),n.d(i,"compare",function(){return X;});var o={};n.d(o,"aggregate",function(){return hn;}),n.d(o,"bin",function(){return dn;}),n.d(o,"collect",function(){return mn;}),n.d(o,"compare",function(){return gn;}),n.d(o,"countpattern",function(){return yn;}),n.d(o,"cross",function(){return bn;}),n.d(o,"density",function(){return Cn;}),n.d(o,"dotbin",function(){return Dn;}),n.d(o,"expression",function(){return Fn;}),n.d(o,"extent",function(){return Nn;}),n.d(o,"facet",function(){return Rn;}),n.d(o,"field",function(){return Mn;}),n.d(o,"filter",function(){return Bn;}),n.d(o,"flatten",function(){return Pn;}),n.d(o,"fold",function(){return Ln;}),n.d(o,"formula",function(){return zn;}),n.d(o,"generate",function(){return Un;}),n.d(o,"impute",function(){return qn;}),n.d(o,"joinaggregate",function(){return $n;}),n.d(o,"kde",function(){return Hn;}),n.d(o,"key",function(){return Gn;}),n.d(o,"load",function(){return Xn;}),n.d(o,"lookup",function(){return Jn;}),n.d(o,"multiextent",function(){return Qn;}),n.d(o,"multivalues",function(){return tr;}),n.d(o,"params",function(){return nr;}),n.d(o,"pivot",function(){return rr;}),n.d(o,"prefacet",function(){return ir;}),n.d(o,"project",function(){return or;}),n.d(o,"proxy",function(){return ar;}),n.d(o,"quantile",function(){return sr;}),n.d(o,"relay",function(){return ur;}),n.d(o,"sample",function(){return cr;}),n.d(o,"sequence",function(){return lr;}),n.d(o,"sieve",function(){return fr;}),n.d(o,"subflow",function(){return In;}),n.d(o,"timeunit",function(){return hr;}),n.d(o,"tupleindex",function(){return pr;}),n.d(o,"values",function(){return mr;}),n.d(o,"window",function(){return xr;});var a={};n.d(a,"interpolate",function(){return Ko;}),n.d(a,"interpolateArray",function(){return zo;}),n.d(a,"interpolateBasis",function(){return _o;}),n.d(a,"interpolateBasisClosed",function(){return So;}),n.d(a,"interpolateDate",function(){return Wo;}),n.d(a,"interpolateDiscrete",function(){return ts;}),n.d(a,"interpolateHue",function(){return es;}),n.d(a,"interpolateNumber",function(){return Vo;}),n.d(a,"interpolateNumberArray",function(){return Po;}),n.d(a,"interpolateObject",function(){return qo;}),n.d(a,"interpolateRound",function(){return Xo;}),n.d(a,"interpolateString",function(){return Go;}),n.d(a,"interpolateTransformCss",function(){return as;}),n.d(a,"interpolateTransformSvg",function(){return ss;}),n.d(a,"interpolateZoom",function(){return ls;}),n.d(a,"interpolateRgb",function(){return Ro;}),n.d(a,"interpolateRgbBasis",function(){return jo;}),n.d(a,"interpolateRgbBasisClosed",function(){return Bo;}),n.d(a,"interpolateHsl",function(){return hs;}),n.d(a,"interpolateHslLong",function(){return ds;}),n.d(a,"interpolateLab",function(){return Rs;}),n.d(a,"interpolateHcl",function(){return js;}),n.d(a,"interpolateHclLong",function(){return Bs;}),n.d(a,"interpolateCubehelix",function(){return Gs;}),n.d(a,"interpolateCubehelixLong",function(){return Ks;}),n.d(a,"piecewise",function(){return Ya;}),n.d(a,"quantize",function(){return Xs;});var s={};n.d(s,"bound",function(){return vp;}),n.d(s,"identifier",function(){return xp;}),n.d(s,"mark",function(){return wp;}),n.d(s,"overlap",function(){return kp;}),n.d(s,"render",function(){return Dp;}),n.d(s,"viewlayout",function(){return Jp;});var u={};n.d(u,"axisticks",function(){return Zp;}),n.d(u,"datajoin",function(){return tm;}),n.d(u,"encode",function(){return nm;}),n.d(u,"legendentries",function(){return rm;}),n.d(u,"linkpath",function(){return um;}),n.d(u,"pie",function(){return dm;}),n.d(u,"scale",function(){return vm;}),n.d(u,"sortitems",function(){return wm;}),n.d(u,"stack",function(){return Em;});var c={};n.d(c,"contour",function(){return rb;}),n.d(c,"geojson",function(){return ab;}),n.d(c,"geopath",function(){return sb;}),n.d(c,"geopoint",function(){return ub;}),n.d(c,"geoshape",function(){return cb;}),n.d(c,"graticule",function(){return lb;}),n.d(c,"heatmap",function(){return fb;}),n.d(c,"isocontour",function(){return Gy;}),n.d(c,"kde2d",function(){return tb;}),n.d(c,"projection",function(){return db;});var l={};n.d(l,"force",function(){return cx;});var f={};n.d(f,"nest",function(){return lw;}),n.d(f,"pack",function(){return mw;}),n.d(f,"partition",function(){return vw;}),n.d(f,"stratify",function(){return yw;}),n.d(f,"tree",function(){return ww;}),n.d(f,"treelinks",function(){return kw;}),n.d(f,"treemap",function(){return Aw;});var h={};n.d(h,"label",function(){return Xw;});var d={};n.d(d,"loess",function(){return Jw;}),n.d(d,"regression",function(){return Zw;});var p={};n.d(p,"voronoi",function(){return yk;});var m={};n.d(m,"wordcloud",function(){return Rk;});var g={};n.d(g,"crossfilter",function(){return Wk;}),n.d(g,"resolvefilter",function(){return Vk;});var v={};n.d(v,"Dataflow",function(){return Pt;}),n.d(v,"EventStream",function(){return Et;}),n.d(v,"MultiPulse",function(){return It;}),n.d(v,"Operator",function(){return xt;}),n.d(v,"Parameters",function(){return vt;}),n.d(v,"Pulse",function(){return Dt;}),n.d(v,"Transform",function(){return zt;}),n.d(v,"changeset",function(){return mt;}),n.d(v,"definition",function(){return Wt;}),n.d(v,"ingest",function(){return ct;}),n.d(v,"isTuple",function(){return at;}),n.d(v,"transform",function(){return Vt;}),n.d(v,"transforms",function(){return Ut;}),n.d(v,"tupleid",function(){return st;}),n.d(v,"interpolate",function(){return ju;}),n.d(v,"interpolateColors",function(){return Iu;}),n.d(v,"interpolateRange",function(){return Nu;}),n.d(v,"quantizeInterpolator",function(){return Ru;}),n.d(v,"scale",function(){return ku;}),n.d(v,"scheme",function(){return zu;}),n.d(v,"projection",function(){return Ry;}),n.d(v,"View",function(){return CS;}),n.d(v,"defaultLocale",function(){return et.a;}),n.d(v,"formatLocale",function(){return et.c;}),n.d(v,"locale",function(){return et.b;}),n.d(v,"resetDefaultLocale",function(){return et.d;}),n.d(v,"timeFormatLocale",function(){return et.e;}),n.d(v,"expressionFunction",function(){return g_;}),n.d(v,"parse",function(){return RN;}),n.d(v,"runtimeContext",function(){return O_;}),n.d(v,"codegenExpression",function(){return OR;}),n.d(v,"parseExpression",function(){return ER;}),n.d(v,"parseSelector",function(){return zR;}),n.d(v,"version",function(){return $R;}),n.d(v,"Debug",function(){return Z.a;}),n.d(v,"Error",function(){return Z.b;}),n.d(v,"Info",function(){return Z.c;}),n.d(v,"None",function(){return Z.d;}),n.d(v,"Warn",function(){return Z.e;}),n.d(v,"accessor",function(){return Z.f;}),n.d(v,"accessorFields",function(){return Z.g;}),n.d(v,"accessorName",function(){return Z.h;}),n.d(v,"array",function(){return Z.i;}),n.d(v,"ascending",function(){return Z.j;}),n.d(v,"clampRange",function(){return Z.k;}),n.d(v,"compare",function(){return Z.l;}),n.d(v,"constant",function(){return Z.m;}),n.d(v,"debounce",function(){return Z.n;}),n.d(v,"error",function(){return Z.o;}),n.d(v,"extend",function(){return Z.p;}),n.d(v,"extent",function(){return Z.q;}),n.d(v,"extentIndex",function(){return Z.r;}),n.d(v,"falsy",function(){return Z.s;}),n.d(v,"fastmap",function(){return Z.t;}),n.d(v,"field",function(){return Z.u;}),n.d(v,"flush",function(){return Z.v;}),n.d(v,"hasOwnProperty",function(){return Z.w;}),n.d(v,"id",function(){return Z.x;}),n.d(v,"identity",function(){return Z.y;}),n.d(v,"inherits",function(){return Z.z;}),n.d(v,"inrange",function(){return Z.A;}),n.d(v,"isArray",function(){return Z.B;}),n.d(v,"isBoolean",function(){return Z.C;}),n.d(v,"isDate",function(){return Z.D;}),n.d(v,"isFunction",function(){return Z.E;}),n.d(v,"isIterable",function(){return Z.F;}),n.d(v,"isNumber",function(){return Z.G;}),n.d(v,"isObject",function(){return Z.H;}),n.d(v,"isRegExp",function(){return Z.I;}),n.d(v,"isString",function(){return Z.J;}),n.d(v,"key",function(){return Z.K;}),n.d(v,"lerp",function(){return Z.L;}),n.d(v,"logger",function(){return Z.M;}),n.d(v,"lruCache",function(){return Z.N;}),n.d(v,"merge",function(){return Z.O;}),n.d(v,"mergeConfig",function(){return Z.P;}),n.d(v,"one",function(){return Z.Q;}),n.d(v,"pad",function(){return Z.R;}),n.d(v,"panLinear",function(){return Z.S;}),n.d(v,"panLog",function(){return Z.T;}),n.d(v,"panPow",function(){return Z.U;}),n.d(v,"panSymlog",function(){return Z.V;}),n.d(v,"peek",function(){return Z.W;}),n.d(v,"quarter",function(){return Z.X;}),n.d(v,"repeat",function(){return Z.Y;}),n.d(v,"span",function(){return Z.Z;}),n.d(v,"splitAccessPath",function(){return Z.Aa;}),n.d(v,"stringValue",function(){return Z.Ba;}),n.d(v,"toBoolean",function(){return Z.Ca;}),n.d(v,"toDate",function(){return Z.Da;}),n.d(v,"toNumber",function(){return Z.Ea;}),n.d(v,"toSet",function(){return Z.Fa;}),n.d(v,"toString",function(){return Z.Ga;}),n.d(v,"truncate",function(){return Z.Ha;}),n.d(v,"truthy",function(){return Z.Ia;}),n.d(v,"utcquarter",function(){return Z.Ja;}),n.d(v,"visitArray",function(){return Z.Ka;}),n.d(v,"writeConfig",function(){return Z.La;}),n.d(v,"zero",function(){return Z.Ma;}),n.d(v,"zoomLinear",function(){return Z.Na;}),n.d(v,"zoomLog",function(){return Z.Oa;}),n.d(v,"zoomPow",function(){return Z.Pa;}),n.d(v,"zoomSymlog",function(){return Z.Qa;}),n.d(v,"bandwidthNRD",function(){return ee;}),n.d(v,"bin",function(){return ne;}),n.d(v,"bootstrapCI",function(){return oe;}),n.d(v,"cumulativeLogNormal",function(){return xe;}),n.d(v,"cumulativeNormal",function(){return pe;}),n.d(v,"cumulativeUniform",function(){return Oe;}),n.d(v,"densityLogNormal",function(){return be;}),n.d(v,"densityNormal",function(){return de;}),n.d(v,"densityUniform",function(){return Ae;}),n.d(v,"dotbin",function(){return ae;}),n.d(v,"quantileLogNormal",function(){return we;}),n.d(v,"quantileNormal",function(){return me;}),n.d(v,"quantileUniform",function(){return _e;}),n.d(v,"quantiles",function(){return Zt;}),n.d(v,"quartiles",function(){return te;}),n.d(v,"random",function(){return re;}),n.d(v,"randomInteger",function(){return ue;}),n.d(v,"randomKDE",function(){return ve;}),n.d(v,"randomLCG",function(){return se;}),n.d(v,"randomLogNormal",function(){return ke;}),n.d(v,"randomMixture",function(){return Ee;}),n.d(v,"randomNormal",function(){return ge;}),n.d(v,"randomUniform",function(){return Se;}),n.d(v,"regressionExp",function(){return Me;}),n.d(v,"regressionLinear",function(){return Ie;}),n.d(v,"regressionLoess",function(){return Ue;}),n.d(v,"regressionLog",function(){return Re;}),n.d(v,"regressionPoly",function(){return Pe;}),n.d(v,"regressionPow",function(){return je;}),n.d(v,"regressionQuad",function(){return Be;}),n.d(v,"sampleCurve",function(){return $e;}),n.d(v,"sampleLogNormal",function(){return ye;}),n.d(v,"sampleNormal",function(){return he;}),n.d(v,"sampleUniform",function(){return Ce;}),n.d(v,"setRandom",function(){return ie;}),n.d(v,"DATE",function(){return Xe.a;}),n.d(v,"DAY",function(){return Xe.b;}),n.d(v,"DAYOFYEAR",function(){return Xe.c;}),n.d(v,"HOURS",function(){return Xe.d;}),n.d(v,"MILLISECONDS",function(){return Xe.e;}),n.d(v,"MINUTES",function(){return Xe.f;}),n.d(v,"MONTH",function(){return Xe.g;}),n.d(v,"QUARTER",function(){return Xe.h;}),n.d(v,"SECONDS",function(){return Xe.i;}),n.d(v,"TIME_UNITS",function(){return Xe.j;}),n.d(v,"WEEK",function(){return Xe.k;}),n.d(v,"YEAR",function(){return Xe.l;}),n.d(v,"dayofyear",function(){return Xe.m;}),n.d(v,"timeBin",function(){return Xe.n;}),n.d(v,"timeFloor",function(){return Xe.o;}),n.d(v,"timeInterval",function(){return Xe.p;}),n.d(v,"timeOffset",function(){return Xe.q;}),n.d(v,"timeSequence",function(){return Xe.r;}),n.d(v,"timeUnitSpecifier",function(){return Xe.s;}),n.d(v,"timeUnits",function(){return Xe.t;}),n.d(v,"utcFloor",function(){return Xe.u;}),n.d(v,"utcInterval",function(){return Xe.v;}),n.d(v,"utcOffset",function(){return Xe.w;}),n.d(v,"utcSequence",function(){return Xe.x;}),n.d(v,"utcdayofyear",function(){return Xe.y;}),n.d(v,"utcweek",function(){return Xe.z;}),n.d(v,"week",function(){return Xe.A;}),n.d(v,"format",function(){return tt.a;}),n.d(v,"formats",function(){return tt.b;}),n.d(v,"inferType",function(){return tt.c;}),n.d(v,"inferTypes",function(){return tt.d;}),n.d(v,"loader",function(){return tt.e;}),n.d(v,"read",function(){return tt.f;}),n.d(v,"responseType",function(){return tt.g;}),n.d(v,"typeParsers",function(){return tt.h;}),n.d(v,"Bounds",function(){return sl;}),n.d(v,"CanvasHandler",function(){return Dh;}),n.d(v,"CanvasRenderer",function(){return Mh;}),n.d(v,"Gradient",function(){return pc;}),n.d(v,"GroupItem",function(){return cl;}),n.d(v,"Handler",function(){return vh;}),n.d(v,"Item",function(){return ul;}),n.d(v,"Marks",function(){return nh;}),n.d(v,"RenderType",function(){return wd;}),n.d(v,"Renderer",function(){return bh;}),n.d(v,"ResourceLoader",function(){return ll;}),n.d(v,"SVGHandler",function(){return Bh;}),n.d(v,"SVGRenderer",function(){return ad;}),n.d(v,"SVGStringRenderer",function(){return xd;}),n.d(v,"Scenegraph",function(){return ch;}),n.d(v,"boundClip",function(){return Dd;}),n.d(v,"boundContext",function(){return Tl;}),n.d(v,"boundItem",function(){return rh;}),n.d(v,"boundMark",function(){return oh;}),n.d(v,"boundStroke",function(){return dl;}),n.d(v,"domChild",function(){return dh;}),n.d(v,"domClear",function(){return ph;}),n.d(v,"domCreate",function(){return fh;}),n.d(v,"domFind",function(){return hh;}),n.d(v,"font",function(){return Yf;}),n.d(v,"fontFamily",function(){return Xf;}),n.d(v,"fontSize",function(){return qf;}),n.d(v,"intersect",function(){return Cd;}),n.d(v,"intersectBoxLine",function(){return Wl;}),n.d(v,"intersectPath",function(){return Pl;}),n.d(v,"intersectPoint",function(){return Ll;}),n.d(v,"intersectRule",function(){return Ul;}),n.d(v,"lineHeight",function(){return $f;}),n.d(v,"markup",function(){return ed;}),n.d(v,"multiLineOffset",function(){return Gf;}),n.d(v,"pathCurves",function(){return gc;}),n.d(v,"pathEqual",function(){return Nd;}),n.d(v,"pathParse",function(){return bc;}),n.d(v,"pathRectangle",function(){return Vc;}),n.d(v,"pathRender",function(){return Tc;}),n.d(v,"pathSymbols",function(){return Rc;}),n.d(v,"pathTrail",function(){return qc;}),n.d(v,"point",function(){return gh;}),n.d(v,"renderModule",function(){return Ed;}),n.d(v,"resetSVGClipId",function(){return ol;}),n.d(v,"resetSVGDefIds",function(){return Id;}),n.d(v,"sceneEqual",function(){return Td;}),n.d(v,"sceneFromJSON",function(){return uh;}),n.d(v,"scenePickVisit",function(){return Zl;}),n.d(v,"sceneToJSON",function(){return sh;}),n.d(v,"sceneVisit",function(){return Ql;}),n.d(v,"sceneZOrder",function(){return Jl;}),n.d(v,"serializeXML",function(){return nd;}),n.d(v,"textMetrics",function(){return Pf;});var y={};n.d(y,"invalidSpec",function(){return GP;}),n.d(y,"FIT_NON_SINGLE",function(){return KP;}),n.d(y,"containerSizeNonSingle",function(){return XP;}),n.d(y,"containerSizeNotCompatibleWithAutosize",function(){return YP;}),n.d(y,"droppingFit",function(){return JP;}),n.d(y,"cannotProjectOnChannelWithoutField",function(){return QP;}),n.d(y,"cannotProjectAggregate",function(){return ZP;}),n.d(y,"nearestNotSupportForContinuous",function(){return tL;}),n.d(y,"selectionNotSupported",function(){return eL;}),n.d(y,"selectionNotFound",function(){return nL;}),n.d(y,"SCALE_BINDINGS_CONTINUOUS",function(){return rL;}),n.d(y,"LEGEND_BINDINGS_PROJECT_LENGTH",function(){return iL;}),n.d(y,"noSameUnitLookup",function(){return oL;}),n.d(y,"noSuchRepeatedValue",function(){return aL;}),n.d(y,"columnsNotSupportByRowCol",function(){return sL;}),n.d(y,"CONCAT_CANNOT_SHARE_AXIS",function(){return uL;}),n.d(y,"unrecognizedParse",function(){return cL;}),n.d(y,"differentParse",function(){return lL;}),n.d(y,"invalidTransformIgnored",function(){return fL;}),n.d(y,"NO_FIELDS_NEEDS_AS",function(){return hL;}),n.d(y,"customFormatTypeNotAllowed",function(){return dL;}),n.d(y,"encodingOverridden",function(){return pL;}),n.d(y,"projectionOverridden",function(){return mL;}),n.d(y,"REPLACE_ANGLE_WITH_THETA",function(){return gL;}),n.d(y,"primitiveChannelDef",function(){return vL;}),n.d(y,"invalidFieldType",function(){return yL;}),n.d(y,"invalidFieldTypeForCountAggregate",function(){return bL;}),n.d(y,"invalidAggregate",function(){return xL;}),n.d(y,"missingFieldType",function(){return wL;}),n.d(y,"droppingColor",function(){return kL;}),n.d(y,"emptyFieldDef",function(){return EL;}),n.d(y,"latLongDeprecated",function(){return CL;}),n.d(y,"LINE_WITH_VARYING_SIZE",function(){return AL;}),n.d(y,"incompatibleChannel",function(){return OL;}),n.d(y,"invalidEncodingChannel",function(){return _L;}),n.d(y,"facetChannelShouldBeDiscrete",function(){return SL;}),n.d(y,"facetChannelDropped",function(){return DL;}),n.d(y,"discreteChannelCannotEncode",function(){return FL;}),n.d(y,"lineWithRange",function(){return TL;}),n.d(y,"orientOverridden",function(){return NL;}),n.d(y,"CANNOT_UNION_CUSTOM_DOMAIN_WITH_FIELD_DOMAIN",function(){return IL;}),n.d(y,"RANGE_STEP_DEPRECATED",function(){return RL;}),n.d(y,"cannotUseScalePropertyWithNonColor",function(){return ML;}),n.d(y,"unaggregateDomainHasNoEffectForRawField",function(){return jL;}),n.d(y,"unaggregateDomainWithNonSharedDomainOp",function(){return BL;}),n.d(y,"unaggregatedDomainWithLogScale",function(){return PL;}),n.d(y,"cannotApplySizeToNonOrientedMark",function(){return LL;}),n.d(y,"scaleTypeNotWorkWithChannel",function(){return zL;}),n.d(y,"scaleTypeNotWorkWithFieldDef",function(){return UL;}),n.d(y,"scalePropertyNotWorkWithScaleType",function(){return WL;}),n.d(y,"scaleTypeNotWorkWithMark",function(){return VL;}),n.d(y,"stepDropped",function(){return qL;}),n.d(y,"mergeConflictingProperty",function(){return $L;}),n.d(y,"mergeConflictingDomainProperty",function(){return HL;}),n.d(y,"independentScaleMeansIndependentGuide",function(){return GL;}),n.d(y,"domainSortDropped",function(){return KL;}),n.d(y,"MORE_THAN_ONE_SORT",function(){return XL;}),n.d(y,"FACETED_INDEPENDENT_DIFFERENT_SOURCES",function(){return YL;}),n.d(y,"FACETED_INDEPENDENT_SAME_FIELDS_DIFFERENT_SOURCES",function(){return JL;}),n.d(y,"FACETED_INDEPENDENT_SAME_SOURCE",function(){return QL;}),n.d(y,"INVALID_CHANNEL_FOR_AXIS",function(){return ZL;}),n.d(y,"cannotStackRangedMark",function(){return tz;}),n.d(y,"cannotStackNonLinearScale",function(){return ez;}),n.d(y,"stackNonSummativeAggregate",function(){return nz;}),n.d(y,"invalidTimeUnit",function(){return rz;}),n.d(y,"droppedDay",function(){return iz;}),n.d(y,"errorBarCenterAndExtentAreNotNeeded",function(){return oz;}),n.d(y,"errorBarCenterIsUsedWithWrongExtent",function(){return az;}),n.d(y,"errorBarContinuousAxisHasCustomizedAggregate",function(){return sz;}),n.d(y,"errorBarCenterIsNotNeeded",function(){return uz;}),n.d(y,"errorBand1DNotSupport",function(){return cz;}),n.d(y,"channelRequiredForBinned",function(){return lz;}),n.d(y,"domainRequiredForThresholdScale",function(){return fz;});var b={};n.d(b,"compile",function(){return XJ;}),n.d(b,"extractTransforms",function(){return JJ;}),n.d(b,"normalize",function(){return Fq;}),n.d(b,"version",function(){return QJ;});var x={};n.d(x,"dark",function(){return tQ;}),n.d(x,"excel",function(){return eQ;}),n.d(x,"fivethirtyeight",function(){return nQ;}),n.d(x,"ggplot2",function(){return rQ;}),n.d(x,"googlecharts",function(){return fQ;}),n.d(x,"latimes",function(){return aQ;}),n.d(x,"quartz",function(){return sQ;}),n.d(x,"urbaninstitute",function(){return lQ;}),n.d(x,"version",function(){return hQ;}),n.d(x,"vox",function(){return uQ;});/*!
 * https://github.com/Starcounter-Jack/JSON-Patch
 * (c) 2017 Joachim Wester
 * MIT license
 */var w=function(){var _t12=function t(e,n){return (_t12=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e;}||function(t,e){for(var n in e){e.hasOwnProperty(n)&&(t[n]=e[n]);}})(e,n);};return function(e,n){function r(){this.constructor=e;}_t12(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r());};}(),k=Object.prototype.hasOwnProperty;function E(t,e){return k.call(t,e);}function C(t){if(Array.isArray(t)){for(var e=new Array(t.length),n=0;n<e.length;n++){e[n]=""+n;}return e;}if(Object.keys)return Object.keys(t);e=[];for(var r in t){E(t,r)&&e.push(r);}return e;}function A(t){switch(_typeof$1(t)){case"object":return JSON.parse(JSON.stringify(t));case"undefined":return null;default:return t;}}function O(t){for(var e,n=0,r=t.length;n<r;){if(!((e=t.charCodeAt(n))>=48&&e<=57))return !1;n++;}return !0;}function _(t){return -1===t.indexOf("/")&&-1===t.indexOf("~")?t:t.replace(/~/g,"~0").replace(/\//g,"~1");}function S(t){return t.replace(/~1/g,"/").replace(/~0/g,"~");}function D(t,e){var n=[t];for(var r in e){var i="object"==_typeof$1(e[r])?JSON.stringify(e[r],null,2):e[r];void 0!==i&&n.push(r+": "+i);}return n.join("\n");}var F=function(t){function e(e,n,r,i,o){var a=this.constructor,s=t.call(this,D(e,{name:n,index:r,operation:i,tree:o}))||this;return s.name=n,s.index=r,s.operation=i,s.tree=o,Object.setPrototypeOf(s,a.prototype),s.message=D(e,{name:n,index:r,operation:i,tree:o}),s;}return w(e,t),e;}(Error),T=F,N=A,I={add:function add(t,e,n){return t[e]=this.value,{newDocument:n};},remove:function remove(t,e,n){var r=t[e];return delete t[e],{newDocument:n,removed:r};},replace:function replace(t,e,n){var r=t[e];return t[e]=this.value,{newDocument:n,removed:r};},move:function move(t,e,n){var r=M(n,this.path);r&&(r=A(r));var i=j(n,{op:"remove",path:this.from}).removed;return j(n,{op:"add",path:this.path,value:i}),{newDocument:n,removed:r};},copy:function copy(t,e,n){var r=M(n,this.from);return j(n,{op:"add",path:this.path,value:A(r)}),{newDocument:n};},test:function test(t,e,n){return {newDocument:n,test:U(t[e],this.value)};},_get:function _get(t,e,n){return this.value=t[e],{newDocument:n};}},R={add:function add(t,e,n){return O(e)?t.splice(e,0,this.value):t[e]=this.value,{newDocument:n,index:e};},remove:function remove(t,e,n){return {newDocument:n,removed:t.splice(e,1)[0]};},replace:function replace(t,e,n){var r=t[e];return t[e]=this.value,{newDocument:n,removed:r};},move:I.move,copy:I.copy,test:I.test,_get:I._get};function M(t,e){if(""==e)return t;var n={op:"_get",path:e};return j(t,n),n.value;}function j(t,e,n,r,i,o){if(void 0===n&&(n=!1),void 0===r&&(r=!0),void 0===i&&(i=!0),void 0===o&&(o=0),n&&("function"==typeof n?n(e,0,t,e.path):L(e,0)),""===e.path){var a={newDocument:t};if("add"===e.op)return a.newDocument=e.value,a;if("replace"===e.op)return a.newDocument=e.value,a.removed=t,a;if("move"===e.op||"copy"===e.op)return a.newDocument=M(t,e.from),"move"===e.op&&(a.removed=t),a;if("test"===e.op){if(a.test=U(t,e.value),!1===a.test)throw new T("Test operation failed","TEST_OPERATION_FAILED",o,e,t);return a.newDocument=t,a;}if("remove"===e.op)return a.removed=t,a.newDocument=null,a;if("_get"===e.op)return e.value=t,a;if(n)throw new T("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",o,e,t);return a;}r||(t=A(t));var s=(e.path||"").split("/"),u=t,c=1,l=s.length,f=void 0,h=void 0,d=void 0;for(d="function"==typeof n?n:L;;){if((h=s[c])&&-1!=h.indexOf("~")&&(h=S(h)),i&&"__proto__"==h)throw new TypeError("JSON-Patch: modifying `__proto__` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(n&&void 0===f&&(void 0===u[h]?f=s.slice(0,c).join("/"):c==l-1&&(f=e.path),void 0!==f&&d(e,0,t,f)),c++,Array.isArray(u)){if("-"===h)h=u.length;else {if(n&&!O(h))throw new T("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",o,e,t);O(h)&&(h=~~h);}if(c>=l){if(n&&"add"===e.op&&h>u.length)throw new T("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",o,e,t);if(!1===(a=R[e.op].call(e,u,h,t)).test)throw new T("Test operation failed","TEST_OPERATION_FAILED",o,e,t);return a;}}else if(c>=l){if(!1===(a=I[e.op].call(e,u,h,t)).test)throw new T("Test operation failed","TEST_OPERATION_FAILED",o,e,t);return a;}if(u=u[h],n&&c<l&&(!u||"object"!=_typeof$1(u)))throw new T("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",o,e,t);}}function B(t,e,n,r,i){if(void 0===r&&(r=!0),void 0===i&&(i=!0),n&&!Array.isArray(e))throw new T("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");r||(t=A(t));for(var o=new Array(e.length),a=0,s=e.length;a<s;a++){o[a]=j(t,e[a],n,!0,i,a),t=o[a].newDocument;}return o.newDocument=t,o;}function P(t,e,n){var r=j(t,e);if(!1===r.test)throw new T("Test operation failed","TEST_OPERATION_FAILED",n,e,t);return r.newDocument;}function L(t,e,n,r){if("object"!=_typeof$1(t)||null===t||Array.isArray(t))throw new T("Operation is not an object","OPERATION_NOT_AN_OBJECT",e,t,n);if(!I[t.op])throw new T("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",e,t,n);if("string"!=typeof t.path)throw new T("Operation `path` property is not a string","OPERATION_PATH_INVALID",e,t,n);if(0!==t.path.indexOf("/")&&t.path.length>0)throw new T('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",e,t,n);if(("move"===t.op||"copy"===t.op)&&"string"!=typeof t.from)throw new T("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",e,t,n);if(("add"===t.op||"replace"===t.op||"test"===t.op)&&void 0===t.value)throw new T("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",e,t,n);if(("add"===t.op||"replace"===t.op||"test"===t.op)&&function t(e){if(void 0===e)return !0;if(e)if(Array.isArray(e)){for(var n=0,r=e.length;n<r;n++){if(t(e[n]))return !0;}}else if("object"==_typeof$1(e)){var i=C(e),o=i.length;for(n=0;n<o;n++){if(t(e[i[n]]))return !0;}}return !1;}(t.value))throw new T("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",e,t,n);if(n)if("add"==t.op){var i=t.path.split("/").length,o=r.split("/").length;if(i!==o+1&&i!==o)throw new T("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",e,t,n);}else if("replace"===t.op||"remove"===t.op||"_get"===t.op){if(t.path!==r)throw new T("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",e,t,n);}else if("move"===t.op||"copy"===t.op){var a=z([{op:"_get",path:t.from,value:void 0}],n);if(a&&"OPERATION_PATH_UNRESOLVABLE"===a.name)throw new T("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",e,t,n);}}function z(t,e,n){try{if(!Array.isArray(t))throw new T("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(e)B(A(e),A(t),n||!0);else {n=n||L;for(var r=0;r<t.length;r++){n(t[r],r,e,void 0);}}}catch(t){if(t instanceof T)return t;throw t;}}function U(t,e){if(t===e)return !0;if(t&&e&&"object"==_typeof$1(t)&&"object"==_typeof$1(e)){var n,r,i,o=Array.isArray(t),a=Array.isArray(e);if(o&&a){if((r=t.length)!=e.length)return !1;for(n=r;0!=n--;){if(!U(t[n],e[n]))return !1;}return !0;}if(o!=a)return !1;var s=Object.keys(t);if((r=s.length)!==Object.keys(e).length)return !1;for(n=r;0!=n--;){if(!e.hasOwnProperty(s[n]))return !1;}for(n=r;0!=n--;){if(!U(t[i=s[n]],e[i]))return !1;}return !0;}return t!=t&&e!=e;}/*!
 * https://github.com/Starcounter-Jack/JSON-Patch
 * (c) 2017 Joachim Wester
 * MIT license
 */var W=new WeakMap(),V=function(){return function(t){this.observers=new Map(),this.obj=t;};}(),q=function(){return function(t,e){this.callback=t,this.observer=e;};}();function $(t,e){e.unobserve();}function H(t,e){var n,r=function(t){return W.get(t);}(t);if(r){var i=function(t,e){return t.observers.get(e);}(r,e);n=i&&i.observer;}else r=new V(t),W.set(t,r);if(n)return n;if(n={},r.value=A(t),e){n.callback=e,n.next=null;var o=function o(){G(n);},a=function a(){clearTimeout(n.next),n.next=setTimeout(o);};"undefined"!=typeof window&&(window.addEventListener("mouseup",a),window.addEventListener("keyup",a),window.addEventListener("mousedown",a),window.addEventListener("keydown",a),window.addEventListener("change",a));}return n.patches=[],n.object=t,n.unobserve=function(){G(n),clearTimeout(n.next),function(t,e){t.observers.delete(e.callback);}(r,n),"undefined"!=typeof window&&(window.removeEventListener("mouseup",a),window.removeEventListener("keyup",a),window.removeEventListener("mousedown",a),window.removeEventListener("keydown",a),window.removeEventListener("change",a));},r.observers.set(e,new q(e,n)),n;}function G(t,e){void 0===e&&(e=!1);var n=W.get(t.object);K(n.value,t.object,t.patches,"",e),t.patches.length&&B(n.value,t.patches);var r=t.patches;return r.length>0&&(t.patches=[],t.callback&&t.callback(r)),r;}function K(t,e,n,r,i){if(e!==t){"function"==typeof e.toJSON&&(e=e.toJSON());for(var o=C(e),a=C(t),s=!1,u=a.length-1;u>=0;u--){var c=t[f=a[u]];if(!E(e,f)||void 0===e[f]&&void 0!==c&&!1===Array.isArray(e))Array.isArray(t)===Array.isArray(e)?(i&&n.push({op:"test",path:r+"/"+_(f),value:A(c)}),n.push({op:"remove",path:r+"/"+_(f)}),s=!0):(i&&n.push({op:"test",path:r,value:t}),n.push({op:"replace",path:r,value:e}),!0);else {var l=e[f];"object"==_typeof$1(c)&&null!=c&&"object"==_typeof$1(l)&&null!=l&&Array.isArray(c)===Array.isArray(l)?K(c,l,n,r+"/"+_(f),i):c!==l&&(i&&n.push({op:"test",path:r+"/"+_(f),value:A(c)}),n.push({op:"replace",path:r+"/"+_(f),value:A(l)}));}}if(s||o.length!=a.length)for(u=0;u<o.length;u++){var f;E(t,f=o[u])||void 0===e[f]||n.push({op:"add",path:r+"/"+_(f),value:A(e[f])});}}}function X(t,e,n){void 0===n&&(n=!1);var r=[];return K(t,e,r,"",n),r;}Object.assign({},r,i,{JsonPatchError:F,deepClone:A,escapePathComponent:_,unescapePathComponent:S});var Y=n(133),J=n.n(Y),Q=n(179),Z=n(1),tt=n(63),et=n(44);function nt(t){var e=t||Z.y,n=[],r={};return n.add=function(t){var i=e(t);return r[i]||(r[i]=1,n.push(t)),n;},n.remove=function(t){var i=e(t);if(r[i]){r[i]=0;var _e10=n.indexOf(t);_e10>=0&&n.splice(_e10,1);}return n;},n;}function rt(_x8,_x9){return _rt.apply(this,arguments);}function _rt(){_rt=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee23(t,e){return regeneratorRuntime.wrap(function _callee23$(_context28){while(1){switch(_context28.prev=_context28.next){case 0:_context28.prev=0;_context28.next=3;return e(t);case 3:_context28.next=8;break;case 5:_context28.prev=5;_context28.t0=_context28["catch"](0);t.error(_context28.t0);case 8:case"end":return _context28.stop();}}},_callee23,null,[[0,5]]);}));return _rt.apply(this,arguments);}var it=Symbol("vega_id");var ot=1;function at(t){return !(!t||!st(t));}function st(t){return t[it];}function ut(t,e){return t[it]=e,t;}function ct(t){var e=t===Object(t)?t:{data:t};return st(e)?e:ut(e,ot++);}function lt(t){return ft(t,ct({}));}function ft(t,e){for(var _n15 in t){e[_n15]=t[_n15];}return e;}function ht(t,e){return ut(e,st(t));}function dt(t,e){return t?e?function(n,r){return t(n,r)||st(e(n))-st(e(r));}:function(e,n){return t(e,n)||st(e)-st(n);}:null;}function pt(t){return t&&t.constructor===mt;}function mt(){var t=[],e=[],n=[],r=[],i=[];var o=null,a=!1;return {constructor:mt,insert:function insert(e){var n=Object(Z.i)(e),r=n.length;for(var _e11=0;_e11<r;++_e11){t.push(n[_e11]);}return this;},remove:function remove(t){var n=Object(Z.E)(t)?r:e,i=Object(Z.i)(t),o=i.length;for(var _t13=0;_t13<o;++_t13){n.push(i[_t13]);}return this;},modify:function modify(t,e,r){var o={field:e,value:Object(Z.m)(r)};return Object(Z.E)(t)?(o.filter=t,i.push(o)):(o.tuple=t,n.push(o)),this;},encode:function encode(t,e){return Object(Z.E)(t)?i.push({filter:t,field:e}):n.push({tuple:t,field:e}),this;},clean:function clean(t){return o=t,this;},reflow:function reflow(){return a=!0,this;},pulse:function pulse(s,u){var c={},l={};var f,h,d,p,m,g;for(f=0,h=u.length;f<h;++f){c[st(u[f])]=1;}for(f=0,h=e.length;f<h;++f){c[st(m=e[f])]=-1;}for(f=0,h=r.length;f<h;++f){p=r[f],u.forEach(function(t){p(t)&&(c[st(t)]=-1);});}for(f=0,h=t.length;f<h;++f){g=st(m=t[f]),c[g]?c[g]=1:s.add.push(ct(t[f]));}for(f=0,h=u.length;f<h;++f){m=u[f],c[st(m)]<0&&s.rem.push(m);}function v(t,e,n){n?t[e]=n(t):s.encode=e,a||(l[st(t)]=t);}for(f=0,h=n.length;f<h;++f){m=(d=n[f]).tuple,p=d.field,(g=c[st(m)])>0&&(v(m,p,d.value),s.modifies(p));}for(f=0,h=i.length;f<h;++f){d=i[f],p=d.filter,u.forEach(function(t){p(t)&&c[st(t)]>0&&v(t,d.field,d.value);}),s.modifies(d.field);}if(a)s.mod=e.length||r.length?u.filter(function(t){return c[st(t)]>0;}):u.slice();else for(g in l){s.mod.push(l[g]);}return (o||null==o&&(e.length||r.length))&&s.clean(!0),s;}};}var gt="_:mod:_";function vt(){Object.defineProperty(this,gt,{writable:!0,value:{}});}vt.prototype={set:function set(t,e,n,r){var i=this,o=i[t],a=i[gt];return null!=e&&e>=0?(o[e]!==n||r)&&(o[e]=n,a[e+":"+t]=-1,a[t]=-1):(o!==n||r)&&(i[t]=n,a[t]=Object(Z.B)(n)?1+n.length:-1),i;},modified:function modified(t,e){var n=this[gt];if(!arguments.length){for(var _t14 in n){if(n[_t14])return !0;}return !1;}if(Object(Z.B)(t)){for(var _e12=0;_e12<t.length;++_e12){if(n[t[_e12]])return !0;}return !1;}return null!=e&&e>=0?e+1<n[t]||!!n[e+":"+t]:!!n[t];},clear:function clear(){return this[gt]={},this;}};var yt=0;var bt=new vt();function xt(t,e,n,r){this.id=++yt,this.value=t,this.stamp=-1,this.rank=-1,this.qrank=-1,this.flags=0,e&&(this._update=e),n&&this.parameters(n,r);}function wt(t){return function(e){var n=this.flags;return 0===arguments.length?!!(n&t):(this.flags=e?n|t:n&~t,this);};}xt.prototype={targets:function targets(){return this._targets||(this._targets=nt(Z.x));},set:function set(t){return this.value!==t?(this.value=t,1):0;},skip:wt(1),modified:wt(2),parameters:function parameters(t,e,n){var _this3=this;e=!1!==e;var r=this._argval=this._argval||new vt(),i=this._argops=this._argops||[],o=[];var a,s,u,c;var l=function l(t,n,a){a instanceof xt?(a!==_this3&&(e&&a.targets().add(_this3),o.push(a)),i.push({op:a,name:t,index:n})):r.set(t,n,a);};for(a in t){if(s=t[a],"pulse"===a)Object(Z.i)(s).forEach(function(t){t instanceof xt?t!==_this3&&(t.targets().add(_this3),o.push(t)):Object(Z.o)("Pulse parameters must be operator instances.");}),this.source=s;else if(Object(Z.B)(s))for(r.set(a,-1,Array(u=s.length)),c=0;c<u;++c){l(a,c,s[c]);}else l(a,-1,s);}return this.marshall().clear(),n&&(i.initonly=!0),o;},marshall:function marshall(t){var e=this._argval||bt,n=this._argops;var r,i,o,a;if(n){var _s6=n.length;for(i=0;i<_s6;++i){a=(o=(r=n[i]).op).modified()&&o.stamp===t,e.set(r.name,r.index,o.value,a);}if(n.initonly){for(i=0;i<_s6;++i){(r=n[i]).op.targets().remove(this);}this._argops=null,this._update=null;}}return e;},detach:function detach(){var t=this._argops;var e,n,i;if(t)for(e=0,n=t.length;e<n;++e){(i=(t[e]).op)._targets&&i._targets.remove(this);}this.pulse=null,this.source=null;},evaluate:function evaluate(t){var e=this._update;if(e){var _n16=this.marshall(t.stamp),_r18=e.call(this,_n16,t);if(_n16.clear(),_r18!==this.value)this.value=_r18;else if(!this.modified())return t.StopPropagation;}},run:function run(t){if(t.stamp<this.stamp)return t.StopPropagation;var e;return this.skip()?(this.skip(!1),e=0):e=this.evaluate(t),this.pulse=e||t;}};var kt=0;function Et(t,e,n){this.id=++kt,this.value=null,n&&(this.receive=n),t&&(this._filter=t),e&&(this._apply=e);}function Ct(t,e,n){return new Et(t,e,n);}Et.prototype={_filter:Z.Ia,_apply:Z.y,targets:function targets(){return this._targets||(this._targets=nt(Z.x));},consume:function consume(t){return arguments.length?(this._consume=!!t,this):!!this._consume;},receive:function receive(t){if(this._filter(t)){var _e13=this.value=this._apply(t),_n17=this._targets,_r19=_n17?_n17.length:0;for(var _t15=0;_t15<_r19;++_t15){_n17[_t15].receive(_e13);}this._consume&&(t.preventDefault(),t.stopPropagation());}},filter:function filter(t){var e=Ct(t);return this.targets().add(e),e;},apply:function apply(t){var e=Ct(null,t);return this.targets().add(e),e;},merge:function merge(){var t=Ct();this.targets().add(t);for(var _e14=0,_n18=arguments.length;_e14<_n18;++_e14){arguments[_e14].targets().add(t);}return t;},throttle:function throttle(t){var e=-1;return this.filter(function(){var n=Date.now();return n-e>t?(e=n,1):0;});},debounce:function debounce(t){var e=Ct();return this.targets().add(Ct(null,null,Object(Z.n)(t,function(t){var n=t.dataflow;e.receive(t),n&&n.run&&n.run();}))),e;},between:function between(t,e){var n=!1;return t.targets().add(Ct(null,null,function(){return n=!0;})),e.targets().add(Ct(null,null,function(){return n=!1;})),this.filter(function(){return n;});},detach:function detach(){this._filter=Z.Ia,this._targets=null;}};var At={skip:!0};function Ot(t,e,n,r,i,o){var a=Object(Z.p)({},o,At);var s,u;Object(Z.E)(n)||(n=Object(Z.m)(n)),void 0===r?s=function s(e){return t.touch(n(e));}:Object(Z.E)(r)?(u=new xt(null,r,i,!1),s=function s(e){u.evaluate(e);var r=n(e),i=u.value;pt(i)?t.pulse(r,i,o):t.update(r,i,a);}):s=function s(e){return t.update(n(e),r,a);},e.apply(s);}function _t(t,e,n,r,i,o){if(void 0===r)e.targets().add(n);else {var _a10=o||{},_s7=new xt(null,function(t,e){return e=Object(Z.E)(e)?e:Object(Z.m)(e),t?function(n,r){var i=e(n,r);return t.skip()||(t.skip(i!==this.value).value=i),i;}:e;}(n,r),i,!1);_s7.modified(_a10.force),_s7.rank=e.rank,e.targets().add(_s7),n&&(_s7.skip(!0),_s7.value=n.value,_s7.targets().add(n),t.connect(n,[_s7]));}}var St={};function Dt(t,e,n){this.dataflow=t,this.stamp=null==e?-1:e,this.add=[],this.rem=[],this.mod=[],this.fields=null,this.encode=n||null;}function Ft(t,e){var n=[];return Object(Z.Ka)(t,e,function(t){return n.push(t);}),n;}function Tt(t,e){var n={};return t.visit(e,function(t){n[st(t)]=1;}),function(t){return n[st(t)]?null:t;};}function Nt(t,e){return t?function(n,r){return t(n,r)&&e(n,r);}:e;}function It(t,e,n,r){var i=this,o=n.length;var a=0;this.dataflow=t,this.stamp=e,this.fields=null,this.encode=r||null,this.pulses=n;for(var _t16=0;_t16<o;++_t16){var _r20=n[_t16];if(_r20.stamp===e){if(_r20.fields){var _t17=i.fields||(i.fields={});for(var _e15 in _r20.fields){_t17[_e15]=1;}}_r20.changed(i.ADD)&&(a|=i.ADD),_r20.changed(i.REM)&&(a|=i.REM),_r20.changed(i.MOD)&&(a|=i.MOD);}}this.changes=a;}function Rt(t){return t.error("Dataflow already running. Use runAsync() to chain invocations."),t;}Dt.prototype={StopPropagation:St,ADD:1,REM:2,MOD:4,ADD_REM:3,ADD_MOD:5,ALL:7,REFLOW:8,SOURCE:16,NO_SOURCE:32,NO_FIELDS:64,fork:function fork(t){return new Dt(this.dataflow).init(this,t);},clone:function clone(){var t=this.fork(7);return t.add=t.add.slice(),t.rem=t.rem.slice(),t.mod=t.mod.slice(),t.source&&(t.source=t.source.slice()),t.materialize(23);},addAll:function addAll(){var t=this;return !t.source||t.add===t.rem||!t.rem.length&&t.source.length===t.add.length?t:((t=new Dt(this.dataflow).init(this)).add=t.source,t.rem=[],t);},init:function init(t,e){var n=this;return n.stamp=t.stamp,n.encode=t.encode,!t.fields||64&e||(n.fields=t.fields),1&e?(n.addF=t.addF,n.add=t.add):(n.addF=null,n.add=[]),2&e?(n.remF=t.remF,n.rem=t.rem):(n.remF=null,n.rem=[]),4&e?(n.modF=t.modF,n.mod=t.mod):(n.modF=null,n.mod=[]),32&e?(n.srcF=null,n.source=null):(n.srcF=t.srcF,n.source=t.source,t.cleans&&(n.cleans=t.cleans)),n;},runAfter:function runAfter(t){this.dataflow.runAfter(t);},changed:function changed(t){var e=t||7;return 1&e&&this.add.length||2&e&&this.rem.length||4&e&&this.mod.length;},reflow:function reflow(t){if(t)return this.fork(7).reflow();var e=this.add.length,n=this.source&&this.source.length;return n&&n!==e&&(this.mod=this.source,e&&this.filter(4,Tt(this,1))),this;},clean:function clean(t){return arguments.length?(this.cleans=!!t,this):this.cleans;},modifies:function modifies(t){var e=this.fields||(this.fields={});return Object(Z.B)(t)?t.forEach(function(t){return e[t]=!0;}):e[t]=!0,this;},modified:function modified(t,e){var n=this.fields;return !(!e&&!this.mod.length||!n)&&(arguments.length?Object(Z.B)(t)?t.some(function(t){return n[t];}):n[t]:!!n);},filter:function filter(t,e){var n=this;return 1&t&&(n.addF=Nt(n.addF,e)),2&t&&(n.remF=Nt(n.remF,e)),4&t&&(n.modF=Nt(n.modF,e)),16&t&&(n.srcF=Nt(n.srcF,e)),n;},materialize:function materialize(t){var e=this;return 1&(t=t||7)&&e.addF&&(e.add=Ft(e.add,e.addF),e.addF=null),2&t&&e.remF&&(e.rem=Ft(e.rem,e.remF),e.remF=null),4&t&&e.modF&&(e.mod=Ft(e.mod,e.modF),e.modF=null),16&t&&e.srcF&&(e.source=e.source.filter(e.srcF),e.srcF=null),e;},visit:function visit(t,e){var n=this,r=e;if(16&t)return Object(Z.Ka)(n.source,n.srcF,r),n;1&t&&Object(Z.Ka)(n.add,n.addF,r),2&t&&Object(Z.Ka)(n.rem,n.remF,r),4&t&&Object(Z.Ka)(n.mod,n.modF,r);var i=n.source;if(8&t&&i){var _t18=n.add.length+n.mod.length;_t18===i.length||(_t18?Object(Z.Ka)(i,Tt(n,5),r):Object(Z.Ka)(i,n.srcF,r));}return n;}},Object(Z.z)(It,Dt,{fork:function fork(t){var e=new Dt(this.dataflow).init(this,t&this.NO_FIELDS);return void 0!==t&&(t&e.ADD&&this.visit(e.ADD,function(t){return e.add.push(t);}),t&e.REM&&this.visit(e.REM,function(t){return e.rem.push(t);}),t&e.MOD&&this.visit(e.MOD,function(t){return e.mod.push(t);})),e;},changed:function changed(t){return this.changes&t;},modified:function modified(t){var e=this,n=e.fields;return n&&e.changes&e.MOD?Object(Z.B)(t)?t.some(function(t){return n[t];}):n[t]:0;},filter:function filter(){Object(Z.o)("MultiPulse does not support filtering.");},materialize:function materialize(){Object(Z.o)("MultiPulse does not support materialization.");},visit:function visit(t,e){var n=this,r=n.pulses,i=r.length;var o=0;if(t&n.SOURCE)for(;o<i;++o){r[o].visit(t,e);}else for(;o<i;++o){r[o].stamp===n.stamp&&r[o].visit(t,e);}return n;}});var Mt={skip:!1,force:!1};function jt(t){var e=[];return {clear:function clear(){return e=[];},size:function size(){return e.length;},peek:function peek(){return e[0];},push:function push(n){return e.push(n),Bt(e,0,e.length-1,t);},pop:function pop(){var n=e.pop();var r;return e.length?(r=e[0],e[0]=n,function(t,e,n){var r=e,i=t.length,o=t[e];var a,s=1+(e<<1);for(;s<i;){(a=s+1)<i&&n(t[s],t[a])>=0&&(s=a),t[e]=t[s],s=1+((e=s)<<1);}t[e]=o,Bt(t,r,e,n);}(e,0,t)):r=n,r;}};}function Bt(t,e,n,r){var i,o;var a=t[n];for(;n>e&&r(a,i=t[o=n-1>>1])<0;){t[n]=i,n=o;}return t[n]=a;}function Pt(){this.logger(Object(Z.M)()),this.logLevel(Z.b),this._clock=0,this._rank=0,this._locale=Object(et.a)();try{this._loader=Object(tt.e)();}catch(t){}this._touched=nt(Z.x),this._input={},this._pulse=null,this._heap=jt(function(t,e){return t.qrank-e.qrank;}),this._postrun=[];}function Lt(t){return function(){return this._log[t].apply(this,arguments);};}function zt(t,e){xt.call(this,t,null,e);}Pt.prototype={stamp:function stamp(){return this._clock;},loader:function loader(t){return arguments.length?(this._loader=t,this):this._loader;},locale:function locale(t){return arguments.length?(this._locale=t,this):this._locale;},logger:function logger(t){return arguments.length?(this._log=t,this):this._log;},error:Lt("error"),warn:Lt("warn"),info:Lt("info"),debug:Lt("debug"),logLevel:Lt("level"),cleanThreshold:1e4,add:function add(t,e,n,r){var i,o=1;return t instanceof xt?i=t:t&&t.prototype instanceof xt?i=new t():Object(Z.E)(t)?i=new xt(null,t):(o=0,i=new xt(t,e)),this.rank(i),o&&(r=n,n=e),n&&this.connect(i,i.parameters(n,r)),this.touch(i),i;},connect:function connect(t,e){var n=t.rank,r=e.length;for(var _i11=0;_i11<r;++_i11){if(n<e[_i11].rank)return void this.rerank(t);}},rank:function rank(t){t.rank=++this._rank;},rerank:function rerank(t){var e=[t];var n,r,i;for(;e.length;){if(this.rank(n=e.pop()),r=n._targets)for(i=r.length;--i>=0;){e.push(n=r[i]),n===t&&Object(Z.o)("Cycle detected in dataflow graph.");}}},pulse:function pulse(t,e,n){this.touch(t,n||Mt);var r=new Dt(this,this._clock+(this._pulse?0:1)),i=t.pulse&&t.pulse.source||[];return r.target=t,this._input[t.id]=e.pulse(r,i),this;},touch:function touch(t,e){var n=e||Mt;return this._pulse?this._enqueue(t):this._touched.add(t),n.skip&&t.skip(!0),this;},update:function update(t,e,n){var r=n||Mt;return (t.set(e)||r.force)&&this.touch(t,r),this;},changeset:mt,ingest:function ingest(t,e,n){return e=this.parse(e,n),this.pulse(t,this.changeset().insert(e));},parse:function parse(t,e){var n=this.locale();return Object(tt.f)(t,e,n.timeParse,n.utcParse);},preload:function(){var _preload=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee7(t,e,n){var r,i,o;return regeneratorRuntime.wrap(function _callee7$(_context7){while(1){switch(_context7.prev=_context7.next){case 0:r=this,i=r._pending||function(t){var e;var n=new Promise(function(t){return e=t;});return n.requests=0,n.done=function(){0==--n.requests&&(t._pending=null,e(t));},t._pending=n;}(r);i.requests+=1;_context7.next=4;return r.request(e,n);case 4:o=_context7.sent;return _context7.abrupt("return",(r.pulse(t,r.changeset().remove(Z.Ia).insert(o.data||[])),i.done(),o));case 6:case"end":return _context7.stop();}}},_callee7,this);}));function preload(_x10,_x11,_x12){return _preload.apply(this,arguments);}return preload;}(),request:function(){var _request=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee8(t,e){var n,r,i;return regeneratorRuntime.wrap(function _callee8$(_context8){while(1){switch(_context8.prev=_context8.next){case 0:n=this;i=0;_context8.prev=2;_context8.next=5;return n.loader().load(t,{context:"dataflow",response:Object(tt.g)(e&&e.type)});case 5:r=_context8.sent;try{r=n.parse(r,e);}catch(e){i=-2,n.warn("Data ingestion failed",t,e);}_context8.next=12;break;case 9:_context8.prev=9;_context8.t0=_context8["catch"](2);i=-1,n.warn("Loading failed",t,_context8.t0);case 12:return _context8.abrupt("return",{data:r,status:i});case 13:case"end":return _context8.stop();}}},_callee8,this,[[2,9]]);}));function request(_x13,_x14){return _request.apply(this,arguments);}return request;}(),events:function events(t,e,n,r){var i=this,o=Ct(n,r),a=function a(t){t.dataflow=i;try{o.receive(t);}catch(t){i.error(t);}finally{i.run();}};var s;var u=(s="string"==typeof t&&"undefined"!=typeof document?document.querySelectorAll(t):Object(Z.i)(t)).length;for(var _t19=0;_t19<u;++_t19){s[_t19].addEventListener(e,a);}return o;},on:function on(t,e,n,r,i){return (t instanceof xt?_t:Ot)(this,t,e,n,r,i),this;},evaluate:function(){var _evaluate=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee9(t,e,n){var r,i,o,a,s,u,c,_t20,_e16;return regeneratorRuntime.wrap(function _callee9$(_context9){while(1){switch(_context9.prev=_context9.next){case 0:r=this,i=[];if(!r._pulse){_context9.next=3;break;}return _context9.abrupt("return",Rt(r));case 3:_context9.t0=r._pending;if(!_context9.t0){_context9.next=7;break;}_context9.next=7;return r._pending;case 7:_context9.t1=e;if(!_context9.t1){_context9.next=11;break;}_context9.next=11;return rt(r,e);case 11:if(r._touched.length){_context9.next=13;break;}return _context9.abrupt("return",(r.debug("Dataflow invoked, but nothing to do."),r));case 13:o=++r._clock;r._pulse=new Dt(r,o,t),r._touched.forEach(function(t){return r._enqueue(t,!0);}),r._touched=nt(Z.x);c=0;_context9.prev=16;case 17:if(!(r._heap.size()>0)){_context9.next=33;break;}if(!((a=r._heap.pop()).rank===a.qrank)){_context9.next=30;break;}if(!(s=a.run(r._getPulse(a,t))).then){_context9.next=25;break;}_context9.next=22;return s;case 22:s=_context9.sent;_context9.next=26;break;case 25:s.async&&(i.push(s.async),s=St);case 26:s!==St&&a._targets&&a._targets.forEach(function(t){return r._enqueue(t);});++c;_context9.next=31;break;case 30:r._enqueue(a,!0);case 31:_context9.next=17;break;case 33:_context9.next=38;break;case 35:_context9.prev=35;_context9.t2=_context9["catch"](16);r._heap.clear(),u=_context9.t2;case 38:if(!(r._input={},r._pulse=null,r.debug("Pulse ".concat(o,": ").concat(c," operators")),u&&(r._postrun=[],r.error(u)),r._postrun.length)){_context9.next=48;break;}_t20=r._postrun.sort(function(t,e){return e.priority-t.priority;});r._postrun=[];_e16=0;case 42:if(!(_e16<_t20.length)){_context9.next=48;break;}_context9.next=45;return rt(r,_t20[_e16].callback);case 45:++_e16;_context9.next=42;break;case 48:_context9.t3=n;if(!_context9.t3){_context9.next=52;break;}_context9.next=52;return rt(r,n);case 52:i.length&&Promise.all(i).then(function(t){return r.runAsync(null,function(){t.forEach(function(t){try{t(r);}catch(t){r.error(t);}});});});return _context9.abrupt("return",r);case 54:case"end":return _context9.stop();}}},_callee9,this,[[16,35]]);}));function evaluate(_x15,_x16,_x17){return _evaluate.apply(this,arguments);}return evaluate;}(),run:function run(t,e,n){return this._pulse?Rt(this):(this.evaluate(t,e,n),this);},runAsync:function(){var _runAsync=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee10(t,e,n){var _this4=this;var r;return regeneratorRuntime.wrap(function _callee10$(_context10){while(1){switch(_context10.prev=_context10.next){case 0:if(!this._running){_context10.next=5;break;}_context10.next=3;return this._running;case 3:_context10.next=0;break;case 5:r=function r(){return _this4._running=null;};return _context10.abrupt("return",((this._running=this.evaluate(t,e,n)).then(r,r),this._running));case 7:case"end":return _context10.stop();}}},_callee10,this);}));function runAsync(_x18,_x19,_x20){return _runAsync.apply(this,arguments);}return runAsync;}(),runAfter:function runAfter(t,e,n){if(this._pulse||e)this._postrun.push({priority:n||0,callback:t});else try{t(this);}catch(t){this.error(t);}},_enqueue:function _enqueue(t,e){var n=t.stamp<this._clock;n&&(t.stamp=this._clock),(n||e)&&(t.qrank=t.rank,this._heap.push(t));},_getPulse:function _getPulse(t,e){var n=t.source,r=this._clock;return n&&Object(Z.B)(n)?new It(this,r,n.map(function(t){return t.pulse;}),e):this._input[t.id]||function(t,e){return e&&e.stamp===t.stamp?e:(t=t.fork(),e&&e!==St&&(t.source=e.source),t);}(this._pulse,n&&n.pulse);}},Object(Z.z)(zt,xt,{run:function run(t){var _this5=this;if(t.stamp<this.stamp)return t.StopPropagation;var e;return this.skip()?this.skip(!1):e=this.evaluate(t),(e=e||t).then?e=e.then(function(t){return _this5.pulse=t;}):e!==t.StopPropagation&&(this.pulse=e),e;},evaluate:function evaluate(t){var e=this.marshall(t.stamp),n=this.transform(e,t);return e.clear(),n;},transform:function transform(){}});var Ut={};function Wt(t){var e=Vt(t);return e&&e.Definition||null;}function Vt(t){return t=t&&t.toLowerCase(),Object(Z.w)(Ut,t)?Ut[t]:null;}var qt=n(87);function $t(t,e){var n;if(void 0===e){var _iterator3=_createForOfIteratorHelper(t),_step3;try{for(_iterator3.s();!(_step3=_iterator3.n()).done;){var _e17=_step3.value;null!=_e17&&(n<_e17||void 0===n&&_e17>=_e17)&&(n=_e17);}}catch(err){_iterator3.e(err);}finally{_iterator3.f();}}else {var _r21=-1;var _iterator4=_createForOfIteratorHelper(t),_step4;try{for(_iterator4.s();!(_step4=_iterator4.n()).done;){var _i12=_step4.value;null!=(_i12=e(_i12,++_r21,t))&&(n<_i12||void 0===n&&_i12>=_i12)&&(n=_i12);}}catch(err){_iterator4.e(err);}finally{_iterator4.f();}}return n;}function Ht(t,e){var n;if(void 0===e){var _iterator5=_createForOfIteratorHelper(t),_step5;try{for(_iterator5.s();!(_step5=_iterator5.n()).done;){var _e18=_step5.value;null!=_e18&&(n>_e18||void 0===n&&_e18>=_e18)&&(n=_e18);}}catch(err){_iterator5.e(err);}finally{_iterator5.f();}}else {var _r22=-1;var _iterator6=_createForOfIteratorHelper(t),_step6;try{for(_iterator6.s();!(_step6=_iterator6.n()).done;){var _i13=_step6.value;null!=(_i13=e(_i13,++_r22,t))&&(n>_i13||void 0===n&&_i13>=_i13)&&(n=_i13);}}catch(err){_iterator6.e(err);}finally{_iterator6.f();}}return n;}function Gt(t,e,n){var r=t[e];t[e]=t[n],t[n]=r;}var Kt=function Kt(t){return null===t?NaN:+t;};function Xt(t,e,n){if(r=(t=Float64Array.from(/*#__PURE__*/regeneratorRuntime.mark(function _callee11(t,e){var _iterator7,_step7,_e19,_n19,_iterator8,_step8,_r23;return regeneratorRuntime.wrap(function _callee11$(_context11){while(1){switch(_context11.prev=_context11.next){case 0:if(!(void 0===e)){_context11.next=22;break;}_iterator7=_createForOfIteratorHelper(t);_context11.prev=2;_iterator7.s();case 4:if((_step7=_iterator7.n()).done){_context11.next=12;break;}_e19=_step7.value;_context11.t0=null!=_e19&&(_e19=+_e19)>=_e19;if(!_context11.t0){_context11.next=10;break;}_context11.next=10;return _e19;case 10:_context11.next=4;break;case 12:_context11.next=17;break;case 14:_context11.prev=14;_context11.t1=_context11["catch"](2);_iterator7.e(_context11.t1);case 17:_context11.prev=17;_iterator7.f();return _context11.finish(17);case 20:_context11.next=42;break;case 22:_n19=-1;_iterator8=_createForOfIteratorHelper(t);_context11.prev=24;_iterator8.s();case 26:if((_step8=_iterator8.n()).done){_context11.next=34;break;}_r23=_step8.value;_context11.t2=null!=(_r23=e(_r23,++_n19,t))&&(_r23=+_r23)>=_r23;if(!_context11.t2){_context11.next=32;break;}_context11.next=32;return _r23;case 32:_context11.next=26;break;case 34:_context11.next=39;break;case 36:_context11.prev=36;_context11.t3=_context11["catch"](24);_iterator8.e(_context11.t3);case 39:_context11.prev=39;_iterator8.f();return _context11.finish(39);case 42:case"end":return _context11.stop();}}},_callee11,null,[[2,14,17,20],[24,36,39,42]]);})(t,n))).length){if((e=+e)<=0||r<2)return Ht(t);if(e>=1)return $t(t);var r,i=(r-1)*e,o=Math.floor(i),a=$t(function t(e,n){var r=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;var i=arguments.length>3&&arguments[3]!==undefined?arguments[3]:e.length-1;var o=arguments.length>4&&arguments[4]!==undefined?arguments[4]:qt.a;for(;i>r;){if(i-r>600){var _a12=i-r+1,_s9=n-r+1,_u5=Math.log(_a12),_c2=.5*Math.exp(2*_u5/3),_l2=.5*Math.sqrt(_u5*_c2*(_a12-_c2)/_a12)*(_s9-_a12/2<0?-1:1);t(e,n,Math.max(r,Math.floor(n-_s9*_c2/_a12+_l2)),Math.min(i,Math.floor(n+(_a12-_s9)*_c2/_a12+_l2)),o);}var _a11=e[n];var _s8=r,_u4=i;for(Gt(e,r,n),o(e[i],_a11)>0&&Gt(e,r,i);_s8<_u4;){for(Gt(e,_s8,_u4),++_s8,--_u4;o(e[_s8],_a11)<0;){++_s8;}for(;o(e[_u4],_a11)>0;){--_u4;}}0===o(e[r],_a11)?Gt(e,r,_u4):Gt(e,++_u4,i),_u4<=n&&(r=_u4+1),n<=_u4&&(i=_u4-1);}return e;}(t,o).subarray(0,o+1));return a+(Ht(t.subarray(o+1))-a)*(i-o);}}function Yt(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:Kt;if(r=t.length){if((e=+e)<=0||r<2)return +n(t[0],0,t);if(e>=1)return +n(t[r-1],r-1,t);var r,i=(r-1)*e,o=Math.floor(i),a=+n(t[o],o,t);return a+(+n(t[o+1],o+1,t)-a)*(i-o);}}var Jt=function Jt(t,e){return Xt(t,.5,e);};function Qt(t,e){var _iterator9,_step9,_e20,_n20,_iterator10,_step10,_r24;return regeneratorRuntime.wrap(function Qt$(_context12){while(1){switch(_context12.prev=_context12.next){case 0:if(!(null==e)){_context12.next=22;break;}_iterator9=_createForOfIteratorHelper(t);_context12.prev=2;_iterator9.s();case 4:if((_step9=_iterator9.n()).done){_context12.next=12;break;}_e20=_step9.value;_context12.t0=null!=_e20&&""!==_e20&&(_e20=+_e20)>=_e20;if(!_context12.t0){_context12.next=10;break;}_context12.next=10;return _e20;case 10:_context12.next=4;break;case 12:_context12.next=17;break;case 14:_context12.prev=14;_context12.t1=_context12["catch"](2);_iterator9.e(_context12.t1);case 17:_context12.prev=17;_iterator9.f();return _context12.finish(17);case 20:_context12.next=42;break;case 22:_n20=-1;_iterator10=_createForOfIteratorHelper(t);_context12.prev=24;_iterator10.s();case 26:if((_step10=_iterator10.n()).done){_context12.next=34;break;}_r24=_step10.value;_context12.t2=null!=(_r24=e(_r24,++_n20,t))&&""!==_r24&&(_r24=+_r24)>=_r24;if(!_context12.t2){_context12.next=32;break;}_context12.next=32;return _r24;case 32:_context12.next=26;break;case 34:_context12.next=39;break;case 36:_context12.prev=36;_context12.t3=_context12["catch"](24);_iterator10.e(_context12.t3);case 39:_context12.prev=39;_iterator10.f();return _context12.finish(39);case 42:case"end":return _context12.stop();}}},_marked,null,[[2,14,17,20],[24,36,39,42]]);}function Zt(t,e,n){var r=Float64Array.from(Qt(t,n));return r.sort(qt.a),e.map(function(t){return Yt(r,t);});}function te(t,e){return Zt(t,[.25,.5,.75],e);}function ee(t,e){var n=t.length,r=function(t,e){var n=function(t,e){var n,r=0,i=0,o=0;if(void 0===e){var _iterator11=_createForOfIteratorHelper(t),_step11;try{for(_iterator11.s();!(_step11=_iterator11.n()).done;){var _e21=_step11.value;null!=_e21&&(_e21=+_e21)>=_e21&&(o+=(n=_e21-i)*(_e21-(i+=n/++r)));}}catch(err){_iterator11.e(err);}finally{_iterator11.f();}}else {var _a13=-1;var _iterator12=_createForOfIteratorHelper(t),_step12;try{for(_iterator12.s();!(_step12=_iterator12.n()).done;){var _s10=_step12.value;null!=(_s10=e(_s10,++_a13,t))&&(_s10=+_s10)>=_s10&&(o+=(n=_s10-i)*(_s10-(i+=n/++r)));}}catch(err){_iterator12.e(err);}finally{_iterator12.f();}}if(r>1)return o/(r-1);}(t,e);return n?Math.sqrt(n):n;}(t,e),i=te(t,e),o=(i[2]-i[0])/1.34;return 1.06*(Math.min(r,o)||r||Math.abs(i[0])||1)*Math.pow(n,-.2);}function ne(t){var e=t.maxbins||20,n=t.base||10,r=Math.log(n),i=t.divide||[5,2];var o,a,s,u,c,l,f=t.extent[0],h=t.extent[1];var d=t.span||h-f||Math.abs(f)||1;if(t.step)o=t.step;else if(t.steps){for(u=d/e,c=0,l=t.steps.length;c<l&&t.steps[c]<u;++c){}o=t.steps[Math.max(0,c-1)];}else {for(a=Math.ceil(Math.log(e)/r),s=t.minstep||0,o=Math.max(s,Math.pow(n,Math.round(Math.log(d)/r)-a));Math.ceil(d/o)>e;){o*=n;}for(c=0,l=i.length;c<l;++c){(u=o/i[c])>=s&&d/u<=e&&(o=u);}}var p=(u=Math.log(o))>=0?0:1+~~(-u/r),m=Math.pow(n,-p-1);return (t.nice||void 0===t.nice)&&(f=f<(u=Math.floor(f/o+m)*o)?u-o:u,h=Math.ceil(h/o)*o),{start:f,stop:h===f?f+o:h,step:o};}var re=Math.random;function ie(t){re=t;}function oe(t,e,n,r){if(!t.length)return [void 0,void 0];var i=Float64Array.from(Qt(t,r)),o=i.length,a=e;var s,u,c,l;for(c=0,l=Array(a);c<a;++c){for(s=0,u=0;u<o;++u){s+=i[~~(re()*o)];}l[c]=s/o;}return l.sort(qt.a),[Xt(l,n/2),Xt(l,1-n/2)];}function ae(t,e,n,r){r=r||function(t){return t;};var i=t.length,o=new Float64Array(i);var a,s=0,u=1,c=r(t[0]),l=c,f=c+e;for(;u<i;++u){if((a=r(t[u]))>=f){for(l=(c+l)/2;s<u;++s){o[s]=l;}f=a+e,c=a;}l=a;}for(l=(c+l)/2;s<u;++s){o[s]=l;}return n?function(t,e){var n=t.length;var r,i,o=0,a=1;for(;t[o]===t[a];){++a;}for(;a<n;){for(r=a+1;t[a]===t[r];){++r;}if(t[a]-t[a-1]<e){for(i=a+(o+r-a-a>>1);i<a;){t[i++]=t[a];}for(;i>a;){t[i--]=t[o];}}o=a,a=r;}return t;}(o,e+e/4):o;}function se(t){return function(){return (t=(1103515245*t+12345)%2147483647)/2147483647;};}function ue(t,e){var n,r,i;null==e&&(e=t,t=0);var o={min:function min(t){return arguments.length?(i=r-(n=t||0),o):n;},max:function max(t){return arguments.length?(i=(r=t||0)-n,o):r;},sample:function sample(){return n+Math.floor(i*re());},pdf:function pdf(t){return t===Math.floor(t)&&t>=n&&t<r?1/i:0;},cdf:function cdf(t){var e=Math.floor(t);return e<n?0:e>=r?1:(e-n+1)/i;},icdf:function icdf(t){return t>=0&&t<=1?n-1+Math.floor(t*i):NaN;}};return o.min(t).max(e);}var ce=Math.sqrt(2*Math.PI),le=Math.SQRT2;var fe=NaN;function he(t,e){t=t||0,e=null==e?1:e;var n,r,i=0,o=0;if(fe==fe)i=fe,fe=NaN;else {do{n=(i=2*re()-1)*i+(o=2*re()-1)*o;}while(0===n||n>1);i*=r=Math.sqrt(-2*Math.log(n)/n),fe=o*r;}return t+i*e;}function de(t,e,n){n=null==n?1:n;var r=(t-(e||0))/n;return Math.exp(-.5*r*r)/(n*ce);}function pe(t,e,n){var r=(t-(e=e||0))/(n=null==n?1:n),i=Math.abs(r);var o;if(i>37)o=0;else {var _t21=Math.exp(-i*i/2);i<7.07106781186547?(o=_t21*((((((.0352624965998911*i+.700383064443688)*i+6.37396220353165)*i+33.912866078383)*i+112.079291497871)*i+221.213596169931)*i+220.206867912376),o/=((((((.0883883476483184*i+1.75566716318264)*i+16.064177579207)*i+86.7807322029461)*i+296.564248779674)*i+637.333633378831)*i+793.826512519948)*i+440.413735824752):o=_t21/(i+1/(i+2/(i+3/(i+4/(i+.65)))))/2.506628274631;}return r>0?1-o:o;}function me(t,e,n){return t<0||t>1?NaN:(e||0)+(null==n?1:n)*le*function(t){var e,n=-Math.log((1-t)*(1+t));n<6.25?e=1.6536545626831027+(e=.24015818242558962+(e=(e=(e=.00018673420803405714+(e=(e=(e=4.2347877827932404e-7+(e=(e=(e=1.0512122733215323e-9+(e=(e=(e=2.6335093153082323e-12+(e=(e=(e=6.637638134358324e-15+(e=2.0972767875968562e-17+(e=(e=1.1157877678025181e-17+(e=1.28584807152564e-18+(e=(e=-3.64441206401782e-21)*(n-=3.125)-1.6850591381820166e-19)*n)*n)*n-1.333171662854621e-16)*n)*n)*n-4.054566272975207e-14)*n-8.151934197605472e-14)*n)*n-1.2975133253453532e-11)*n-5.415412054294628e-11)*n)*n-4.112633980346984e-9)*n-2.9070369957882005e-8)*n)*n-13654692000834679e-22)*n-13882523362786469e-21)*n)*n-.000740702534166267)*n-.006033670871430149)*n)*n:n<16?(n=Math.sqrt(n)-3.25,e=3.0838856104922208+(e=1.0052589676941592+(e=.005370914553590064+(e=(e=.002491442096107851+(e=(e=.0009532893797373805+(e=(e=24031110387097894e-21+(e=6828485145957318e-20+(e=(e=12475304481671779e-21+(e=29234449089955446e-22+(e=(e=15027403968909828e-22+(e=1.8239629214389228e-8+(e=(e=9.075656193888539e-8+(e=2.2137376921775787e-9)*n)*n-2.7517406297064545e-7)*n)*n)*n-4013867526981546e-21)*n)*n)*n-47318229009055734e-21)*n)*n)*n-.0003550375203628475)*n)*n-.0016882755560235047)*n)*n-.003751208507569241)*n)*n)*n):Number.isFinite(n)?(n=Math.sqrt(n)-5,e=4.849906401408584+(e=1.0103004648645344+(e=(e=(e=7599527703001776e-20+(e=(e=4526062597223154e-21+(e=(e=2.2900482228026655e-7+(e=(e=2.914795345090108e-8+(e=(e=7.61570120807834e-9+(e=(e=1.5076572693500548e-9+(e=(e=-2.7109920616438573e-11)*n-2.555641816996525e-10)*n)*n-3.789465440126737e-9)*n)*n-1.496002662714924e-8)*n)*n-6.771199775845234e-8)*n)*n-9.9298272942317e-7)*n)*n-1968177810553167e-20)*n)*n-.00021503011930044477)*n-.00013871931833623122)*n)*n):e=1/0;return e*t;}(2*t-1);}function ge(t,e){var n,r;var i={mean:function mean(t){return arguments.length?(n=t||0,i):n;},stdev:function stdev(t){return arguments.length?(r=null==t?1:t,i):r;},sample:function sample(){return he(n,r);},pdf:function pdf(t){return de(t,n,r);},cdf:function cdf(t){return pe(t,n,r);},icdf:function icdf(t){return me(t,n,r);}};return i.mean(t).stdev(e);}function ve(t,e){var n=ge();var r=0;var i={data:function data(n){return arguments.length?(t=n,r=n?n.length:0,i.bandwidth(e)):t;},bandwidth:function bandwidth(n){return arguments.length?(!(e=n)&&t&&(e=ee(t)),i):e;},sample:function sample(){return t[~~(re()*r)]+e*n.sample();},pdf:function pdf(i){var o=0,a=0;for(;a<r;++a){o+=n.pdf((i-t[a])/e);}return o/e/r;},cdf:function cdf(i){var o=0,a=0;for(;a<r;++a){o+=n.cdf((i-t[a])/e);}return o/r;},icdf:function icdf(){throw Error("KDE icdf not supported.");}};return i.data(t);}function ye(t,e){return t=t||0,e=null==e?1:e,Math.exp(t+he()*e);}function be(t,e,n){if(t<=0)return 0;e=e||0,n=null==n?1:n;var r=(Math.log(t)-e)/n;return Math.exp(-.5*r*r)/(n*ce*t);}function xe(t,e,n){return pe(Math.log(t),e,n);}function we(t,e,n){return Math.exp(me(t,e,n));}function ke(t,e){var n,r;var i={mean:function mean(t){return arguments.length?(n=t||0,i):n;},stdev:function stdev(t){return arguments.length?(r=null==t?1:t,i):r;},sample:function sample(){return ye(n,r);},pdf:function pdf(t){return be(t,n,r);},cdf:function cdf(t){return xe(t,n,r);},icdf:function icdf(t){return we(t,n,r);}};return i.mean(t).stdev(e);}function Ee(t,e){var n,r=0;var i={weights:function weights(t){return arguments.length?(n=function(t){var e=[];var n,i=0;for(n=0;n<r;++n){i+=e[n]=null==t[n]?1:+t[n];}for(n=0;n<r;++n){e[n]/=i;}return e;}(e=t||[]),i):e;},distributions:function distributions(n){return arguments.length?(n?(r=n.length,t=n):(r=0,t=[]),i.weights(e)):t;},sample:function sample(){var e=re();var i=t[r-1],o=n[0],a=0;for(;a<r-1;o+=n[++a]){if(e<o){i=t[a];break;}}return i.sample();},pdf:function pdf(e){var i=0,o=0;for(;o<r;++o){i+=n[o]*t[o].pdf(e);}return i;},cdf:function cdf(e){var i=0,o=0;for(;o<r;++o){i+=n[o]*t[o].cdf(e);}return i;},icdf:function icdf(){throw Error("Mixture icdf not supported.");}};return i.distributions(t).weights(e);}function Ce(t,e){return null==e&&(e=null==t?1:t,t=0),t+(e-t)*re();}function Ae(t,e,n){return null==n&&(n=null==e?1:e,e=0),t>=e&&t<=n?1/(n-e):0;}function Oe(t,e,n){return null==n&&(n=null==e?1:e,e=0),t<e?0:t>n?1:(t-e)/(n-e);}function _e(t,e,n){return null==n&&(n=null==e?1:e,e=0),t>=0&&t<=1?e+t*(n-e):NaN;}function Se(t,e){var n,r;var i={min:function min(t){return arguments.length?(n=t||0,i):n;},max:function max(t){return arguments.length?(r=null==t?1:t,i):r;},sample:function sample(){return Ce(n,r);},pdf:function pdf(t){return Ae(t,n,r);},cdf:function cdf(t){return Oe(t,n,r);},icdf:function icdf(t){return _e(t,n,r);}};return null==e&&(e=null==t?1:t,t=0),i.min(t).max(e);}function De(t,e,n,r){var i=r-t*t,o=Math.abs(i)<1e-24?0:(n-t*e)/i;return [e-o*t,o];}function Fe(t,e,n,r){t=t.filter(function(t){var r=e(t),i=n(t);return null!=r&&(r=+r)>=r&&null!=i&&(i=+i)>=i;}),r&&t.sort(function(t,n){return e(t)-e(n);});var i=t.length,o=new Float64Array(i),a=new Float64Array(i);var s,u,c,l=0,f=0,h=0;var _iterator13=_createForOfIteratorHelper(t),_step13;try{for(_iterator13.s();!(_step13=_iterator13.n()).done;){c=_step13.value;o[l]=s=+e(c),a[l]=u=+n(c),f+=(s-f)/++l,h+=(u-h)/l;}}catch(err){_iterator13.e(err);}finally{_iterator13.f();}for(l=0;l<i;++l){o[l]-=f,a[l]-=h;}return [o,a,f,h];}function Te(t,e,n,r){var i,o,a=-1;var _iterator14=_createForOfIteratorHelper(t),_step14;try{for(_iterator14.s();!(_step14=_iterator14.n()).done;){var _s11=_step14.value;i=e(_s11),o=n(_s11),null!=i&&(i=+i)>=i&&null!=o&&(o=+o)>=o&&r(i,o,++a);}}catch(err){_iterator14.e(err);}finally{_iterator14.f();}}function Ne(t,e,n,r,i){var o=0,a=0;return Te(t,e,n,function(t,e){var n=e-i(t),s=e-r;o+=n*n,a+=s*s;}),1-o/a;}function Ie(t,e,n){var r=0,i=0,o=0,a=0,s=0;Te(t,e,n,function(t,e){r+=(t-r)/++s,i+=(e-i)/s,o+=(t*e-o)/s,a+=(t*t-a)/s;});var u=De(r,i,o,a),c=function c(t){return u[0]+u[1]*t;};return {coef:u,predict:c,rSquared:Ne(t,e,n,i,c)};}function Re(t,e,n){var r=0,i=0,o=0,a=0,s=0;Te(t,e,n,function(t,e){++s,t=Math.log(t),r+=(t-r)/s,i+=(e-i)/s,o+=(t*e-o)/s,a+=(t*t-a)/s;});var u=De(r,i,o,a),c=function c(t){return u[0]+u[1]*Math.log(t);};return {coef:u,predict:c,rSquared:Ne(t,e,n,i,c)};}function Me(t,e,n){var _Fe=Fe(t,e,n),_Fe2=_slicedToArray(_Fe,4),r=_Fe2[0];_Fe2[1];var o=_Fe2[2],a=_Fe2[3];var s,u,c,l=0,f=0,h=0,d=0,p=0;Te(t,e,n,function(t,e){s=r[p++],u=Math.log(e),l+=(e*u-l)/p,f+=((c=s*e)-f)/p,h+=(c*u-h)/p,d+=(s*c-d)/p;});var _De=De(f/a,l/a,h/a,d/a),_De2=_slicedToArray(_De,2),m=_De2[0],g=_De2[1],v=function v(t){return Math.exp(m+g*(t-o));};return {coef:[Math.exp(m-g*o),g],predict:v,rSquared:Ne(t,e,n,a,v)};}function je(t,e,n){var r=0,i=0,o=0,a=0,s=0,u=0;Te(t,e,n,function(t,e){var n=Math.log(t),c=Math.log(e);r+=(n-r)/++u,i+=(c-i)/u,o+=(n*c-o)/u,a+=(n*n-a)/u,s+=(e-s)/u;});var c=De(r,i,o,a),l=function l(t){return c[0]*Math.pow(t,c[1]);};return c[0]=Math.exp(c[0]),{coef:c,predict:l,rSquared:Ne(t,e,n,s,l)};}function Be(t,e,n){var _Fe3=Fe(t,e,n),_Fe4=_slicedToArray(_Fe3,4),r=_Fe4[0],i=_Fe4[1],o=_Fe4[2],a=_Fe4[3],s=r.length;var u,c,l,f,h=0,d=0,p=0,m=0,g=0;for(u=0;u<s;){c=r[u],l=i[u++],h+=((f=c*c)-h)/u,d+=(f*c-d)/u,p+=(f*f-p)/u,m+=(c*l-m)/u,g+=(f*l-g)/u;}var v=p-h*h,y=h*v-d*d,b=(g*h-m*d)/y,x=(m*v-g*d)/y,w=-b*h,k=function k(t){return b*(t-=o)*t+x*t+w+a;};return {coef:[w-x*o+b*o*o+a,x-2*b*o,b],predict:k,rSquared:Ne(t,e,n,a,k)};}function Pe(t,e,n,r){if(1===r)return Ie(t,e,n);if(2===r)return Be(t,e,n);var _Fe5=Fe(t,e,n),_Fe6=_slicedToArray(_Fe5,4),i=_Fe6[0],o=_Fe6[1],a=_Fe6[2],s=_Fe6[3],u=i.length,c=[],l=[],f=r+1;var h,d,p,m,g;for(h=0;h<f;++h){for(p=0,m=0;p<u;++p){m+=Math.pow(i[p],h)*o[p];}for(c.push(m),g=new Float64Array(f),d=0;d<f;++d){for(p=0,m=0;p<u;++p){m+=Math.pow(i[p],h+d);}g[d]=m;}l.push(g);}l.push(c);var v=function(t){var e=t.length-1,n=[];var r,i,o,a,s;for(r=0;r<e;++r){for(a=r,i=r+1;i<e;++i){Math.abs(t[r][i])>Math.abs(t[r][a])&&(a=i);}for(o=r;o<e+1;++o){s=t[o][r],t[o][r]=t[o][a],t[o][a]=s;}for(i=r+1;i<e;++i){for(o=e;o>=r;o--){t[o][i]-=t[o][r]*t[r][i]/t[r][r];}}}for(i=e-1;i>=0;--i){for(s=0,o=i+1;o<e;++o){s+=t[o][i]*n[o];}n[i]=(t[e][i]-s)/t[i][i];}return n;}(l),y=function y(t){t-=a;var e=s+v[0]+v[1]*t+v[2]*t*t;for(h=3;h<f;++h){e+=v[h]*Math.pow(t,h);}return e;};return {coef:function(t,e,n,r){var i=Array(t);var o,a,s,u;for(o=0;o<t;++o){i[o]=0;}for(o=t-1;o>=0;--o){for(s=e[o],u=1,i[o]+=s,a=1;a<=o;++a){u*=(o+1-a)/a,i[o-a]+=s*Math.pow(n,a)*u;}}return i[0]+=r,i;}(f,v,-a,s),predict:y,rSquared:Ne(t,e,n,s,y)};}var Le=2,ze=1e-12;function Ue(t,e,n,r){var _Fe7=Fe(t,e,n,!0),_Fe8=_slicedToArray(_Fe7,4),i=_Fe8[0],o=_Fe8[1],a=_Fe8[2],s=_Fe8[3],u=i.length,c=Math.max(2,~~(r*u)),l=new Float64Array(u),f=new Float64Array(u),h=new Float64Array(u).fill(1);for(var _t22=-1;++_t22<=Le;){var _e23=[0,c-1];for(var _t23=0;_t23<u;++_t23){var _n22=i[_t23],_r25=_e23[0],_a14=_e23[1],_s12=_n22-i[_r25]>i[_a14]-_n22?_r25:_a14;var _u6=0,_c3=0,_d2=0,_p2=0,_m2=0;var _g2=1/Math.abs(i[_s12]-_n22||1);for(var _t24=_r25;_t24<=_a14;++_t24){var _e24=i[_t24],_r26=o[_t24],_a15=We(Math.abs(_n22-_e24)*_g2)*h[_t24],_s13=_e24*_a15;_u6+=_a15,_c3+=_s13,_d2+=_r26*_a15,_p2+=_r26*_s13,_m2+=_e24*_s13;}var _De3=De(_c3/_u6,_d2/_u6,_p2/_u6,_m2/_u6),_De4=_slicedToArray(_De3,2),_v2=_De4[0],_y2=_De4[1];l[_t23]=_v2+_y2*_n22,f[_t23]=Math.abs(o[_t23]-l[_t23]),Ve(i,_t23+1,_e23);}if(_t22===Le)break;var _n21=Jt(f);if(Math.abs(_n21)<ze)break;for(var _t25,_e25,_r27=0;_r27<u;++_r27){_t25=f[_r27]/(6*_n21),h[_r27]=_t25>=1?ze:(_e25=1-_t25*_t25)*_e25;}}return function(t,e,n,r){var i=t.length,o=[];var a,s=0,u=0,c=[];for(;s<i;++s){a=t[s]+n,c[0]===a?c[1]+=(e[s]-c[1])/++u:(u=0,c[1]+=r,c=[a,e[s]],o.push(c));}return c[1]+=r,o;}(i,l,a,s);}function We(t){return (t=1-t*t*t)*t*t;}function Ve(t,e,n){var r=t[e];var i=n[0],o=n[1]+1;if(!(o>=t.length))for(;e>i&&t[o]-r<=r-t[i];){n[0]=++i,n[1]=o,++o;}}var qe=.5*Math.PI/180;function $e(t,e,n,r){n=n||25,r=Math.max(n,r||200);var i=function i(e){return [e,t(e)];},o=e[0],a=e[1],s=a-o,u=s/r,c=[i(o)],l=[];if(n===r){for(var _t26=1;_t26<r;++_t26){c.push(i(o+_t26/n*s));}return c.push(i(a)),c;}l.push(i(a));for(var _t27=n;--_t27>0;){l.push(i(o+_t27/n*s));}var f=c[0],h=l[l.length-1];var d=1/s,p=function(t,e){var n=t,r=t;var i=e.length;for(var _t28=0;_t28<i;++_t28){var _i14=e[_t28][1];_i14<n&&(n=_i14),_i14>r&&(r=_i14);}return 1/(r-n);}(f[1],l);for(;h;){var _t29=i((f[0]+h[0])/2);_t29[0]-f[0]>=u&&He(f,_t29,h,d,p)>qe?l.push(_t29):(f=h,c.push(h),l.pop()),h=l[l.length-1];}return c;}function He(t,e,n,r,i){var o=Math.atan2(i*(n[1]-t[1]),r*(n[0]-t[0])),a=Math.atan2(i*(e[1]-t[1]),r*(e[0]-t[0]));return Math.abs(o-a);}var Ge=function Ge(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=0|Math.max(0,Math.ceil((e-t)/n)),o=new Array(i);++r<i;){o[r]=t+r*n;}return o;},Ke=n(108),Xe=n(11);function Ye(t){return t&&t.length?1===t.length?t[0]:function(t){return function(e){var n=t.length;var r=1,i=String(t[0](e));for(;r<n;++r){i+="|"+t[r](e);}return i;};}(t):function(){return "";};}function Je(t,e,n){return n||t+(e?"_"+e:"");}var Qe=function Qe(){},Ze={init:Qe,add:Qe,rem:Qe,idx:0},tn={values:{init:function init(t){return t.cell.store=!0;},value:function value(t){return t.cell.data.values();},idx:-1},count:{value:function value(t){return t.cell.num;}},__count__:{value:function value(t){return t.missing+t.valid;}},missing:{value:function value(t){return t.missing;}},valid:{value:function value(t){return t.valid;}},sum:{init:function init(t){return t.sum=0;},value:function value(t){return t.sum;},add:function add(t,e){return t.sum+=+e;},rem:function rem(t,e){return t.sum-=e;}},product:{init:function init(t){return t.product=1;},value:function value(t){return t.valid?t.product:void 0;},add:function add(t,e){return t.product*=e;},rem:function rem(t,e){return t.product/=e;}},mean:{init:function init(t){return t.mean=0;},value:function value(t){return t.valid?t.mean:void 0;},add:function add(t,e){return t.mean_d=e-t.mean,t.mean+=t.mean_d/t.valid;},rem:function rem(t,e){return t.mean_d=e-t.mean,t.mean-=t.valid?t.mean_d/t.valid:t.mean;}},average:{value:function value(t){return t.valid?t.mean:void 0;},req:["mean"],idx:1},variance:{init:function init(t){return t.dev=0;},value:function value(t){return t.valid>1?t.dev/(t.valid-1):void 0;},add:function add(t,e){return t.dev+=t.mean_d*(e-t.mean);},rem:function rem(t,e){return t.dev-=t.mean_d*(e-t.mean);},req:["mean"],idx:1},variancep:{value:function value(t){return t.valid>1?t.dev/t.valid:void 0;},req:["variance"],idx:2},stdev:{value:function value(t){return t.valid>1?Math.sqrt(t.dev/(t.valid-1)):void 0;},req:["variance"],idx:2},stdevp:{value:function value(t){return t.valid>1?Math.sqrt(t.dev/t.valid):void 0;},req:["variance"],idx:2},stderr:{value:function value(t){return t.valid>1?Math.sqrt(t.dev/(t.valid*(t.valid-1))):void 0;},req:["variance"],idx:2},distinct:{value:function value(t){return t.cell.data.distinct(t.get);},req:["values"],idx:3},ci0:{value:function value(t){return t.cell.data.ci0(t.get);},req:["values"],idx:3},ci1:{value:function value(t){return t.cell.data.ci1(t.get);},req:["values"],idx:3},median:{value:function value(t){return t.cell.data.q2(t.get);},req:["values"],idx:3},q1:{value:function value(t){return t.cell.data.q1(t.get);},req:["values"],idx:3},q3:{value:function value(t){return t.cell.data.q3(t.get);},req:["values"],idx:3},min:{init:function init(t){return t.min=void 0;},value:function value(t){return t.min=Number.isNaN(t.min)?t.cell.data.min(t.get):t.min;},add:function add(t,e){(e<t.min||void 0===t.min)&&(t.min=e);},rem:function rem(t,e){e<=t.min&&(t.min=NaN);},req:["values"],idx:4},max:{init:function init(t){return t.max=void 0;},value:function value(t){return t.max=Number.isNaN(t.max)?t.cell.data.max(t.get):t.max;},add:function add(t,e){(e>t.max||void 0===t.max)&&(t.max=e);},rem:function rem(t,e){e>=t.max&&(t.max=NaN);},req:["values"],idx:4},argmin:{init:function init(t){return t.argmin=void 0;},value:function value(t){return t.argmin||t.cell.data.argmin(t.get);},add:function add(t,e,n){e<t.min&&(t.argmin=n);},rem:function rem(t,e){e<=t.min&&(t.argmin=void 0);},req:["min","values"],idx:3},argmax:{init:function init(t){return t.argmax=void 0;},value:function value(t){return t.argmax||t.cell.data.argmax(t.get);},add:function add(t,e,n){e>t.max&&(t.argmax=n);},rem:function rem(t,e){e>=t.max&&(t.argmax=void 0);},req:["max","values"],idx:3}},en=Object.keys(tn);function nn(t,e){return tn[t](e);}function rn(t,e){return t.idx-e.idx;}function on(){var _this6=this;this.valid=0,this.missing=0,this._ops.forEach(function(t){return t.init(_this6);});}function an(t,e){var _this7=this;null!=t&&""!==t?t==t&&(++this.valid,this._ops.forEach(function(n){return n.add(_this7,t,e);})):++this.missing;}function sn(t,e){var _this8=this;null!=t&&""!==t?t==t&&(--this.valid,this._ops.forEach(function(n){return n.rem(_this8,t,e);})):--this.missing;}function un(t){var _this9=this;return this._out.forEach(function(e){return t[e.out]=e.value(_this9);}),t;}function cn(t,e){var n=e||Z.y,r=function(t){var e={};t.forEach(function(t){return e[t.name]=t;});var n=function n(t){t.req&&t.req.forEach(function(t){e[t]||n(e[t]=tn[t]());});};return t.forEach(n),Object.values(e).sort(rn);}(t),i=t.slice().sort(rn);function o(t){this._ops=r,this._out=i,this.cell=t,this.init();}return o.prototype.init=on,o.prototype.add=an,o.prototype.rem=sn,o.prototype.set=un,o.prototype.get=n,o.fields=t.map(function(t){return t.out;}),o;}function ln(t){this._key=t?Object(Z.u)(t):st,this.reset();}en.forEach(function(t){tn[t]=function(t,e){return function(n){return Object(Z.p)({name:t,out:n||t},Ze,e);};}(t,tn[t]);});var fn=ln.prototype;function hn(t){zt.call(this,null,t),this._adds=[],this._mods=[],this._alen=0,this._mlen=0,this._drop=!0,this._cross=!1,this._dims=[],this._dnames=[],this._measures=[],this._countOnly=!1,this._counts=null,this._prev=null,this._inputs=null,this._outputs=null;}fn.reset=function(){this._add=[],this._rem=[],this._ext=null,this._get=null,this._q=null;},fn.add=function(t){this._add.push(t);},fn.rem=function(t){this._rem.push(t);},fn.values=function(){if(this._get=null,0===this._rem.length)return this._add;var t=this._add,e=this._rem,n=this._key,r=t.length,i=e.length,o=Array(r-i),a={};var s,u,c;for(s=0;s<i;++s){a[n(e[s])]=1;}for(s=0,u=0;s<r;++s){a[n(c=t[s])]?a[n(c)]=0:o[u++]=c;}return this._rem=[],this._add=o;},fn.distinct=function(t){var e=this.values(),n={};var r,i=e.length,o=0;for(;--i>=0;){r=t(e[i])+"",Object(Z.w)(n,r)||(n[r]=1,++o);}return o;},fn.extent=function(t){if(this._get!==t||!this._ext){var _e26=this.values(),_n23=Object(Z.r)(_e26,t);this._ext=[_e26[_n23[0]],_e26[_n23[1]]],this._get=t;}return this._ext;},fn.argmin=function(t){return this.extent(t)[0]||{};},fn.argmax=function(t){return this.extent(t)[1]||{};},fn.min=function(t){var e=this.extent(t)[0];return null!=e?t(e):void 0;},fn.max=function(t){var e=this.extent(t)[1];return null!=e?t(e):void 0;},fn.quartile=function(t){return this._get===t&&this._q||(this._q=te(this.values(),t),this._get=t),this._q;},fn.q1=function(t){return this.quartile(t)[0];},fn.q2=function(t){return this.quartile(t)[1];},fn.q3=function(t){return this.quartile(t)[2];},fn.ci=function(t){return this._get===t&&this._ci||(this._ci=oe(this.values(),1e3,.05,t),this._get=t),this._ci;},fn.ci0=function(t){return this.ci(t)[0];},fn.ci1=function(t){return this.ci(t)[1];},hn.Definition={type:"Aggregate",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:en},{name:"fields",type:"field",null:!0,array:!0},{name:"as",type:"string",null:!0,array:!0},{name:"drop",type:"boolean",default:!0},{name:"cross",type:"boolean",default:!1},{name:"key",type:"field"}]},Object(Z.z)(hn,zt,{transform:function transform(t,e){var _this10=this;var n=this,r=e.fork(e.NO_SOURCE|e.NO_FIELDS),i=t.modified();return n.stamp=r.stamp,n.value&&(i||e.modified(n._inputs,!0))?(n._prev=n.value,n.value=i?n.init(t):{},e.visit(e.SOURCE,function(t){return n.add(t);})):(n.value=n.value||n.init(t),e.visit(e.REM,function(t){return n.rem(t);}),e.visit(e.ADD,function(t){return n.add(t);})),r.modifies(n._outputs),n._drop=!1!==t.drop,t.cross&&n._dims.length>1&&(n._drop=!1,n.cross()),e.clean()&&n._drop&&r.clean(!0).runAfter(function(){return _this10.clean();}),n.changes(r);},cross:function cross(){var t=this,e=t.value,n=t._dnames,r=n.map(function(){return {};}),i=n.length;function o(t){var e,o,a,s;for(e in t){for(a=t[e].tuple,o=0;o<i;++o){r[o][s=a[n[o]]]=s;}}}o(t._prev),o(e),function o(a,s,u){var c=n[u],l=r[u++];for(var _n24 in l){var _r28=a?a+"|"+_n24:_n24;s[c]=l[_n24],u<i?o(_r28,s,u):e[_r28]||t.cell(_r28,s);}}("",{},0);},init:function init(t){var e=this._inputs=[],n=this._outputs=[],r={};function i(t){var n=Object(Z.i)(Object(Z.g)(t)),i=n.length;var o,a=0;for(;a<i;++a){r[o=n[a]]||(r[o]=1,e.push(o));}}this._dims=Object(Z.i)(t.groupby),this._dnames=this._dims.map(function(t){var e=Object(Z.h)(t);return i(t),n.push(e),e;}),this.cellkey=t.key?t.key:Ye(this._dims),this._countOnly=!0,this._counts=[],this._measures=[];var o=t.fields||[null],a=t.ops||["count"],s=t.as||[],u=o.length,c={};var l,f,h,d,p,m;for(u!==a.length&&Object(Z.o)("Unmatched number of fields and aggregate ops."),m=0;m<u;++m){l=o[m],f=a[m],null==l&&"count"!==f&&Object(Z.o)("Null aggregate field specified."),p=Je(f,d=Object(Z.h)(l),s[m]),n.push(p),"count"!==f?((h=c[d])||(i(l),(h=c[d]=[]).field=l,this._measures.push(h)),"count"!==f&&(this._countOnly=!1),h.push(nn(f,p))):this._counts.push(p);}return this._measures=this._measures.map(function(t){return cn(t,t.field);}),{};},cellkey:Ye(),cell:function cell(t,e){var n=this.value[t];return n?0===n.num&&this._drop&&n.stamp<this.stamp?(n.stamp=this.stamp,this._adds[this._alen++]=n):n.stamp<this.stamp&&(n.stamp=this.stamp,this._mods[this._mlen++]=n):(n=this.value[t]=this.newcell(t,e),this._adds[this._alen++]=n),n;},newcell:function newcell(t,e){var n={key:t,num:0,agg:null,tuple:this.newtuple(e,this._prev&&this._prev[t]),stamp:this.stamp,store:!1};if(!this._countOnly){var _t30=this._measures,_e27=_t30.length;n.agg=Array(_e27);for(var _r29=0;_r29<_e27;++_r29){n.agg[_r29]=new _t30[_r29](n);}}return n.store&&(n.data=new ln()),n;},newtuple:function newtuple(t,e){var n=this._dnames,r=this._dims,i=r.length,o={};for(var _e28=0;_e28<i;++_e28){o[n[_e28]]=r[_e28](t);}return e?ht(e.tuple,o):ct(o);},clean:function clean(){var t=this.value;for(var _e29 in t){0===t[_e29].num&&delete t[_e29];}},add:function add(t){var e=this.cellkey(t),n=this.cell(e,t);if(n.num+=1,this._countOnly)return;n.store&&n.data.add(t);var r=n.agg;for(var _e30=0,_n25=r.length;_e30<_n25;++_e30){r[_e30].add(r[_e30].get(t),t);}},rem:function rem(t){var e=this.cellkey(t),n=this.cell(e,t);if(n.num-=1,this._countOnly)return;n.store&&n.data.rem(t);var r=n.agg;for(var _e31=0,_n26=r.length;_e31<_n26;++_e31){r[_e31].rem(r[_e31].get(t),t);}},celltuple:function celltuple(t){var e=t.tuple,n=this._counts;t.store&&t.data.values();for(var _r30=0,_i15=n.length;_r30<_i15;++_r30){e[n[_r30]]=t.num;}if(!this._countOnly){var _n27=t.agg;for(var _t31=0,_r31=_n27.length;_t31<_r31;++_t31){_n27[_t31].set(e);}}return e;},changes:function changes(t){var e=this._adds,n=this._mods,r=this._prev,i=this._drop,o=t.add,a=t.rem,s=t.mod;var u,c,l,f;if(r)for(c in r){u=r[c],i&&!u.num||a.push(u.tuple);}for(l=0,f=this._alen;l<f;++l){o.push(this.celltuple(e[l])),e[l]=null;}for(l=0,f=this._mlen;l<f;++l){(0===(u=n[l]).num&&i?a:s).push(this.celltuple(u)),n[l]=null;}return this._alen=this._mlen=0,this._prev=null,t;}});function dn(t){zt.call(this,null,t);}function pn(t,e,n){var r=t;var i=e||[],o=n||[],a={},s=0;return {add:function add(t){return o.push(t);},remove:function remove(t){return a[r(t)]=++s;},size:function size(){return i.length;},data:function data(t,e){return s&&(i=i.filter(function(t){return !a[r(t)];}),a={},s=0),e&&t&&i.sort(t),o.length&&(i=t?Object(Z.O)(t,i,o.sort(t)):i.concat(o),o=[]),i;}};}function mn(t){zt.call(this,[],t);}function gn(t){xt.call(this,null,vn,t);}function vn(t){return this.value&&!t.modified()?this.value:Object(Z.l)(t.fields,t.orders);}function yn(t){zt.call(this,null,t);}function bn(t){zt.call(this,null,t);}dn.Definition={type:"Bin",metadata:{modifies:!0},params:[{name:"field",type:"field",required:!0},{name:"interval",type:"boolean",default:!0},{name:"anchor",type:"number"},{name:"maxbins",type:"number",default:20},{name:"base",type:"number",default:10},{name:"divide",type:"number",array:!0,default:[5,2]},{name:"extent",type:"number",array:!0,length:2,required:!0},{name:"span",type:"number"},{name:"step",type:"number"},{name:"steps",type:"number",array:!0},{name:"minstep",type:"number",default:0},{name:"nice",type:"boolean",default:!0},{name:"name",type:"string"},{name:"as",type:"string",array:!0,length:2,default:["bin0","bin1"]}]},Object(Z.z)(dn,zt,{transform:function transform(t,e){var n=!1!==t.interval,r=this._bins(t),i=r.start,o=r.step,a=t.as||["bin0","bin1"],s=a[0],u=a[1];var c;return c=t.modified()?(e=e.reflow(!0)).SOURCE:e.modified(Object(Z.g)(t.field))?e.ADD_MOD:e.ADD,e.visit(c,n?function(t){var e=r(t);t[s]=e,t[u]=null==e?null:i+o*(1+(e-i)/o);}:function(t){return t[s]=r(t);}),e.modifies(n?a:s);},_bins:function _bins(t){if(this.value&&!t.modified())return this.value;var e=t.field,n=ne(t),r=n.step;var i,o,a=n.start,s=a+Math.ceil((n.stop-a)/r)*r;null!=(i=t.anchor)&&(o=i-(a+r*Math.floor((i-a)/r)),a+=o,s+=o);var u=function u(t){var n=Object(Z.Ea)(e(t));return null==n?null:n<a?-1/0:n>s?1/0:(n=Math.max(a,Math.min(n,s-r)),a+r*Math.floor(1e-14+(n-a)/r));};return u.start=a,u.stop=n.stop,u.step=r,this.value=Object(Z.f)(u,Object(Z.g)(e),t.name||"bin_"+Object(Z.h)(e));}}),mn.Definition={type:"Collect",metadata:{source:!0},params:[{name:"sort",type:"compare"}]},Object(Z.z)(mn,zt,{transform:function transform(t,e){var n=e.fork(e.ALL),r=pn(st,this.value,n.materialize(n.ADD).add),i=t.sort,o=e.changed()||i&&(t.modified("sort")||e.modified(i.fields));return n.visit(n.REM,r.remove),this.modified(o),this.value=n.source=r.data(dt(i),o),e.source&&e.source.root&&(this.value.root=e.source.root),n;}}),Object(Z.z)(gn,xt),yn.Definition={type:"CountPattern",metadata:{generates:!0,changes:!0},params:[{name:"field",type:"field",required:!0},{name:"case",type:"enum",values:["upper","lower","mixed"],default:"mixed"},{name:"pattern",type:"string",default:'[\\w"]+'},{name:"stopwords",type:"string",default:""},{name:"as",type:"string",array:!0,length:2,default:["text","count"]}]},Object(Z.z)(yn,zt,{transform:function transform(t,e){var n=function n(e){return function(n){for(var r,i=function(t,e,n){switch(e){case"upper":t=t.toUpperCase();break;case"lower":t=t.toLowerCase();}return t.match(n);}(s(n),t.case,o)||[],u=0,c=i.length;u<c;++u){a.test(r=i[u])||e(r);}};},r=this._parameterCheck(t,e),i=this._counts,o=this._match,a=this._stop,s=t.field,u=t.as||["text","count"],c=n(function(t){return i[t]=1+(i[t]||0);}),l=n(function(t){return i[t]-=1;});return r?e.visit(e.SOURCE,c):(e.visit(e.ADD,c),e.visit(e.REM,l)),this._finish(e,u);},_parameterCheck:function _parameterCheck(t,e){var n=!1;return !t.modified("stopwords")&&this._stop||(this._stop=new RegExp("^"+(t.stopwords||"")+"$","i"),n=!0),!t.modified("pattern")&&this._match||(this._match=new RegExp(t.pattern||"[\\w']+","g"),n=!0),(t.modified("field")||e.modified(t.field.fields))&&(n=!0),n&&(this._counts={}),n;},_finish:function _finish(t,e){var n=this._counts,r=this._tuples||(this._tuples={}),i=e[0],o=e[1],a=t.fork(t.NO_SOURCE|t.NO_FIELDS);var s,u,c;for(s in n){u=r[s],c=n[s]||0,!u&&c?(r[s]=u=ct({}),u[i]=s,u[o]=c,a.add.push(u)):0===c?(u&&a.rem.push(u),n[s]=null,r[s]=null):u[o]!==c&&(u[o]=c,a.mod.push(u));}return a.modifies(e);}}),bn.Definition={type:"Cross",metadata:{generates:!0},params:[{name:"filter",type:"expr"},{name:"as",type:"string",array:!0,length:2,default:["a","b"]}]},Object(Z.z)(bn,zt,{transform:function transform(t,e){var n=e.fork(e.NO_SOURCE),r=t.as||["a","b"],i=r[0],o=r[1],a=!this.value||e.changed(e.ADD_REM)||t.modified("as")||t.modified("filter");var s=this.value;return a?(s&&(n.rem=s),s=e.materialize(e.SOURCE).source,n.add=this.value=function(t,e,n,r){for(var i,o,a=[],s={},u=t.length,c=0;c<u;++c){for(s[e]=o=t[c],i=0;i<u;++i){s[n]=t[i],r(s)&&(a.push(ct(s)),(s={})[e]=o);}}return a;}(s,i,o,t.filter||Z.Ia)):n.mod=s,n.source=this.value,n.modifies(r);}});var xn={kde:ve,mixture:Ee,normal:ge,lognormal:ke,uniform:Se},wn="distributions",kn="function",En="field";function Cn(t){zt.call(this,null,t);}var An=[{key:{function:"normal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"lognormal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"uniform"},params:[{name:"min",type:"number",default:0},{name:"max",type:"number",default:1}]},{key:{function:"kde"},params:[{name:"field",type:"field",required:!0},{name:"from",type:"data"},{name:"bandwidth",type:"number",default:0}]}],On={key:{function:"mixture"},params:[{name:"distributions",type:"param",array:!0,params:An},{name:"weights",type:"number",array:!0}]};function _n(t,e){return t?t.map(function(t,n){return e[n]||Object(Z.h)(t);}):null;}function Sn(t,e,n){var r=[],i=function i(t){return t(u);};var o,a,s,u,c,l;if(null==e)r.push(t.map(n));else for(o={},a=0,s=t.length;a<s;++a){u=t[a],(l=o[c=e.map(i)])||(o[c]=l=[],l.dims=c,r.push(l)),l.push(n(u));}return r;}Cn.Definition={type:"Density",metadata:{generates:!0},params:[{name:"extent",type:"number",array:!0,length:2},{name:"steps",type:"number"},{name:"minsteps",type:"number",default:25},{name:"maxsteps",type:"number",default:200},{name:"method",type:"string",default:"pdf",values:["pdf","cdf"]},{name:"distribution",type:"param",params:An.concat(On)},{name:"as",type:"string",array:!0,default:["value","density"]}]},Object(Z.z)(Cn,zt,{transform:function transform(t,e){var n=e.fork(e.NO_SOURCE|e.NO_FIELDS);if(!this.value||e.changed()||t.modified()){var _r32=function t(e,n){var r=e[kn];Object(Z.w)(xn,r)||Object(Z.o)("Unknown distribution function: "+r);var i=xn[r]();for(var _r33 in e){_r33===En?i.data((e.from||n()).map(e[_r33])):_r33===wn?i[_r33](e[_r33].map(function(e){return t(e,n);})):_typeof$1(i[_r33])===kn&&i[_r33](e[_r33]);}return i;}(t.distribution,function(t){return function(){return t.materialize(t.SOURCE).source;};}(e)),_i16=t.steps||t.minsteps||25,_o8=t.steps||t.maxsteps||200;var _a16=t.method||"pdf";"pdf"!==_a16&&"cdf"!==_a16&&Object(Z.o)("Invalid density method: "+_a16),t.extent||_r32.data||Object(Z.o)("Missing density extent parameter."),_a16=_r32[_a16];var _s14=t.as||["value","density"],_u7=$e(_a16,t.extent||Object(Z.q)(_r32.data()),_i16,_o8).map(function(t){var e={};return e[_s14[0]]=t[0],e[_s14[1]]=t[1],ct(e);});this.value&&(n.rem=this.value),this.value=n.add=n.source=_u7;}return n;}});function Dn(t){zt.call(this,null,t);}Dn.Definition={type:"DotBin",metadata:{modifies:!0},params:[{name:"field",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"step",type:"number"},{name:"smooth",type:"boolean",default:!1},{name:"as",type:"string",default:"bin"}]};function Fn(t){xt.call(this,null,Tn,t),this.modified(!0);}function Tn(t){var e=t.expr;return this.value&&!t.modified("expr")?this.value:Object(Z.f)(function(n){return e(n,t);},Object(Z.g)(e),Object(Z.h)(e));}function Nn(t){zt.call(this,[void 0,void 0],t);}function In(t,e){xt.call(this,t),this.parent=e,this.count=0;}function Rn(t){zt.call(this,{},t),this._keys=Object(Z.t)();var e=this._targets=[];e.active=0,e.forEach=function(t){for(var _n28=0,_r34=e.active;_n28<_r34;++_n28){t(e[_n28],_n28,e);}};}function Mn(t){xt.call(this,null,jn,t);}function jn(t){return this.value&&!t.modified()?this.value:Object(Z.B)(t.name)?Object(Z.i)(t.name).map(function(t){return Object(Z.u)(t);}):Object(Z.u)(t.name,t.as);}function Bn(t){zt.call(this,Object(Z.t)(),t);}function Pn(t){zt.call(this,[],t);}function Ln(t){zt.call(this,[],t);}function zn(t){zt.call(this,null,t);}function Un(t){zt.call(this,[],t);}Object(Z.z)(Dn,zt,{transform:function transform(t,e){if(this.value&&!t.modified()&&!e.changed())return e;var n=e.materialize(e.SOURCE).source,r=Sn(e.source,t.groupby,Z.y),i=t.smooth||!1,o=t.field,a=t.step||function(t,e){return Object(Z.Z)(Object(Z.q)(t,e))/30;}(n,o),s=dt(function(t,e){return o(t)-o(e);}),u=t.as||"bin",c=r.length;var l,f=1/0,h=-1/0,d=0;for(;d<c;++d){var _t32=r[d].sort(s);l=-1;var _iterator15=_createForOfIteratorHelper(ae(_t32,a,i,o)),_step15;try{for(_iterator15.s();!(_step15=_iterator15.n()).done;){var _e32=_step15.value;_e32<f&&(f=_e32),_e32>h&&(h=_e32),_t32[++l][u]=_e32;}}catch(err){_iterator15.e(err);}finally{_iterator15.f();}}return this.value={start:f,stop:h,step:a},e.reflow(!0).modifies(u);}}),Object(Z.z)(Fn,xt),Nn.Definition={type:"Extent",metadata:{},params:[{name:"field",type:"field",required:!0}]},Object(Z.z)(Nn,zt,{transform:function transform(t,e){var n=this.value,r=t.field,i=e.changed()||e.modified(r.fields)||t.modified("field");var o=n[0],a=n[1];if((i||null==o)&&(o=1/0,a=-1/0),e.visit(i?e.SOURCE:e.ADD,function(t){var e=Object(Z.Ea)(r(t));null!=e&&(e<o&&(o=e),e>a&&(a=e));}),!Number.isFinite(o)||!Number.isFinite(a)){var _t33=Object(Z.h)(r);_t33&&(_t33=" for field \"".concat(_t33,"\"")),e.dataflow.warn("Infinite extent".concat(_t33,": [").concat(o,", ").concat(a,"]")),o=a=void 0;}this.value=[o,a];}}),Object(Z.z)(In,xt,{connect:function connect(t){return this.detachSubflow=t.detachSubflow,this.targets().add(t),t.source=this;},add:function add(t){this.count+=1,this.value.add.push(t);},rem:function rem(t){this.count-=1,this.value.rem.push(t);},mod:function mod(t){this.value.mod.push(t);},init:function init(t){this.value.init(t,t.NO_SOURCE);},evaluate:function evaluate(){return this.value;}}),Object(Z.z)(Rn,zt,{activate:function activate(t){this._targets[this._targets.active++]=t;},subflow:function subflow(t,e,n,r){var i=this.value;var o,a,s=Object(Z.w)(i,t)&&i[t];return s?s.value.stamp<n.stamp&&(s.init(n),this.activate(s)):(a=r||(a=this._group[t])&&a.tuple,o=n.dataflow,s=new In(n.fork(n.NO_SOURCE),this),o.add(s).connect(e(o,t,a)),i[t]=s,this.activate(s)),s;},clean:function clean(){var t=this.value;var e=0;for(var _n29 in t){if(0===t[_n29].count){var _r35=t[_n29].detachSubflow;_r35&&_r35(),delete t[_n29],++e;}}if(e){var _t34=this._targets.filter(function(t){return t&&t.count>0;});this.initTargets(_t34);}},initTargets:function initTargets(t){var e=this._targets,n=e.length,r=t?t.length:0;var i=0;for(;i<r;++i){e[i]=t[i];}for(;i<n&&null!=e[i];++i){e[i]=null;}e.active=r;},transform:function transform(t,e){var _this11=this;var n=e.dataflow,r=t.key,i=t.subflow,o=this._keys,a=t.modified("key"),s=function s(t){return _this11.subflow(t,i,e);};return this._group=t.group||{},this.initTargets(),e.visit(e.REM,function(t){var e=st(t),n=o.get(e);void 0!==n&&(o.delete(e),s(n).rem(t));}),e.visit(e.ADD,function(t){var e=r(t);o.set(st(t),e),s(e).add(t);}),a||e.modified(r.fields)?e.visit(e.MOD,function(t){var e=st(t),n=o.get(e),i=r(t);n===i?s(i).mod(t):(o.set(e,i),s(n).rem(t),s(i).add(t));}):e.changed(e.MOD)&&e.visit(e.MOD,function(t){s(o.get(st(t))).mod(t);}),a&&e.visit(e.REFLOW,function(t){var e=st(t),n=o.get(e),i=r(t);n!==i&&(o.set(e,i),s(n).rem(t),s(i).add(t));}),e.clean()?n.runAfter(function(){_this11.clean(),o.clean();}):o.empty>n.cleanThreshold&&n.runAfter(o.clean),e;}}),Object(Z.z)(Mn,xt),Bn.Definition={type:"Filter",metadata:{changes:!0},params:[{name:"expr",type:"expr",required:!0}]},Object(Z.z)(Bn,zt,{transform:function transform(t,e){var n=e.dataflow,r=this.value,i=e.fork(),o=i.add,a=i.rem,s=i.mod,u=t.expr;var c=!0;function l(e){var n=st(e),i=u(e,t),l=r.get(n);i&&l?(r.delete(n),o.push(e)):i||l?c&&i&&!l&&s.push(e):(r.set(n,1),a.push(e));}return e.visit(e.REM,function(t){var e=st(t);r.has(e)?r.delete(e):a.push(t);}),e.visit(e.ADD,function(e){u(e,t)?o.push(e):r.set(st(e),1);}),e.visit(e.MOD,l),t.modified()&&(c=!1,e.visit(e.REFLOW,l)),r.empty>n.cleanThreshold&&n.runAfter(r.clean),i;}}),Pn.Definition={type:"Flatten",metadata:{generates:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"index",type:"string"},{name:"as",type:"string",array:!0}]},Object(Z.z)(Pn,zt,{transform:function transform(t,e){var n=e.fork(e.NO_SOURCE),r=t.fields,i=_n(r,t.as||[]),o=t.index||null,a=i.length;return n.rem=this.value,e.visit(e.SOURCE,function(t){var e=r.map(function(e){return e(t);}),s=e.reduce(function(t,e){return Math.max(t,e.length);},0);var u,c,l,f=0;for(;f<s;++f){for(c=lt(t),u=0;u<a;++u){c[i[u]]=null==(l=e[u][f])?null:l;}o&&(c[o]=f),n.add.push(c);}}),this.value=n.source=n.add,o&&n.modifies(o),n.modifies(i);}}),Ln.Definition={type:"Fold",metadata:{generates:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0,length:2,default:["key","value"]}]},Object(Z.z)(Ln,zt,{transform:function transform(t,e){var n=e.fork(e.NO_SOURCE),r=t.fields,i=r.map(Z.h),o=t.as||["key","value"],a=o[0],s=o[1],u=r.length;return n.rem=this.value,e.visit(e.SOURCE,function(t){for(var _e33,_o9=0;_o9<u;++_o9){(_e33=lt(t))[a]=i[_o9],_e33[s]=r[_o9](t),n.add.push(_e33);}}),this.value=n.source=n.add,n.modifies(o);}}),zn.Definition={type:"Formula",metadata:{modifies:!0},params:[{name:"expr",type:"expr",required:!0},{name:"as",type:"string",required:!0},{name:"initonly",type:"boolean"}]},Object(Z.z)(zn,zt,{transform:function transform(t,e){var n=t.expr,r=t.as,i=t.modified(),o=t.initonly?e.ADD:i?e.SOURCE:e.modified(n.fields)||e.modified(r)?e.ADD_MOD:e.ADD;return i&&(e=e.materialize().reflow(!0)),t.initonly||e.modifies(r),e.visit(o,function(e){return e[r]=n(e,t);});}}),Object(Z.z)(Un,zt,{transform:function transform(t,e){var n=e.fork(e.ALL),r=t.generator;var i,o,a,s=this.value,u=t.size-s.length;if(u>0){for(i=[];--u>=0;){i.push(a=ct(r(t))),s.push(a);}n.add=n.add.length?n.materialize(n.ADD).add.concat(i):i;}else o=s.slice(0,-u),n.rem=n.rem.length?n.materialize(n.REM).rem.concat(o):o,s=s.slice(-u);return n.source=this.value=s,n;}});var Wn={value:"value",median:Jt,mean:function mean(t,e){var n=0,r=0;if(void 0===e){var _iterator16=_createForOfIteratorHelper(t),_step16;try{for(_iterator16.s();!(_step16=_iterator16.n()).done;){var _e34=_step16.value;null!=_e34&&(_e34=+_e34)>=_e34&&(++n,r+=_e34);}}catch(err){_iterator16.e(err);}finally{_iterator16.f();}}else {var _i17=-1;var _iterator17=_createForOfIteratorHelper(t),_step17;try{for(_iterator17.s();!(_step17=_iterator17.n()).done;){var _o10=_step17.value;null!=(_o10=e(_o10,++_i17,t))&&(_o10=+_o10)>=_o10&&(++n,r+=_o10);}}catch(err){_iterator17.e(err);}finally{_iterator17.f();}}if(n)return r/n;},min:Ht,max:$t},Vn=[];function qn(t){zt.call(this,[],t);}function $n(t){hn.call(this,t);}function Hn(t){zt.call(this,null,t);}function Gn(t){xt.call(this,null,Kn,t);}function Kn(t){return this.value&&!t.modified()?this.value:Object(Z.K)(t.fields,t.flat);}function Xn(t){zt.call(this,[],t),this._pending=null;}function Yn(t,e,n){n.forEach(ct);var r=e.fork(e.NO_FIELDS&e.NO_SOURCE);return r.rem=t.value,t.value=r.source=r.add=n,t._pending=null,r.rem.length&&r.clean(!0),r;}function Jn(t){zt.call(this,{},t);}function Qn(t){xt.call(this,null,Zn,t);}function Zn(t){if(this.value&&!t.modified())return this.value;var e=t.extents,n=e.length;var r,i,o=1/0,a=-1/0;for(r=0;r<n;++r){(i=e[r])[0]<o&&(o=i[0]),i[1]>a&&(a=i[1]);}return [o,a];}function tr(t){xt.call(this,null,er,t);}function er(t){return this.value&&!t.modified()?this.value:t.values.reduce(function(t,e){return t.concat(e);},[]);}function nr(t){zt.call(this,null,t);}function rr(t){hn.call(this,t);}function ir(t){Rn.call(this,t);}function or(t){zt.call(this,null,t);}function ar(t){zt.call(this,null,t);}function sr(t){zt.call(this,null,t);}qn.Definition={type:"Impute",metadata:{changes:!0},params:[{name:"field",type:"field",required:!0},{name:"key",type:"field",required:!0},{name:"keyvals",array:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"enum",default:"value",values:["value","mean","median","max","min"]},{name:"value",default:0}]},Object(Z.z)(qn,zt,{transform:function transform(t,e){var n,r,i,o,a,s,u,c,l,f,h=e.fork(e.ALL),d=function(t){var e,n=t.method||Wn.value;if(null!=Wn[n])return n===Wn.value?(e=void 0!==t.value?t.value:0,function(){return e;}):Wn[n];Object(Z.o)("Unrecognized imputation method: "+n);}(t),p=function(t){var e=t.field;return function(t){return t?e(t):NaN;};}(t),m=Object(Z.h)(t.field),g=Object(Z.h)(t.key),v=(t.groupby||[]).map(Z.h),y=function(t,e,n,r){var i,o,a,s,u,c,l,f,h=function h(t){return t(f);},d=[],p=r?r.slice():[],m={},g={};for(p.forEach(function(t,e){return m[t]=e+1;}),s=0,l=t.length;s<l;++s){f=t[s],c=n(f),u=m[c]||(m[c]=p.push(c)),o=(i=e?e.map(h):Vn)+"",(a=g[o])||(a=g[o]=[],d.push(a),a.values=i),a[u-1]=f;}return d.domain=p,d;}(e.source,t.groupby,t.key,t.keyvals),b=[],x=this.value,w=y.domain.length;for(a=0,c=y.length;a<c;++a){for(i=(n=y[a]).values,r=NaN,u=0;u<w;++u){if(null==n[u]){for(o=y.domain[u],f={_impute:!0},s=0,l=i.length;s<l;++s){f[v[s]]=i[s];}f[g]=o,f[m]=Number.isNaN(r)?r=d(n,p):r,b.push(ct(f));}}}return b.length&&(h.add=h.materialize(h.ADD).add.concat(b)),x.length&&(h.rem=h.materialize(h.REM).rem.concat(x)),this.value=b,h;}}),$n.Definition={type:"JoinAggregate",metadata:{modifies:!0},params:[{name:"groupby",type:"field",array:!0},{name:"fields",type:"field",null:!0,array:!0},{name:"ops",type:"enum",array:!0,values:en},{name:"as",type:"string",null:!0,array:!0},{name:"key",type:"field"}]},Object(Z.z)($n,hn,{transform:function transform(t,e){var n=this,r=t.modified();var i;return n.value&&(r||e.modified(n._inputs,!0))?(i=n.value=r?n.init(t):{},e.visit(e.SOURCE,function(t){return n.add(t);})):(i=n.value=n.value||this.init(t),e.visit(e.REM,function(t){return n.rem(t);}),e.visit(e.ADD,function(t){return n.add(t);})),n.changes(),e.visit(e.SOURCE,function(t){Object(Z.p)(t,i[n.cellkey(t)].tuple);}),e.reflow(r).modifies(this._outputs);},changes:function changes(){var t=this._adds,e=this._mods;var n,r;for(n=0,r=this._alen;n<r;++n){this.celltuple(t[n]),t[n]=null;}for(n=0,r=this._mlen;n<r;++n){this.celltuple(e[n]),e[n]=null;}this._alen=this._mlen=0;}}),Hn.Definition={type:"KDE",metadata:{generates:!0},params:[{name:"groupby",type:"field",array:!0},{name:"field",type:"field",required:!0},{name:"cumulative",type:"boolean",default:!1},{name:"counts",type:"boolean",default:!1},{name:"bandwidth",type:"number",default:0},{name:"extent",type:"number",array:!0,length:2},{name:"resolve",type:"enum",values:["shared","independent"],default:"independent"},{name:"steps",type:"number"},{name:"minsteps",type:"number",default:25},{name:"maxsteps",type:"number",default:200},{name:"as",type:"string",array:!0,default:["value","density"]}]},Object(Z.z)(Hn,zt,{transform:function transform(t,e){var n=e.fork(e.NO_SOURCE|e.NO_FIELDS);if(!this.value||e.changed()||t.modified()){var _r36=e.materialize(e.SOURCE).source,_i18=Sn(_r36,t.groupby,t.field),_o11=(t.groupby||[]).map(Z.h),_a17=t.bandwidth,_s15=t.cumulative?"cdf":"pdf",_u8=t.as||["value","density"],_c4=[];var _l3=t.extent,_f3=t.steps||t.minsteps||25,_h3=t.steps||t.maxsteps||200;"pdf"!==_s15&&"cdf"!==_s15&&Object(Z.o)("Invalid density method: "+_s15),"shared"===t.resolve&&(_l3||(_l3=Object(Z.q)(_r36,t.field)),_f3=_h3=t.steps||_h3),_i18.forEach(function(e){var n=ve(e,_a17)[_s15],r=t.counts?e.length:1;$e(n,_l3||Object(Z.q)(e),_f3,_h3).forEach(function(t){var n={};for(var _t35=0;_t35<_o11.length;++_t35){n[_o11[_t35]]=e.dims[_t35];}n[_u8[0]]=t[0],n[_u8[1]]=t[1]*r,_c4.push(ct(n));});}),this.value&&(n.rem=this.value),this.value=n.add=n.source=_c4;}return n;}}),Object(Z.z)(Gn,xt),Object(Z.z)(Xn,zt,{transform:function transform(t,e){var _this12=this;var n=e.dataflow;if(this._pending)return Yn(this,e,this._pending);if(function(t){return t.modified("async")&&!(t.modified("values")||t.modified("url")||t.modified("format"));}(t))return e.StopPropagation;if(t.values)return Yn(this,e,n.parse(t.values,t.format));if(t.async){return {async:n.request(t.url,t.format).then(function(t){return _this12._pending=Object(Z.i)(t.data),function(t){return t.touch(_this12);};})};}return n.request(t.url,t.format).then(function(t){return Yn(_this12,e,Object(Z.i)(t.data));});}}),Jn.Definition={type:"Lookup",metadata:{modifies:!0},params:[{name:"index",type:"index",params:[{name:"from",type:"data",required:!0},{name:"key",type:"field",required:!0}]},{name:"values",type:"field",array:!0},{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0},{name:"default",default:null}]},Object(Z.z)(Jn,zt,{transform:function transform(t,e){var n=t.fields,r=t.index,i=t.values,o=null==t.default?null:t.default,a=t.modified(),s=n.length;var u,c,f=a?e.SOURCE:e.ADD,h=e,d=t.as;return i?(c=i.length,s>1&&!d&&Object(Z.o)('Multi-field lookup requires explicit "as" parameter.'),d&&d.length!==s*c&&Object(Z.o)('The "as" parameter has too few output field names.'),d=d||i.map(Z.h),u=function u(t){for(var e,a,u=0,l=0;u<s;++u){if(null==(a=r.get(n[u](t))))for(e=0;e<c;++e,++l){t[d[l]]=o;}else for(e=0;e<c;++e,++l){t[d[l]]=i[e](a);}}}):(d||Object(Z.o)("Missing output field names."),u=function u(t){for(var e,i=0;i<s;++i){e=r.get(n[i](t)),t[d[i]]=null==e?o:e;}}),a?h=e.reflow(!0):f|=(n.some(function(t){return e.modified(t.fields);}))?e.MOD:0,e.visit(f,u),h.modifies(d);}}),Object(Z.z)(Qn,xt),Object(Z.z)(tr,xt),Object(Z.z)(nr,zt,{transform:function transform(t,e){return this.modified(t.modified()),this.value=t,e.fork(e.NO_SOURCE|e.NO_FIELDS);}}),rr.Definition={type:"Pivot",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"field",type:"field",required:!0},{name:"value",type:"field",required:!0},{name:"op",type:"enum",values:en,default:"sum"},{name:"limit",type:"number",default:0},{name:"key",type:"field"}]},Object(Z.z)(rr,hn,{_transform:hn.prototype.transform,transform:function transform(t,e){return this._transform(function(t,e){var n=t.field,r=t.value,i=("count"===t.op?"__count__":t.op)||"sum",o=Object(Z.g)(n).concat(Object(Z.g)(r)),a=function(t,e,n){var r={},i=[];return n.visit(n.SOURCE,function(e){var n=t(e);r[n]||(r[n]=1,i.push(n));}),i.sort(Z.j),e?i.slice(0,e):i;}(n,t.limit||0,e);e.changed()&&t.set("__pivot__",null,null,!0);return {key:t.key,groupby:t.groupby,ops:a.map(function(){return i;}),fields:a.map(function(t){return function(t,e,n,r){return Object(Z.f)(function(r){return e(r)===t?n(r):NaN;},r,t+"");}(t,n,r,o);}),as:a.map(function(t){return t+"";}),modified:t.modified.bind(t)};}(t,e),e);}}),Object(Z.z)(ir,Rn,{transform:function transform(t,e){var _this13=this;var n=t.subflow,r=t.field,i=function i(t){return _this13.subflow(st(t),n,e,t);};return (t.modified("field")||r&&e.modified(Object(Z.g)(r)))&&Object(Z.o)("PreFacet does not support field modification."),this.initTargets(),r?(e.visit(e.MOD,function(t){var e=i(t);r(t).forEach(function(t){return e.mod(t);});}),e.visit(e.ADD,function(t){var e=i(t);r(t).forEach(function(t){return e.add(ct(t));});}),e.visit(e.REM,function(t){var e=i(t);r(t).forEach(function(t){return e.rem(t);});})):(e.visit(e.MOD,function(t){return i(t).mod(t);}),e.visit(e.ADD,function(t){return i(t).add(t);}),e.visit(e.REM,function(t){return i(t).rem(t);})),e.clean()&&e.runAfter(function(){return _this13.clean();}),e;}}),or.Definition={type:"Project",metadata:{generates:!0,changes:!0},params:[{name:"fields",type:"field",array:!0},{name:"as",type:"string",null:!0,array:!0}]},Object(Z.z)(or,zt,{transform:function transform(t,e){var n=e.fork(e.NO_SOURCE),r=t.fields,i=_n(t.fields,t.as||[]),o=r?function(t,e){return function(t,e,n,r){for(var _i19=0,_o12=n.length;_i19<_o12;++_i19){e[r[_i19]]=n[_i19](t);}return e;}(t,e,r,i);}:ft;var a;return this.value?a=this.value:(e=e.addAll(),a=this.value={}),e.visit(e.REM,function(t){var e=st(t);n.rem.push(a[e]),a[e]=null;}),e.visit(e.ADD,function(t){var e=o(t,ct({}));a[st(t)]=e,n.add.push(e);}),e.visit(e.MOD,function(t){n.mod.push(o(t,a[st(t)]));}),n;}}),Object(Z.z)(ar,zt,{transform:function transform(t,e){return this.value=t.value,t.modified("value")?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation;}}),sr.Definition={type:"Quantile",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"field",type:"field",required:!0},{name:"probs",type:"number",array:!0},{name:"step",type:"number",default:.01},{name:"as",type:"string",array:!0,default:["prob","value"]}]};function ur(t){zt.call(this,null,t);}function cr(t){zt.call(this,[],t),this.count=0;}function lr(t){zt.call(this,null,t);}function fr(t){zt.call(this,null,t),this.modified(!0);}function hr(t){zt.call(this,null,t);}Object(Z.z)(sr,zt,{transform:function transform(t,e){var n=e.fork(e.NO_SOURCE|e.NO_FIELDS),r=t.as||["prob","value"];if(this.value&&!t.modified()&&!e.changed())return n.source=this.value,n;var i=Sn(e.materialize(e.SOURCE).source,t.groupby,t.field),o=(t.groupby||[]).map(Z.h),a=[],s=t.step||.01,u=t.probs||Ge(s/2,1-1e-14,s),c=u.length;return i.forEach(function(t){var e=Zt(t,u);for(var _n30=0;_n30<c;++_n30){var _i20={};for(var _e35=0;_e35<o.length;++_e35){_i20[o[_e35]]=t.dims[_e35];}_i20[r[0]]=u[_n30],_i20[r[1]]=e[_n30],a.push(ct(_i20));}}),this.value&&(n.rem=this.value),this.value=n.add=n.source=a,n;}}),Object(Z.z)(ur,zt,{transform:function transform(t,e){var n,r;return this.value?r=this.value:(n=e=e.addAll(),r=this.value={}),t.derive&&(n=e.fork(e.NO_SOURCE),e.visit(e.REM,function(t){var e=st(t);n.rem.push(r[e]),r[e]=null;}),e.visit(e.ADD,function(t){var e=lt(t);r[st(t)]=e,n.add.push(e);}),e.visit(e.MOD,function(t){var e=r[st(t)];for(var _r37 in t){e[_r37]=t[_r37],n.modifies(_r37);}n.mod.push(e);})),n;}}),cr.Definition={type:"Sample",metadata:{},params:[{name:"size",type:"number",default:1e3}]},Object(Z.z)(cr,zt,{transform:function transform(t,e){var n=e.fork(e.NO_SOURCE),r=t.modified("size"),i=t.size,o=this.value.reduce(function(t,e){return t[st(e)]=1,t;},{});var a=this.value,s=this.count,u=0;function c(t){var e,r;a.length<i?a.push(t):(r=~~((s+1)*re()))<a.length&&r>=u&&(e=a[r],o[st(e)]&&n.rem.push(e),a[r]=t),++s;}if(e.rem.length&&(e.visit(e.REM,function(t){var e=st(t);o[e]&&(o[e]=-1,n.rem.push(t)),--s;}),a=a.filter(function(t){return -1!==o[st(t)];})),(e.rem.length||r)&&a.length<i&&e.source&&(u=s=a.length,e.visit(e.SOURCE,function(t){o[st(t)]||c(t);}),u=-1),r&&a.length>i){var _t36=a.length-i;for(var _e36=0;_e36<_t36;++_e36){o[st(a[_e36])]=-1,n.rem.push(a[_e36]);}a=a.slice(_t36);}return e.mod.length&&e.visit(e.MOD,function(t){o[st(t)]&&n.mod.push(t);}),e.add.length&&e.visit(e.ADD,c),(e.add.length||u<0)&&(n.add=a.filter(function(t){return !o[st(t)];})),this.count=s,this.value=n.source=a,n;}}),lr.Definition={type:"Sequence",metadata:{generates:!0,changes:!0},params:[{name:"start",type:"number",required:!0},{name:"stop",type:"number",required:!0},{name:"step",type:"number",default:1},{name:"as",type:"string",default:"data"}]},Object(Z.z)(lr,zt,{transform:function transform(t,e){if(this.value&&!t.modified())return;var n=e.materialize().fork(e.MOD),r=t.as||"data";return n.rem=this.value?e.rem.concat(this.value):e.rem,this.value=Ge(t.start,t.stop,t.step||1).map(function(t){var e={};return e[r]=t,ct(e);}),n.add=e.add.concat(this.value),n;}}),Object(Z.z)(fr,zt,{transform:function transform(t,e){return this.value=e.source,e.changed()?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation;}});var dr=["unit0","unit1"];function pr(t){zt.call(this,Object(Z.t)(),t);}function mr(t){zt.call(this,null,t);}hr.Definition={type:"TimeUnit",metadata:{modifies:!0},params:[{name:"field",type:"field",required:!0},{name:"interval",type:"boolean",default:!0},{name:"units",type:"enum",values:Xe.j,array:!0},{name:"step",type:"number",default:1},{name:"maxbins",type:"number",default:40},{name:"extent",type:"date",array:!0},{name:"timezone",type:"enum",default:"local",values:["local","utc"]},{name:"as",type:"string",array:!0,length:2,default:dr}]},Object(Z.z)(hr,zt,{transform:function transform(t,e){var n=t.field,r=!1!==t.interval,i="utc"===t.timezone,o=this._floor(t,e),a=(i?Xe.v:Xe.p)(o.unit).offset,s=t.as||dr,u=s[0],c=s[1],l=o.step;var f=o.start||1/0,h=o.stop||-1/0,d=e.ADD;return (t.modified()||e.modified(Object(Z.g)(n)))&&(d=(e=e.reflow(!0)).SOURCE,f=1/0,h=-1/0),e.visit(d,function(t){var e=n(t);var i,s;null==e?(t[u]=null,r&&(t[c]=null)):(t[u]=i=s=o(e),r&&(t[c]=s=a(i,l)),i<f&&(f=i),s>h&&(h=s));}),o.start=f,o.stop=h,e.modifies(r?s:u);},_floor:function _floor(t,e){var n="utc"===t.timezone,_ref2=t.units?{units:t.units,step:t.step||1}:Object(Xe.n)({extent:t.extent||Object(Z.q)(e.materialize(e.SOURCE).source,t.field),maxbins:t.maxbins}),r=_ref2.units,i=_ref2.step,o=Object(Xe.t)(r),a=this.value||{},s=(n?Xe.u:Xe.o)(o,i);return s.unit=Object(Z.W)(o),s.units=o,s.step=i,s.start=a.start,s.stop=a.stop,this.value=s;}}),Object(Z.z)(pr,zt,{transform:function transform(t,e){var n=e.dataflow,r=t.field,i=this.value,o=function o(t){return i.set(r(t),t);};var a=!0;return t.modified("field")||e.modified(r.fields)?(i.clear(),e.visit(e.SOURCE,o)):e.changed()?(e.visit(e.REM,function(t){return i.delete(r(t));}),e.visit(e.ADD,o)):a=!1,this.modified(a),i.empty>n.cleanThreshold&&n.runAfter(i.clean),e.fork();}}),Object(Z.z)(mr,zt,{transform:function transform(t,e){(!this.value||t.modified("field")||t.modified("sort")||e.changed()||t.sort&&e.modified(t.sort.fields))&&(this.value=(t.sort?e.source.slice().sort(dt(t.sort)):e.source).map(t.field));}});var gr={row_number:function row_number(){return {next:function next(t){return t.index+1;}};},rank:function rank(){var t;return {init:function init(){return t=1;},next:function next(e){var n=e.index,r=e.data;return n&&e.compare(r[n-1],r[n])?t=n+1:t;}};},dense_rank:function dense_rank(){var t;return {init:function init(){return t=1;},next:function next(e){var n=e.index,r=e.data;return n&&e.compare(r[n-1],r[n])?++t:t;}};},percent_rank:function percent_rank(){var t=gr.rank(),e=t.next;return {init:t.init,next:function next(t){return (e(t)-1)/(t.data.length-1);}};},cume_dist:function cume_dist(){var t;return {init:function init(){return t=0;},next:function next(e){var n=e.data,r=e.compare;var i=e.index;if(t<i){for(;i+1<n.length&&!r(n[i],n[i+1]);){++i;}t=i;}return (1+t)/n.length;}};},ntile:function ntile(t,e){(e=+e)>0||Object(Z.o)("ntile num must be greater than zero.");var n=gr.cume_dist(),r=n.next;return {init:n.init,next:function next(t){return Math.ceil(e*r(t));}};},lag:function lag(t,e){return e=+e||1,{next:function next(n){var r=n.index-e;return r>=0?t(n.data[r]):null;}};},lead:function lead(t,e){return e=+e||1,{next:function next(n){var r=n.index+e,i=n.data;return r<i.length?t(i[r]):null;}};},first_value:function first_value(t){return {next:function next(e){return t(e.data[e.i0]);}};},last_value:function last_value(t){return {next:function next(e){return t(e.data[e.i1-1]);}};},nth_value:function nth_value(t,e){return (e=+e)>0||Object(Z.o)("nth_value nth must be greater than zero."),{next:function next(n){var r=n.i0+(e-1);return r<n.i1?t(n.data[r]):null;}};},prev_value:function prev_value(t){var e;return {init:function init(){return e=null;},next:function next(n){var r=t(n.data[n.index]);return null!=r?e=r:e;}};},next_value:function next_value(t){var e,n;return {init:function init(){return e=null,n=-1;},next:function next(r){var i=r.data;return r.index<=n?e:(n=function(t,e,n){for(var _r38=e.length;n<_r38;++n){var _r39=t(e[n]);if(null!=_r39)return n;}return -1;}(t,i,r.index))<0?(n=i.length,e=null):e=t(i[n]);}};}};var vr=Object.keys(gr);function yr(t){var e=Object(Z.i)(t.ops),n=Object(Z.i)(t.fields),r=Object(Z.i)(t.params),i=Object(Z.i)(t.as),o=this.outputs=[],a=this.windows=[],s={},u={},c=[],l=[];var f=!0;function h(t){Object(Z.i)(Object(Z.g)(t)).forEach(function(t){return s[t]=1;});}h(t.sort),e.forEach(function(t,e){var s=n[e],d=Object(Z.h)(s),p=Je(t,d,i[e]);if(h(s),o.push(p),Object(Z.w)(gr,t))a.push(function(t,e,n,r){var i=gr[t](e,n);return {init:i.init||Z.Ma,update:function update(t,e){e[r]=i.next(t);}};}(t,n[e],r[e],p));else {if(null==s&&"count"!==t&&Object(Z.o)("Null aggregate field specified."),"count"===t)return void c.push(p);f=!1;var _e37=u[d];_e37||((_e37=u[d]=[]).field=s,l.push(_e37)),_e37.push(nn(t,p));}}),(c.length||l.length)&&(this.cell=function(t,e,n){t=t.map(function(t){return cn(t,t.field);});var r={num:0,agg:null,store:!1,count:e};if(!n)for(var i=t.length,o=r.agg=Array(i),a=0;a<i;++a){o[a]=new t[a](r);}if(r.store)var s=r.data=new ln();return r.add=function(t){if(r.num+=1,!n){s&&s.add(t);for(var _e38=0;_e38<i;++_e38){o[_e38].add(o[_e38].get(t),t);}}},r.rem=function(t){if(r.num-=1,!n){s&&s.rem(t);for(var _e39=0;_e39<i;++_e39){o[_e39].rem(o[_e39].get(t),t);}}},r.set=function(t){var i,a;for(s&&s.values(),i=0,a=e.length;i<a;++i){t[e[i]]=r.num;}if(!n)for(i=0,a=o.length;i<a;++i){o[i].set(t);}},r.init=function(){r.num=0,s&&s.reset();for(var _t37=0;_t37<i;++_t37){o[_t37].init();}},r;}(l,c,f)),this.inputs=Object.keys(s);}var br=yr.prototype;function xr(t){zt.call(this,{},t),this._mlen=0,this._mods=[];}function wr(t,e,n,r){var i=r.sort,o=i&&!r.ignorePeers,a=r.frame||[null,0],s=t.data(n),u=s.length,c=o?Object(Ke.a)(i):null,l={i0:0,i1:0,p0:0,p1:0,index:0,data:s,compare:i||Object(Z.m)(-1)};e.init();for(var _t38=0;_t38<u;++_t38){kr(l,a,_t38,u),o&&Er(l,c),e.update(l,s[_t38]);}}function kr(t,e,n,r){t.p0=t.i0,t.p1=t.i1,t.i0=null==e[0]?0:Math.max(0,n-Math.abs(e[0])),t.i1=null==e[1]?r:Math.min(r,n+Math.abs(e[1])+1),t.index=n;}function Er(t,e){var n=t.i0,r=t.i1-1,i=t.compare,o=t.data,a=o.length-1;n>0&&!i(o[n],o[n-1])&&(t.i0=e.left(o,o[n])),r<a&&!i(o[r],o[r+1])&&(t.i1=e.right(o,o[r]));}function Cr(t,e,n){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+e)/6,(t._y0+4*t._y1+n)/6);}function Ar(t){this._context=t;}br.init=function(){this.windows.forEach(function(t){return t.init();}),this.cell&&this.cell.init();},br.update=function(t,e){var n=this.cell,r=this.windows,i=t.data,o=r&&r.length;var a;if(n){for(a=t.p0;a<t.i0;++a){n.rem(i[a]);}for(a=t.p1;a<t.i1;++a){n.add(i[a]);}n.set(e);}for(a=0;a<o;++a){r[a].update(t,e);}},xr.Definition={type:"Window",metadata:{modifies:!0},params:[{name:"sort",type:"compare"},{name:"groupby",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:vr.concat(en)},{name:"params",type:"number",null:!0,array:!0},{name:"fields",type:"field",null:!0,array:!0},{name:"as",type:"string",null:!0,array:!0},{name:"frame",type:"number",null:!0,array:!0,length:2,default:[null,0]},{name:"ignorePeers",type:"boolean",default:!1}]},Object(Z.z)(xr,zt,{transform:function transform(t,e){var _this14=this;this.stamp=e.stamp;var n=t.modified(),r=dt(t.sort),i=Ye(t.groupby),o=function o(t){return _this14.group(i(t));};var a=this.state;a&&!n||(a=this.state=new yr(t)),n||e.modified(a.inputs)?(this.value={},e.visit(e.SOURCE,function(t){return o(t).add(t);})):(e.visit(e.REM,function(t){return o(t).remove(t);}),e.visit(e.ADD,function(t){return o(t).add(t);}));for(var _e40=0,_n31=this._mlen;_e40<_n31;++_e40){wr(this._mods[_e40],a,r,t);}return this._mlen=0,this._mods=[],e.reflow(n).modifies(a.outputs);},group:function group(t){var e=this.value[t];return e||((e=this.value[t]=pn(st)).stamp=-1),e.stamp<this.stamp&&(e.stamp=this.stamp,this._mods[this._mlen++]=e),e;}}),Ar.prototype={areaStart:function areaStart(){this._line=0;},areaEnd:function areaEnd(){this._line=NaN;},lineStart:function lineStart(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0;},lineEnd:function lineEnd(){switch(this._point){case 3:Cr(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line;},point:function point(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Cr(this,t,e);}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e;}};var Or=function Or(){};function _r(t){this._context=t;}_r.prototype={areaStart:Or,areaEnd:Or,lineStart:function lineStart(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0;},lineEnd:function lineEnd(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);}},point:function point(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x2=t,this._y2=e;break;case 1:this._point=2,this._x3=t,this._y3=e;break;case 2:this._point=3,this._x4=t,this._y4=e,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+e)/6);break;default:Cr(this,t,e);}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e;}};function Sr(t){this._context=t;}Sr.prototype={areaStart:function areaStart(){this._line=0;},areaEnd:function areaEnd(){this._line=NaN;},lineStart:function lineStart(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0;},lineEnd:function lineEnd(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line;},point:function point(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+t)/6,r=(this._y0+4*this._y1+e)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:Cr(this,t,e);}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e;}};function Dr(t,e){this._basis=new Ar(t),this._beta=e;}Dr.prototype={lineStart:function lineStart(){this._x=[],this._y=[],this._basis.lineStart();},lineEnd:function lineEnd(){var t=this._x,e=this._y,n=t.length-1;if(n>0)for(var r,i=t[0],o=e[0],a=t[n]-i,s=e[n]-o,u=-1;++u<=n;){r=u/n,this._basis.point(this._beta*t[u]+(1-this._beta)*(i+r*a),this._beta*e[u]+(1-this._beta)*(o+r*s));}this._x=this._y=null,this._basis.lineEnd();},point:function point(t,e){this._x.push(+t),this._y.push(+e);}};var Fr=function t(e){function n(t){return 1===e?new Ar(t):new Dr(t,e);}return n.beta=function(e){return t(+e);},n;}(.85);function Tr(t,e,n){t._context.bezierCurveTo(t._x1+t._k*(t._x2-t._x0),t._y1+t._k*(t._y2-t._y0),t._x2+t._k*(t._x1-e),t._y2+t._k*(t._y1-n),t._x2,t._y2);}function Nr(t,e){this._context=t,this._k=(1-e)/6;}Nr.prototype={areaStart:function areaStart(){this._line=0;},areaEnd:function areaEnd(){this._line=NaN;},lineStart:function lineStart(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0;},lineEnd:function lineEnd(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:Tr(this,this._x1,this._y1);}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line;},point:function point(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2,this._x1=t,this._y1=e;break;case 2:this._point=3;default:Tr(this,t,e);}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e;}};var Ir=function t(e){function n(t){return new Nr(t,e);}return n.tension=function(e){return t(+e);},n;}(0);function Rr(t,e){this._context=t,this._k=(1-e)/6;}Rr.prototype={areaStart:function areaStart(){this._line=0;},areaEnd:function areaEnd(){this._line=NaN;},lineStart:function lineStart(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0;},lineEnd:function lineEnd(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line;},point:function point(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:Tr(this,t,e);}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e;}};var Mr=function t(e){function n(t){return new Rr(t,e);}return n.tension=function(e){return t(+e);},n;}(0);function jr(t,e){this._context=t,this._k=(1-e)/6;}jr.prototype={areaStart:Or,areaEnd:Or,lineStart:function lineStart(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0;},lineEnd:function lineEnd(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5);}},point:function point(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._x3=t,this._y3=e;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=e);break;case 2:this._point=3,this._x5=t,this._y5=e;break;default:Tr(this,t,e);}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e;}};var Br=function t(e){function n(t){return new jr(t,e);}return n.tension=function(e){return t(+e);},n;}(0),Pr=Math.abs,Lr=Math.atan2,zr=Math.cos,Ur=Math.max,Wr=Math.min,Vr=Math.sin,qr=Math.sqrt,$r=1e-12,Hr=Math.PI,Gr=Hr/2,Kr=2*Hr;function Xr(t){return t>=1?Gr:t<=-1?-Gr:Math.asin(t);}function Yr(t,e,n){var r=t._x1,i=t._y1,o=t._x2,a=t._y2;if(t._l01_a>$r){var s=2*t._l01_2a+3*t._l01_a*t._l12_a+t._l12_2a,u=3*t._l01_a*(t._l01_a+t._l12_a);r=(r*s-t._x0*t._l12_2a+t._x2*t._l01_2a)/u,i=(i*s-t._y0*t._l12_2a+t._y2*t._l01_2a)/u;}if(t._l23_a>$r){var c=2*t._l23_2a+3*t._l23_a*t._l12_a+t._l12_2a,l=3*t._l23_a*(t._l23_a+t._l12_a);o=(o*c+t._x1*t._l23_2a-e*t._l12_2a)/l,a=(a*c+t._y1*t._l23_2a-n*t._l12_2a)/l;}t._context.bezierCurveTo(r,i,o,a,t._x2,t._y2);}function Jr(t,e){this._context=t,this._alpha=e;}Jr.prototype={areaStart:function areaStart(){this._line=0;},areaEnd:function areaEnd(){this._line=NaN;},lineStart:function lineStart(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0;},lineEnd:function lineEnd(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line;},point:function point(t,e){if(t=+t,e=+e,this._point){var n=this._x2-t,r=this._y2-e;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha));}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3;default:Yr(this,t,e);}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e;}};var Qr=function t(e){function n(t){return e?new Jr(t,e):new Nr(t,0);}return n.alpha=function(e){return t(+e);},n;}(.5);function Zr(t,e){this._context=t,this._alpha=e;}Zr.prototype={areaStart:Or,areaEnd:Or,lineStart:function lineStart(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0;},lineEnd:function lineEnd(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5);}},point:function point(t,e){if(t=+t,e=+e,this._point){var n=this._x2-t,r=this._y2-e;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha));}switch(this._point){case 0:this._point=1,this._x3=t,this._y3=e;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=e);break;case 2:this._point=3,this._x5=t,this._y5=e;break;default:Yr(this,t,e);}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e;}};var ti=function t(e){function n(t){return e?new Zr(t,e):new jr(t,0);}return n.alpha=function(e){return t(+e);},n;}(.5);function ei(t,e){this._context=t,this._alpha=e;}ei.prototype={areaStart:function areaStart(){this._line=0;},areaEnd:function areaEnd(){this._line=NaN;},lineStart:function lineStart(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0;},lineEnd:function lineEnd(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line;},point:function point(t,e){if(t=+t,e=+e,this._point){var n=this._x2-t,r=this._y2-e;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha));}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:Yr(this,t,e);}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=e;}};var ni=function t(e){function n(t){return e?new ei(t,e):new Rr(t,0);}return n.alpha=function(e){return t(+e);},n;}(.5);function ri(t){this._context=t;}ri.prototype={areaStart:function areaStart(){this._line=0;},areaEnd:function areaEnd(){this._line=NaN;},lineStart:function lineStart(){this._point=0;},lineEnd:function lineEnd(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line;},point:function point(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:this._context.lineTo(t,e);}}};var ii=function ii(t){return new ri(t);};function oi(t){this._context=t;}oi.prototype={areaStart:Or,areaEnd:Or,lineStart:function lineStart(){this._point=0;},lineEnd:function lineEnd(){this._point&&this._context.closePath();},point:function point(t,e){t=+t,e=+e,this._point?this._context.lineTo(t,e):(this._point=1,this._context.moveTo(t,e));}};function ai(t){return t<0?-1:1;}function si(t,e,n){var r=t._x1-t._x0,i=e-t._x1,o=(t._y1-t._y0)/(r||i<0&&-0),a=(n-t._y1)/(i||r<0&&-0),s=(o*i+a*r)/(r+i);return (ai(o)+ai(a))*Math.min(Math.abs(o),Math.abs(a),.5*Math.abs(s))||0;}function ui(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e;}function ci(t,e,n){var r=t._x0,i=t._y0,o=t._x1,a=t._y1,s=(o-r)/3;t._context.bezierCurveTo(r+s,i+s*e,o-s,a-s*n,o,a);}function li(t){this._context=t;}function fi(t){this._context=new hi(t);}function hi(t){this._context=t;}function di(t){this._context=t;}function pi(t){var e,n,r=t.length-1,i=new Array(r),o=new Array(r),a=new Array(r);for(i[0]=0,o[0]=2,a[0]=t[0]+2*t[1],e=1;e<r-1;++e){i[e]=1,o[e]=4,a[e]=4*t[e]+2*t[e+1];}for(i[r-1]=2,o[r-1]=7,a[r-1]=8*t[r-1]+t[r],e=1;e<r;++e){n=i[e]/o[e-1],o[e]-=n,a[e]-=n*a[e-1];}for(i[r-1]=a[r-1]/o[r-1],e=r-2;e>=0;--e){i[e]=(a[e]-i[e+1])/o[e];}for(o[r-1]=(t[r]+i[r-1])/2,e=0;e<r-1;++e){o[e]=2*t[e+1]-i[e+1];}return [i,o];}li.prototype={areaStart:function areaStart(){this._line=0;},areaEnd:function areaEnd(){this._line=NaN;},lineStart:function lineStart(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0;},lineEnd:function lineEnd(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:ci(this,this._t0,ui(this,this._t0));}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line;},point:function point(t,e){var n=NaN;if(e=+e,(t=+t)!==this._x1||e!==this._y1){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;break;case 2:this._point=3,ci(this,ui(this,n=si(this,t,e)),n);break;default:ci(this,this._t0,n=si(this,t,e));}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n;}}},(fi.prototype=Object.create(li.prototype)).point=function(t,e){li.prototype.point.call(this,e,t);},hi.prototype={moveTo:function moveTo(t,e){this._context.moveTo(e,t);},closePath:function closePath(){this._context.closePath();},lineTo:function lineTo(t,e){this._context.lineTo(e,t);},bezierCurveTo:function bezierCurveTo(t,e,n,r,i,o){this._context.bezierCurveTo(e,t,r,n,o,i);}},di.prototype={areaStart:function areaStart(){this._line=0;},areaEnd:function areaEnd(){this._line=NaN;},lineStart:function lineStart(){this._x=[],this._y=[];},lineEnd:function lineEnd(){var t=this._x,e=this._y,n=t.length;if(n)if(this._line?this._context.lineTo(t[0],e[0]):this._context.moveTo(t[0],e[0]),2===n)this._context.lineTo(t[1],e[1]);else for(var r=pi(t),i=pi(e),o=0,a=1;a<n;++o,++a){this._context.bezierCurveTo(r[0][o],i[0][o],r[1][o],i[1][o],t[a],e[a]);}(this._line||0!==this._line&&1===n)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null;},point:function point(t,e){this._x.push(+t),this._y.push(+e);}};function mi(t,e){this._context=t,this._t=e;}mi.prototype={areaStart:function areaStart(){this._line=0;},areaEnd:function areaEnd(){this._line=NaN;},lineStart:function lineStart(){this._x=this._y=NaN,this._point=0;},lineEnd:function lineEnd(){0<this._t&&this._t<1&&2===this._point&&this._context.lineTo(this._x,this._y),(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line);},point:function point(t,e){switch(t=+t,e=+e,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,e),this._context.lineTo(t,e);else {var n=this._x*(1-this._t)+t*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,e);}}this._x=t,this._y=e;}};var gi=Math.PI,vi=2*gi,yi=vi-1e-6;function bi(){this._x0=this._y0=this._x1=this._y1=null,this._="";}function xi(){return new bi();}bi.prototype=xi.prototype={constructor:bi,moveTo:function moveTo(t,e){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e);},closePath:function closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z");},lineTo:function lineTo(t,e){this._+="L"+(this._x1=+t)+","+(this._y1=+e);},quadraticCurveTo:function quadraticCurveTo(t,e,n,r){this._+="Q"+ +t+","+ +e+","+(this._x1=+n)+","+(this._y1=+r);},bezierCurveTo:function bezierCurveTo(t,e,n,r,i,o){this._+="C"+ +t+","+ +e+","+ +n+","+ +r+","+(this._x1=+i)+","+(this._y1=+o);},arcTo:function arcTo(t,e,n,r,i){t=+t,e=+e,n=+n,r=+r,i=+i;var o=this._x1,a=this._y1,s=n-t,u=r-e,c=o-t,l=a-e,f=c*c+l*l;if(i<0)throw new Error("negative radius: "+i);if(null===this._x1)this._+="M"+(this._x1=t)+","+(this._y1=e);else if(f>1e-6){if(Math.abs(l*s-u*c)>1e-6&&i){var h=n-o,d=r-a,p=s*s+u*u,m=h*h+d*d,g=Math.sqrt(p),v=Math.sqrt(f),y=i*Math.tan((gi-Math.acos((p+f-m)/(2*g*v)))/2),b=y/v,x=y/g;Math.abs(b-1)>1e-6&&(this._+="L"+(t+b*c)+","+(e+b*l)),this._+="A"+i+","+i+",0,0,"+ +(l*h>c*d)+","+(this._x1=t+x*s)+","+(this._y1=e+x*u);}else this._+="L"+(this._x1=t)+","+(this._y1=e);}else;},arc:function arc(t,e,n,r,i,o){t=+t,e=+e,o=!!o;var a=(n=+n)*Math.cos(r),s=n*Math.sin(r),u=t+a,c=e+s,l=1^o,f=o?r-i:i-r;if(n<0)throw new Error("negative radius: "+n);null===this._x1?this._+="M"+u+","+c:(Math.abs(this._x1-u)>1e-6||Math.abs(this._y1-c)>1e-6)&&(this._+="L"+u+","+c),n&&(f<0&&(f=f%vi+vi),f>yi?this._+="A"+n+","+n+",0,1,"+l+","+(t-a)+","+(e-s)+"A"+n+","+n+",0,1,"+l+","+(this._x1=u)+","+(this._y1=c):f>1e-6&&(this._+="A"+n+","+n+",0,"+ +(f>=gi)+","+l+","+(this._x1=t+n*Math.cos(i))+","+(this._y1=e+n*Math.sin(i))));},rect:function rect(t,e,n,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+e)+"h"+ +n+"v"+ +r+"h"+-n+"Z";},toString:function toString(){return this._;}};var wi=xi,ki=function ki(t){return function(){return t;};};function Ei(t){return t.innerRadius;}function Ci(t){return t.outerRadius;}function Ai(t){return t.startAngle;}function Oi(t){return t.endAngle;}function _i(t){return t&&t.padAngle;}function Si(t,e,n,r,i,o,a){var s=t-n,u=e-r,c=(a?o:-o)/qr(s*s+u*u),l=c*u,f=-c*s,h=t+l,d=e+f,p=n+l,m=r+f,g=(h+p)/2,v=(d+m)/2,y=p-h,b=m-d,x=y*y+b*b,w=i-o,k=h*m-p*d,E=(b<0?-1:1)*qr(Ur(0,w*w*x-k*k)),C=(k*b-y*E)/x,A=(-k*y-b*E)/x,O=(k*b+y*E)/x,_=(-k*y+b*E)/x,S=C-g,D=A-v,F=O-g,T=_-v;return S*S+D*D>F*F+T*T&&(C=O,A=_),{cx:C,cy:A,x01:-l,y01:-f,x11:C*(i/w-1),y11:A*(i/w-1)};}var Di=function Di(t){return "object"==_typeof$1(t)&&"length"in t?t:Array.from(t);};function Fi(t){return t[0];}function Ti(t){return t[1];}var Ni=function Ni(t,e){var n=ki(!0),r=null,i=ii,o=null;function a(a){var s,u,c,l=(a=Di(a)).length,f=!1;for(null==r&&(o=i(c=wi())),s=0;s<=l;++s){!(s<l&&n(u=a[s],s,a))===f&&((f=!f)?o.lineStart():o.lineEnd()),f&&o.point(+t(u,s,a),+e(u,s,a));}if(c)return o=null,c+""||null;}return t="function"==typeof t?t:void 0===t?Fi:ki(t),e="function"==typeof e?e:void 0===e?Ti:ki(e),a.x=function(e){return arguments.length?(t="function"==typeof e?e:ki(+e),a):t;},a.y=function(t){return arguments.length?(e="function"==typeof t?t:ki(+t),a):e;},a.defined=function(t){return arguments.length?(n="function"==typeof t?t:ki(!!t),a):n;},a.curve=function(t){return arguments.length?(i=t,null!=r&&(o=i(r)),a):i;},a.context=function(t){return arguments.length?(null==t?r=o=null:o=i(r=t),a):r;},a;},Ii=function Ii(t,e,n){var r=null,i=ki(!0),o=null,a=ii,s=null;function u(u){var c,l,f,h,d,p=(u=Di(u)).length,m=!1,g=new Array(p),v=new Array(p);for(null==o&&(s=a(d=wi())),c=0;c<=p;++c){if(!(c<p&&i(h=u[c],c,u))===m)if(m=!m)l=c,s.areaStart(),s.lineStart();else {for(s.lineEnd(),s.lineStart(),f=c-1;f>=l;--f){s.point(g[f],v[f]);}s.lineEnd(),s.areaEnd();}m&&(g[c]=+t(h,c,u),v[c]=+e(h,c,u),s.point(r?+r(h,c,u):g[c],n?+n(h,c,u):v[c]));}if(d)return s=null,d+""||null;}function c(){return Ni().defined(i).curve(a).context(o);}return t="function"==typeof t?t:void 0===t?Fi:ki(+t),e="function"==typeof e?e:ki(void 0===e?0:+e),n="function"==typeof n?n:void 0===n?Ti:ki(+n),u.x=function(e){return arguments.length?(t="function"==typeof e?e:ki(+e),r=null,u):t;},u.x0=function(e){return arguments.length?(t="function"==typeof e?e:ki(+e),u):t;},u.x1=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:ki(+t),u):r;},u.y=function(t){return arguments.length?(e="function"==typeof t?t:ki(+t),n=null,u):e;},u.y0=function(t){return arguments.length?(e="function"==typeof t?t:ki(+t),u):e;},u.y1=function(t){return arguments.length?(n=null==t?null:"function"==typeof t?t:ki(+t),u):n;},u.lineX0=u.lineY0=function(){return c().x(t).y(e);},u.lineY1=function(){return c().x(t).y(n);},u.lineX1=function(){return c().x(r).y(e);},u.defined=function(t){return arguments.length?(i="function"==typeof t?t:ki(!!t),u):i;},u.curve=function(t){return arguments.length?(a=t,null!=o&&(s=a(o)),u):a;},u.context=function(t){return arguments.length?(null==t?o=s=null:s=a(o=t),u):o;},u;},Ri={draw:function draw(t,e){var n=Math.sqrt(e/Hr);t.moveTo(n,0),t.arc(0,0,n,0,Kr);}};function ji(t,e){if("undefined"!=typeof document&&document.createElement){var _n32=document.createElement("canvas");if(_n32&&_n32.getContext)return _n32.width=t,_n32.height=e,_n32;}return null;}var Bi=function Bi(){return "undefined"!=typeof Image?Image:null;},Pi=Object(Ke.a)(qt.a),Li=Pi.right,zi=Pi.left;Object(Ke.a)(Kt).center;var Ui=Li;function Wi(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);}return this;}function Vi(t,e){switch(arguments.length){case 0:break;case 1:"function"==typeof t?this.interpolator(t):this.range(t);break;default:this.domain(t),"function"==typeof e?this.interpolator(e):this.range(e);}return this;}var qi=Symbol("implicit");function $i(){var t=new Map(),e=[],n=[],r=qi;function i(i){var o=i+"",a=t.get(o);if(!a){if(r!==qi)return r;t.set(o,a=e.push(i));}return n[(a-1)%n.length];}return i.domain=function(n){if(!arguments.length)return e.slice();e=[],t=new Map();var _iterator18=_createForOfIteratorHelper(n),_step18;try{for(_iterator18.s();!(_step18=_iterator18.n()).done;){var _r40=_step18.value;var _n33=_r40+"";t.has(_n33)||t.set(_n33,e.push(_r40));}}catch(err){_iterator18.e(err);}finally{_iterator18.f();}return i;},i.range=function(t){return arguments.length?(n=Array.from(t),i):n.slice();},i.unknown=function(t){return arguments.length?(r=t,i):r;},i.copy=function(){return $i(e,n).unknown(r);},Wi.apply(i,arguments),i;}var Hi=n(45),Gi=n(50);function Ki(t,e,n,r){var i,o=Object(Hi.c)(t,e,n);switch((r=Object(Gi.formatSpecifier)(null==r?",f":r)).type){case"s":var a=Math.max(Math.abs(t),Math.abs(e));return null!=r.precision||isNaN(i=Object(Gi.precisionPrefix)(o,a))||(r.precision=i),Object(Gi.formatPrefix)(r,a);case"":case"e":case"g":case"p":case"r":null!=r.precision||isNaN(i=Object(Gi.precisionRound)(o,Math.max(Math.abs(t),Math.abs(e))))||(r.precision=i-("e"===r.type));break;case"f":case"%":null!=r.precision||isNaN(i=Object(Gi.precisionFixed)(o))||(r.precision=i-2*("%"===r.type));}return Object(Gi.format)(r);}var Xi=function Xi(t,e,n){t.prototype=e.prototype=n,n.constructor=t;};function Yi(t,e){var n=Object.create(t.prototype);for(var r in e){n[r]=e[r];}return n;}function Ji(){}var Qi="\\s*([+-]?\\d+)\\s*",Zi="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",to="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",eo=/^#([0-9a-f]{3,8})$/,no=new RegExp("^rgb\\("+[Qi,Qi,Qi]+"\\)$"),ro=new RegExp("^rgb\\("+[to,to,to]+"\\)$"),io=new RegExp("^rgba\\("+[Qi,Qi,Qi,Zi]+"\\)$"),oo=new RegExp("^rgba\\("+[to,to,to,Zi]+"\\)$"),ao=new RegExp("^hsl\\("+[Zi,to,to]+"\\)$"),so=new RegExp("^hsla\\("+[Zi,to,to,Zi]+"\\)$"),uo={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function co(){return this.rgb().formatHex();}function lo(){return this.rgb().formatRgb();}function fo(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=eo.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?ho(e):3===n?new vo(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?po(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?po(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=no.exec(t))?new vo(e[1],e[2],e[3],1):(e=ro.exec(t))?new vo(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=io.exec(t))?po(e[1],e[2],e[3],e[4]):(e=oo.exec(t))?po(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=ao.exec(t))?wo(e[1],e[2]/100,e[3]/100,1):(e=so.exec(t))?wo(e[1],e[2]/100,e[3]/100,e[4]):uo.hasOwnProperty(t)?ho(uo[t]):"transparent"===t?new vo(NaN,NaN,NaN,0):null;}function ho(t){return new vo(t>>16&255,t>>8&255,255&t,1);}function po(t,e,n,r){return r<=0&&(t=e=n=NaN),new vo(t,e,n,r);}function mo(t){return t instanceof Ji||(t=fo(t)),t?new vo((t=t.rgb()).r,t.g,t.b,t.opacity):new vo();}function go(t,e,n,r){return 1===arguments.length?mo(t):new vo(t,e,n,null==r?1:r);}function vo(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r;}function yo(){return "#"+xo(this.r)+xo(this.g)+xo(this.b);}function bo(){var t=this.opacity;return (1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")");}function xo(t){return ((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16);}function wo(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Co(t,e,n,r);}function ko(t){if(t instanceof Co)return new Co(t.h,t.s,t.l,t.opacity);if(t instanceof Ji||(t=fo(t)),!t)return new Co();if(t instanceof Co)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),a=NaN,s=o-i,u=(o+i)/2;return s?(a=e===o?(n-r)/s+6*(n<r):n===o?(r-e)/s+2:(e-n)/s+4,s/=u<.5?o+i:2-o-i,a*=60):s=u>0&&u<1?0:a,new Co(a,s,u,t.opacity);}function Eo(t,e,n,r){return 1===arguments.length?ko(t):new Co(t,e,n,null==r?1:r);}function Co(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r;}function Ao(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e);}function Oo(t,e,n,r,i){var o=t*t,a=o*t;return ((1-3*t+3*o-a)*e+(4-6*o+3*a)*n+(1+3*t+3*o-3*a)*r+a*i)/6;}Xi(Ji,fo,{copy:function copy(t){return Object.assign(new this.constructor(),this,t);},displayable:function displayable(){return this.rgb().displayable();},hex:co,formatHex:co,formatHsl:function formatHsl(){return ko(this).formatHsl();},formatRgb:lo,toString:lo}),Xi(vo,go,Yi(Ji,{brighter:function brighter(t){return t=null==t?1/.7:Math.pow(1/.7,t),new vo(this.r*t,this.g*t,this.b*t,this.opacity);},darker:function darker(t){return t=null==t?.7:Math.pow(.7,t),new vo(this.r*t,this.g*t,this.b*t,this.opacity);},rgb:function rgb(){return this;},displayable:function displayable(){return -.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1;},hex:yo,formatHex:yo,formatRgb:bo,toString:bo})),Xi(Co,Eo,Yi(Ji,{brighter:function brighter(t){return t=null==t?1/.7:Math.pow(1/.7,t),new Co(this.h,this.s,this.l*t,this.opacity);},darker:function darker(t){return t=null==t?.7:Math.pow(.7,t),new Co(this.h,this.s,this.l*t,this.opacity);},rgb:function rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new vo(Ao(t>=240?t-240:t+120,i,r),Ao(t,i,r),Ao(t<120?t+240:t-120,i,r),this.opacity);},displayable:function displayable(){return (0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1;},formatHsl:function formatHsl(){var t=this.opacity;return (1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")");}}));var _o=function _o(t){var e=t.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,e-1):Math.floor(n*e),i=t[r],o=t[r+1],a=r>0?t[r-1]:2*i-o,s=r<e-1?t[r+2]:2*o-i;return Oo((n-r/e)*e,a,i,o,s);};},So=function So(t){var e=t.length;return function(n){var r=Math.floor(((n%=1)<0?++n:n)*e),i=t[(r+e-1)%e],o=t[r%e],a=t[(r+1)%e],s=t[(r+2)%e];return Oo((n-r/e)*e,i,o,a,s);};},Do=function Do(t){return function(){return t;};};function Fo(t,e){return function(n){return t+n*e;};}function To(t,e){var n=e-t;return n?Fo(t,n>180||n<-180?n-360*Math.round(n/360):n):Do(isNaN(t)?e:t);}function No(t){return 1==(t=+t)?Io:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n);};}(e,n,t):Do(isNaN(e)?n:e);};}function Io(t,e){var n=e-t;return n?Fo(t,n):Do(isNaN(t)?e:t);}var Ro=function t(e){var n=No(e);function r(t,e){var r=n((t=go(t)).r,(e=go(e)).r),i=n(t.g,e.g),o=n(t.b,e.b),a=Io(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=o(e),t.opacity=a(e),t+"";};}return r.gamma=t,r;}(1);function Mo(t){return function(e){var n,r,i=e.length,o=new Array(i),a=new Array(i),s=new Array(i);for(n=0;n<i;++n){r=go(e[n]),o[n]=r.r||0,a[n]=r.g||0,s[n]=r.b||0;}return o=t(o),a=t(a),s=t(s),r.opacity=1,function(t){return r.r=o(t),r.g=a(t),r.b=s(t),r+"";};};}var jo=Mo(_o),Bo=Mo(So),Po=function Po(t,e){e||(e=[]);var n,r=t?Math.min(e.length,t.length):0,i=e.slice();return function(o){for(n=0;n<r;++n){i[n]=t[n]*(1-o)+e[n]*o;}return i;};};function Lo(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView);}var zo=function zo(t,e){return (Lo(e)?Po:Uo)(t,e);};function Uo(t,e){var n,r=e?e.length:0,i=t?Math.min(r,t.length):0,o=new Array(i),a=new Array(r);for(n=0;n<i;++n){o[n]=Ko(t[n],e[n]);}for(;n<r;++n){a[n]=e[n];}return function(t){for(n=0;n<i;++n){a[n]=o[n](t);}return a;};}var Wo=function Wo(t,e){var n=new Date();return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n;};},Vo=function Vo(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n;};},qo=function qo(t,e){var n,r={},i={};for(n in null!==t&&"object"==_typeof$1(t)||(t={}),null!==e&&"object"==_typeof$1(e)||(e={}),e){n in t?r[n]=Ko(t[n],e[n]):i[n]=e[n];}return function(t){for(n in r){i[n]=r[n](t);}return i;};},$o=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ho=new RegExp($o.source,"g");var Go=function Go(t,e){var n,r,i,o=$o.lastIndex=Ho.lastIndex=0,a=-1,s=[],u=[];for(t+="",e+="";(n=$o.exec(t))&&(r=Ho.exec(e));){(i=r.index)>o&&(i=e.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,u.push({i:a,x:Vo(n,r)})),o=Ho.lastIndex;}return o<e.length&&(i=e.slice(o),s[a]?s[a]+=i:s[++a]=i),s.length<2?u[0]?function(t){return function(e){return t(e)+"";};}(u[0].x):function(t){return function(){return t;};}(e):(e=u.length,function(t){for(var n,r=0;r<e;++r){s[(n=u[r]).i]=n.x(t);}return s.join("");});},Ko=function Ko(t,e){var n,r=_typeof$1(e);return null==e||"boolean"===r?Do(e):("number"===r?Vo:"string"===r?(n=fo(e))?(e=n,Ro):Go:e instanceof fo?Ro:e instanceof Date?Wo:Lo(e)?Po:Array.isArray(e)?Uo:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?qo:Vo)(t,e);},Xo=function Xo(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n);};};function Yo(t){return +t;}var Jo=[0,1];function Qo(t){return t;}function Zo(t,e){return (e-=t=+t)?function(n){return (n-t)/e;}:function(t){return function(){return t;};}(isNaN(e)?NaN:.5);}function ta(t,e,n){var r=t[0],i=t[1],o=e[0],a=e[1];return i<r?(r=Zo(i,r),o=n(a,o)):(r=Zo(r,i),o=n(o,a)),function(t){return o(r(t));};}function ea(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),o=new Array(r),a=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++a<r;){i[a]=Zo(t[a],t[a+1]),o[a]=n(e[a],e[a+1]);}return function(e){var n=Ui(t,e,1,r)-1;return o[n](i[n](e));};}function na(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown());}function ra(){var t,e,n,r,i,o,a=Jo,s=Jo,u=Ko,c=Qo;function l(){var t=Math.min(a.length,s.length);return c!==Qo&&(c=function(t,e){var n;return t>e&&(n=t,t=e,e=n),function(n){return Math.max(t,Math.min(e,n));};}(a[0],a[t-1])),r=t>2?ea:ta,i=o=null,f;}function f(e){return null==e||isNaN(e=+e)?n:(i||(i=r(a.map(t),s,u)))(t(c(e)));}return f.invert=function(n){return c(e((o||(o=r(s,a.map(t),Vo)))(n)));},f.domain=function(t){return arguments.length?(a=Array.from(t,Yo),l()):a.slice();},f.range=function(t){return arguments.length?(s=Array.from(t),l()):s.slice();},f.rangeRound=function(t){return s=Array.from(t),u=Xo,l();},f.clamp=function(t){return arguments.length?(c=!!t||Qo,l()):c!==Qo;},f.interpolate=function(t){return arguments.length?(u=t,l()):u;},f.unknown=function(t){return arguments.length?(n=t,f):n;},function(n,r){return t=n,e=r,l();};}function ia(){return ra()(Qo,Qo);}function oa(t){var e=t.domain;return t.ticks=function(t){var n=e();return Object(Hi.a)(n[0],n[n.length-1],null==t?10:t);},t.tickFormat=function(t,n){var r=e();return Ki(r[0],r[r.length-1],null==t?10:t,n);},t.nice=function(n){null==n&&(n=10);var r,i,o=e(),a=0,s=o.length-1,u=o[a],c=o[s],l=10;for(c<u&&(i=u,u=c,c=i,i=a,a=s,s=i);l-->0;){if((i=Object(Hi.b)(u,c,n))===r)return o[a]=u,o[s]=c,e(o);if(i>0)u=Math.floor(u/i)*i,c=Math.ceil(c/i)*i;else {if(!(i<0))break;u=Math.ceil(u*i)/i,c=Math.floor(c*i)/i;}r=i;}return t;},t;}function aa(t,e){var n,r=0,i=(t=t.slice()).length-1,o=t[r],a=t[i];return a<o&&(n=r,r=i,i=n,n=o,o=a,a=n),t[r]=e.floor(o),t[i]=e.ceil(a),t;}function sa(t){return Math.log(t);}function ua(t){return Math.exp(t);}function ca(t){return -Math.log(-t);}function la(t){return -Math.exp(-t);}function fa(t){return isFinite(t)?+("1e"+t):t<0?0:t;}function ha(t){return function(e){return -t(-e);};}function da(t){var e,n,r=t(sa,ua),i=r.domain,o=10;function a(){return e=function(t){return t===Math.E?Math.log:10===t&&Math.log10||2===t&&Math.log2||(t=Math.log(t),function(e){return Math.log(e)/t;});}(o),n=function(t){return 10===t?fa:t===Math.E?Math.exp:function(e){return Math.pow(t,e);};}(o),i()[0]<0?(e=ha(e),n=ha(n),t(ca,la)):t(sa,ua),r;}return r.base=function(t){return arguments.length?(o=+t,a()):o;},r.domain=function(t){return arguments.length?(i(t),a()):i();},r.ticks=function(t){var r,a=i(),s=a[0],u=a[a.length-1];(r=u<s)&&(h=s,s=u,u=h);var c,l,f,h=e(s),d=e(u),p=null==t?10:+t,m=[];if(!(o%1)&&d-h<p){if(h=Math.floor(h),d=Math.ceil(d),s>0){for(;h<=d;++h){for(l=1,c=n(h);l<o;++l){if(!((f=c*l)<s)){if(f>u)break;m.push(f);}}}}else for(;h<=d;++h){for(l=o-1,c=n(h);l>=1;--l){if(!((f=c*l)<s)){if(f>u)break;m.push(f);}}}2*m.length<p&&(m=Object(Hi.a)(s,u,p));}else m=Object(Hi.a)(h,d,Math.min(d-h,p)).map(n);return r?m.reverse():m;},r.tickFormat=function(t,i){if(null==i&&(i=10===o?".0e":","),"function"!=typeof i&&(i=Object(Gi.format)(i)),t===1/0)return i;null==t&&(t=10);var a=Math.max(1,o*t/r.ticks().length);return function(t){var r=t/n(Math.round(e(t)));return r*o<o-.5&&(r*=o),r<=a?i(t):"";};},r.nice=function(){return i(aa(i(),{floor:function floor(t){return n(Math.floor(e(t)));},ceil:function ceil(t){return n(Math.ceil(e(t)));}}));},r;}function pa(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t);};}function ma(t){return t<0?-Math.sqrt(-t):Math.sqrt(t);}function ga(t){return t<0?-t*t:t*t;}function va(t){var e=t(Qo,Qo),n=1;return e.exponent=function(e){return arguments.length?1===(n=+e)?t(Qo,Qo):.5===n?t(ma,ga):t(pa(n),pa(1/n)):n;},oa(e);}function ya(){var t=va(ra());return t.copy=function(){return na(t,ya()).exponent(t.exponent());},Wi.apply(t,arguments),t;}function ba(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t));};}function xa(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t;};}function wa(t){var e=1,n=t(ba(e),xa(e));return n.constant=function(n){return arguments.length?t(ba(e=+n),xa(e)):e;},oa(n);}var ka=n(12),Ea=n(182),Ca=n(69),Aa=n(183),Oa=n(184),_a=n(72),Sa=n(40),Da=n(135),Fa=n(70),Ta=n(180),Na=n(181),Ia=n(71),Ra=n(39),Ma=n(134),ja=n(68);function Ba(t,e,n,r,i,o){var a=[[Ca.a,1,ka.e],[Ca.a,5,5*ka.e],[Ca.a,15,15*ka.e],[Ca.a,30,30*ka.e],[o,1,ka.c],[o,5,5*ka.c],[o,15,15*ka.c],[o,30,30*ka.c],[i,1,ka.b],[i,3,3*ka.b],[i,6,6*ka.b],[i,12,12*ka.b],[r,1,ka.a],[r,2,2*ka.a],[n,1,ka.f],[e,1,ka.d],[e,3,3*ka.d],[t,1,ka.g]];function s(e,n,r){var i=Math.abs(n-e)/r,o=Object(Ke.a)(function(_ref3){var _ref4=_slicedToArray(_ref3,3),t=_ref4[2];return t;}).right(a,i);if(o===a.length)return t.every(Object(Hi.c)(e/ka.g,n/ka.g,r));if(0===o)return Ea.a.every(Math.max(Object(Hi.c)(e,n,r),1));var _a18=_slicedToArray(a[i/a[o-1][2]<a[o][2]/i?o-1:o],2),s=_a18[0],u=_a18[1];return s.every(u);}return [function(t,e,n){var _ref5;var r=e<t;r&&(_ref5=[e,t],t=_ref5[0],e=_ref5[1],_ref5);var i=n&&"function"==typeof n.range?n:s(t,e,n),o=i?i.range(t,+e+1):[];return r?o.reverse():o;},s];}var _Ba=Ba(ja.a,Ma.a,Ra.b,Ia.a,Na.a,Ta.a),_Ba2=_slicedToArray(_Ba,2),Pa=_Ba2[0],La=_Ba2[1],_Ba3=Ba(Fa.a,Da.a,Sa.b,_a.a,Oa.a,Aa.a),_Ba4=_slicedToArray(_Ba3,2),za=_Ba4[0],Ua=_Ba4[1];var Wa=n(100);function Va(t){return new Date(t);}function qa(t){return t instanceof Date?+t:+new Date(+t);}function $a(t,e,n,r,i,o,a,s,u,c){var l=ia(),f=l.invert,h=l.domain,d=c(".%L"),p=c(":%S"),m=c("%I:%M"),g=c("%I %p"),v=c("%a %d"),y=c("%b %d"),b=c("%B"),x=c("%Y");function w(t){return (u(t)<t?d:s(t)<t?p:a(t)<t?m:o(t)<t?g:r(t)<t?i(t)<t?v:y:n(t)<t?b:x)(t);}return l.invert=function(t){return new Date(f(t));},l.domain=function(t){return arguments.length?h(Array.from(t,qa)):h().map(Va);},l.ticks=function(e){var n=h();return t(n[0],n[n.length-1],null==e?10:e);},l.tickFormat=function(t,e){return null==e?w:c(e);},l.nice=function(t){var n=h();return t&&"function"==typeof t.range||(t=e(n[0],n[n.length-1],null==t?10:t)),t?h(aa(n,t)):l;},l.copy=function(){return na(l,$a(t,e,n,r,i,o,a,s,u,c));},l;}function Ha(){var t,e,n,r,i,o=0,a=1,s=Qo,u=!1;function c(e){return null==e||isNaN(e=+e)?i:s(0===n?.5:(e=(r(e)-t)*n,u?Math.max(0,Math.min(1,e)):e));}function l(t){return function(e){var _e41,_e42;var n,r;return arguments.length?((_e41=e,_e42=_slicedToArray(_e41,2),n=_e42[0],r=_e42[1],_e41),s=t(n,r),c):[s(0),s(1)];};}return c.domain=function(i){var _i21,_i22;return arguments.length?((_i21=i,_i22=_slicedToArray(_i21,2),o=_i22[0],a=_i22[1],_i21),t=r(o=+o),e=r(a=+a),n=t===e?0:1/(e-t),c):[o,a];},c.clamp=function(t){return arguments.length?(u=!!t,c):u;},c.interpolator=function(t){return arguments.length?(s=t,c):s;},c.range=l(Ko),c.rangeRound=l(Xo),c.unknown=function(t){return arguments.length?(i=t,c):i;},function(i){return r=i,t=i(o),e=i(a),n=t===e?0:1/(e-t),c;};}function Ga(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown());}function Ka(){var t=oa(Ha()(Qo));return t.copy=function(){return Ga(t,Ka());},Vi.apply(t,arguments);}function Xa(){var t=va(Ha());return t.copy=function(){return Ga(t,Xa()).exponent(t.exponent());},Vi.apply(t,arguments);}function Ya(t,e){void 0===e&&(e=t,t=Ko);for(var n=0,r=e.length-1,i=e[0],o=new Array(r<0?0:r);n<r;){o[n]=t(i,i=e[++n]);}return function(t){var e=Math.max(0,Math.min(r-1,Math.floor(t*=r)));return o[e](t-e);};}function Ja(){var t,e,n,r,i,o,a,s=0,u=.5,c=1,l=1,f=Qo,h=!1;function d(t){return isNaN(t=+t)?a:(t=.5+((t=+o(t))-e)*(l*t<l*e?r:i),f(h?Math.max(0,Math.min(1,t)):t));}function p(t){return function(e){var _e43,_e44;var n,r,i;return arguments.length?((_e43=e,_e44=_slicedToArray(_e43,3),n=_e44[0],r=_e44[1],i=_e44[2],_e43),f=Ya(t,[n,r,i]),d):[f(0),f(.5),f(1)];};}return d.domain=function(a){var _a19,_a20;return arguments.length?((_a19=a,_a20=_slicedToArray(_a19,3),s=_a20[0],u=_a20[1],c=_a20[2],_a19),t=o(s=+s),e=o(u=+u),n=o(c=+c),r=t===e?0:.5/(e-t),i=e===n?0:.5/(n-e),l=e<t?-1:1,d):[s,u,c];},d.clamp=function(t){return arguments.length?(h=!!t,d):h;},d.interpolator=function(t){return arguments.length?(f=t,d):f;},d.range=p(Ko),d.rangeRound=p(Xo),d.unknown=function(t){return arguments.length?(a=t,d):a;},function(a){return o=a,t=a(s),e=a(u),n=a(c),r=t===e?0:.5/(e-t),i=e===n?0:.5/(n-e),l=e<t?-1:1,d;};}function Qa(){var t=va(Ja());return t.copy=function(){return Ga(t,Qa()).exponent(t.exponent());},Vi.apply(t,arguments);}var Za,ts=function ts(t){var e=t.length;return function(n){return t[Math.max(0,Math.min(e-1,Math.floor(n*e)))];};},es=function es(t,e){var n=To(+t,+e);return function(t){var e=n(t);return e-360*Math.floor(e/360);};},ns=180/Math.PI,rs={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1},is=function is(t,e,n,r,i,o){var a,s,u;return (a=Math.sqrt(t*t+e*e))&&(t/=a,e/=a),(u=t*n+e*r)&&(n-=t*u,r-=e*u),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,u/=s),t*r<e*n&&(t=-t,e=-e,u=-u,a=-a),{translateX:i,translateY:o,rotate:Math.atan2(e,t)*ns,skewX:Math.atan(u)*ns,scaleX:a,scaleY:s};};function os(t,e,n,r){function i(t){return t.length?t.pop()+" ":"";}return function(o,a){var s=[],u=[];return o=t(o),a=t(a),function(t,r,i,o,a,s){if(t!==i||r!==o){var u=a.push("translate(",null,e,null,n);s.push({i:u-4,x:Vo(t,i)},{i:u-2,x:Vo(r,o)});}else (i||o)&&a.push("translate("+i+e+o+n);}(o.translateX,o.translateY,a.translateX,a.translateY,s,u),function(t,e,n,o){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),o.push({i:n.push(i(n)+"rotate(",null,r)-2,x:Vo(t,e)})):e&&n.push(i(n)+"rotate("+e+r);}(o.rotate,a.rotate,s,u),function(t,e,n,o){t!==e?o.push({i:n.push(i(n)+"skewX(",null,r)-2,x:Vo(t,e)}):e&&n.push(i(n)+"skewX("+e+r);}(o.skewX,a.skewX,s,u),function(t,e,n,r,o,a){if(t!==n||e!==r){var s=o.push(i(o)+"scale(",null,",",null,")");a.push({i:s-4,x:Vo(t,n)},{i:s-2,x:Vo(e,r)});}else 1===n&&1===r||o.push(i(o)+"scale("+n+","+r+")");}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,s,u),o=a=null,function(t){for(var e,n=-1,r=u.length;++n<r;){s[(e=u[n]).i]=e.x(t);}return s.join("");};};}var as=os(function(t){var e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?rs:is(e.a,e.b,e.c,e.d,e.e,e.f);},"px, ","px)","deg)"),ss=os(function(t){return null==t?rs:(Za||(Za=document.createElementNS("http://www.w3.org/2000/svg","g")),Za.setAttribute("transform",t),(t=Za.transform.baseVal.consolidate())?(t=t.matrix,is(t.a,t.b,t.c,t.d,t.e,t.f)):rs);},", ",")",")"),us=1e-12;function cs(t){return ((t=Math.exp(t))+1/t)/2;}var ls=function t(e,n,r){function i(t,i){var o,a,s=t[0],u=t[1],c=t[2],l=i[0],f=i[1],h=i[2],d=l-s,p=f-u,m=d*d+p*p;if(m<us)a=Math.log(h/c)/e,o=function o(t){return [s+t*d,u+t*p,c*Math.exp(e*t*a)];};else {var g=Math.sqrt(m),v=(h*h-c*c+r*m)/(2*c*n*g),y=(h*h-c*c-r*m)/(2*h*n*g),b=Math.log(Math.sqrt(v*v+1)-v),x=Math.log(Math.sqrt(y*y+1)-y);a=(x-b)/e,o=function o(t){var r=t*a,i=cs(b),o=c/(n*g)*(i*function(t){return ((t=Math.exp(2*t))-1)/(t+1);}(e*r+b)-function(t){return ((t=Math.exp(t))-1/t)/2;}(b));return [s+o*d,u+o*p,c*i/cs(e*r+b)];};}return o.duration=1e3*a*e/Math.SQRT2,o;}return i.rho=function(e){var n=Math.max(.001,+e),r=n*n;return t(n,r,r*r);},i;}(Math.SQRT2,2,4);function fs(t){return function(e,n){var r=t((e=Eo(e)).h,(n=Eo(n)).h),i=Io(e.s,n.s),o=Io(e.l,n.l),a=Io(e.opacity,n.opacity);return function(t){return e.h=r(t),e.s=i(t),e.l=o(t),e.opacity=a(t),e+"";};};}var hs=fs(To),ds=fs(Io);var ps=Math.PI/180,ms=180/Math.PI,gs=.96422,vs=1,ys=.82521,bs=4/29,xs=6/29,ws=3*xs*xs,ks=xs*xs*xs;function Es(t){if(t instanceof As)return new As(t.l,t.a,t.b,t.opacity);if(t instanceof Ns)return Is(t);t instanceof vo||(t=mo(t));var e,n,r=Ds(t.r),i=Ds(t.g),o=Ds(t.b),a=Os((.2225045*r+.7168786*i+.0606169*o)/vs);return r===i&&i===o?e=n=a:(e=Os((.4360747*r+.3850649*i+.1430804*o)/gs),n=Os((.0139322*r+.0971045*i+.7141733*o)/ys)),new As(116*a-16,500*(e-a),200*(a-n),t.opacity);}function Cs(t,e,n,r){return 1===arguments.length?Es(t):new As(t,e,n,null==r?1:r);}function As(t,e,n,r){this.l=+t,this.a=+e,this.b=+n,this.opacity=+r;}function Os(t){return t>ks?Math.pow(t,1/3):t/ws+bs;}function _s(t){return t>xs?t*t*t:ws*(t-bs);}function Ss(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055);}function Ds(t){return (t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4);}function Fs(t){if(t instanceof Ns)return new Ns(t.h,t.c,t.l,t.opacity);if(t instanceof As||(t=Es(t)),0===t.a&&0===t.b)return new Ns(NaN,0<t.l&&t.l<100?0:NaN,t.l,t.opacity);var e=Math.atan2(t.b,t.a)*ms;return new Ns(e<0?e+360:e,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity);}function Ts(t,e,n,r){return 1===arguments.length?Fs(t):new Ns(t,e,n,null==r?1:r);}function Ns(t,e,n,r){this.h=+t,this.c=+e,this.l=+n,this.opacity=+r;}function Is(t){if(isNaN(t.h))return new As(t.l,0,0,t.opacity);var e=t.h*ps;return new As(t.l,Math.cos(e)*t.c,Math.sin(e)*t.c,t.opacity);}function Rs(t,e){var n=Io((t=Cs(t)).l,(e=Cs(e)).l),r=Io(t.a,e.a),i=Io(t.b,e.b),o=Io(t.opacity,e.opacity);return function(e){return t.l=n(e),t.a=r(e),t.b=i(e),t.opacity=o(e),t+"";};}function Ms(t){return function(e,n){var r=t((e=Ts(e)).h,(n=Ts(n)).h),i=Io(e.c,n.c),o=Io(e.l,n.l),a=Io(e.opacity,n.opacity);return function(t){return e.h=r(t),e.c=i(t),e.l=o(t),e.opacity=a(t),e+"";};};}Xi(As,Cs,Yi(Ji,{brighter:function brighter(t){return new As(this.l+18*(null==t?1:t),this.a,this.b,this.opacity);},darker:function darker(t){return new As(this.l-18*(null==t?1:t),this.a,this.b,this.opacity);},rgb:function rgb(){var t=(this.l+16)/116,e=isNaN(this.a)?t:t+this.a/500,n=isNaN(this.b)?t:t-this.b/200;return new vo(Ss(3.1338561*(e=gs*_s(e))-1.6168667*(t=vs*_s(t))-.4906146*(n=ys*_s(n))),Ss(-.9787684*e+1.9161415*t+.033454*n),Ss(.0719453*e-.2289914*t+1.4052427*n),this.opacity);}})),Xi(Ns,Ts,Yi(Ji,{brighter:function brighter(t){return new Ns(this.h,this.c,this.l+18*(null==t?1:t),this.opacity);},darker:function darker(t){return new Ns(this.h,this.c,this.l-18*(null==t?1:t),this.opacity);},rgb:function rgb(){return Is(this).rgb();}}));var js=Ms(To),Bs=Ms(Io),Ps=-.29227,Ls=-.90649,zs=1.97294,Us=zs*Ls,Ws=1.78277*zs,Vs=1.78277*Ps- -.14861*Ls;function qs(t,e,n,r){return 1===arguments.length?function(t){if(t instanceof $s)return new $s(t.h,t.s,t.l,t.opacity);t instanceof vo||(t=mo(t));var e=t.r/255,n=t.g/255,r=t.b/255,i=(Vs*r+Us*e-Ws*n)/(Vs+Us-Ws),o=r-i,a=(zs*(n-i)-Ps*o)/Ls,s=Math.sqrt(a*a+o*o)/(zs*i*(1-i)),u=s?Math.atan2(a,o)*ms-120:NaN;return new $s(u<0?u+360:u,s,i,t.opacity);}(t):new $s(t,e,n,null==r?1:r);}function $s(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r;}function Hs(t){return function e(n){function r(e,r){var i=t((e=qs(e)).h,(r=qs(r)).h),o=Io(e.s,r.s),a=Io(e.l,r.l),s=Io(e.opacity,r.opacity);return function(t){return e.h=i(t),e.s=o(t),e.l=a(Math.pow(t,n)),e.opacity=s(t),e+"";};}return n=+n,r.gamma=e,r;}(1);}Xi($s,qs,Yi(Ji,{brighter:function brighter(t){return t=null==t?1/.7:Math.pow(1/.7,t),new $s(this.h,this.s,this.l*t,this.opacity);},darker:function darker(t){return t=null==t?.7:Math.pow(.7,t),new $s(this.h,this.s,this.l*t,this.opacity);},rgb:function rgb(){var t=isNaN(this.h)?0:(this.h+120)*ps,e=+this.l,n=isNaN(this.s)?0:this.s*e*(1-e),r=Math.cos(t),i=Math.sin(t);return new vo(255*(e+n*(-.14861*r+1.78277*i)),255*(e+n*(Ps*r+Ls*i)),255*(e+n*(zs*r)),this.opacity);}}));var Gs=Hs(To),Ks=Hs(Io),Xs=function Xs(t,e){for(var n=new Array(e),r=0;r<e;++r){n[r]=t(r/(e-1));}return n;};function Ys(t,e,n){var r=t-e+2*n;return t?r>0?r:1:0;}var Js="linear",Qs="log",Zs="pow",tu="sqrt",eu="symlog",nu="time",ru="utc",iu="sequential",ou="diverging",au="quantile",su="quantize",uu="threshold",cu="ordinal",lu="point",fu="band",hu="bin-ordinal",du="continuous",pu="discrete",mu="discretizing",gu="interpolating",vu="temporal";function yu(){var t=$i().unknown(void 0),e=t.domain,n=t.range;var r,i,o=[0,1],a=!1,s=0,u=0,c=.5;function l(){var t=e().length,l=o[1]<o[0],f=o[1-l],h=Ys(t,s,u);var d=o[l-0];r=(f-d)/(h||1),a&&(r=Math.floor(r)),d+=(f-d-r*(t-s))*c,i=r*(1-s),a&&(d=Math.round(d),i=Math.round(i));var p=Ge(t).map(function(t){return d+r*t;});return n(l?p.reverse():p);}return delete t.unknown,t.domain=function(t){return arguments.length?(e(t),l()):e();},t.range=function(t){return arguments.length?(o=[+t[0],+t[1]],l()):o.slice();},t.rangeRound=function(t){return o=[+t[0],+t[1]],a=!0,l();},t.bandwidth=function(){return i;},t.step=function(){return r;},t.round=function(t){return arguments.length?(a=!!t,l()):a;},t.padding=function(t){return arguments.length?(u=Math.max(0,Math.min(1,t)),s=u,l()):s;},t.paddingInner=function(t){return arguments.length?(s=Math.max(0,Math.min(1,t)),l()):s;},t.paddingOuter=function(t){return arguments.length?(u=Math.max(0,Math.min(1,t)),l()):u;},t.align=function(t){return arguments.length?(c=Math.max(0,Math.min(1,t)),l()):c;},t.invertRange=function(t){if(null==t[0]||null==t[1])return;var r=o[1]<o[0],a=r?n().reverse():n(),s=a.length-1;var u,c,l,f=+t[0],h=+t[1];return f!=f||h!=h||(h<f&&(l=f,f=h,h=l),h<a[0]||f>o[1-r])?void 0:(u=Math.max(0,Li(a,f)-1),c=f===h?u:Li(a,h)-1,f-a[u]>i+1e-10&&++u,r&&(l=u,u=s-c,c=s-l),u>c?void 0:e().slice(u,c+1));},t.invert=function(e){var n=t.invertRange([e,e]);return n?n[0]:n;},t.copy=function(){return yu().domain(e()).range(o).round(a).paddingInner(s).paddingOuter(u).align(c);},l();}var bu=Array.prototype.map;var xu=Array.prototype.slice;var wu={};function ku(t,e,n){return arguments.length>1?(wu[t]=function(t,e,n){var r=function r(){var n=e();return n.invertRange||(n.invertRange=n.invert?function(t){return function(e){var n,r=e[0],i=e[1];return i<r&&(n=r,r=i,i=n),[t.invert(r),t.invert(i)];};}(n):n.invertExtent?function(t){return function(e){var n=t.range();var r,i,o,a,s=e[0],u=e[1],c=-1;for(u<s&&(i=s,s=u,u=i),o=0,a=n.length;o<a;++o){n[o]>=s&&n[o]<=u&&(c<0&&(c=o),r=o);}if(!(c<0))return s=t.invertExtent(n[c]),u=t.invertExtent(n[r]),[void 0===s[0]?s[1]:s[0],void 0===u[1]?u[0]:u[1]];};}(n):void 0),n.type=t,n;};return r.metadata=Object(Z.Fa)(Object(Z.i)(n)),r;}(t,e,n),this):Eu(t)?wu[t]:void 0;}function Eu(t){return Object(Z.w)(wu,t);}function Cu(t,e){var n=wu[t];return n&&n.metadata[e];}function Au(t){return Cu(t,du);}function Ou(t){return Cu(t,pu);}function _u(t){return Cu(t,mu);}function Su(t){return Cu(t,Qs);}function Du(t){return Cu(t,gu);}function Fu(t){return Cu(t,au);}ku("identity",function t(e){var n;function r(t){return null==t||isNaN(t=+t)?n:t;}return r.invert=r,r.domain=r.range=function(t){return arguments.length?(e=Array.from(t,Yo),r):e.slice();},r.unknown=function(t){return arguments.length?(n=t,r):n;},r.copy=function(){return t(e).unknown(n);},e=arguments.length?Array.from(e,Yo):[0,1],oa(r);}),ku(Js,function t(){var e=ia();return e.copy=function(){return na(e,t());},Wi.apply(e,arguments),oa(e);},du),ku(Qs,function t(){var e=da(ra()).domain([1,10]);return e.copy=function(){return na(e,t()).base(e.base());},Wi.apply(e,arguments),e;},[du,Qs]),ku(Zs,ya,du),ku(tu,function(){return ya.apply(null,arguments).exponent(.5);},du),ku(eu,function t(){var e=wa(ra());return e.copy=function(){return na(e,t()).constant(e.constant());},Wi.apply(e,arguments);},du),ku(nu,function(){return Wi.apply($a(za,Ua,Fa.a,Da.a,Sa.b,_a.a,Oa.a,Aa.a,Ca.a,Wa.a).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments);},[du,vu]),ku(ru,function(){return Wi.apply($a(Pa,La,ja.a,Ma.a,Ra.b,Ia.a,Na.a,Ta.a,Ca.a,Wa.c).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments);},[du,vu]),ku(iu,Ka,[du,gu]),ku("".concat(iu,"-").concat(Js),Ka,[du,gu]),ku("".concat(iu,"-").concat(Qs),function t(){var e=da(Ha()).domain([1,10]);return e.copy=function(){return Ga(e,t()).base(e.base());},Vi.apply(e,arguments);},[du,gu,Qs]),ku("".concat(iu,"-").concat(Zs),Xa,[du,gu]),ku("".concat(iu,"-").concat(tu),function(){return Xa.apply(null,arguments).exponent(.5);},[du,gu]),ku("".concat(iu,"-").concat(eu),function t(){var e=wa(Ha());return e.copy=function(){return Ga(e,t()).constant(e.constant());},Vi.apply(e,arguments);},[du,gu]),ku("".concat(ou,"-").concat(Js),function t(){var e=oa(Ja()(Qo));return e.copy=function(){return Ga(e,t());},Vi.apply(e,arguments);},[du,gu]),ku("".concat(ou,"-").concat(Qs),function t(){var e=da(Ja()).domain([.1,1,10]);return e.copy=function(){return Ga(e,t()).base(e.base());},Vi.apply(e,arguments);},[du,gu,Qs]),ku("".concat(ou,"-").concat(Zs),Qa,[du,gu]),ku("".concat(ou,"-").concat(tu),function(){return Qa.apply(null,arguments).exponent(.5);},[du,gu]),ku("".concat(ou,"-").concat(eu),function t(){var e=wa(Ja());return e.copy=function(){return Ga(e,t()).constant(e.constant());},Vi.apply(e,arguments);},[du,gu]),ku(au,function t(){var e,n=[],r=[],i=[];function o(){var t=0,e=Math.max(1,r.length);for(i=new Array(e-1);++t<e;){i[t-1]=Yt(n,t/e);}return a;}function a(t){return null==t||isNaN(t=+t)?e:r[Ui(i,t)];}return a.invertExtent=function(t){var e=r.indexOf(t);return e<0?[NaN,NaN]:[e>0?i[e-1]:n[0],e<i.length?i[e]:n[n.length-1]];},a.domain=function(t){if(!arguments.length)return n.slice();n=[];var _iterator19=_createForOfIteratorHelper(t),_step19;try{for(_iterator19.s();!(_step19=_iterator19.n()).done;){var _e45=_step19.value;null==_e45||isNaN(_e45=+_e45)||n.push(_e45);}}catch(err){_iterator19.e(err);}finally{_iterator19.f();}return n.sort(qt.a),o();},a.range=function(t){return arguments.length?(r=Array.from(t),o()):r.slice();},a.unknown=function(t){return arguments.length?(e=t,a):e;},a.quantiles=function(){return i.slice();},a.copy=function(){return t().domain(n).range(r).unknown(e);},Wi.apply(a,arguments);},[mu,au]),ku(su,function t(){var e,n=0,r=1,i=1,o=[.5],a=[0,1];function s(t){return null!=t&&t<=t?a[Ui(o,t,0,i)]:e;}function u(){var t=-1;for(o=new Array(i);++t<i;){o[t]=((t+1)*r-(t-i)*n)/(i+1);}return s;}return s.domain=function(t){var _t39,_t40;return arguments.length?((_t39=t,_t40=_slicedToArray(_t39,2),n=_t40[0],r=_t40[1],_t39),n=+n,r=+r,u()):[n,r];},s.range=function(t){return arguments.length?(i=(a=Array.from(t)).length-1,u()):a.slice();},s.invertExtent=function(t){var e=a.indexOf(t);return e<0?[NaN,NaN]:e<1?[n,o[0]]:e>=i?[o[i-1],r]:[o[e-1],o[e]];},s.unknown=function(t){return arguments.length?(e=t,s):s;},s.thresholds=function(){return o.slice();},s.copy=function(){return t().domain([n,r]).range(a).unknown(e);},Wi.apply(oa(s),arguments);},mu),ku(uu,function t(){var e,n=[.5],r=[0,1],i=1;function o(t){return null!=t&&t<=t?r[Ui(n,t,0,i)]:e;}return o.domain=function(t){return arguments.length?(n=Array.from(t),i=Math.min(n.length,r.length-1),o):n.slice();},o.range=function(t){return arguments.length?(r=Array.from(t),i=Math.min(n.length,r.length-1),o):r.slice();},o.invertExtent=function(t){var e=r.indexOf(t);return [n[e-1],n[e]];},o.unknown=function(t){return arguments.length?(e=t,o):e;},o.copy=function(){return t().domain(n).range(r).unknown(e);},Wi.apply(o,arguments);},mu),ku(hu,function t(){var e=[],n=[];function r(t){return null==t||t!=t?void 0:n[(Ui(e,t)-1)%n.length];}return r.domain=function(t){return arguments.length?(e=function(t){return bu.call(t,Z.Ea);}(t),r):e.slice();},r.range=function(t){return arguments.length?(n=xu.call(t),r):n.slice();},r.tickFormat=function(t,n){return Ki(e[0],Object(Z.W)(e),null==t?10:t,n);},r.copy=function(){return t().domain(r.domain()).range(r.range());},r;},[pu,mu]),ku(cu,$i,pu),ku(fu,yu,pu),ku(lu,function(){return function t(e){var n=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,e.copy=function(){return t(n());},e;}(yu().paddingInner(1));},pu);var Tu=["clamp","base","constant","exponent"];function Nu(t,e){var n=e[0],r=Object(Z.W)(e)-n;return function(e){return t(n+e*r);};}function Iu(t,e,n){return Ya(ju(e||"rgb",n),t);}function Ru(t,e){var n=new Array(e),r=e+1;for(var _i23=0;_i23<e;){n[_i23]=t(++_i23/r);}return n;}function Mu(t,e,n){var r=n-e;var i,o,a;return r&&Number.isFinite(r)?(i=(o=t.type).indexOf("-"),o=i<0?o:o.slice(i+1),a=ku(o)().domain([e,n]).range([0,1]),Tu.forEach(function(e){return t[e]?a[e](t[e]()):0;}),a):Object(Z.m)(.5);}function ju(t,e){var n=a[function(t){return "interpolate"+t.toLowerCase().split("-").map(function(t){return t[0].toUpperCase()+t.slice(1);}).join("");}(t)];return null!=e&&n&&n.gamma?n.gamma(e):n;}function Bu(t){var e=t.length/6|0,n=new Array(e);for(var _r41=0;_r41<e;){n[_r41]="#"+t.slice(6*_r41,6*++_r41);}return n;}function Pu(t,e){for(var _n34 in t){zu(_n34,e(t[_n34]));}}var Lu={};function zu(t,e){return t=t&&t.toLowerCase(),arguments.length>1?(Lu[t]=e,this):Lu[t];}Pu({category10:"1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf",category20:"1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5",category20b:"393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6",category20c:"3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9",tableau10:"4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac",tableau20:"4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5",accent:"7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666",dark2:"1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666",paired:"a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928",pastel1:"fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2",pastel2:"b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc",set1:"e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999",set2:"66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3",set3:"8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"},Bu),Pu({blues:"cfe1f2bed8eca8cee58fc1de74b2d75ba3cf4592c63181bd206fb2125ca40a4a90",greens:"d3eecdc0e6baabdda594d3917bc77d60ba6c46ab5e329a512089430e7735036429",greys:"e2e2e2d4d4d4c4c4c4b1b1b19d9d9d8888887575756262624d4d4d3535351e1e1e",oranges:"fdd8b3fdc998fdb87bfda55efc9244f87f2cf06b18e4580bd14904b93d029f3303",purples:"e2e1efd4d4e8c4c5e0b4b3d6a3a0cc928ec3827cb97566ae684ea25c3696501f8c",reds:"fdc9b4fcb49afc9e80fc8767fa7051f6573fec3f2fdc2a25c81b1db21218970b13",blueGreen:"d5efedc1e8e0a7ddd18bd2be70c6a958ba9144ad77319c5d2089460e7736036429",bluePurple:"ccddecbad0e4a8c2dd9ab0d4919cc98d85be8b6db28a55a6873c99822287730f71",greenBlue:"d3eecec5e8c3b1e1bb9bd8bb82cec269c2ca51b2cd3c9fc7288abd1675b10b60a1",orangeRed:"fddcaffdcf9bfdc18afdad77fb9562f67d53ee6545e24932d32d1ebf130da70403",purpleBlue:"dbdaebc8cee4b1c3de97b7d87bacd15b9fc93a90c01e7fb70b70ab056199045281",purpleBlueGreen:"dbd8eac8cee4b0c3de93b7d872acd1549fc83892bb1c88a3097f8702736b016353",purpleRed:"dcc9e2d3b3d7ce9eccd186c0da6bb2e14da0e23189d91e6fc61159ab07498f023a",redPurple:"fccfccfcbec0faa9b8f98faff571a5ec539ddb3695c41b8aa908808d0179700174",yellowGreen:"e4f4acd1eca0b9e2949ed68880c97c62bb6e47aa5e3297502083440e723b036034",yellowOrangeBrown:"feeaa1fedd84fecc63feb746fca031f68921eb7215db5e0bc54c05ab3d038f3204",yellowOrangeRed:"fee087fed16ffebd59fea849fd903efc7335f9522bee3423de1b20ca0b22af0225",blueOrange:"134b852f78b35da2cb9dcae1d2e5eff2f0ebfce0bafbbf74e8932fc5690d994a07",brownBlueGreen:"704108a0651ac79548e3c78af3e6c6eef1eac9e9e48ed1c74da79e187a72025147",purpleGreen:"5b1667834792a67fb6c9aed3e6d6e8eff0efd9efd5aedda971bb75368e490e5e29",purpleOrange:"4114696647968f83b7b9b4d6dadbebf3eeeafce0bafbbf74e8932fc5690d994a07",redBlue:"8c0d25bf363adf745ef4ae91fbdbc9f2efeed2e5ef9dcae15da2cb2f78b3134b85",redGrey:"8c0d25bf363adf745ef4ae91fcdccbfaf4f1e2e2e2c0c0c0969696646464343434",yellowGreenBlue:"eff9bddbf1b4bde5b594d5b969c5be45b4c22c9ec02182b82163aa23479c1c3185",redYellowBlue:"a50026d4322cf16e43fcac64fedd90faf8c1dcf1ecabd6e875abd04a74b4313695",redYellowGreen:"a50026d4322cf16e43fcac63fedd8df9f7aed7ee8ea4d86e64bc6122964f006837",pinkYellowGreen:"8e0152c0267edd72adf0b3d6faddedf5f3efe1f2cab6de8780bb474f9125276419",spectral:"9e0142d13c4bf0704afcac63fedd8dfbf8b0e0f3a1a9dda269bda94288b55e4fa2",viridis:"440154470e61481a6c482575472f7d443a834144873d4e8a39568c35608d31688e2d708e2a788e27818e23888e21918d1f988b1fa08822a8842ab07f35b77943bf7154c56866cc5d7ad1518fd744a5db36bcdf27d2e21be9e51afde725",magma:"0000040404130b0924150e3720114b2c11603b0f704a107957157e651a80721f817f24828c29819a2e80a8327db6377ac43c75d1426fde4968e95462f1605df76f5cfa7f5efc8f65fe9f6dfeaf78febf84fece91fddea0fcedaffcfdbf",inferno:"0000040403130c0826170c3b240c4f330a5f420a68500d6c5d126e6b176e781c6d86216b932667a12b62ae305cbb3755c73e4cd24644dd513ae65c30ed6925f3771af8850ffb9506fca50afcb519fac62df6d645f2e661f3f484fcffa4",plasma:"0d088723069033059742039d5002a25d01a66a00a87801a88405a7900da49c179ea72198b12a90ba3488c33d80cb4779d35171da5a69e16462e76e5bed7953f2834cf68f44fa9a3dfca636fdb32ffec029fcce25f9dc24f5ea27f0f921",cividis:"00205100235800265d002961012b65042e670831690d346b11366c16396d1c3c6e213f6e26426e2c456e31476e374a6e3c4d6e42506e47536d4c566d51586e555b6e5a5e6e5e616e62646f66676f6a6a706e6d717270717573727976737c79747f7c75827f758682768985778c8877908b78938e789691789a94789e9778a19b78a59e77a9a177aea575b2a874b6ab73bbaf71c0b26fc5b66dc9b96acebd68d3c065d8c462ddc85fe2cb5ce7cf58ebd355f0d652f3da4ff7de4cfae249fce647",rainbow:"6e40aa883eb1a43db3bf3cafd83fa4ee4395fe4b83ff576eff6659ff7847ff8c38f3a130e2b72fcfcc36bee044aff05b8ff4576ff65b52f6673af27828ea8d1ddfa319d0b81cbecb23abd82f96e03d82e14c6edb5a5dd0664dbf6e40aa",sinebow:"ff4040fc582af47218e78d0bd5a703bfbf00a7d5038de70b72f41858fc2a40ff402afc5818f4720be78d03d5a700bfbf03a7d50b8de71872f42a58fc4040ff582afc7218f48d0be7a703d5bf00bfd503a7e70b8df41872fc2a58ff4040",turbo:"23171b32204a3e2a71453493493eae4b49c54a53d7485ee44569ee4074f53c7ff8378af93295f72e9ff42ba9ef28b3e926bce125c5d925cdcf27d5c629dcbc2de3b232e9a738ee9d3ff39347f68950f9805afc7765fd6e70fe667cfd5e88fc5795fb51a1f84badf545b9f140c5ec3cd0e637dae034e4d931ecd12ef4c92bfac029ffb626ffad24ffa223ff9821ff8d1fff821dff771cfd6c1af76118f05616e84b14df4111d5380fcb2f0dc0260ab61f07ac1805a313029b0f00950c00910b00",browns:"eedbbdecca96e9b97ae4a865dc9856d18954c7784cc0673fb85536ad44339f3632",tealBlues:"bce4d89dd3d181c3cb65b3c245a2b9368fae347da0306a932c5985",teals:"bbdfdfa2d4d58ac9c975bcbb61b0af4da5a43799982b8b8c1e7f7f127273006667",warmGreys:"dcd4d0cec5c1c0b8b4b3aaa7a59c9998908c8b827f7e7673726866665c5a59504e",goldGreen:"f4d166d5ca60b6c35c98bb597cb25760a6564b9c533f8f4f33834a257740146c36",goldOrange:"f4d166f8be5cf8aa4cf5983bf3852aef701be2621fd65322c54923b142239e3a26",goldRed:"f4d166f6be59f9aa51fc964ef6834bee734ae56249db5247cf4244c43141b71d3e",lightGreyRed:"efe9e6e1dad7d5cbc8c8bdb9bbaea9cd967ddc7b43e15f19df4011dc000b",lightGreyTeal:"e4eaead6dcddc8ced2b7c2c7a6b4bc64b0bf22a6c32295c11f85be1876bc",lightMulti:"e0f1f2c4e9d0b0de9fd0e181f6e072f6c053f3993ef77440ef4a3c",lightOrange:"f2e7daf7d5baf9c499fab184fa9c73f68967ef7860e8645bde515bd43d5b",lightTealBlue:"e3e9e0c0dccf9aceca7abfc859afc0389fb9328dad2f7ca0276b95255988",darkBlue:"3232322d46681a5c930074af008cbf05a7ce25c0dd38daed50f3faffffff",darkGold:"3c3c3c584b37725e348c7631ae8b2bcfa424ecc31ef9de30fff184ffffff",darkGreen:"3a3a3a215748006f4d048942489e4276b340a6c63dd2d836ffeb2cffffaa",darkMulti:"3737371f5287197d8c29a86995ce3fffe800ffffff",darkRed:"3434347036339e3c38cc4037e75d1eec8620eeab29f0ce32ffeb2c"},function(t){return Iu(Bu(t));});var Uu="symbol",Wu="discrete",Vu=function Vu(t){return Object(Z.B)(t)?t.map(function(t){return String(t);}):String(t);},qu=function qu(t,e){return t[1]-e[1];},$u=function $u(t,e){return e[1]-t[1];};function Hu(t,e,n){var r;return Object(Z.G)(e)&&(t.bins&&(e=Math.max(e,t.bins.length)),null!=n&&(e=Math.min(e,Math.floor(Object(Z.Z)(t.domain())/n||1)))),Object(Z.H)(e)&&(r=e.step,e=e.interval),Object(Z.J)(e)&&(e=t.type===nu?Object(Xe.p)(e):t.type==ru?Object(Xe.v)(e):Object(Z.o)("Only time and utc scales accept interval strings."),r&&(e=e.every(r))),e;}function Gu(t,e,n){var r=t.range(),i=r[0],o=Object(Z.W)(r),a=qu;if(i>o&&(r=o,o=i,i=r,a=$u),i=Math.floor(i),o=Math.ceil(o),e=e.map(function(e){return [e,t(e)];}).filter(function(t){return i<=t[1]&&t[1]<=o;}).sort(a).map(function(t){return t[0];}),n>0&&e.length>1){var _t41=[e[0],Object(Z.W)(e)];for(;e.length>n&&e.length>=3;){e=e.filter(function(t,e){return !(e%2);});}e.length<3&&(e=_t41);}return e;}function Ku(t,e){return t.bins?Gu(t,t.bins):t.ticks?t.ticks(e):t.domain();}function Xu(t,e,n,r,i,o){var a=e.type;var s=Vu;if(a===nu||i===nu)s=t.timeFormat(r);else if(a===ru||i===ru)s=t.utcFormat(r);else if(Su(a)){var _i24=t.formatFloat(r);if(o||e.bins)s=_i24;else {var _t42=Yu(e,n,!1);s=function s(e){return _t42(e)?_i24(e):"";};}}else if(e.tickFormat){var _i25=e.domain();s=t.formatSpan(_i25[0],_i25[_i25.length-1],n,r);}else r&&(s=t.format(r));return s;}function Yu(t,e,n){var r=Ku(t,e),i=t.base(),o=Math.log(i),a=Math.max(1,i*e/r.length),s=function s(t){var e=t/Math.pow(i,Math.round(Math.log(t)/o));return e*i<i-.5&&(e*=i),e<=a;};return n?r.filter(s):s;}var Ju=(_Ju={},_defineProperty(_Ju,au,"quantiles"),_defineProperty(_Ju,su,"thresholds"),_defineProperty(_Ju,uu,"domain"),_Ju),Qu=(_Qu={},_defineProperty(_Qu,au,"quantiles"),_defineProperty(_Qu,su,"domain"),_Qu);function Zu(t,e){return t.bins?function(t){var e=t.slice(0,-1);return e.max=Object(Z.W)(t),e;}(t.bins):t.type===Qs?Yu(t,e,!0):Ju[t.type]?function(t){var e=[-1/0].concat(t);return e.max=1/0,e;}(t[Ju[t.type]]()):Ku(t,e);}var tc=function tc(t){return Ju[t.type]||t.bins;};function ec(t,e,n,r,i,o,a){var s=Qu[e.type]&&o!==nu&&o!==ru?function(t,e,n){var r=e[Qu[e.type]](),i=r.length;var o,a=i>1?r[1]-r[0]:r[0];for(o=1;o<i;++o){a=Math.min(a,r[o]-r[o-1]);}return t.formatSpan(0,a,30,n);}(t,e,i):Xu(t,e,n,i,o,a);return r===Uu&&tc(e)?nc(s):r===Wu?ic(s):oc(s);}var nc=function nc(t){return function(e,n,r){var i=rc(r[n+1],rc(r.max,1/0)),o=ac(e,t),a=ac(i,t);return o&&a?o+" – "+a:a?"< "+a:"≥ "+o;};},rc=function rc(t,e){return null!=t?t:e;},ic=function ic(t){return function(e,n){return n?t(e):null;};},oc=function oc(t){return function(e){return t(e);};},ac=function ac(t,e){return Number.isFinite(t)?e(t):null;};function sc(t,e,n,r){var i=r||e.type;return Object(Z.J)(n)&&function(t){return Cu(t,vu);}(i)&&(n=n.replace(/%a/g,"%A").replace(/%b/g,"%B")),n||i!==nu?n||i!==ru?ec(t,e,5,null,n,r,!0):t.utcFormat("%A, %d %B %Y, %X UTC"):t.timeFormat("%A, %d %B %Y, %X");}function uc(t,e,n){n=n||{};var r=Math.max(3,n.maxlen||7),i=sc(t,e,n.format,n.formatType);if(_u(e.type)){var _t43=Zu(e).slice(1).map(i),_n35=_t43.length;return "".concat(_n35," boundar").concat(1===_n35?"y":"ies",": ").concat(_t43.join(", "));}if(Ou(e.type)){var _t44=e.domain(),_n36=_t44.length,_o13=_n36>r?_t44.slice(0,r-2).map(i).join(", ")+", ending with "+_t44.slice(-1).map(i):_t44.map(i).join(", ");return "".concat(_n36," value").concat(1===_n36?"":"s",": ").concat(_o13);}{var _t45=e.domain();return "values from ".concat(i(_t45[0])," to ").concat(i(Object(Z.W)(_t45)));}}var cc=0;var lc="p_";function fc(t){return t&&t.gradient;}function hc(t,e,n){var r=t.gradient;var i=t.id,o="radial"===r?lc:"";return i||(i=t.id="gradient_"+cc++,"radial"===r?(t.x1=dc(t.x1,.5),t.y1=dc(t.y1,.5),t.r1=dc(t.r1,0),t.x2=dc(t.x2,.5),t.y2=dc(t.y2,.5),t.r2=dc(t.r2,.5),o=lc):(t.x1=dc(t.x1,0),t.y1=dc(t.y1,0),t.x2=dc(t.x2,1),t.y2=dc(t.y2,0))),e[i]=t,"url("+(n||"")+"#"+o+i+")";}function dc(t,e){return null!=t?t:e;}function pc(t,e){var n,r=[];return n={gradient:"linear",x1:t?t[0]:0,y1:t?t[1]:0,x2:e?e[0]:1,y2:e?e[1]:0,stops:r,stop:function stop(t,e){return r.push({offset:t,color:e}),n;}};}var mc={basis:{curve:function curve(t){return new Ar(t);}},"basis-closed":{curve:function curve(t){return new _r(t);}},"basis-open":{curve:function curve(t){return new Sr(t);}},bundle:{curve:Fr,tension:"beta",value:.85},cardinal:{curve:Ir,tension:"tension",value:0},"cardinal-open":{curve:Mr,tension:"tension",value:0},"cardinal-closed":{curve:Br,tension:"tension",value:0},"catmull-rom":{curve:Qr,tension:"alpha",value:.5},"catmull-rom-closed":{curve:ti,tension:"alpha",value:.5},"catmull-rom-open":{curve:ni,tension:"alpha",value:.5},linear:{curve:ii},"linear-closed":{curve:function curve(t){return new oi(t);}},monotone:{horizontal:function horizontal(t){return new fi(t);},vertical:function vertical(t){return new li(t);}},natural:{curve:function curve(t){return new di(t);}},step:{curve:function curve(t){return new mi(t,.5);}},"step-after":{curve:function curve(t){return new mi(t,1);}},"step-before":{curve:function curve(t){return new mi(t,0);}}};function gc(t,e,n){var r=Object(Z.w)(mc,t)&&mc[t],i=null;return r&&(i=r.curve||r[e||"vertical"],r.tension&&null!=n&&(i=i[r.tension](n))),i;}var vc={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},yc=[/([MLHVCSQTAZmlhvcsqtaz])/g,/###/,/(\.\d+)(\.\d)/g,/(\d)([-+])/g,/\s|,|###/];function bc(t){var e=[];var n,r,i,o,a,s,u,c,l,f;var h=t.slice().replace(yc[0],"###$1").split(yc[1]).slice(1);for(u=0,l=h.length;u<l;++u){for(r=(n=h[u]).slice(1).trim().replace(yc[2],"$1###$2").replace(yc[3],"$1###$2").split(yc[4]),i=[a=n.charAt(0)],c=0,f=r.length;c<f;++c){(o=+r[c])===o&&i.push(o);}if(s=vc[a.toLowerCase()],i.length-1>s){var _t46=i.length;for(c=1,e.push([a].concat(i.slice(c,c+=s))),a="M"===a?"L":"m"===a?"l":a;c<_t46;c+=s){e.push([a].concat(i.slice(c,c+s)));}}else e.push(i);}return e;}var xc=Math.PI/180,wc=1e-14,kc=Math.PI/2,Ec=2*Math.PI,Cc=Math.sqrt(3)/2;var Ac={},Oc={},_c=[].join;function Sc(t){var e=_c.call(t);if(Oc[e])return Oc[e];var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],u=t[6],c=t[7];var l=c*a,f=-u*s,h=u*a,d=c*s,p=Math.cos(i),m=Math.sin(i),g=Math.cos(o),v=Math.sin(o),y=.5*(o-i),b=Math.sin(.5*y),x=8/3*b*b/Math.sin(y),w=n+p-x*m,k=r+m+x*p,E=n+g,C=r+v,A=E+x*v,O=C-x*g;return Oc[e]=[l*w+f*k,h*w+d*k,l*A+f*O,h*A+d*O,l*E+f*C,h*E+d*C];}var Dc=["l",0,0,0,0,0,0,0];function Fc(t,e,n){var r=Dc[0]=t[0];if("a"===r||"A"===r)Dc[1]=e*t[1],Dc[2]=n*t[2],Dc[3]=t[3],Dc[4]=t[4],Dc[5]=t[5],Dc[6]=e*t[6],Dc[7]=n*t[7];else if("h"===r||"H"===r)Dc[1]=e*t[1];else if("v"===r||"V"===r)Dc[1]=n*t[1];else for(var i=1,o=t.length;i<o;++i){Dc[i]=(i%2==1?e:n)*t[i];}return Dc;}function Tc(t,e,n,r,i,o){var a,s,u,c,l,f=null,h=0,d=0,p=0,m=0;null==n&&(n=0),null==r&&(r=0),null==i&&(i=1),null==o&&(o=i),t.beginPath&&t.beginPath();for(var g=0,v=e.length;g<v;++g){switch(a=e[g],1===i&&1===o||(a=Fc(a,i,o)),a[0]){case"l":h+=a[1],d+=a[2],t.lineTo(h+n,d+r);break;case"L":h=a[1],d=a[2],t.lineTo(h+n,d+r);break;case"h":h+=a[1],t.lineTo(h+n,d+r);break;case"H":h=a[1],t.lineTo(h+n,d+r);break;case"v":d+=a[1],t.lineTo(h+n,d+r);break;case"V":d=a[1],t.lineTo(h+n,d+r);break;case"m":h+=a[1],d+=a[2],t.moveTo(h+n,d+r);break;case"M":h=a[1],d=a[2],t.moveTo(h+n,d+r);break;case"c":s=h+a[5],u=d+a[6],p=h+a[3],m=d+a[4],t.bezierCurveTo(h+a[1]+n,d+a[2]+r,p+n,m+r,s+n,u+r),h=s,d=u;break;case"C":h=a[5],d=a[6],p=a[3],m=a[4],t.bezierCurveTo(a[1]+n,a[2]+r,p+n,m+r,h+n,d+r);break;case"s":s=h+a[3],u=d+a[4],p=2*h-p,m=2*d-m,t.bezierCurveTo(p+n,m+r,h+a[1]+n,d+a[2]+r,s+n,u+r),p=h+a[1],m=d+a[2],h=s,d=u;break;case"S":s=a[3],u=a[4],p=2*h-p,m=2*d-m,t.bezierCurveTo(p+n,m+r,a[1]+n,a[2]+r,s+n,u+r),h=s,d=u,p=a[1],m=a[2];break;case"q":s=h+a[3],u=d+a[4],p=h+a[1],m=d+a[2],t.quadraticCurveTo(p+n,m+r,s+n,u+r),h=s,d=u;break;case"Q":s=a[3],u=a[4],t.quadraticCurveTo(a[1]+n,a[2]+r,s+n,u+r),h=s,d=u,p=a[1],m=a[2];break;case"t":s=h+a[1],u=d+a[2],null===f[0].match(/[QqTt]/)?(p=h,m=d):"t"===f[0]?(p=2*h-c,m=2*d-l):"q"===f[0]&&(p=2*h-p,m=2*d-m),c=p,l=m,t.quadraticCurveTo(p+n,m+r,s+n,u+r),d=u,p=(h=s)+a[1],m=d+a[2];break;case"T":s=a[1],u=a[2],p=2*h-p,m=2*d-m,t.quadraticCurveTo(p+n,m+r,s+n,u+r),h=s,d=u;break;case"a":Nc(t,h+n,d+r,[a[1],a[2],a[3],a[4],a[5],a[6]+h+n,a[7]+d+r]),h+=a[6],d+=a[7];break;case"A":Nc(t,h+n,d+r,[a[1],a[2],a[3],a[4],a[5],a[6]+n,a[7]+r]),h=a[6],d=a[7];break;case"z":case"Z":t.closePath();}f=a;}}function Nc(t,e,n,r){var i=function(t,e,n,r,i,o,a,s,u){var c=_c.call(arguments);if(Ac[c])return Ac[c];var l=a*xc,f=Math.sin(l),h=Math.cos(l),d=h*(s-t)*.5+f*(u-e)*.5,p=h*(u-e)*.5-f*(s-t)*.5;var m=d*d/((n=Math.abs(n))*n)+p*p/((r=Math.abs(r))*r);m>1&&(n*=m=Math.sqrt(m),r*=m);var g=h/n,v=f/n,y=-f/r,b=h/r,x=g*s+v*u,w=y*s+b*u,k=g*t+v*e,E=y*t+b*e;var C=1/((k-x)*(k-x)+(E-w)*(E-w))-.25;C<0&&(C=0);var A=Math.sqrt(C);o==i&&(A=-A);var O=.5*(x+k)-A*(E-w),_=.5*(w+E)+A*(k-x),S=Math.atan2(w-_,x-O);var D=Math.atan2(E-_,k-O)-S;D<0&&1===o?D+=Ec:D>0&&0===o&&(D-=Ec);var F=Math.ceil(Math.abs(D/(kc+.001))),T=[];for(var _t47=0;_t47<F;++_t47){var _e46=S+_t47*D/F,_i26=S+(_t47+1)*D/F;T[_t47]=[O,_,_e46,_i26,n,r,f,h];}return Ac[c]=T;}(r[5],r[6],r[0],r[1],r[3],r[4],r[2],e,n);for(var _e47=0;_e47<i.length;++_e47){var _n37=Sc(i[_e47]);t.bezierCurveTo(_n37[0],_n37[1],_n37[2],_n37[3],_n37[4],_n37[5]);}}var Ic={circle:{draw:function draw(t,e){var n=Math.sqrt(e)/2;t.moveTo(n,0),t.arc(0,0,n,0,Ec);}},cross:{draw:function draw(t,e){var n=Math.sqrt(e)/2,r=n/2.5;t.moveTo(-n,-r),t.lineTo(-n,r),t.lineTo(-r,r),t.lineTo(-r,n),t.lineTo(r,n),t.lineTo(r,r),t.lineTo(n,r),t.lineTo(n,-r),t.lineTo(r,-r),t.lineTo(r,-n),t.lineTo(-r,-n),t.lineTo(-r,-r),t.closePath();}},diamond:{draw:function draw(t,e){var n=Math.sqrt(e)/2;t.moveTo(-n,0),t.lineTo(0,-n),t.lineTo(n,0),t.lineTo(0,n),t.closePath();}},square:{draw:function draw(t,e){var n=Math.sqrt(e),r=-n/2;t.rect(r,r,n,n);}},arrow:{draw:function draw(t,e){var n=Math.sqrt(e)/2,r=n/7,i=n/2.5,o=n/8;t.moveTo(-r,n),t.lineTo(r,n),t.lineTo(r,-o),t.lineTo(i,-o),t.lineTo(0,-n),t.lineTo(-i,-o),t.lineTo(-r,-o),t.closePath();}},wedge:{draw:function draw(t,e){var n=Math.sqrt(e)/2,r=Cc*n,i=r-.5773502691896257*n,o=n/4;t.moveTo(0,-r-i),t.lineTo(-o,r-i),t.lineTo(o,r-i),t.closePath();}},triangle:{draw:function draw(t,e){var n=Math.sqrt(e)/2,r=Cc*n,i=r-.5773502691896257*n;t.moveTo(0,-r-i),t.lineTo(-n,r-i),t.lineTo(n,r-i),t.closePath();}},"triangle-up":{draw:function draw(t,e){var n=Math.sqrt(e)/2,r=Cc*n;t.moveTo(0,-r),t.lineTo(-n,r),t.lineTo(n,r),t.closePath();}},"triangle-down":{draw:function draw(t,e){var n=Math.sqrt(e)/2,r=Cc*n;t.moveTo(0,r),t.lineTo(-n,-r),t.lineTo(n,-r),t.closePath();}},"triangle-right":{draw:function draw(t,e){var n=Math.sqrt(e)/2,r=Cc*n;t.moveTo(r,0),t.lineTo(-r,-n),t.lineTo(-r,n),t.closePath();}},"triangle-left":{draw:function draw(t,e){var n=Math.sqrt(e)/2,r=Cc*n;t.moveTo(-r,0),t.lineTo(r,-n),t.lineTo(r,n),t.closePath();}},stroke:{draw:function draw(t,e){var n=Math.sqrt(e)/2;t.moveTo(-n,0),t.lineTo(n,0);}}};function Rc(t){return Object(Z.w)(Ic,t)?Ic[t]:function(t){if(!Object(Z.w)(Mc,t)){var _e48=bc(t);Mc[t]={draw:function draw(t,n){Tc(t,_e48,0,0,Math.sqrt(n)/2);}};}return Mc[t];}(t);}var Mc={};var jc=.448084975506;function Bc(t){return t.x;}function Pc(t){return t.y;}function Lc(t){return t.width;}function zc(t){return t.height;}function Uc(t){return "function"==typeof t?t:function(){return +t;};}function Wc(t,e,n){return Math.max(e,Math.min(t,n));}function Vc(){var t=Bc,e=Pc,n=Lc,r=zc,i=Uc(0),o=i,a=i,s=i,u=null;function c(c,l,f){var h,d=null!=l?l:+t.call(this,c),p=null!=f?f:+e.call(this,c),m=+n.call(this,c),g=+r.call(this,c),v=Math.min(m,g)/2,y=Wc(+i.call(this,c),0,v),b=Wc(+o.call(this,c),0,v),x=Wc(+a.call(this,c),0,v),w=Wc(+s.call(this,c),0,v);if(u||(u=h=wi()),y<=0&&b<=0&&x<=0&&w<=0)u.rect(d,p,m,g);else {var k=d+m,E=p+g;u.moveTo(d+y,p),u.lineTo(k-b,p),u.bezierCurveTo(k-jc*b,p,k,p+jc*b,k,p+b),u.lineTo(k,E-w),u.bezierCurveTo(k,E-jc*w,k-jc*w,E,k-w,E),u.lineTo(d+x,E),u.bezierCurveTo(d+jc*x,E,d,E-jc*x,d,E-x),u.lineTo(d,p+y),u.bezierCurveTo(d,p+jc*y,d+jc*y,p,d+y,p),u.closePath();}if(h)return u=null,h+""||null;}return c.x=function(e){return arguments.length?(t=Uc(e),c):t;},c.y=function(t){return arguments.length?(e=Uc(t),c):e;},c.width=function(t){return arguments.length?(n=Uc(t),c):n;},c.height=function(t){return arguments.length?(r=Uc(t),c):r;},c.cornerRadius=function(t,e,n,r){return arguments.length?(i=Uc(t),o=null!=e?Uc(e):i,s=null!=n?Uc(n):i,a=null!=r?Uc(r):o,c):i;},c.context=function(t){return arguments.length?(u=null==t?null:t,c):u;},c;}function qc(){var t,e,n,r,i,o,a,s,u=null;function c(t,e,n){var r=n/2;if(i){var c=a-e,l=t-o;if(c||l){var f=Math.sqrt(c*c+l*l),h=(c/=f)*s,d=(l/=f)*s,p=Math.atan2(l,c);u.moveTo(o-h,a-d),u.lineTo(t-c*r,e-l*r),u.arc(t,e,r,p-Math.PI,p),u.lineTo(o+h,a+d),u.arc(o,a,s,p,p+Math.PI);}else u.arc(t,e,r,0,Ec);u.closePath();}else i=1;o=t,a=e,s=r;}function l(o){var a,s,l,f=o.length,h=!1;for(null==u&&(u=l=wi()),a=0;a<=f;++a){!(a<f&&r(s=o[a],a,o))===h&&(h=!h)&&(i=0),h&&c(+t(s,a,o),+e(s,a,o),+n(s,a,o));}if(l)return u=null,l+""||null;}return l.x=function(e){return arguments.length?(t=e,l):t;},l.y=function(t){return arguments.length?(e=t,l):e;},l.size=function(t){return arguments.length?(n=t,l):n;},l.defined=function(t){return arguments.length?(r=t,l):r;},l.context=function(t){return arguments.length?(u=null==t?null:t,l):u;},l;}function $c(t,e){return null!=t?t:e;}var Hc=function Hc(t){return t.x||0;},Gc=function Gc(t){return t.y||0;},Kc=function Kc(t){return !(!1===t.defined);},Xc=function(){var t=Ei,e=Ci,n=ki(0),r=null,i=Ai,o=Oi,a=_i,s=null;function u(){var u,c,l=+t.apply(this,arguments),f=+e.apply(this,arguments),h=i.apply(this,arguments)-Gr,d=o.apply(this,arguments)-Gr,p=Pr(d-h),m=d>h;if(s||(s=u=wi()),f<l&&(c=f,f=l,l=c),f>$r){if(p>Kr-$r)s.moveTo(f*zr(h),f*Vr(h)),s.arc(0,0,f,h,d,!m),l>$r&&(s.moveTo(l*zr(d),l*Vr(d)),s.arc(0,0,l,d,h,m));else {var g,v,y=h,b=d,x=h,w=d,k=p,E=p,C=a.apply(this,arguments)/2,A=C>$r&&(r?+r.apply(this,arguments):qr(l*l+f*f)),O=Wr(Pr(f-l)/2,+n.apply(this,arguments)),_=O,S=O;if(A>$r){var D=Xr(A/l*Vr(C)),F=Xr(A/f*Vr(C));(k-=2*D)>$r?(x+=D*=m?1:-1,w-=D):(k=0,x=w=(h+d)/2),(E-=2*F)>$r?(y+=F*=m?1:-1,b-=F):(E=0,y=b=(h+d)/2);}var T=f*zr(y),N=f*Vr(y),I=l*zr(w),R=l*Vr(w);if(O>$r){var M,j=f*zr(b),B=f*Vr(b),P=l*zr(x),L=l*Vr(x);if(p<Hr&&(M=function(t,e,n,r,i,o,a,s){var u=n-t,c=r-e,l=a-i,f=s-o,h=f*u-l*c;if(!(h*h<$r))return [t+(h=(l*(e-o)-f*(t-i))/h)*u,e+h*c];}(T,N,P,L,j,B,I,R))){var z=T-M[0],U=N-M[1],W=j-M[0],V=B-M[1],q=1/Vr(function(t){return t>1?0:t<-1?Hr:Math.acos(t);}((z*W+U*V)/(qr(z*z+U*U)*qr(W*W+V*V)))/2),$=qr(M[0]*M[0]+M[1]*M[1]);_=Wr(O,(l-$)/(q-1)),S=Wr(O,(f-$)/(q+1));}}E>$r?S>$r?(g=Si(P,L,T,N,f,S,m),v=Si(j,B,I,R,f,S,m),s.moveTo(g.cx+g.x01,g.cy+g.y01),S<O?s.arc(g.cx,g.cy,S,Lr(g.y01,g.x01),Lr(v.y01,v.x01),!m):(s.arc(g.cx,g.cy,S,Lr(g.y01,g.x01),Lr(g.y11,g.x11),!m),s.arc(0,0,f,Lr(g.cy+g.y11,g.cx+g.x11),Lr(v.cy+v.y11,v.cx+v.x11),!m),s.arc(v.cx,v.cy,S,Lr(v.y11,v.x11),Lr(v.y01,v.x01),!m))):(s.moveTo(T,N),s.arc(0,0,f,y,b,!m)):s.moveTo(T,N),l>$r&&k>$r?_>$r?(g=Si(I,R,j,B,l,-_,m),v=Si(T,N,P,L,l,-_,m),s.lineTo(g.cx+g.x01,g.cy+g.y01),_<O?s.arc(g.cx,g.cy,_,Lr(g.y01,g.x01),Lr(v.y01,v.x01),!m):(s.arc(g.cx,g.cy,_,Lr(g.y01,g.x01),Lr(g.y11,g.x11),!m),s.arc(0,0,l,Lr(g.cy+g.y11,g.cx+g.x11),Lr(v.cy+v.y11,v.cx+v.x11),m),s.arc(v.cx,v.cy,_,Lr(v.y11,v.x11),Lr(v.y01,v.x01),!m))):s.arc(0,0,l,w,x,m):s.lineTo(I,R);}}else s.moveTo(0,0);if(s.closePath(),u)return s=null,u+""||null;}return u.centroid=function(){var n=(+t.apply(this,arguments)+ +e.apply(this,arguments))/2,r=(+i.apply(this,arguments)+ +o.apply(this,arguments))/2-Hr/2;return [zr(r)*n,Vr(r)*n];},u.innerRadius=function(e){return arguments.length?(t="function"==typeof e?e:ki(+e),u):t;},u.outerRadius=function(t){return arguments.length?(e="function"==typeof t?t:ki(+t),u):e;},u.cornerRadius=function(t){return arguments.length?(n="function"==typeof t?t:ki(+t),u):n;},u.padRadius=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:ki(+t),u):r;},u.startAngle=function(t){return arguments.length?(i="function"==typeof t?t:ki(+t),u):i;},u.endAngle=function(t){return arguments.length?(o="function"==typeof t?t:ki(+t),u):o;},u.padAngle=function(t){return arguments.length?(a="function"==typeof t?t:ki(+t),u):a;},u.context=function(t){return arguments.length?(s=null==t?null:t,u):s;},u;}().startAngle(function(t){return t.startAngle||0;}).endAngle(function(t){return t.endAngle||0;}).padAngle(function(t){return t.padAngle||0;}).innerRadius(function(t){return t.innerRadius||0;}).outerRadius(function(t){return t.outerRadius||0;}).cornerRadius(function(t){return t.cornerRadius||0;}),Yc=Ii().x(Hc).y1(Gc).y0(function(t){return (t.y||0)+(t.height||0);}).defined(Kc),Jc=Ii().y(Gc).x1(Hc).x0(function(t){return (t.x||0)+(t.width||0);}).defined(Kc),Qc=Ni().x(Hc).y(Gc).defined(Kc),Zc=Vc().x(Hc).y(Gc).width(function(t){return t.width||0;}).height(function(t){return t.height||0;}).cornerRadius(function(t){return $c(t.cornerRadiusTopLeft,t.cornerRadius)||0;},function(t){return $c(t.cornerRadiusTopRight,t.cornerRadius)||0;},function(t){return $c(t.cornerRadiusBottomRight,t.cornerRadius)||0;},function(t){return $c(t.cornerRadiusBottomLeft,t.cornerRadius)||0;}),tl=function(t,e){var n=null;function r(){var r;if(n||(n=r=wi()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),r)return n=null,r+""||null;}return t="function"==typeof t?t:ki(t||Ri),e="function"==typeof e?e:ki(void 0===e?64:+e),r.type=function(e){return arguments.length?(t="function"==typeof e?e:ki(e),r):t;},r.size=function(t){return arguments.length?(e="function"==typeof t?t:ki(+t),r):e;},r.context=function(t){return arguments.length?(n=null==t?null:t,r):n;},r;}().type(function(t){return Rc(t.shape||"circle");}).size(function(t){return $c(t.size,64);}),el=qc().x(Hc).y(Gc).defined(Kc).size(function(t){return t.size||1;});function nl(t){return t.cornerRadius||t.cornerRadiusTopLeft||t.cornerRadiusTopRight||t.cornerRadiusBottomRight||t.cornerRadiusBottomLeft;}function rl(t,e,n,r){return Zc.context(t)(e,n,r);}var il=1;function ol(){il=1;}function al(t,e,n){var r=e.clip,i=t._defs,o=e.clip_id||(e.clip_id="clip"+il++),a=i.clipping[o]||(i.clipping[o]={id:o});return Object(Z.E)(r)?a.path=r(null):nl(n)?a.path=rl(null,n,0,0):(a.width=n.width||0,a.height=n.height||0),"url(#"+o+")";}function sl(t){this.clear(),t&&this.union(t);}function ul(t){this.mark=t,this.bounds=this.bounds||new sl();}function cl(t){ul.call(this,t),this.items=this.items||[];}function ll(t){this._pending=0,this._loader=t||Object(tt.e)();}function fl(t){t._pending+=1;}function hl(t){t._pending-=1;}function dl(t,e,n){if(e.stroke&&0!==e.opacity&&0!==e.strokeOpacity){var _r42=null!=e.strokeWidth?+e.strokeWidth:1;t.expand(_r42+(n?function(t,e){return t.strokeJoin&&"miter"!==t.strokeJoin?0:e;}(e,_r42):0));}return t;}sl.prototype={clone:function clone(){return new sl(this);},clear:function clear(){return this.x1=+Number.MAX_VALUE,this.y1=+Number.MAX_VALUE,this.x2=-Number.MAX_VALUE,this.y2=-Number.MAX_VALUE,this;},empty:function empty(){return this.x1===+Number.MAX_VALUE&&this.y1===+Number.MAX_VALUE&&this.x2===-Number.MAX_VALUE&&this.y2===-Number.MAX_VALUE;},equals:function equals(t){return this.x1===t.x1&&this.y1===t.y1&&this.x2===t.x2&&this.y2===t.y2;},set:function set(t,e,n,r){return n<t?(this.x2=t,this.x1=n):(this.x1=t,this.x2=n),r<e?(this.y2=e,this.y1=r):(this.y1=e,this.y2=r),this;},add:function add(t,e){return t<this.x1&&(this.x1=t),e<this.y1&&(this.y1=e),t>this.x2&&(this.x2=t),e>this.y2&&(this.y2=e),this;},expand:function expand(t){return this.x1-=t,this.y1-=t,this.x2+=t,this.y2+=t,this;},round:function round(){return this.x1=Math.floor(this.x1),this.y1=Math.floor(this.y1),this.x2=Math.ceil(this.x2),this.y2=Math.ceil(this.y2),this;},scale:function scale(t){return this.x1*=t,this.y1*=t,this.x2*=t,this.y2*=t,this;},translate:function translate(t,e){return this.x1+=t,this.x2+=t,this.y1+=e,this.y2+=e,this;},rotate:function rotate(t,e,n){var r=this.rotatedPoints(t,e,n);return this.clear().add(r[0],r[1]).add(r[2],r[3]).add(r[4],r[5]).add(r[6],r[7]);},rotatedPoints:function rotatedPoints(t,e,n){var r=this.x1,i=this.y1,o=this.x2,a=this.y2,s=Math.cos(t),u=Math.sin(t),c=e-e*s+n*u,l=n-e*u-n*s;return [s*r-u*i+c,u*r+s*i+l,s*r-u*a+c,u*r+s*a+l,s*o-u*i+c,u*o+s*i+l,s*o-u*a+c,u*o+s*a+l];},union:function union(t){return t.x1<this.x1&&(this.x1=t.x1),t.y1<this.y1&&(this.y1=t.y1),t.x2>this.x2&&(this.x2=t.x2),t.y2>this.y2&&(this.y2=t.y2),this;},intersect:function intersect(t){return t.x1>this.x1&&(this.x1=t.x1),t.y1>this.y1&&(this.y1=t.y1),t.x2<this.x2&&(this.x2=t.x2),t.y2<this.y2&&(this.y2=t.y2),this;},encloses:function encloses(t){return t&&this.x1<=t.x1&&this.x2>=t.x2&&this.y1<=t.y1&&this.y2>=t.y2;},alignsWith:function alignsWith(t){return t&&(this.x1==t.x1||this.x2==t.x2||this.y1==t.y1||this.y2==t.y2);},intersects:function intersects(t){return t&&!(this.x2<t.x1||this.x1>t.x2||this.y2<t.y1||this.y1>t.y2);},contains:function contains(t,e){return !(t<this.x1||t>this.x2||e<this.y1||e>this.y2);},width:function width(){return this.x2-this.x1;},height:function height(){return this.y2-this.y1;}},Object(Z.z)(cl,ul),ll.prototype={pending:function pending(){return this._pending;},sanitizeURL:function sanitizeURL(t){var e=this;return fl(e),e._loader.sanitize(t,{context:"href"}).then(function(t){return hl(e),t;}).catch(function(){return hl(e),null;});},loadImage:function loadImage(t){var e=this,n=Bi();return fl(e),e._loader.sanitize(t,{context:"image"}).then(function(t){var r=t.href;if(!r||!n)throw {url:r};var i=new n(),o=Object(Z.w)(t,"crossOrigin")?t.crossOrigin:"anonymous";return null!=o&&(i.crossOrigin=o),i.onload=function(){return hl(e);},i.onerror=function(){return hl(e);},i.src=r,i;}).catch(function(t){return hl(e),{complete:!1,width:0,height:0,src:t&&t.url||""};});},ready:function ready(){var t=this;return new Promise(function(e){!function n(r){t.pending()?setTimeout(function(){n(!0);},10):e(r);}(!1);});}};var pl=Ec-1e-8;var ml,gl,vl,yl,bl,xl,wl,kl;var El=function El(t,e){return ml.add(t,e);},Cl=function Cl(t,e){return El(gl=t,vl=e);},Al=function Al(t){return El(t,ml.y1);},Ol=function Ol(t){return El(ml.x1,t);},_l=function _l(t,e){return bl*t+wl*e;},Sl=function Sl(t,e){return xl*t+kl*e;},Dl=function Dl(t,e){return El(_l(t,e),Sl(t,e));},Fl=function Fl(t,e){return Cl(_l(t,e),Sl(t,e));};function Tl(t,e){return ml=t,e?(yl=e*xc,bl=kl=Math.cos(yl),xl=Math.sin(yl),wl=-xl):(bl=kl=1,yl=xl=wl=0),Nl;}var Nl={beginPath:function beginPath(){},closePath:function closePath(){},moveTo:Fl,lineTo:Fl,rect:function rect(t,e,n,r){yl?(Dl(t+n,e),Dl(t+n,e+r),Dl(t,e+r),Fl(t,e)):(El(t+n,e+r),Cl(t,e));},quadraticCurveTo:function quadraticCurveTo(t,e,n,r){var i=_l(t,e),o=Sl(t,e),a=_l(n,r),s=Sl(n,r);Il(gl,i,a,Al),Il(vl,o,s,Ol),Cl(a,s);},bezierCurveTo:function bezierCurveTo(t,e,n,r,i,o){var a=_l(t,e),s=Sl(t,e),u=_l(n,r),c=Sl(n,r),l=_l(i,o),f=Sl(i,o);Rl(gl,a,u,l,Al),Rl(vl,s,c,f,Ol),Cl(l,f);},arc:function arc(t,e,n,r,i,o){if(r+=yl,i+=yl,gl=n*Math.cos(i)+t,vl=n*Math.sin(i)+e,Math.abs(i-r)>pl)El(t-n,e-n),El(t+n,e+n);else {var _a21=function _a21(r){return El(n*Math.cos(r)+t,n*Math.sin(r)+e);};var _s16,_u9;if(_a21(r),_a21(i),i!==r)if((r%=Ec)<0&&(r+=Ec),(i%=Ec)<0&&(i+=Ec),i<r&&(o=!o,_s16=r,r=i,i=_s16),o)for(i-=Ec,_s16=r-r%kc,_u9=0;_u9<4&&_s16>i;++_u9,_s16-=kc){_a21(_s16);}else for(_s16=r-r%kc+kc,_u9=0;_u9<4&&_s16<i;++_u9,_s16+=kc){_a21(_s16);}}}};function Il(t,e,n,r){var i=(t-e)/(t+n-2*e);0<i&&i<1&&r(t+(e-t)*i);}function Rl(t,e,n,r,i){var o=r-t+3*e-3*n,a=t+n-2*e,s=t-e;var u,c=0,l=0;Math.abs(o)>wc?(u=a*a+s*o)>=0&&(c=(-a+(u=Math.sqrt(u)))/o,l=(-a-u)/o):c=.5*s/a,0<c&&c<1&&i(Ml(c,t,e,n,r)),0<l&&l<1&&i(Ml(l,t,e,n,r));}function Ml(t,e,n,r,i){var o=1-t,a=o*o,s=t*t;return a*o*e+3*a*t*n+3*o*s*r+s*t*i;}var jl=(jl=ji(1,1))?jl.getContext("2d"):null;var Bl=new sl();function Pl(t){return function(e,n){if(!jl)return !0;t(jl,e),Bl.clear().union(e.bounds).intersect(n).round();var r=Bl.x1,i=Bl.y1,o=Bl.x2,a=Bl.y2;for(var _t48=i;_t48<=a;++_t48){for(var _e49=r;_e49<=o;++_e49){if(jl.isPointInPath(_e49,_t48))return !0;}}return !1;};}function Ll(t,e){return e.contains(t.x||0,t.y||0);}function zl(t,e){var n=t.x||0,r=t.y||0,i=t.width||0,o=t.height||0;return e.intersects(Bl.set(n,r,n+i,r+o));}function Ul(t,e){var n=t.x||0,r=t.y||0;return Wl(e,n,r,null!=t.x2?t.x2:n,null!=t.y2?t.y2:r);}function Wl(t,e,n,r,i){var o=t.x1,a=t.y1,s=t.x2,u=t.y2,c=r-e,l=i-n;var f,h,d,p,m=0,g=1;for(p=0;p<4;++p){if(0===p&&(f=-c,h=-(o-e)),1===p&&(f=c,h=s-e),2===p&&(f=-l,h=-(a-n)),3===p&&(f=l,h=u-n),Math.abs(f)<1e-10&&h<0)return !1;if(d=h/f,f<0){if(d>g)return !1;d>m&&(m=d);}else if(f>0){if(d<m)return !1;d<g&&(g=d);}}return !0;}function Vl(t,e){t.globalCompositeOperation=e.blend||"source-over";}function ql(t,e){return null==t?e:t;}function $l(t,e){var n=e.length;for(var _r43=0;_r43<n;++_r43){t.addColorStop(e[_r43].offset,e[_r43].color);}return t;}function Hl(t,e,n){return fc(n)?function(t,e,n){var r=n.width(),i=n.height();var o;if("radial"===e.gradient)o=t.createRadialGradient(n.x1+ql(e.x1,.5)*r,n.y1+ql(e.y1,.5)*i,Math.max(r,i)*ql(e.r1,0),n.x1+ql(e.x2,.5)*r,n.y1+ql(e.y2,.5)*i,Math.max(r,i)*ql(e.r2,.5));else {var _a22=ql(e.x1,0),_s17=ql(e.y1,0),_u10=ql(e.x2,1),_c5=ql(e.y2,0);if(_a22!==_u10&&_s17!==_c5&&r!==i){var _n38=ji(Math.ceil(r),Math.ceil(i)),_o14=_n38.getContext("2d");return _o14.scale(r,i),_o14.fillStyle=$l(_o14.createLinearGradient(_a22,_s17,_u10,_c5),e.stops),_o14.fillRect(0,0,r,i),t.createPattern(_n38,"no-repeat");}o=t.createLinearGradient(n.x1+_a22*r,n.y1+_s17*i,n.x1+_u10*r,n.y1+_c5*i);}return $l(o,e.stops);}(t,n,e.bounds):n;}function Gl(t,e,n){return (n*=null==e.fillOpacity?1:e.fillOpacity)>0&&(t.globalAlpha=n,t.fillStyle=Hl(t,e,e.fill),!0);}var Kl=[];function Xl(t,e,n){var r=null!=(r=e.strokeWidth)?r:1;return !(r<=0)&&(n*=null==e.strokeOpacity?1:e.strokeOpacity)>0&&(t.globalAlpha=n,t.strokeStyle=Hl(t,e,e.stroke),t.lineWidth=r,t.lineCap=e.strokeCap||"butt",t.lineJoin=e.strokeJoin||"miter",t.miterLimit=e.strokeMiterLimit||10,t.setLineDash&&(t.setLineDash(e.strokeDash||Kl),t.lineDashOffset=e.strokeDashOffset||0),!0);}function Yl(t,e){return t.zindex-e.zindex||t.index-e.index;}function Jl(t){if(!t.zdirty)return t.zitems;var e,n,r,i=t.items,o=[];for(n=0,r=i.length;n<r;++n){(e=i[n]).index=n,e.zindex&&o.push(e);}return t.zdirty=!1,t.zitems=o.sort(Yl);}function Ql(t,e){var n,r,i=t.items;if(!i||!i.length)return;var o=Jl(t);if(o&&o.length){for(n=0,r=i.length;n<r;++n){i[n].zindex||e(i[n]);}i=o;}for(n=0,r=i.length;n<r;++n){e(i[n]);}}function Zl(t,e){var n,r,i=t.items;if(!i||!i.length)return null;var o=Jl(t);for(o&&o.length&&(i=o),r=i.length;--r>=0;){if(n=e(i[r]))return n;}if(i===o)for(r=(i=t.items).length;--r>=0;){if(!i[r].zindex&&(n=e(i[r])))return n;}return null;}function tf(t){return function(e,n,r){Ql(n,function(n){r&&!r.intersects(n.bounds)||ef(t,e,n,n);});};}function ef(t,e,n,r){var i=null==n.opacity?1:n.opacity;0!==i&&(t(e,r)||(Vl(e,n),n.fill&&Gl(e,n,i)&&e.fill(),n.stroke&&Xl(e,n,i)&&e.stroke()));}function nf(t){return t=t||Z.Ia,function(e,n,r,i,o,a){return r*=e.pixelRatio,i*=e.pixelRatio,Zl(n,function(n){var s=n.bounds;if((!s||s.contains(o,a))&&s)return t(e,n,r,i,o,a)?n:void 0;});};}function rf(t,e){return function(n,r,i,o){var a,s,u=Array.isArray(r)?r[0]:r,c=null==e?u.fill:e,l=u.stroke&&n.isPointInStroke;return l&&(a=u.strokeWidth,s=u.strokeCap,n.lineWidth=null!=a?a:1,n.lineCap=null!=s?s:"butt"),!t(n,r)&&(c&&n.isPointInPath(i,o)||l&&n.isPointInStroke(i,o));};}function of(t){return nf(rf(t));}function af(t,e){return "translate("+t+","+e+")";}function sf(t){return "rotate("+t+")";}function uf(t){return af(t.x||0,t.y||0);}function cf(t,e,n){function r(t,n){var r=n.x||0,i=n.y||0,o=n.angle||0;t.translate(r,i),o&&t.rotate(o*=xc),t.beginPath(),e(t,n),o&&t.rotate(-o),t.translate(-r,-i);}return {type:t,tag:"path",nested:!1,attr:function attr(t,n){t("transform",function(t){return af(t.x||0,t.y||0)+(t.angle?" "+sf(t.angle):"");}(n)),t("d",e(null,n));},bound:function bound(t,n){return e(Tl(t,n.angle),n),dl(t,n).translate(n.x||0,n.y||0);},draw:tf(r),pick:of(r),isect:n||Pl(r)};}var lf=cf("arc",function(t,e){return Xc.context(t)(e);});function ff(t,e,n){function r(t,n){t.beginPath(),e(t,n);}var i=rf(r);return {type:t,tag:"path",nested:!0,attr:function attr(t,n){var r=n.mark.items;r.length&&t("d",e(null,r));},bound:function bound(t,n){var r=n.items;return 0===r.length?t:(e(Tl(t),r),dl(t,r[0]));},draw:function(t){return function(e,n,r){!n.items.length||r&&!r.intersects(n.bounds)||ef(t,e,n.items[0],n.items);};}(r),pick:function pick(t,e,n,r,o,a){var s=e.items,u=e.bounds;return !s||!s.length||u&&!u.contains(o,a)?null:(n*=t.pixelRatio,r*=t.pixelRatio,i(t,s,n,r)?s[0]:null);},isect:Ll,tip:n};}var hf=ff("area",function(t,e){var n=e[0],r=n.interpolate||"linear";return ("horizontal"===n.orient?Jc:Yc).curve(gc(r,n.orient,n.tension)).context(t)(e);},function(t,e){for(var n,r,i="horizontal"===t[0].orient?e[1]:e[0],o="horizontal"===t[0].orient?"y":"x",a=t.length,s=1/0;--a>=0;){!1!==t[a].defined&&(r=Math.abs(t[a][o]-i))<s&&(s=r,n=t[a]);}return n;});function df(t,e){t.beginPath(),nl(e)?rl(t,e,0,0):t.rect(0,0,e.width||0,e.height||0),t.clip();}function pf(t){var e=ql(t.strokeWidth,1);return null!=t.strokeOffset?t.strokeOffset:t.stroke&&e>.5&&e<1.5?.5-Math.abs(e-1):0;}function mf(t,e){var n=pf(e);t("d",rl(null,e,n,n));}function gf(t,e,n,r){var i=pf(e);t.beginPath(),rl(t,e,(n||0)+i,(r||0)+i);}var vf=rf(gf),yf=rf(gf,!1),bf=rf(gf,!0);var xf={type:"group",tag:"g",nested:!1,attr:function attr(t,e){t("transform",uf(e));},bound:function bound(t,e){if(!e.clip&&e.items){var _n39=e.items,_r44=_n39.length;for(var _e50=0;_e50<_r44;++_e50){t.union(_n39[_e50].bounds);}}return (e.clip||e.width||e.height)&&!e.noBound&&t.add(0,0).add(e.width||0,e.height||0),dl(t,e),t.translate(e.x||0,e.y||0);},draw:function draw(t,e,n){var _this15=this;Ql(e,function(e){var r=e.x||0,i=e.y||0,o=e.strokeForeground,a=null==e.opacity?1:e.opacity;(e.stroke||e.fill)&&a&&(gf(t,e,r,i),Vl(t,e),e.fill&&Gl(t,e,a)&&t.fill(),e.stroke&&!o&&Xl(t,e,a)&&t.stroke()),t.save(),t.translate(r,i),e.clip&&df(t,e),n&&n.translate(-r,-i),Ql(e,function(e){_this15.draw(t,e,n);}),n&&n.translate(r,i),t.restore(),o&&e.stroke&&a&&(gf(t,e,r,i),Vl(t,e),Xl(t,e,a)&&t.stroke());});},pick:function pick(t,e,n,r,i,o){var _this16=this;if(e.bounds&&!e.bounds.contains(i,o)||!e.items)return null;var a=n*t.pixelRatio,s=r*t.pixelRatio;return Zl(e,function(u){var c,l,f;var h=u.bounds;if(h&&!h.contains(i,o))return;l=u.x||0,f=u.y||0;var d=l+(u.width||0),p=f+(u.height||0),m=u.clip;if(m&&(i<l||i>d||o<f||o>p))return;if(t.save(),t.translate(l,f),l=i-l,f=o-f,m&&nl(u)&&!bf(t,u,a,s))return t.restore(),null;var g=u.strokeForeground,v=!1!==e.interactive;return v&&g&&u.stroke&&yf(t,u,a,s)?(t.restore(),u):(!(c=Zl(u,function(t){return !function(t,e,n){return (!1!==t.interactive||"group"===t.marktype)&&t.bounds&&t.bounds.contains(e,n);}(t,l,f)?null:_this16.pick(t,n,r,l,f);}))&&v&&(u.fill||!g&&u.stroke)&&vf(t,u,a,s)&&(c=u),t.restore(),c||null);});},isect:zl,content:function content(t,e,n){t("clip-path",e.clip?al(n,e,e):null);},background:function background(t,e){t("class","background"),t("aria-hidden",!0),mf(t,e);},foreground:function foreground(t,e){t("class","foreground"),t("aria-hidden",!0),e.strokeForeground?mf(t,e):t("d","");}},wf={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"};function kf(t,e){var n=t.image;return (!n||t.url&&t.url!==n.url)&&(n={complete:!1,width:0,height:0},e.loadImage(t.url).then(function(e){t.image=e,t.image.url=t.url;})),n;}function Ef(t,e){return null!=t.width?t.width:e&&e.width?!1!==t.aspect&&t.height?t.height*e.width/e.height:e.width:0;}function Cf(t,e){return null!=t.height?t.height:e&&e.height?!1!==t.aspect&&t.width?t.width*e.height/e.width:e.height:0;}function Af(t,e){return "center"===t?e/2:"right"===t?e:0;}function Of(t,e){return "middle"===t?e/2:"bottom"===t?e:0;}var _f={type:"image",tag:"image",nested:!1,attr:function attr(t,e,n){var r=kf(e,n),i=Ef(e,r),o=Cf(e,r),a=(e.x||0)-Af(e.align,i),s=(e.y||0)-Of(e.baseline,o);t("href",!r.src&&r.toDataURL?r.toDataURL():r.src||"",wf["xmlns:xlink"],"xlink:href"),t("transform",af(a,s)),t("width",i),t("height",o),t("preserveAspectRatio",!1===e.aspect?"none":"xMidYMid");},bound:function bound(t,e){var n=e.image,r=Ef(e,n),i=Cf(e,n),o=(e.x||0)-Af(e.align,r),a=(e.y||0)-Of(e.baseline,i);return t.set(o,a,o+r,a+i);},draw:function draw(t,e,n){var _this17=this;Ql(e,function(e){if(n&&!n.intersects(e.bounds))return;var r=kf(e,_this17);var i=Ef(e,r),o=Cf(e,r);if(0===i||0===o)return;var a,s,u,c,l=(e.x||0)-Af(e.align,i),f=(e.y||0)-Of(e.baseline,o);!1!==e.aspect&&(s=r.width/r.height,u=e.width/e.height,s==s&&u==u&&s!==u&&(u<s?(f+=(o-(c=i/s))/2,o=c):(l+=(i-(c=o*s))/2,i=c))),(r.complete||r.toDataURL)&&(Vl(t,e),t.globalAlpha=null!=(a=e.opacity)?a:1,t.imageSmoothingEnabled=!1!==e.smooth,t.drawImage(r,l,f,i,o));});},pick:nf(),isect:Z.Ia,get:kf,xOffset:Af,yOffset:Of},Sf=ff("line",function(t,e){var n=e[0],r=n.interpolate||"linear";return Qc.curve(gc(r,n.orient,n.tension)).context(t)(e);},function(t,e){for(var n,r,i=Math.pow(t[0].strokeWidth||1,2),o=t.length;--o>=0;){if(!1!==t[o].defined&&(n=t[o].x-e[0])*n+(r=t[o].y-e[1])*r<i)return t[o];}return null;});function Df(t,e){var n=e.path;if(null==n)return !0;var r=e.x||0,i=e.y||0,o=e.scaleX||1,a=e.scaleY||1,s=(e.angle||0)*xc,u=e.pathCache;u&&u.path===n||((e.pathCache=u=bc(n)).path=n),s&&t.rotate&&t.translate?(t.translate(r,i),t.rotate(s),Tc(t,u,0,0,o,a),t.rotate(-s),t.translate(-r,-i)):Tc(t,u,r,i,o,a);}var Ff={type:"path",tag:"path",nested:!1,attr:function attr(t,e){var n=e.scaleX||1,r=e.scaleY||1;1===n&&1===r||t("vector-effect","non-scaling-stroke"),t("transform",function(t){return af(t.x||0,t.y||0)+(t.angle?" "+sf(t.angle):"")+(t.scaleX||t.scaleY?" "+function(t,e){return "scale("+t+","+e+")";}(t.scaleX||1,t.scaleY||1):"");}(e)),t("d",e.path);},bound:function bound(t,e){return Df(Tl(t,e.angle),e)?t.set(0,0,0,0):dl(t,e,!0);},draw:tf(Df),pick:of(Df),isect:Pl(Df)};function Tf(t,e){t.beginPath(),rl(t,e);}var Nf={type:"rect",tag:"path",nested:!1,attr:function attr(t,e){t("d",rl(null,e));},bound:function bound(t,e){var n,r;return dl(t.set(n=e.x||0,r=e.y||0,n+e.width||0,r+e.height||0),e);},draw:tf(Tf),pick:of(Tf),isect:zl};function If(t,e,n){var r,i,o,a;return !(!e.stroke||!Xl(t,e,n))&&(r=e.x||0,i=e.y||0,o=null!=e.x2?e.x2:r,a=null!=e.y2?e.y2:i,t.beginPath(),t.moveTo(r,i),t.lineTo(o,a),!0);}var Rf={type:"rule",tag:"line",nested:!1,attr:function attr(t,e){t("transform",uf(e)),t("x2",null!=e.x2?e.x2-(e.x||0):0),t("y2",null!=e.y2?e.y2-(e.y||0):0);},bound:function bound(t,e){var n,r;return dl(t.set(n=e.x||0,r=e.y||0,null!=e.x2?e.x2:n,null!=e.y2?e.y2:r),e);},draw:function draw(t,e,n){Ql(e,function(e){if(!n||n.intersects(e.bounds)){var r=null==e.opacity?1:e.opacity;r&&If(t,e,r)&&(Vl(t,e),t.stroke());}});},pick:nf(function(t,e,n,r){return !!t.isPointInStroke&&If(t,e,1)&&t.isPointInStroke(n,r);}),isect:Ul},Mf=cf("shape",function(t,e){return (e.mark.shape||e.shape).context(t)(e);}),jf=cf("symbol",function(t,e){return tl.context(t)(e);},Ll);var Bf=Object(Z.N)();var Pf={height:qf,measureWidth:Wf,estimateWidth:zf,width:zf,canvas:Lf};function Lf(t){Pf.width=t&&jl?Wf:zf;}function zf(t,e){return Uf(Kf(t,e),qf(t));}function Uf(t,e){return ~~(.8*t.length*e);}function Wf(t,e){return qf(t)<=0||!(e=Kf(t,e))?0:Vf(e,Yf(t));}function Vf(t,e){var n="(".concat(e,") ").concat(t);var r=Bf.get(n);return void 0===r&&(jl.font=e,r=jl.measureText(t).width,Bf.set(n,r)),r;}function qf(t){return null!=t.fontSize?+t.fontSize||0:11;}function $f(t){return null!=t.lineHeight?t.lineHeight:qf(t)+2;}function Hf(t){return function(t){return Object(Z.B)(t)?t.length>1?t:t[0]:t;}(t.lineBreak&&t.text&&!Object(Z.B)(t.text)?t.text.split(t.lineBreak):t.text);}function Gf(t){var e=Hf(t);return (Object(Z.B)(e)?e.length-1:0)*$f(t);}function Kf(t,e){var n=null==e?"":(e+"").trim();return t.limit>0&&n.length?function(t,e){var n=+t.limit,r=function(t){if(Pf.width===Wf){var _e51=Yf(t);return function(t){return Vf(t,_e51);};}{var _e52=qf(t);return function(t){return Uf(t,_e52);};}}(t);if(r(e)<n)return e;var i,o=t.ellipsis||"…",a="rtl"===t.dir,s=0,u=e.length;if(n-=r(o),a){for(;s<u;){i=s+u>>>1,r(e.slice(i))>n?s=i+1:u=i;}return o+e.slice(s);}for(;s<u;){i=1+(s+u>>>1),r(e.slice(0,i))<n?s=i:u=i-1;}return e.slice(0,s)+o;}(t,n):n;}function Xf(t,e){var n=t.font;return (e&&n?String(n).replace(/"/g,"'"):n)||"sans-serif";}function Yf(t,e){return (t.fontStyle?t.fontStyle+" ":"")+(t.fontVariant?t.fontVariant+" ":"")+(t.fontWeight?t.fontWeight+" ":"")+qf(t)+"px "+Xf(t,e);}function Jf(t){var e=t.baseline,n=qf(t);return Math.round("top"===e?.79*n:"middle"===e?.3*n:"bottom"===e?-.21*n:"line-top"===e?.29*n+.5*$f(t):"line-bottom"===e?.29*n-.5*$f(t):0);}Lf(!0);var Qf={left:"start",center:"middle",right:"end"},Zf=new sl();function th(t){var e,n=t.x||0,r=t.y||0,i=t.radius||0;return i&&(e=(t.theta||0)-kc,n+=i*Math.cos(e),r+=i*Math.sin(e)),Zf.x1=n,Zf.y1=r,Zf;}function eh(t,e,n){var r,i=Pf.height(e),o=e.align,a=th(e),s=a.x1,u=a.y1,c=e.dx||0,l=(e.dy||0)+Jf(e)-Math.round(.8*i),f=Hf(e);if(Object(Z.B)(f)?(i+=$f(e)*(f.length-1),r=f.reduce(function(t,n){return Math.max(t,Pf.width(e,n));},0)):r=Pf.width(e,f),"center"===o?c-=r/2:"right"===o&&(c-=r),t.set(c+=s,l+=u,c+r,l+i),e.angle&&!n)t.rotate(e.angle*xc,s,u);else if(2===n)return t.rotatedPoints(e.angle*xc,s,u);return t;}var nh={arc:lf,area:hf,group:xf,image:_f,line:Sf,path:Ff,rect:Nf,rule:Rf,shape:Mf,symbol:jf,text:{type:"text",tag:"text",nested:!1,attr:function attr(t,e){var n,r=e.dx||0,i=(e.dy||0)+Jf(e),o=th(e),a=o.x1,s=o.y1,u=e.angle||0;t("text-anchor",Qf[e.align]||"start"),u?(n=af(a,s)+" "+sf(u),(r||i)&&(n+=" "+af(r,i))):n=af(a+r,s+i),t("transform",n);},bound:eh,draw:function draw(t,e,n){Ql(e,function(e){var r,i,o,a,s,u,c,l=null==e.opacity?1:e.opacity;if(!(n&&!n.intersects(e.bounds)||0===l||e.fontSize<=0||null==e.text||0===e.text.length)){if(t.font=Yf(e),t.textAlign=e.align||"left",i=(r=th(e)).x1,o=r.y1,e.angle&&(t.save(),t.translate(i,o),t.rotate(e.angle*xc),i=o=0),i+=e.dx||0,o+=(e.dy||0)+Jf(e),u=Hf(e),Vl(t,e),Object(Z.B)(u))for(s=$f(e),a=0;a<u.length;++a){c=Kf(e,u[a]),e.fill&&Gl(t,e,l)&&t.fillText(c,i,o),e.stroke&&Xl(t,e,l)&&t.strokeText(c,i,o),o+=s;}else c=Kf(e,u),e.fill&&Gl(t,e,l)&&t.fillText(c,i,o),e.stroke&&Xl(t,e,l)&&t.strokeText(c,i,o);e.angle&&t.restore();}});},pick:nf(function(t,e,n,r,i,o){if(e.fontSize<=0)return !1;if(!e.angle)return !0;var a=th(e),s=a.x1,u=a.y1,c=eh(Zf,e,1),l=-e.angle*xc,f=Math.cos(l),h=Math.sin(l),d=f*i-h*o+(s-f*s+h*u),p=h*i+f*o+(u-h*s-f*u);return c.contains(d,p);}),isect:function isect(t,e){var n=eh(Zf,t,2);return Wl(e,n[0],n[1],n[2],n[3])||Wl(e,n[0],n[1],n[4],n[5])||Wl(e,n[4],n[5],n[6],n[7])||Wl(e,n[2],n[3],n[6],n[7]);}},trail:ff("trail",function(t,e){return el.context(t)(e);},function(t,e){for(var n,r,i=t.length;--i>=0;){if(!1!==t[i].defined&&(n=t[i].x-e[0])*n+(r=t[i].y-e[1])*r<(n=t[i].size||1)*n)return t[i];}return null;})};function rh(t,e,n){var r=nh[t.mark.marktype],i=e||r.bound;return r.nested&&(t=t.mark),i(t.bounds||(t.bounds=new sl()),t,n);}var ih={mark:null};function oh(t,e,n){var r,i,o,a,s=nh[t.marktype],u=s.bound,c=t.items,l=c&&c.length;if(s.nested)return l?o=c[0]:(ih.mark=t,o=ih),a=rh(o,u,n),e=e&&e.union(a)||a;if(e=e||t.bounds&&t.bounds.clear()||new sl(),l)for(r=0,i=c.length;r<i;++r){e.union(rh(c[r],u,n));}return t.bounds=e;}var ah=["marktype","name","role","interactive","clip","items","zindex","x","y","width","height","align","baseline","fill","fillOpacity","opacity","blend","stroke","strokeOpacity","strokeWidth","strokeCap","strokeDash","strokeDashOffset","strokeForeground","strokeOffset","startAngle","endAngle","innerRadius","outerRadius","cornerRadius","padAngle","cornerRadiusTopLeft","cornerRadiusTopRight","cornerRadiusBottomLeft","cornerRadiusBottomRight","interpolate","tension","orient","defined","url","aspect","smooth","path","scaleX","scaleY","x2","y2","size","shape","text","angle","theta","radius","dir","dx","dy","ellipsis","limit","lineBreak","lineHeight","font","fontSize","fontWeight","fontStyle","fontVariant","description","aria","ariaRole","ariaRoleDescription"];function sh(t,e){return JSON.stringify(t,ah,e);}function uh(t){return function t(e){var n,r,i,o=e.marktype,a=e.items;if(a)for(r=0,i=a.length;r<i;++r){n=o?"mark":"group",a[r][n]=e,a[r].zindex&&(a[r][n].zdirty=!0),"group"===(o||n)&&t(a[r]);}o&&oh(e);return e;}("string"==typeof t?JSON.parse(t):t);}function ch(t){arguments.length?this.root=uh(t):(this.root=lh({marktype:"group",name:"root",role:"frame"}),this.root.items=[new cl(this.root)]);}function lh(t,e){var n={bounds:new sl(),clip:!!t.clip,group:e,interactive:!1!==t.interactive,items:[],marktype:t.marktype,name:t.name||void 0,role:t.role||void 0,zindex:t.zindex||0};return null!=t.aria&&(n.aria=t.aria),t.description&&(n.description=t.description),n;}function fh(t,e,n){return !t&&"undefined"!=typeof document&&document.createElement&&(t=document),t?n?t.createElementNS(n,e):t.createElement(e):null;}function hh(t,e){e=e.toLowerCase();for(var n=t.childNodes,r=0,i=n.length;r<i;++r){if(n[r].tagName.toLowerCase()===e)return n[r];}}function dh(t,e,n,r){var i,o=t.childNodes[e];return o&&o.tagName.toLowerCase()===n.toLowerCase()||(i=o||null,o=fh(t.ownerDocument,n,r),t.insertBefore(o,i)),o;}function ph(t,e){for(var n=t.childNodes,r=n.length;r>e;){t.removeChild(n[--r]);}return t;}function mh(t){return "mark-"+t.marktype+(t.role?" role-"+t.role:"")+(t.name?" "+t.name:"");}function gh(t,e){var n=e.getBoundingClientRect();return [t.clientX-n.left-(e.clientLeft||0),t.clientY-n.top-(e.clientTop||0)];}function vh(t,e){this._active=null,this._handlers={},this._loader=t||Object(tt.e)(),this._tooltip=e||yh;}function yh(t,e,n,r){t.element().setAttribute("title",r||"");}function bh(t){this._el=null,this._bgcolor=null,this._loader=new ll(t);}ch.prototype={toJSON:function toJSON(t){return sh(this.root,t||0);},mark:function mark(t,e,n){var r=lh(t,e=e||this.root.items[0]);return e.items[n]=r,r.zindex&&(r.group.zdirty=!0),r;}},vh.prototype={initialize:function initialize(t,e,n){return this._el=t,this._obj=n||null,this.origin(e);},element:function element(){return this._el;},canvas:function canvas(){return this._el&&this._el.firstChild;},origin:function origin(t){return arguments.length?(this._origin=t||[0,0],this):this._origin.slice();},scene:function scene(t){return arguments.length?(this._scene=t,this):this._scene;},on:function on(){},off:function off(){},_handlerIndex:function _handlerIndex(t,e,n){for(var _r45=t?t.length:0;--_r45>=0;){if(t[_r45].type===e&&(!n||t[_r45].handler===n))return _r45;}return -1;},handlers:function handlers(t){var e=this._handlers,n=[];if(t)n.push.apply(n,_toConsumableArray(e[this.eventName(t)]));else for(var _t49 in e){n.push.apply(n,_toConsumableArray(e[_t49]));}return n;},eventName:function eventName(t){var e=t.indexOf(".");return e<0?t:t.slice(0,e);},handleHref:function handleHref(t,e,n){this._loader.sanitize(n,{context:"href"}).then(function(e){var n=new MouseEvent(t.type,t),r=fh(null,"a");for(var _t50 in e){r.setAttribute(_t50,e[_t50]);}r.dispatchEvent(n);}).catch(function(){});},handleTooltip:function handleTooltip(t,e,n){if(e&&null!=e.tooltip){e=function(t,e,n,r){var i,o,a=t&&t.mark;if(a&&(i=nh[a.marktype]).tip){for((o=gh(e,n))[0]-=r[0],o[1]-=r[1];t=t.mark.group;){o[0]-=t.x||0,o[1]-=t.y||0;}t=i.tip(a.items,o);}return t;}(e,t,this.canvas(),this._origin);var _r46=n&&e&&e.tooltip||null;this._tooltip.call(this._obj,this,t,e,_r46);}},getItemBoundingClientRect:function getItemBoundingClientRect(t){var e=this.canvas();if(!e)return;var n=e.getBoundingClientRect(),r=this._origin,i=t.bounds,o=i.width(),a=i.height();var s=i.x1+r[0]+n.left,u=i.y1+r[1]+n.top;for(;t.mark&&(t=t.mark.group);){s+=t.x||0,u+=t.y||0;}return {x:s,y:u,width:o,height:a,left:s,top:u,right:s+o,bottom:u+a};}},bh.prototype={initialize:function initialize(t,e,n,r,i){return this._el=t,this.resize(e,n,r,i);},element:function element(){return this._el;},canvas:function canvas(){return this._el&&this._el.firstChild;},background:function background(t){return 0===arguments.length?this._bgcolor:(this._bgcolor=t,this);},resize:function resize(t,e,n,r){return this._width=t,this._height=e,this._origin=n||[0,0],this._scale=r||1,this;},dirty:function dirty(){},render:function render(t){var e=this;return e._call=function(){e._render(t);},e._call(),e._call=null,e;},_render:function _render(){},renderAsync:function renderAsync(t){var e=this.render(t);return this._ready?this._ready.then(function(){return e;}):Promise.resolve(e);},_load:function _load(t,e){var n=this,r=n._loader[t](e);if(!n._ready){var _t51=n._call;n._ready=n._loader.ready().then(function(e){e&&_t51(),n._ready=null;});}return r;},sanitizeURL:function sanitizeURL(t){return this._load("sanitizeURL",t);},loadImage:function loadImage(t){return this._load("loadImage",t);}};var xh="dragleave",wh="mousedown",kh="mousemove",Eh="mouseout",Ch="click",Ah=["keydown","keypress","keyup","dragenter",xh,"dragover",wh,"mouseup",kh,Eh,"mouseover",Ch,"dblclick","wheel","mousewheel","touchstart","touchmove","touchend"],Oh=kh,_h=Eh,Sh=Ch;function Dh(t,e){vh.call(this,t,e),this._down=null,this._touch=null,this._first=!0,this._events={};}var Fh=function Fh(t){return "touchstart"===t||"touchmove"===t||"touchend"===t?["touchstart","touchmove","touchend"]:[t];};function Th(t,e){Fh(e).forEach(function(e){return function(t,e){var n=t.canvas();n&&!t._events[e]&&(t._events[e]=1,n.addEventListener(e,t[e]?function(n){return t[e](n);}:function(n){return t.fire(e,n);}));}(t,e);});}function Nh(t,e,n){return function(r){var i=this._active,o=this.pickEvent(r);o===i?this.fire(t,r):(i&&i.exit||this.fire(n,r),this._active=o,this.fire(e,r),this.fire(t,r));};}function Ih(t){return function(e){this.fire(t,e),this._active=null;};}Object(Z.z)(Dh,vh,{initialize:function initialize(t,e,n){var _this18=this;return this._canvas=t&&hh(t,"canvas"),[Ch,wh,kh,Eh,xh].forEach(function(t){return Th(_this18,t);}),vh.prototype.initialize.call(this,t,e,n);},canvas:function canvas(){return this._canvas;},context:function context(){return this._canvas.getContext("2d");},events:Ah,DOMMouseScroll:function DOMMouseScroll(t){this.fire("mousewheel",t);},mousemove:Nh(kh,"mouseover",Eh),dragover:Nh("dragover","dragenter",xh),mouseout:Ih(Eh),dragleave:Ih(xh),mousedown:function mousedown(t){this._down=this._active,this.fire(wh,t);},click:function click(t){this._down===this._active&&(this.fire(Ch,t),this._down=null);},touchstart:function touchstart(t){this._touch=this.pickEvent(t.changedTouches[0]),this._first&&(this._active=this._touch,this._first=!1),this.fire("touchstart",t,!0);},touchmove:function touchmove(t){this.fire("touchmove",t,!0);},touchend:function touchend(t){this.fire("touchend",t,!0),this._touch=null;},fire:function fire(t,e,n){var r=n?this._touch:this._active,i=this._handlers[t];if(e.vegaType=t,t===Sh&&r&&r.href?this.handleHref(e,r,r.href):t!==Oh&&t!==_h||this.handleTooltip(e,r,t!==_h),i)for(var _t52=0,_n40=i.length;_t52<_n40;++_t52){i[_t52].handler.call(this._obj,e,r);}},on:function on(t,e){var n=this.eventName(t),r=this._handlers;return this._handlerIndex(r[n],t,e)<0&&(Th(this,t),(r[n]||(r[n]=[])).push({type:t,handler:e})),this;},off:function off(t,e){var n=this.eventName(t),r=this._handlers[n],i=this._handlerIndex(r,t,e);return i>=0&&r.splice(i,1),this;},pickEvent:function pickEvent(t){var e=gh(t,this._canvas),n=this._origin;return this.pick(this._scene,e[0],e[1],e[0]-n[0],e[1]-n[1]);},pick:function pick(t,e,n,r,i){var o=this.context();return nh[t.marktype].pick.call(this,o,t,e,n,r,i);}});var Rh="undefined"!=typeof window&&window.devicePixelRatio||1;function Mh(t){bh.call(this,t),this._options={},this._redraw=!1,this._dirty=new sl(),this._tempb=new sl();}var jh=bh.prototype;function Bh(t,e){vh.call(this,t,e);var n=this;n._hrefHandler=Ph(n,function(t,e){e&&e.href&&n.handleHref(t,e,e.href);}),n._tooltipHandler=Ph(n,function(t,e){n.handleTooltip(t,e,t.type!==_h);});}Object(Z.z)(Mh,bh,{initialize:function initialize(t,e,n,r,i,o){return this._options=o||{},this._canvas=this._options.externalContext?null:ji(1,1,this._options.type),t&&this._canvas&&(ph(t,0).appendChild(this._canvas),this._canvas.setAttribute("class","marks")),jh.initialize.call(this,t,e,n,r,i);},resize:function resize(t,e,n,r){if(jh.resize.call(this,t,e,n,r),this._canvas)!function(t,e,n,r,i,o){var a="undefined"!=typeof HTMLElement&&t instanceof HTMLElement&&null!=t.parentNode,s=t.getContext("2d"),u=a?Rh:i;t.width=e*u,t.height=n*u;for(var _t53 in o){s[_t53]=o[_t53];}a&&1!==u&&(t.style.width=e+"px",t.style.height=n+"px"),s.pixelRatio=u,s.setTransform(u,0,0,u,u*r[0],u*r[1]);}(this._canvas,this._width,this._height,this._origin,this._scale,this._options.context);else {var _t54=this._options.externalContext;_t54||Object(Z.o)("CanvasRenderer is missing a valid canvas or context"),_t54.scale(this._scale,this._scale),_t54.translate(this._origin[0],this._origin[1]);}return this._redraw=!0,this;},canvas:function canvas(){return this._canvas;},context:function context(){return this._options.externalContext||(this._canvas?this._canvas.getContext("2d"):null);},dirty:function dirty(t){var e=this._tempb.clear().union(t.bounds);var n=t.mark.group;for(;n;){e.translate(n.x||0,n.y||0),n=n.mark.group;}this._dirty.union(e);},_render:function _render(t){var e=this.context(),n=this._origin,r=this._width,i=this._height,o=this._dirty,a=function(t,e,n){return new sl().set(0,0,e,n).translate(-t[0],-t[1]);}(n,r,i);e.save();var s=this._redraw||o.empty()?(this._redraw=!1,a.expand(1)):function(t,e,n){return e.expand(1).round(),t.pixelRatio%1&&e.scale(t.pixelRatio).round().scale(1/t.pixelRatio),e.translate(-n[0]%1,-n[1]%1),t.beginPath(),t.rect(e.x1,e.y1,e.width(),e.height()),t.clip(),e;}(e,a.intersect(o),n);return this.clear(-n[0],-n[1],r,i),this.draw(e,t,s),e.restore(),o.clear(),this;},draw:function draw(t,e,n){var r=nh[e.marktype];e.clip&&function(t,e){var n=e.clip;t.save(),Object(Z.E)(n)?(t.beginPath(),n(t),t.clip()):df(t,e.group);}(t,e),r.draw.call(this,t,e,n),e.clip&&t.restore();},clear:function clear(t,e,n,r){var i=this._options,o=this.context();"pdf"===i.type||i.externalContext||o.clearRect(t,e,n,r),null!=this._bgcolor&&(o.fillStyle=this._bgcolor,o.fillRect(t,e,n,r));}});var Ph=function Ph(t,e){return function(n){var r=n.target.__data__;r=Array.isArray(r)?r[0]:r,n.vegaType=n.type,e.call(t._obj,n,r);};};Object(Z.z)(Bh,vh,{initialize:function initialize(t,e,n){var r=this._svg;return r&&(r.removeEventListener(Sh,this._hrefHandler),r.removeEventListener(Oh,this._tooltipHandler),r.removeEventListener(_h,this._tooltipHandler)),this._svg=r=t&&hh(t,"svg"),r&&(r.addEventListener(Sh,this._hrefHandler),r.addEventListener(Oh,this._tooltipHandler),r.addEventListener(_h,this._tooltipHandler)),vh.prototype.initialize.call(this,t,e,n);},canvas:function canvas(){return this._svg;},on:function on(t,e){var n=this.eventName(t),r=this._handlers;if(this._handlerIndex(r[n],t,e)<0){var _i27={type:t,handler:e,listener:Ph(this,e)};(r[n]||(r[n]=[])).push(_i27),this._svg&&this._svg.addEventListener(n,_i27.listener);}return this;},off:function off(t,e){var n=this.eventName(t),r=this._handlers[n],i=this._handlerIndex(r,t,e);return i>=0&&(this._svg&&this._svg.removeEventListener(n,r[i].listener),r.splice(i,1)),this;}});var Lh="aria-hidden",zh="aria-label",Uh="role",Wh="aria-roledescription",Vh="graphics-object",qh="graphics-symbol",$h=function $h(t,e,n){var _ref6;return _ref6={},_defineProperty(_ref6,Uh,t),_defineProperty(_ref6,Wh,e),_defineProperty(_ref6,zh,n||void 0),_ref6;},Hh=Object(Z.Fa)(["axis-domain","axis-grid","axis-label","axis-tick","axis-title","legend-band","legend-entry","legend-gradient","legend-label","legend-title","legend-symbol","title"]),Gh={axis:{desc:"axis",caption:function caption(t){var e=t.datum,n=t.orient,r=e.title?Qh(t):null,i=t.context,o=i.scales[e.scale].value,a=i.dataflow.locale(),s=o.type;return "".concat("left"===n||"right"===n?"Y":"X","-axis")+(r?" titled '".concat(r,"'"):"")+" for a ".concat(Ou(s)?"discrete":s," scale")+" with ".concat(uc(a,o,t));}},legend:{desc:"legend",caption:function caption(t){var e=t.datum,n=e.title?Qh(t):null,r="".concat(e.type||""," legend").trim(),i=e.scales,o=Object.keys(i),a=t.context,s=a.scales[i[o[0]]].value,u=a.dataflow.locale();return function(t){return t.length?t[0].toUpperCase()+t.slice(1):t;}(r)+(n?" titled '".concat(n,"'"):"")+" for ".concat(function(t){return (t=t.map(function(t){return t+("fill"===t||"stroke"===t?" color":"");})).length<2?t[0]:t.slice(0,-1).join(", ")+" and "+Object(Z.W)(t);}(o))+" with ".concat(uc(u,s,t));}},"title-text":{desc:"title",caption:function caption(t){return "Title text '".concat(Jh(t),"'");}},"title-subtitle":{desc:"subtitle",caption:function caption(t){return "Subtitle text '".concat(Jh(t),"'");}}},Kh={ariaRole:Uh,ariaRoleDescription:Wh,description:zh};function Xh(t,e){var n=!1===e.aria;if(t(Lh,n||void 0),n||null==e.description)for(var _e53 in Kh){t(Kh[_e53],void 0);}else {var _n41=e.mark.marktype;t(zh,e.description),t(Uh,e.ariaRole||("group"===_n41?Vh:qh)),t(Wh,e.ariaRoleDescription||"".concat(_n41," mark"));}}function Yh(t){return !1===t.aria?_defineProperty({},Lh,!0):Hh[t.role]?null:Gh[t.role]?function(t,e){try{var _n42=t.items[0],_r47=e.caption||function(){return "";};return $h(e.role||qh,e.desc,_n42.description||_r47(_n42));}catch(t){return null;}}(t,Gh[t.role]):function(t){var e=t.marktype,n="group"===e||"text"===e||t.items.some(function(t){return null!=t.description&&!1!==t.aria;});return $h(n?Vh:qh,"".concat(e," mark container"),t.description);}(t);}function Jh(t){return Object(Z.i)(t.text).join(" ");}function Qh(t){try{return Object(Z.i)(Object(Z.W)(t.items).items[0].text).join(" ");}catch(t){return null;}}var Zh=function Zh(t){return (t+"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");},td=function td(t){return Zh(t).replace(/"/g,"&quot;").replace(/\t/g,"&#x9;").replace(/\n/g,"&#xA;").replace(/\r/g,"&#xD;");};function ed(){var t="",e="",n="";var r=[],i=function i(){return e=n="";},o=function o(t,n){return null!=n&&(e+=" ".concat(t,"=\"").concat(td(n),"\"")),a;},a={open:function open(s){(function(o){e&&(t+="".concat(e,">").concat(n),i()),r.push(o);})(s),e="<"+s;for(var _len2=arguments.length,u=new Array(_len2>1?_len2-1:0),_key2=1;_key2<_len2;_key2++){u[_key2-1]=arguments[_key2];}for(var _i28=0,_u11=u;_i28<_u11.length;_i28++){var _t55=_u11[_i28];for(var _e54 in _t55){o(_e54,_t55[_e54]);}}return a;},close:function close(){var o=r.pop();return t+=e?e+(n?">".concat(n,"</").concat(o,">"):"/>"):"</".concat(o,">"),i(),a;},attr:o,text:function text(t){return n+=Zh(t),a;},toString:function toString(){return t;}};return a;}var nd=function nd(t){return function t(e,n){e.open(n.tagName);if(n.hasAttributes()){var _t56=n.attributes,_r48=_t56.length;for(var _n43=0;_n43<_r48;++_n43){e.attr(_t56[_n43].name,_t56[_n43].value);}}if(n.hasChildNodes()){var _r49=n.childNodes,_i29=_r49.length;for(var _n44=0;_n44<_i29;_n44++){var _i30=_r49[_n44];3===_i30.nodeType?e.text(_i30.nodeValue):t(e,_i30);}}return e.close();}(ed(),t)+"";};var rd={fill:"fill",fillOpacity:"fill-opacity",stroke:"stroke",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",strokeCap:"stroke-linecap",strokeJoin:"stroke-linejoin",strokeDash:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeMiterLimit:"stroke-miterlimit",opacity:"opacity",blend:"mix-blend-mode"},id={fill:"none","stroke-miterlimit":10},od=wf.xmlns;function ad(t){bh.call(this,t),this._dirtyID=0,this._dirty=[],this._svg=null,this._root=null,this._defs=null;}var sd=bh.prototype;function ud(t,e){for(;t&&t.dirty!==e;t=t.mark.group){if(t.dirty=e,!t.mark||t.mark.dirty===e)return;t.mark.dirty=e;}}function cd(t,e,n){var r,i,o;if("radial"===e.gradient){var _r50=dh(t,n++,"pattern",od);vd(_r50,{id:lc+e.id,viewBox:"0,0,1,1",width:"100%",height:"100%",preserveAspectRatio:"xMidYMid slice"}),vd(_r50=dh(_r50,0,"rect",od),{width:1,height:1,fill:"url(".concat(bd(),"#").concat(e.id,")")}),vd(t=dh(t,n++,"radialGradient",od),{id:e.id,fx:e.x1,fy:e.y1,fr:e.r1,cx:e.x2,cy:e.y2,r:e.r2});}else vd(t=dh(t,n++,"linearGradient",od),{id:e.id,x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2});for(r=0,i=e.stops.length;r<i;++r){(o=dh(t,r,"stop",od)).setAttribute("offset",e.stops[r].offset),o.setAttribute("stop-color",e.stops[r].color);}return ph(t,r),n;}function ld(t,e,n){return (t=dh(t,n,"clipPath",od)).setAttribute("id",e.id),e.path?(dh(t,0,"path",od)).setAttribute("d",e.path):vd(dh(t,0,"rect",od),{x:0,y:0,width:e.width,height:e.height}),ph(t,1),n+1;}function fd(t,e,n,r,i){var o,a=t._svg;if(!a&&(a=fh(o=e.ownerDocument,r,od),t._svg=a,t.mark&&(a.__data__=t,a.__values__={fill:"default"},"g"===r))){var _e55=fh(o,"path",od);a.appendChild(_e55),_e55.__data__=t;var _n45=fh(o,"g",od);a.appendChild(_n45),_n45.__data__=t;var _r51=fh(o,"path",od);a.appendChild(_r51),_r51.__data__=t,_r51.__values__={fill:"default"};}return (a.ownerSVGElement!==i||function(t,e){return t.parentNode&&t.parentNode.childNodes.length>1&&t.previousSibling!=e;}(a,n))&&e.insertBefore(a,n?n.nextSibling:e.firstChild),a;}Object(Z.z)(ad,bh,{initialize:function initialize(t,e,n,r,i){return this._defs={},this._clearDefs(),t&&(this._svg=dh(t,0,"svg",od),this._svg.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns",od),this._svg.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink",wf["xmlns:xlink"]),this._svg.setAttribute("version",wf.version),this._svg.setAttribute("class","marks"),ph(t,1),this._root=dh(this._svg,0,"g",od),vd(this._root,id),ph(this._svg,1)),this.background(this._bgcolor),sd.initialize.call(this,t,e,n,r,i);},background:function background(t){return arguments.length&&this._svg&&this._svg.style.setProperty("background-color",t),sd.background.apply(this,arguments);},resize:function resize(t,e,n,r){return sd.resize.call(this,t,e,n,r),this._svg&&(vd(this._svg,{width:this._width*this._scale,height:this._height*this._scale,viewBox:"0 0 ".concat(this._width," ").concat(this._height)}),this._root.setAttribute("transform","translate(".concat(this._origin,")"))),this._dirty=[],this;},canvas:function canvas(){return this._svg;},svg:function svg(){var t=this._svg,e=this._bgcolor;if(!t)return null;var n;e&&(t.removeAttribute("style"),vd(n=dh(t,0,"rect",od),{width:this._width,height:this._height,fill:e}));var r=nd(t);return e&&(t.removeChild(n),this._svg.style.setProperty("background-color",e)),r;},_render:function _render(t){return this._dirtyCheck()&&(this._dirtyAll&&this._clearDefs(),this.mark(this._root,t),ph(this._root,1)),this.defs(),this._dirty=[],++this._dirtyID,this;},dirty:function dirty(t){t.dirty!==this._dirtyID&&(t.dirty=this._dirtyID,this._dirty.push(t));},isDirty:function isDirty(t){return this._dirtyAll||!t._svg||t.dirty===this._dirtyID;},_dirtyCheck:function _dirtyCheck(){this._dirtyAll=!0;var t=this._dirty;if(!t.length||!this._dirtyID)return !0;var e=++this._dirtyID;var n,r,i,o,a,s,u;for(a=0,s=t.length;a<s;++a){(r=(n=t[a]).mark).marktype!==i&&(i=r.marktype,o=nh[i]),r.zdirty&&r.dirty!==e&&(this._dirtyAll=!1,ud(n,e),r.items.forEach(function(t){t.dirty=e;})),r.zdirty||(n.exit?(o.nested&&r.items.length?(u=r.items[0])._svg&&this._update(o,u._svg,u):n._svg&&(u=n._svg.parentNode)&&u.removeChild(n._svg),n._svg=null):(n=o.nested?r.items[0]:n)._update!==e&&(n._svg&&n._svg.ownerSVGElement?this._update(o,n._svg,n):(this._dirtyAll=!1,ud(n,e)),n._update=e));}return !this._dirtyAll;},mark:function mark(t,e,n){var _this19=this;if(!this.isDirty(e))return e._svg;var r=this._svg,i=nh[e.marktype],o=!1===e.interactive?"none":null,a="g"===i.tag;var s=null,u=0;var c=fd(e,t,n,"g",r);c.setAttribute("class",mh(e));var l=Yh(e);for(var _t57 in l){yd(c,_t57,l[_t57]);}a||yd(c,"pointer-events",o),yd(c,"clip-path",e.clip?al(this,e,e.group):null);var f=function f(t){var e=_this19.isDirty(t),n=fd(t,c,s,i.tag,r);e&&(_this19._update(i,n,t),a&&function(t,e,n){e=e.lastChild.previousSibling;var r,i=0;Ql(n,function(n){r=t.mark(e,n,r),++i;}),ph(e,1+i);}(_this19,n,t)),s=n,++u;};return i.nested?e.items.length&&f(e.items[0]):Ql(e,f),ph(c,u),c;},_update:function _update(t,e,n){hd=e,dd=e.__values__,Xh(md,n),t.attr(md,n,this);var r=pd[t.type];r&&r.call(this,t,e,n),hd&&this.style(hd,n);},style:function style(t,e){if(null!=e)for(var _n46 in rd){var _r52="font"===_n46?Xf(e):e[_n46];if(_r52===dd[_n46])continue;var _i31=rd[_n46];null==_r52?t.removeAttribute(_i31):(fc(_r52)&&(_r52=hc(_r52,this._defs.gradient,bd())),t.setAttribute(_i31,_r52+"")),dd[_n46]=_r52;}},defs:function defs(){var t=this._svg,e=this._defs;var n=e.el,r=0;for(var _i32 in e.gradient){n||(e.el=n=dh(t,1,"defs",od)),r=cd(n,e.gradient[_i32],r);}for(var _i33 in e.clipping){n||(e.el=n=dh(t,1,"defs",od)),r=ld(n,e.clipping[_i33],r);}n&&(0===r?(t.removeChild(n),e.el=null):ph(n,r));},_clearDefs:function _clearDefs(){var t=this._defs;t.gradient={},t.clipping={};}});var hd=null,dd=null;var pd={group:function group(t,e,n){var r=hd=e.childNodes[2];dd=r.__values__,t.foreground(md,n,this),dd=e.__values__,hd=e.childNodes[1],t.content(md,n,this);var i=hd=e.childNodes[0];t.background(md,n,this);var o=!1===n.mark.interactive?"none":null;if(o!==dd.events&&(yd(r,"pointer-events",o),yd(i,"pointer-events",o),dd.events=o),n.strokeForeground&&n.stroke){var _t58=n.fill;yd(r,"display",null),this.style(i,n),yd(i,"stroke",null),_t58&&(n.fill=null),dd=r.__values__,this.style(r,n),_t58&&(n.fill=_t58),hd=null;}else yd(r,"display","none");},image:function image(t,e,n){!1===n.smooth?(gd(e,"image-rendering","optimizeSpeed"),gd(e,"image-rendering","pixelated")):gd(e,"image-rendering",null);},text:function text(t,e,n){var r=Hf(n);var i,o,a,s;Object(Z.B)(r)?(i=(o=r.map(function(t){return Kf(n,t);})).join("\n"))!==dd.text&&(ph(e,0),a=e.ownerDocument,s=$f(n),o.forEach(function(t,r){var i=fh(a,"tspan",od);i.__data__=n,i.textContent=t,r&&(i.setAttribute("x",0),i.setAttribute("dy",s)),e.appendChild(i);}),dd.text=i):(o=Kf(n,r))!==dd.text&&(e.textContent=o,dd.text=o),yd(e,"font-family",Xf(n)),yd(e,"font-size",qf(n)+"px"),yd(e,"font-style",n.fontStyle),yd(e,"font-variant",n.fontVariant),yd(e,"font-weight",n.fontWeight);}};function md(t,e,n){e!==dd[t]&&(n?function(t,e,n,r){null!=n?t.setAttributeNS(r,e,n):t.removeAttributeNS(r,e);}(hd,t,e,n):yd(hd,t,e),dd[t]=e);}function gd(t,e,n){n!==dd[e]&&(null==n?t.style.removeProperty(e):t.style.setProperty(e,n+""),dd[e]=n);}function vd(t,e){for(var _n47 in e){yd(t,_n47,e[_n47]);}}function yd(t,e,n){null!=n?t.setAttribute(e,n):t.removeAttribute(e);}function bd(){var t;return "undefined"==typeof window?"":(t=window.location).hash?t.href.slice(0,-t.hash.length):t.href;}function xd(t){bh.call(this,t),this._text=null,this._defs={gradient:{},clipping:{}};}Object(Z.z)(xd,bh,{svg:function svg(){return this._text;},_render:function _render(t){var e=ed();e.open("svg",Object(Z.p)({},wf,{class:"marks",width:this._width*this._scale,height:this._height*this._scale,viewBox:"0 0 ".concat(this._width," ").concat(this._height)}));var n=this._bgcolor;return n&&"transparent"!==n&&"none"!==n&&e.open("rect",{width:this._width,height:this._height,fill:n}).close(),e.open("g",id,{transform:"translate("+this._origin+")"}),this.mark(e,t),e.close(),this.defs(e),this._text=e.close()+"",this;},mark:function mark(t,e){var _this20=this;var n=nh[e.marktype],r=n.tag,i=[Xh,n.attr];t.open("g",{class:mh(e),"clip-path":e.clip?al(this,e,e.group):null},Yh(e),{"pointer-events":"g"!==r&&!1===e.interactive?"none":null});var o=function o(_o15){var a=_this20.href(_o15);if(a&&t.open("a",a),t.open(r,_this20.attr(e,_o15,i,"g"!==r?r:null)),"text"===r){var _e56=Hf(_o15);if(Object(Z.B)(_e56)){var _n48={x:0,dy:$f(_o15)};for(var _r53=0;_r53<_e56.length;++_r53){t.open("tspan",_r53?_n48:null).text(Kf(_o15,_e56[_r53])).close();}}else t.text(Kf(_o15,_e56));}else if("g"===r){var _r54=_o15.strokeForeground,_i34=_o15.fill,_a23=_o15.stroke;_r54&&_a23&&(_o15.stroke=null),t.open("path",_this20.attr(e,_o15,n.background,"bgrect")).close(),t.open("g",_this20.attr(e,_o15,n.content)),Ql(_o15,function(e){return _this20.mark(t,e);}),t.close(),_r54&&_a23?(_i34&&(_o15.fill=null),_o15.stroke=_a23,t.open("path",_this20.attr(e,_o15,n.foreground,"bgrect")).close(),_i34&&(_o15.fill=_i34)):t.open("path",_this20.attr(e,_o15,n.foreground,"bgfore")).close();}t.close(),a&&t.close();};return n.nested?e.items&&e.items.length&&o(e.items[0]):Ql(e,o),t.close();},href:function href(t){var _this21=this;var e=t.href;var n;if(e){if(n=this._hrefs&&this._hrefs[e])return n;this.sanitizeURL(e).then(function(t){t["xlink:href"]=t.href,t.href=null,(_this21._hrefs||(_this21._hrefs={}))[e]=t;});}return null;},attr:function attr(t,e,n,r){var _this22=this;var i={},o=function o(t,e,n,r){i[r||t]=e;};return Array.isArray(n)?n.forEach(function(t){return t(o,e,_this22);}):n(o,e,this),r&&function(t,e,n,r,i){if(null==e)return t;"bgrect"===r&&!1===n.interactive&&(t["pointer-events"]="none");if("bgfore"===r&&(!1===n.interactive&&(t["pointer-events"]="none"),t.display="none",null!==e.fill))return t;"image"===r&&!1===e.smooth&&(t.style="image-rendering: optimizeSpeed; image-rendering: pixelated;");"text"===r&&(t["font-family"]=Xf(e),t["font-size"]=qf(e)+"px",t["font-style"]=e.fontStyle,t["font-variant"]=e.fontVariant,t["font-weight"]=e.fontWeight);for(var _n49 in rd){var _r55=e[_n49];var _o16=rd[_n49];("transparent"!==_r55||"fill"!==_o16&&"stroke"!==_o16)&&null!=_r55&&(fc(_r55)&&(_r55=hc(_r55,i.gradient,"")),t[_o16]=_r55);}}(i,e,t,r,this._defs),i;},defs:function defs(t){var e=this._defs.gradient,n=this._defs.clipping;if(0!==Object.keys(e).length+Object.keys(n).length){t.open("defs");for(var _n50 in e){var _r56=e[_n50],_i35=_r56.stops;"radial"===_r56.gradient?(t.open("pattern",{id:lc+_n50,viewBox:"0,0,1,1",width:"100%",height:"100%",preserveAspectRatio:"xMidYMid slice"}),t.open("rect",{width:"1",height:"1",fill:"url(#"+_n50+")"}).close(),t.close(),t.open("radialGradient",{id:_n50,fx:_r56.x1,fy:_r56.y1,fr:_r56.r1,cx:_r56.x2,cy:_r56.y2,r:_r56.r2})):t.open("linearGradient",{id:_n50,x1:_r56.x1,x2:_r56.x2,y1:_r56.y1,y2:_r56.y2});for(var _e57=0;_e57<_i35.length;++_e57){t.open("stop",{offset:_i35[_e57].offset,"stop-color":_i35[_e57].color}).close();}t.close();}for(var _e58 in n){var _r57=n[_e58];t.open("clipPath",{id:_e58}),_r57.path?t.open("path",{d:_r57.path}).close():t.open("rect",{x:0,y:0,width:_r57.width,height:_r57.height}).close(),t.close();}t.close();}}});var wd={Canvas:"canvas",PNG:"png",SVG:"svg",None:"none"},kd={};function Ed(t,e){return t=String(t||"").toLowerCase(),arguments.length>1?(kd[t]=e,this):kd[t];}function Cd(t,e,n){var r=[],i=new sl().union(e),o=t.marktype;return o?Ad(t,i,n,r):"group"===o?Od(t,i,n,r):Object(Z.o)("Intersect scene must be mark node or group item.");}function Ad(t,e,n,r){if(function(t,e,n){return t.bounds&&e.intersects(t.bounds)&&("group"===t.marktype||!1!==t.interactive&&(!n||n(t)));}(t,e,n)){var _i36=t.items,_o17=t.marktype,_a24=_i36.length;var _s18=0;if("group"===_o17)for(;_s18<_a24;++_s18){Od(_i36[_s18],e,n,r);}else for(var _t59=nh[_o17].isect;_s18<_a24;++_s18){var _n51=_i36[_s18];_d(_n51,e,_t59)&&r.push(_n51);}}return r;}function Od(t,e,n,r){n&&n(t.mark)&&_d(t,e,nh.group.isect)&&r.push(t);var i=t.items,o=i&&i.length;if(o){var _a25=t.x||0,_s19=t.y||0;e.translate(-_a25,-_s19);for(var _t60=0;_t60<o;++_t60){Ad(i[_t60],e,n,r);}e.translate(_a25,_s19);}return r;}function _d(t,e,n){var r=t.bounds;return e.encloses(r)||e.intersects(r)&&n(t,e);}kd.canvas=kd.png={renderer:Mh,headless:Mh,handler:Dh},kd.svg={renderer:ad,headless:xd,handler:Bh},kd.none={};var Sd=new sl();function Dd(t){var e=t.clip;if(Object(Z.E)(e))e(Tl(Sd.clear()));else {if(!e)return;Sd.set(0,0,t.group.width,t.group.height);}t.bounds.intersect(Sd);}var Fd=1e-9;function Td(t,e,n){return t===e||("path"===n?Nd(t,e):t instanceof Date&&e instanceof Date?+t==+e:Object(Z.G)(t)&&Object(Z.G)(e)?Math.abs(t-e)<=Fd:t&&e&&(Object(Z.H)(t)||Object(Z.H)(e))?function(t,e){var n,r,i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return !1;for(i.sort(),o.sort(),r=i.length-1;r>=0;r--){if(i[r]!=o[r])return !1;}for(r=i.length-1;r>=0;r--){if(n=i[r],!Td(t[n],e[n],n))return !1;}return _typeof$1(t)==_typeof$1(e);}(t,e):t==e);}function Nd(t,e){return Td(bc(t),bc(e));}function Id(){ol(),cc=0;}var Rd="top",Md="left",jd="right",Bd="bottom",Pd="top-left",Ld="top-right",zd="bottom-left",Ud="bottom-right",Wd="start",Vd="middle",qd="end",$d="x",Hd="y",Gd="group",Kd="axis",Xd="title",Yd="frame",Jd="scope",Qd="legend",Zd="row-header",tp="row-footer",ep="row-title",np="column-header",rp="column-footer",ip="column-title",op="padding",ap="symbol",sp="fit",up="fit-x",cp="fit-y",lp="pad",fp="none",hp="all",dp="each",pp="flush",mp="column",gp="row";function vp(t){zt.call(this,null,t);}function yp(t,e,n){return e(t.bounds.clear(),t,n);}Object(Z.z)(vp,zt,{transform:function transform(t,e){var n=e.dataflow,r=t.mark,i=r.marktype,o=nh[i],a=o.bound;var s,u=r.bounds;if(o.nested)r.items.length&&n.dirty(r.items[0]),u=yp(r,a),r.items.forEach(function(t){t.bounds.clear().union(u);});else if(i===Gd||t.modified())switch(e.visit(e.MOD,function(t){return n.dirty(t);}),u.clear(),r.items.forEach(function(t){return u.union(yp(t,a));}),r.role){case Kd:case Qd:case Xd:e.reflow();}else s=e.changed(e.REM),e.visit(e.ADD,function(t){u.union(yp(t,a));}),e.visit(e.MOD,function(t){s=s||u.alignsWith(t.bounds),n.dirty(t),u.union(yp(t,a));}),s&&(u.clear(),r.items.forEach(function(t){return u.union(t.bounds);}));return Dd(r),e.modifies("bounds");}});var bp=":vega_identifier:";function xp(t){zt.call(this,0,t);}function wp(t){zt.call(this,null,t);}function kp(t){zt.call(this,null,t);}xp.Definition={type:"Identifier",metadata:{modifies:!0},params:[{name:"as",type:"string",required:!0}]},Object(Z.z)(xp,zt,{transform:function transform(t,e){var n=function(t){return t._signals[bp]||(t._signals[bp]=t.add(0));}(e.dataflow),r=t.as;var i=n.value;return e.visit(e.ADD,function(t){return t[r]=t[r]||++i;}),n.set(this.value=i),e;}}),Object(Z.z)(wp,zt,{transform:function transform(t,e){var n=this.value;n||((n=e.dataflow.scenegraph().mark(t.markdef,function(t){var e=t.groups,n=t.parent;return e&&1===e.size?e.get(Object.keys(e.object)[0]):e&&n?e.lookup(n):null;}(t),t.index)).group.context=t.context,t.context.group||(t.context.group=n.group),n.source=this.source,n.clip=t.clip,n.interactive=t.interactive,this.value=n);var r=n.marktype===Gd?cl:ul;return e.visit(e.ADD,function(t){return r.call(t,n);}),(t.modified("clip")||t.modified("interactive"))&&(n.clip=t.clip,n.interactive=!!t.interactive,n.zdirty=!0,e.reflow()),n.items=e.source,e;}});var Ep={parity:function parity(t){return t.filter(function(t,e){return e%2?t.opacity=0:1;});},greedy:function greedy(t,e){var n;return t.filter(function(t,r){return r&&Cp(n.bounds,t.bounds,e)?t.opacity=0:(n=t,1);});}},Cp=function Cp(t,e,n){return n>Math.max(e.x1-t.x2,t.x1-e.x2,e.y1-t.y2,t.y1-e.y2);},Ap=function Ap(t,e){for(var n,r=1,i=t.length,o=t[0].bounds;r<i;o=n,++r){if(Cp(o,n=t[r].bounds,e))return !0;}},Op=function Op(t){var e=t.bounds;return e.width()>1&&e.height()>1;},_p=function _p(t){return t.forEach(function(t){return t.opacity=1;}),t;},Sp=function Sp(t,e){return t.reflow(e.modified()).modifies("opacity");};function Dp(t){zt.call(this,null,t);}Object(Z.z)(kp,zt,{transform:function transform(t,e){var n=Ep[t.method]||Ep.parity,r=t.separation||0;var i,o,a=e.materialize(e.SOURCE).source;if(!a||!a.length)return;if(!t.method)return t.modified("method")&&(_p(a),e=Sp(e,t)),e;if(!(a=a.filter(Op)).length)return;if(t.sort&&(a=a.slice().sort(t.sort)),i=_p(a),e=Sp(e,t),i.length>=3&&Ap(i,r)){do{i=n(i,r);}while(i.length>=3&&Ap(i,r));i.length<3&&!Object(Z.W)(a).opacity&&(i.length>1&&(Object(Z.W)(i).opacity=0),Object(Z.W)(a).opacity=1);}t.boundScale&&t.boundTolerance>=0&&(o=function(t,e,n){var r=t.range(),i=new sl();return e===Rd||e===Bd?i.set(r[0],-1/0,r[1],1/0):i.set(-1/0,r[0],1/0,r[1]),i.expand(n||1),function(t){return i.encloses(t.bounds);};}(t.boundScale,t.boundOrient,+t.boundTolerance),a.forEach(function(t){o(t)||(t.opacity=0);}));var s=i[0].mark.bounds.clear();return a.forEach(function(t){t.opacity&&s.union(t.bounds);}),e;}}),Object(Z.z)(Dp,zt,{transform:function transform(t,e){var n=e.dataflow;if(e.visit(e.ALL,function(t){return n.dirty(t);}),e.fields&&e.fields.zindex){var _t61=e.source&&e.source[0];_t61&&(_t61.mark.zdirty=!0);}}});var Fp=new sl();function Tp(t,e,n){return t[e]===n?0:(t[e]=n,1);}function Np(t){var e=t.items[0].orient;return e===Md||e===jd;}function Ip(t,e,n,r){var i,o,a=e.items[0],s=a.datum,u=null!=a.translate?a.translate:.5,c=a.orient,l=function(t){var e=+t.grid;return [t.ticks?e++:-1,t.labels?e++:-1,e+ +t.domain];}(s),f=a.range,h=a.offset,d=a.position,p=a.minExtent,m=a.maxExtent,g=s.title&&a.items[l[2]].items[0],v=a.titlePadding,y=a.bounds,b=g&&Gf(g),x=0,w=0;switch(Fp.clear().union(y),y.clear(),(i=l[0])>-1&&y.union(a.items[i].bounds),(i=l[1])>-1&&y.union(a.items[i].bounds),c){case Rd:x=d||0,w=-h,o=Math.max(p,Math.min(m,-y.y1)),y.add(0,-o).add(f,0),g&&Rp(t,g,o,v,b,0,-1,y);break;case Md:x=-h,w=d||0,o=Math.max(p,Math.min(m,-y.x1)),y.add(-o,0).add(0,f),g&&Rp(t,g,o,v,b,1,-1,y);break;case jd:x=n+h,w=d||0,o=Math.max(p,Math.min(m,y.x2)),y.add(0,0).add(o,f),g&&Rp(t,g,o,v,b,1,1,y);break;case Bd:x=d||0,w=r+h,o=Math.max(p,Math.min(m,y.y2)),y.add(0,0).add(f,o),g&&Rp(t,g,o,v,0,0,1,y);break;default:x=a.x,w=a.y;}return dl(y.translate(x,w),a),Tp(a,"x",x+u)|Tp(a,"y",w+u)&&(a.bounds=Fp,t.dirty(a),a.bounds=y,t.dirty(a)),a.mark.bounds.clear().union(y);}function Rp(t,e,n,r,i,o,a,s){var u=e.bounds;if(e.auto){var _s20=a*(n+i+r);var _c6=0,_l4=0;t.dirty(e),o?_c6=(e.x||0)-(e.x=_s20):_l4=(e.y||0)-(e.y=_s20),e.mark.bounds.clear().union(u.translate(-_c6,-_l4)),t.dirty(e);}s.union(u);}var Mp=function Mp(t,e){return Math.floor(Math.min(t,e));},jp=function jp(t,e){return Math.ceil(Math.max(t,e));};function Bp(t){return new sl().set(0,0,t.width||0,t.height||0);}function Pp(t){var e=t.bounds.clone();return e.empty()?e.set(0,0,0,0):e.translate(-(t.x||0),-(t.y||0));}function Lp(t,e,n){var r=Object(Z.H)(t)?t[e]:t;return null!=r?r:void 0!==n?n:0;}function zp(t){return t<0?Math.ceil(-t):0;}function Up(t,e,n){var r,i,o,a,s,u,c,l,f,h,d,p=!n.nodirty,m=n.bounds===pp?Bp:Pp,g=Fp.set(0,0,0,0),v=Lp(n.align,mp),y=Lp(n.align,gp),b=Lp(n.padding,mp),x=Lp(n.padding,gp),w=n.columns||e.length,k=w<=0?1:Math.ceil(e.length/w),E=e.length,C=Array(E),A=Array(w),O=0,_=Array(E),S=Array(k),D=0,F=Array(E),T=Array(E),N=Array(E);for(i=0;i<w;++i){A[i]=0;}for(i=0;i<k;++i){S[i]=0;}for(i=0;i<E;++i){u=e[i],s=N[i]=m(u),u.x=u.x||0,F[i]=0,u.y=u.y||0,T[i]=0,o=i%w,a=~~(i/w),O=Math.max(O,c=Math.ceil(s.x2)),D=Math.max(D,l=Math.ceil(s.y2)),A[o]=Math.max(A[o],c),S[a]=Math.max(S[a],l),C[i]=b+zp(s.x1),_[i]=x+zp(s.y1),p&&t.dirty(e[i]);}for(i=0;i<E;++i){i%w==0&&(C[i]=0),i<w&&(_[i]=0);}if(v===dp)for(o=1;o<w;++o){for(d=0,i=o;i<E;i+=w){d<C[i]&&(d=C[i]);}for(i=o;i<E;i+=w){C[i]=d+A[o-1];}}else if(v===hp){for(d=0,i=0;i<E;++i){i%w&&d<C[i]&&(d=C[i]);}for(i=0;i<E;++i){i%w&&(C[i]=d+O);}}else for(v=!1,o=1;o<w;++o){for(i=o;i<E;i+=w){C[i]+=A[o-1];}}if(y===dp)for(a=1;a<k;++a){for(d=0,r=(i=a*w)+w;i<r;++i){d<_[i]&&(d=_[i]);}for(i=a*w;i<r;++i){_[i]=d+S[a-1];}}else if(y===hp){for(d=0,i=w;i<E;++i){d<_[i]&&(d=_[i]);}for(i=w;i<E;++i){_[i]=d+D;}}else for(y=!1,a=1;a<k;++a){for(r=(i=a*w)+w;i<r;++i){_[i]+=S[a-1];}}for(f=0,i=0;i<E;++i){f=C[i]+(i%w?f:0),F[i]+=f-e[i].x;}for(o=0;o<w;++o){for(h=0,i=o;i<E;i+=w){h+=_[i],T[i]+=h-e[i].y;}}if(v&&Lp(n.center,mp)&&k>1)for(i=0;i<E;++i){(f=(s=v===hp?O:A[i%w])-N[i].x2-e[i].x-F[i])>0&&(F[i]+=f/2);}if(y&&Lp(n.center,gp)&&1!==w)for(i=0;i<E;++i){(h=(s=y===hp?D:S[~~(i/w)])-N[i].y2-e[i].y-T[i])>0&&(T[i]+=h/2);}for(i=0;i<E;++i){g.union(N[i].translate(F[i],T[i]));}switch(f=Lp(n.anchor,$d),h=Lp(n.anchor,Hd),Lp(n.anchor,mp)){case qd:f-=g.width();break;case Vd:f-=g.width()/2;}switch(Lp(n.anchor,gp)){case qd:h-=g.height();break;case Vd:h-=g.height()/2;}for(f=Math.round(f),h=Math.round(h),g.clear(),i=0;i<E;++i){e[i].mark.bounds.clear();}for(i=0;i<E;++i){(u=e[i]).x+=F[i]+=f,u.y+=T[i]+=h,g.union(u.mark.bounds.union(u.bounds.translate(F[i],T[i]))),p&&t.dirty(u);}return g;}function Wp(t,e,n){var r,i,o,a,s,u,c,l=function(t){var _a$rowheaders,_a$rowfooters,_a$colheaders,_a$colfooters,_a$marks;var e,n,r=t.items,i=r.length,o=0;var a={marks:[],rowheaders:[],rowfooters:[],colheaders:[],colfooters:[],rowtitle:null,coltitle:null};for(;o<i;++o){if(n=(e=r[o]).items,e.marktype===Gd)switch(e.role){case Kd:case Qd:case Xd:break;case Zd:(_a$rowheaders=a.rowheaders).push.apply(_a$rowheaders,_toConsumableArray(n));break;case tp:(_a$rowfooters=a.rowfooters).push.apply(_a$rowfooters,_toConsumableArray(n));break;case np:(_a$colheaders=a.colheaders).push.apply(_a$colheaders,_toConsumableArray(n));break;case rp:(_a$colfooters=a.colfooters).push.apply(_a$colfooters,_toConsumableArray(n));break;case ep:a.rowtitle=n[0];break;case ip:a.coltitle=n[0];break;default:(_a$marks=a.marks).push.apply(_a$marks,_toConsumableArray(n));}}return a;}(e),f=l.marks,h=n.bounds===pp?Vp:qp,d=n.offset,p=n.columns||f.length,m=p<=0?1:Math.ceil(f.length/p),g=m*p;var v=Up(t,f,n);v.empty()&&v.set(0,0,0,0),l.rowheaders&&(u=Lp(n.headerBand,gp,null),r=$p(t,l.rowheaders,f,p,m,-Lp(d,"rowHeader"),Mp,0,h,"x1",0,p,1,u)),l.colheaders&&(u=Lp(n.headerBand,mp,null),i=$p(t,l.colheaders,f,p,p,-Lp(d,"columnHeader"),Mp,1,h,"y1",0,1,p,u)),l.rowfooters&&(u=Lp(n.footerBand,gp,null),o=$p(t,l.rowfooters,f,p,m,Lp(d,"rowFooter"),jp,0,h,"x2",p-1,p,1,u)),l.colfooters&&(u=Lp(n.footerBand,mp,null),a=$p(t,l.colfooters,f,p,p,Lp(d,"columnFooter"),jp,1,h,"y2",g-p,1,p,u)),l.rowtitle&&(s=Lp(n.titleAnchor,gp),c=Lp(d,"rowTitle"),c=s===qd?o+c:r-c,u=Lp(n.titleBand,gp,.5),Hp(t,l.rowtitle,c,0,v,u)),l.coltitle&&(s=Lp(n.titleAnchor,mp),c=Lp(d,"columnTitle"),c=s===qd?a+c:i-c,u=Lp(n.titleBand,mp,.5),Hp(t,l.coltitle,c,1,v,u));}function Vp(t,e){return "x1"===e?t.x||0:"y1"===e?t.y||0:"x2"===e?(t.x||0)+(t.width||0):"y2"===e?(t.y||0)+(t.height||0):void 0;}function qp(t,e){return t.bounds[e];}function $p(t,e,n,r,i,o,a,s,u,c,l,f,h,d){var p,m,g,v,y,b,x,w,k,E=n.length,C=0,A=0;if(!E)return C;for(p=l;p<E;p+=f){n[p]&&(C=a(C,u(n[p],c)));}if(!e.length)return C;for(e.length>i&&(t.warn("Grid headers exceed limit: "+i),e=e.slice(0,i)),C+=o,m=0,v=e.length;m<v;++m){t.dirty(e[m]),e[m].mark.bounds.clear();}for(p=l,m=0,v=e.length;m<v;++m,p+=f){for(y=(b=e[m]).mark.bounds,g=p;g>=0&&null==(x=n[g]);g-=h){}s?(w=null==d?x.x:Math.round(x.bounds.x1+d*x.bounds.width()),k=C):(w=C,k=null==d?x.y:Math.round(x.bounds.y1+d*x.bounds.height())),y.union(b.bounds.translate(w-(b.x||0),k-(b.y||0))),b.x=w,b.y=k,t.dirty(b),A=a(A,y[c]);}return A;}function Hp(t,e,n,r,i,o){if(e){t.dirty(e);var a=n,s=n;r?a=Math.round(i.x1+o*i.width()):s=Math.round(i.y1+o*i.height()),e.bounds.translate(a-(e.x||0),s-(e.y||0)),e.mark.bounds.clear().union(e.bounds),e.x=a,e.y=s,t.dirty(e);}}function Gp(t,e,n,r,i,o,a){var s=function(t,e){var n=t[e]||{};return function(e,r){return null!=n[e]?n[e]:null!=t[e]?t[e]:r;};}(n,e),u=function(t,e){var n=-1/0;return t.forEach(function(t){null!=t.offset&&(n=Math.max(n,t.offset));}),n>-1/0?n:e;}(t,s("offset",0)),c=s("anchor",Wd),l=c===qd?1:c===Vd?.5:0,f={align:dp,bounds:s("bounds",pp),columns:"vertical"===s("direction")?1:t.length,padding:s("margin",8),center:s("center"),nodirty:!0};switch(e){case Md:f.anchor={x:Math.floor(r.x1)-u,column:qd,y:l*(a||r.height()+2*r.y1),row:c};break;case jd:f.anchor={x:Math.ceil(r.x2)+u,y:l*(a||r.height()+2*r.y1),row:c};break;case Rd:f.anchor={y:Math.floor(i.y1)-u,row:qd,x:l*(o||i.width()+2*i.x1),column:c};break;case Bd:f.anchor={y:Math.ceil(i.y2)+u,x:l*(o||i.width()+2*i.x1),column:c};break;case Pd:f.anchor={x:u,y:u};break;case Ld:f.anchor={x:o-u,y:u,column:qd};break;case zd:f.anchor={x:u,y:a-u,row:qd};break;case Ud:f.anchor={x:o-u,y:a-u,column:qd,row:qd};}return f;}function Kp(t,e){var n,r,i=e.items[0],o=i.datum,a=i.orient,s=i.bounds,u=i.x,c=i.y;return i._bounds?i._bounds.clear().union(s):i._bounds=s.clone(),s.clear(),function(t,e,n){var r=e.padding,i=r-n.x,o=r-n.y;if(e.datum.title){var a=e.items[1].items[0],s=a.anchor,u=e.titlePadding||0,c=r-a.x,l=r-a.y;switch(a.orient){case Md:i+=Math.ceil(a.bounds.width())+u;break;case jd:case Bd:break;default:o+=a.bounds.height()+u;}switch((i||o)&&Yp(t,n,i,o),a.orient){case Md:l+=Xp(e,n,a,s,1,1);break;case jd:c+=Xp(e,n,a,qd,0,0)+u,l+=Xp(e,n,a,s,1,1);break;case Bd:c+=Xp(e,n,a,s,0,0),l+=Xp(e,n,a,qd,-1,0,1)+u;break;default:c+=Xp(e,n,a,s,0,0);}(c||l)&&Yp(t,a,c,l),(c=Math.round(a.bounds.x1-r))<0&&(Yp(t,n,-c,0),Yp(t,a,-c,0));}else (i||o)&&Yp(t,n,i,o);}(t,i,i.items[0].items[0]),s=function(t,e){return t.items.forEach(function(t){return e.union(t.bounds);}),e.x1=t.padding,e.y1=t.padding,e;}(i,s),n=2*i.padding,r=2*i.padding,s.empty()||(n=Math.ceil(s.width()+n),r=Math.ceil(s.height()+r)),o.type===ap&&function(t){var e=t.reduce(function(t,e){return t[e.column]=Math.max(e.bounds.x2-e.x,t[e.column]||0),t;},{});t.forEach(function(t){t.width=e[t.column],t.height=t.bounds.y2-t.y;});}(i.items[0].items[0].items[0].items),a!==fp&&(i.x=u=0,i.y=c=0),i.width=n,i.height=r,dl(s.set(u,c,u+n,c+r),i),i.mark.bounds.clear().union(s),i;}function Xp(t,e,n,r,i,o,a){var s="symbol"!==t.datum.type,u=n.datum.vgrad,c=(!s||!o&&u||a?e:e.items[0]).bounds[i?"y2":"x2"]-t.padding,l=u&&o?c:0,f=u&&o?0:c,h=i<=0?0:Gf(n);return Math.round(r===Wd?l:r===qd?f-h:.5*(c-h));}function Yp(t,e,n,r){e.x+=n,e.y+=r,e.bounds.translate(n,r),e.mark.bounds.translate(n,r),t.dirty(e);}function Jp(t){zt.call(this,null,t);}function Qp(t,e){var n=0;if(void 0===e){var _iterator20=_createForOfIteratorHelper(t),_step20;try{for(_iterator20.s();!(_step20=_iterator20.n()).done;){var _e59=_step20.value;(_e59=+_e59)&&(n+=_e59);}}catch(err){_iterator20.e(err);}finally{_iterator20.f();}}else {var _r58=-1;var _iterator21=_createForOfIteratorHelper(t),_step21;try{for(_iterator21.s();!(_step21=_iterator21.n()).done;){var _i37=_step21.value;(_i37=+e(_i37,++_r58,t))&&(n+=_i37);}}catch(err){_iterator21.e(err);}finally{_iterator21.f();}}return n;}function Zp(t){zt.call(this,null,t);}function tm(t){zt.call(this,null,t);}function em(){return ct({});}function nm(t){zt.call(this,null,t);}function rm(t){zt.call(this,[],t);}Object(Z.z)(Jp,zt,{transform:function transform(t,e){var n=e.dataflow;return t.mark.items.forEach(function(e){t.layout&&Wp(n,e,t.layout),function(t,e,n){var r,i,o,a,s,u=e.items,c=Math.max(0,e.width||0),l=Math.max(0,e.height||0),f=new sl().set(0,0,c,l),h=f.clone(),d=f.clone(),p=[];for(a=0,s=u.length;a<s;++a){switch((i=u[a]).role){case Kd:(Np(i)?h:d).union(Ip(t,i,c,l));break;case Xd:r=i;break;case Qd:p.push(Kp(t,i));break;case Yd:case Jd:case Zd:case tp:case ep:case np:case rp:case ip:h.union(i.bounds),d.union(i.bounds);break;default:f.union(i.bounds);}}if(p.length){var _e60={};p.forEach(function(t){(o=t.orient||jd)!==fp&&(_e60[o]||(_e60[o]=[])).push(t);});for(var _r59 in _e60){var _i38=_e60[_r59];Up(t,_i38,Gp(_i38,_r59,n.legends,h,d,c,l));}p.forEach(function(e){var r=e.bounds;if(r.equals(e._bounds)||(e.bounds=e._bounds,t.dirty(e),e.bounds=r,t.dirty(e)),n.autosize&&n.autosize.type===sp)switch(e.orient){case Md:case jd:f.add(r.x1,0).add(r.x2,0);break;case Rd:case Bd:f.add(0,r.y1).add(0,r.y2);}else f.union(r);});}f.union(h).union(d),r&&f.union(function(t,e,n,r,i){var o,a=e.items[0],s=a.frame,u=a.orient,c=a.anchor,l=a.offset,f=a.padding,h=a.items[0].items[0],d=a.items[1]&&a.items[1].items[0],p=u===Md||u===jd?r:n,m=0,g=0,v=0,y=0,b=0;if(s!==Gd?u===Md?(m=i.y2,p=i.y1):u===jd?(m=i.y1,p=i.y2):(m=i.x1,p=i.x2):u===Md&&(m=r,p=0),o=c===Wd?m:c===qd?p:(m+p)/2,d&&d.text){switch(u){case Rd:case Bd:b=h.bounds.height()+f;break;case Md:y=h.bounds.width()+f;break;case jd:y=-h.bounds.width()-f;}Fp.clear().union(d.bounds),Fp.translate(y-(d.x||0),b-(d.y||0)),Tp(d,"x",y)|Tp(d,"y",b)&&(t.dirty(d),d.bounds.clear().union(Fp),d.mark.bounds.clear().union(Fp),t.dirty(d)),Fp.clear().union(d.bounds);}else Fp.clear();switch(Fp.union(h.bounds),u){case Rd:g=o,v=i.y1-Fp.height()-l;break;case Md:g=i.x1-Fp.width()-l,v=o;break;case jd:g=i.x2+Fp.width()+l,v=o;break;case Bd:g=o,v=i.y2+l;break;default:g=a.x,v=a.y;}return Tp(a,"x",g)|Tp(a,"y",v)&&(Fp.translate(g,v),t.dirty(a),a.bounds.clear().union(Fp),e.bounds.clear().union(Fp),t.dirty(a)),a.bounds;}(t,r,c,l,f));e.clip&&f.set(0,0,e.width||0,e.height||0);!function(t,e,n,r){var i=r.autosize||{},o=i.type;if(t._autosize<1||!o)return;var a=t._width,s=t._height,u=Math.max(0,e.width||0),c=Math.max(0,Math.ceil(-n.x1)),l=Math.max(0,e.height||0),f=Math.max(0,Math.ceil(-n.y1));var h=Math.max(0,Math.ceil(n.x2-u)),d=Math.max(0,Math.ceil(n.y2-l));if(i.contains===op){var _e61=t.padding();a-=_e61.left+_e61.right,s-=_e61.top+_e61.bottom;}o===fp?(c=0,f=0,u=a,l=s):o===sp?(u=Math.max(0,a-c-h),l=Math.max(0,s-f-d)):o===up?(u=Math.max(0,a-c-h),s=l+f+d):o===cp?(a=u+c+h,l=Math.max(0,s-f-d)):o===lp&&(a=u+c+h,s=l+f+d);t._resizeView(a,s,u,l,[c,f],i.resize);}(t,e,f,n);}(n,e,t);}),function(t){return t&&"legend-entry"!==t.mark.role;}(t.mark.group)?e.reflow():e;}}),Object(Z.z)(Zp,zt,{transform:function transform(t,e){if(this.value&&!t.modified())return e.StopPropagation;var n=e.dataflow.locale(),r=e.fork(e.NO_SOURCE|e.NO_FIELDS),i=this.value,o=t.scale,a=Hu(o,null==t.count?t.values?t.values.length:10:t.count,t.minstep),s=t.format||Xu(n,o,a,t.formatSpecifier,t.formatType,!!t.values),u=t.values?Gu(o,t.values,a):Ku(o,a);return i&&(r.rem=i),i=u.map(function(t,e){return ct({index:e/(u.length-1||1),value:t,label:s(t)});}),t.extra&&i.length&&i.push(ct({index:-1,extra:{value:i[0].value},label:""})),r.source=i,r.add=i,this.value=i,r;}}),Object(Z.z)(tm,zt,{transform:function transform(t,e){var n=e.dataflow,r=e.fork(e.NO_SOURCE|e.NO_FIELDS),i=t.item||em,o=t.key||st,a=this.value;return Object(Z.B)(r.encode)&&(r.encode=null),a&&(t.modified("key")||e.modified(o))&&Object(Z.o)("DataJoin does not support modified key function or fields."),a||(e=e.addAll(),this.value=a=function(t){var e=Object(Z.t)().test(function(t){return t.exit;});return e.lookup=function(n){return e.get(t(n));},e;}(o)),e.visit(e.ADD,function(t){var e=o(t);var n=a.get(e);n?n.exit?(a.empty--,r.add.push(n)):r.mod.push(n):(n=i(t),a.set(e,n),r.add.push(n)),n.datum=t,n.exit=!1;}),e.visit(e.MOD,function(t){var e=o(t),n=a.get(e);n&&(n.datum=t,r.mod.push(n));}),e.visit(e.REM,function(t){var e=o(t),n=a.get(e);t!==n.datum||n.exit||(r.rem.push(n),n.exit=!0,++a.empty);}),e.changed(e.ADD_MOD)&&r.modifies("datum"),(e.clean()||t.clean&&a.empty>n.cleanThreshold)&&n.runAfter(a.clean),r;}}),Object(Z.z)(nm,zt,{transform:function transform(t,e){var n=e.fork(e.ADD_REM),r=t.mod||!1,i=t.encoders,o=e.encode;if(Object(Z.B)(o)){if(!n.changed()&&!o.every(function(t){return i[t];}))return e.StopPropagation;o=o[0],n.encode=null;}var a="enter"===o,s=i.update||Z.s,u=i.enter||Z.s,c=i.exit||Z.s,l=(o&&!a?i[o]:s)||Z.s;if(e.changed(e.ADD)&&(e.visit(e.ADD,function(e){u(e,t),s(e,t);}),n.modifies(u.output),n.modifies(s.output),l!==Z.s&&l!==s&&(e.visit(e.ADD,function(e){l(e,t);}),n.modifies(l.output))),e.changed(e.REM)&&c!==Z.s&&(e.visit(e.REM,function(e){c(e,t);}),n.modifies(c.output)),a||l!==Z.s){var _i39=e.MOD|(t.modified()?e.REFLOW:0);a?(e.visit(_i39,function(e){var i=u(e,t)||r;(l(e,t)||i)&&n.mod.push(e);}),n.mod.length&&n.modifies(u.output)):e.visit(_i39,function(e){(l(e,t)||r)&&n.mod.push(e);}),n.mod.length&&n.modifies(l.output);}return n.changed()?n:e.StopPropagation;}}),Object(Z.z)(rm,zt,{transform:function transform(t,e){if(null!=this.value&&!t.modified())return e.StopPropagation;var n,r,i,o,a,s=e.dataflow.locale(),u=e.fork(e.NO_SOURCE|e.NO_FIELDS),c=this.value,l=t.type||Uu,f=t.scale,h=+t.limit,d=Hu(f,null==t.count?5:t.count,t.minstep),p=!!t.values||l===Uu,m=t.format||ec(s,f,d,l,t.formatSpecifier,t.formatType,p),g=t.values||Zu(f,d);return c&&(u.rem=c),l===Uu?(h&&g.length>h?(e.dataflow.warn("Symbol legend count exceeds limit, filtering items."),c=g.slice(0,h-1),a=!0):c=g,Object(Z.E)(i=t.size)?(t.values||0!==f(c[0])||(c=c.slice(1)),o=c.reduce(function(e,n){return Math.max(e,i(n,t));},0)):i=Object(Z.m)(o=i||8),c=c.map(function(e,n){return ct({index:n,label:m(e,n,c),value:e,offset:o,size:i(e,t)});}),a&&(a=g[c.length],c.push(ct({index:c.length,label:"…".concat(g.length-c.length," entries"),value:a,offset:o,size:i(a,t)})))):"gradient"===l?(n=f.domain(),r=Mu(f,n[0],Object(Z.W)(n)),g.length<3&&!t.values&&n[0]!==Object(Z.W)(n)&&(g=[n[0],Object(Z.W)(n)]),c=g.map(function(t,e){return ct({index:e,label:m(t,e,g),value:t,perc:r(t)});})):(i=g.length-1,r=function(t){var e=t.domain(),n=e.length-1;var r=+e[0],i=+Object(Z.W)(e),o=i-r;if(t.type===uu){var _t62=n?o/n:.1;o=(i+=_t62)-(r-=_t62);}return function(t){return (t-r)/o;};}(f),c=g.map(function(t,e){return ct({index:e,label:m(t,e,g),value:t,perc:e?r(t):0,perc2:e===i?1:r(g[e+1])});})),u.source=c,u.add=c,this.value=c,u;}});var im=function im(t){return t.source.x;},om=function om(t){return t.source.y;},am=function am(t){return t.target.x;},sm=function sm(t){return t.target.y;};function um(t){zt.call(this,{},t);}um.Definition={type:"LinkPath",metadata:{modifies:!0},params:[{name:"sourceX",type:"field",default:"source.x"},{name:"sourceY",type:"field",default:"source.y"},{name:"targetX",type:"field",default:"target.x"},{name:"targetY",type:"field",default:"target.y"},{name:"orient",type:"enum",default:"vertical",values:["horizontal","vertical","radial"]},{name:"shape",type:"enum",default:"line",values:["line","arc","curve","diagonal","orthogonal"]},{name:"require",type:"signal"},{name:"as",type:"string",default:"path"}]},Object(Z.z)(um,zt,{transform:function transform(t,e){var n=t.sourceX||im,r=t.sourceY||om,i=t.targetX||am,o=t.targetY||sm,a=t.as||"path",s=t.orient||"vertical",u=t.shape||"line",c=hm.get(u+"-"+s)||hm.get(u);return c||Object(Z.o)("LinkPath unsupported type: "+t.shape+(t.orient?"-"+t.orient:"")),e.visit(e.SOURCE,function(t){t[a]=c(n(t),r(t),i(t),o(t));}),e.reflow(t.modified()).modifies(a);}});var cm=function cm(t,e,n,r){return "M"+t+","+e+"L"+n+","+r;},lm=function lm(t,e,n,r){var i=n-t,o=r-e,a=Math.sqrt(i*i+o*o)/2;return "M"+t+","+e+"A"+a+","+a+" "+180*Math.atan2(o,i)/Math.PI+" 0 1 "+n+","+r;},fm=function fm(t,e,n,r){var i=n-t,o=r-e,a=.2*(i+o),s=.2*(o-i);return "M"+t+","+e+"C"+(t+a)+","+(e+s)+" "+(n+s)+","+(r-a)+" "+n+","+r;},hm=Object(Z.t)({line:cm,"line-radial":function lineRadial(t,e,n,r){return cm(e*Math.cos(t),e*Math.sin(t),r*Math.cos(n),r*Math.sin(n));},arc:lm,"arc-radial":function arcRadial(t,e,n,r){return lm(e*Math.cos(t),e*Math.sin(t),r*Math.cos(n),r*Math.sin(n));},curve:fm,"curve-radial":function curveRadial(t,e,n,r){return fm(e*Math.cos(t),e*Math.sin(t),r*Math.cos(n),r*Math.sin(n));},"orthogonal-horizontal":function orthogonalHorizontal(t,e,n,r){return "M"+t+","+e+"V"+r+"H"+n;},"orthogonal-vertical":function orthogonalVertical(t,e,n,r){return "M"+t+","+e+"H"+n+"V"+r;},"orthogonal-radial":function orthogonalRadial(t,e,n,r){var i=Math.cos(t),o=Math.sin(t),a=Math.cos(n),s=Math.sin(n);return "M"+e*i+","+e*o+"A"+e+","+e+" 0 0,"+((Math.abs(n-t)>Math.PI?n<=t:n>t)?1:0)+" "+e*a+","+e*s+"L"+r*a+","+r*s;},"diagonal-horizontal":function diagonalHorizontal(t,e,n,r){var i=(t+n)/2;return "M"+t+","+e+"C"+i+","+e+" "+i+","+r+" "+n+","+r;},"diagonal-vertical":function diagonalVertical(t,e,n,r){var i=(e+r)/2;return "M"+t+","+e+"C"+t+","+i+" "+n+","+i+" "+n+","+r;},"diagonal-radial":function diagonalRadial(t,e,n,r){var i=Math.cos(t),o=Math.sin(t),a=Math.cos(n),s=Math.sin(n),u=(e+r)/2;return "M"+e*i+","+e*o+"C"+u*i+","+u*o+" "+u*a+","+u*s+" "+r*a+","+r*s;}});function dm(t){zt.call(this,null,t);}dm.Definition={type:"Pie",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"startAngle",type:"number",default:0},{name:"endAngle",type:"number",default:6.283185307179586},{name:"sort",type:"boolean",default:!1},{name:"as",type:"string",array:!0,length:2,default:["startAngle","endAngle"]}]},Object(Z.z)(dm,zt,{transform:function transform(t,e){var n,r,i,o=t.as||["startAngle","endAngle"],a=o[0],s=o[1],u=t.field||Z.Q,c=t.startAngle||0,l=null!=t.endAngle?t.endAngle:2*Math.PI,f=e.source,h=f.map(u),d=h.length,p=c,m=(l-c)/Qp(h),g=Ge(d);for(t.sort&&g.sort(function(t,e){return h[t]-h[e];}),n=0;n<d;++n){i=h[g[n]],(r=f[g[n]])[a]=p,r[s]=p+=i*m;}return this.value=h,e.reflow(t.modified()).modifies(o);}});var pm=5;function mm(t){return Au(t)&&t!==iu;}var gm=Object(Z.Fa)(["set","modified","clear","type","scheme","schemeExtent","schemeCount","domain","domainMin","domainMid","domainMax","domainRaw","domainImplicit","nice","zero","bins","range","rangeStep","round","reverse","interpolate","interpolateGamma"]);function vm(t){zt.call(this,null,t),this.modified(!0);}function ym(t,e,n){Su(t)&&Math.abs(e.reduce(function(t,e){return t+(e<0?-1:e>0?1:0);},0))!==e.length&&n.warn("Log scale domain includes zero: "+Object(Z.Ba)(e));return e;}function bm(t,e,n){return Object(Z.E)(t)&&(e||n)?Nu(t,xm(e||[0,1],n)):t;}function xm(t,e){return e?t.slice().reverse():t;}function wm(t){zt.call(this,null,t);}Object(Z.z)(vm,zt,{transform:function transform(t,e){var n=e.dataflow,r=this.value,i=function(t){var e,n=t.type,r="";if(n===iu)return iu+"-"+Js;(function(t){var e=t.type;return Au(e)&&e!==nu&&e!==ru&&(t.scheme||t.range&&t.range.length&&t.range.every(Z.J));})(t)&&(e=t.rawDomain?t.rawDomain.length:t.domain?t.domain.length+ +(null!=t.domainMid):0,r=2===e?iu+"-":3===e?ou+"-":"");return (r+n||Js).toLowerCase();}(t);for(i in r&&i===r.type||(this.value=r=ku(i)()),t){if(!gm[i]){if("padding"===i&&mm(r.type))continue;Object(Z.E)(r[i])?r[i](t[i]):n.warn("Unsupported scale property: "+i);}}return function(t,e,n){var r=t.type,i=e.round||!1,o=e.range;if(null!=e.rangeStep)o=function(t,e,n){t!==fu&&t!==lu&&Object(Z.o)("Only band and point scales support rangeStep.");var r=(null!=e.paddingOuter?e.paddingOuter:e.padding)||0,i=t===lu?1:(null!=e.paddingInner?e.paddingInner:e.padding)||0;return [0,e.rangeStep*Ys(n,i,r)];}(r,e,n);else if(e.scheme&&(o=function(t,e,n){var r,i,o=e.schemeExtent;Object(Z.B)(e.scheme)?i=Iu(e.scheme,e.interpolate,e.interpolateGamma):(r=e.scheme.toLowerCase(),(i=zu(r))||Object(Z.o)("Unrecognized scheme name: ".concat(e.scheme)));return n=t===uu?n+1:t===hu?n-1:t===au||t===su?+e.schemeCount||pm:n,Du(t)?bm(i,o,e.reverse):Object(Z.E)(i)?Ru(bm(i,o),n):t===cu?i:i.slice(0,n);}(r,e,n),Object(Z.E)(o))){if(t.interpolator)return t.interpolator(o);Object(Z.o)("Scale type ".concat(r," does not support interpolating color schemes."));}if(o&&Du(r))return t.interpolator(Iu(xm(o,e.reverse),e.interpolate,e.interpolateGamma));o&&e.interpolate&&t.interpolate?t.interpolate(ju(e.interpolate,e.interpolateGamma)):Object(Z.E)(t.round)?t.round(i):Object(Z.E)(t.rangeRound)&&t.interpolate(i?Xo:Ko);o&&t.range(xm(o,e.reverse));}(r,t,function(t,e,n){var r=e.bins;if(r&&!Object(Z.B)(r)){var _e62=t.domain(),_n52=_e62[0],_i40=Object(Z.W)(_e62),_o18=r.step;var _a26=null==r.start?_n52:r.start,_s21=null==r.stop?_i40:r.stop;_o18||Object(Z.o)("Scale bins parameter missing step property."),_a26<_n52&&(_a26=_o18*Math.ceil(_n52/_o18)),_s21>_i40&&(_s21=_o18*Math.floor(_i40/_o18)),r=Ge(_a26,_s21+_o18/2,_o18);}r?t.bins=r:t.bins&&delete t.bins;t.type===hu&&(r?e.domain||e.domainRaw||(t.domain(r),n=r.length):t.bins=t.domain());return n;}(r,t,function(t,e,n){var r=function(t,e,n){return e?(t.domain(ym(t.type,e,n)),e.length):-1;}(t,e.domainRaw,n);if(r>-1)return r;var i,o,a=e.domain,s=t.type,u=e.zero||void 0===e.zero&&function(t){var e=t.type;return !t.bins&&(e===Js||e===Zs||e===tu);}(t);if(!a)return 0;mm(s)&&e.padding&&a[0]!==Object(Z.W)(a)&&(a=function(t,e,n,r,i,o){var a=Math.abs(Object(Z.W)(n)-n[0]),s=a/(a-2*r),u=t===Qs?Object(Z.Oa)(e,null,s):t===tu?Object(Z.Pa)(e,null,s,.5):t===Zs?Object(Z.Pa)(e,null,s,i||1):t===eu?Object(Z.Qa)(e,null,s,o||1):Object(Z.Na)(e,null,s);return (e=e.slice())[0]=u[0],e[e.length-1]=u[1],e;}(s,a,e.range,e.padding,e.exponent,e.constant));if((u||null!=e.domainMin||null!=e.domainMax||null!=e.domainMid)&&(i=(a=a.slice()).length-1||1,u&&(a[0]>0&&(a[0]=0),a[i]<0&&(a[i]=0)),null!=e.domainMin&&(a[0]=e.domainMin),null!=e.domainMax&&(a[i]=e.domainMax),null!=e.domainMid)){var _t63=(o=e.domainMid)>a[i]?i+1:o<a[0]?0:i;_t63!==i&&n.warn("Scale domainMid exceeds domain min or max.",o),a.splice(_t63,0,o);}t.domain(ym(s,a,n)),s===cu&&t.unknown(e.domainImplicit?qi:void 0);e.nice&&t.nice&&t.nice(!0!==e.nice&&Hu(t,e.nice)||null);return a.length;}(r,t,n))),e.fork(e.NO_SOURCE|e.NO_FIELDS);}}),Object(Z.z)(wm,zt,{transform:function transform(t,e){var n=t.modified("sort")||e.changed(e.ADD)||e.modified(t.sort.fields)||e.modified("datum");return n&&e.source.sort(dt(t.sort)),this.modified(n),e;}});var km=["y0","y1"];function Em(t){zt.call(this,null,t);}function Cm(t,e,n,r,i){for(var o,a=(e-t.sum)/2,s=t.length,u=0;u<s;++u){(o=t[u])[r]=a,o[i]=a+=Math.abs(n(o));}}function Am(t,e,n,r,i){for(var o,a=1/t.sum,s=0,u=t.length,c=0,l=0;c<u;++c){(o=t[c])[r]=s,o[i]=s=a*(l+=Math.abs(n(o)));}}function Om(t,e,n,r,i){for(var o,a,s=0,u=0,c=t.length,l=0;l<c;++l){(o=+n(a=t[l]))<0?(a[r]=u,a[i]=u+=o):(a[r]=s,a[i]=s+=o);}}Em.Definition={type:"Stack",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"groupby",type:"field",array:!0},{name:"sort",type:"compare"},{name:"offset",type:"enum",default:"zero",values:["zero","center","normalize"]},{name:"as",type:"string",array:!0,length:2,default:km}]},Object(Z.z)(Em,zt,{transform:function transform(t,e){var n,r,i,o,a=t.as||km,s=a[0],u=a[1],c=dt(t.sort),l=t.field||Z.Q,f="center"===t.offset?Cm:"normalize"===t.offset?Am:Om;for(n=function(t,e,n,r){var i,o,a,s,u,c,l,f,h,d=[],p=function p(t){return t(u);};if(null==e)d.push(t.slice());else for(i={},o=0,a=t.length;o<a;++o){u=t[o],c=e.map(p),(l=i[c])||(i[c]=l=[],d.push(l)),l.push(u);}for(c=0,h=0,s=d.length;c<s;++c){for(l=d[c],o=0,f=0,a=l.length;o<a;++o){f+=Math.abs(r(l[o]));}l.sum=f,f>h&&(h=f),n&&l.sort(n);}return d.max=h,d;}(e.source,t.groupby,c,l),r=0,i=n.length,o=n.max;r<i;++r){f(n[r],o,l,s,u);}return e.reflow(t.modified()).modifies(a);}});var _m=function _m(t){return t;};function Sm(t,e){t&&Fm.hasOwnProperty(t.type)&&Fm[t.type](t,e);}var Dm={Feature:function Feature(t,e){Sm(t.geometry,e);},FeatureCollection:function FeatureCollection(t,e){for(var n=t.features,r=-1,i=n.length;++r<i;){Sm(n[r].geometry,e);}}},Fm={Sphere:function Sphere(t,e){e.sphere();},Point:function Point(t,e){t=t.coordinates,e.point(t[0],t[1],t[2]);},MultiPoint:function MultiPoint(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;){t=n[r],e.point(t[0],t[1],t[2]);}},LineString:function LineString(t,e){Tm(t.coordinates,e,0);},MultiLineString:function MultiLineString(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;){Tm(n[r],e,0);}},Polygon:function Polygon(t,e){Nm(t.coordinates,e);},MultiPolygon:function MultiPolygon(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;){Nm(n[r],e);}},GeometryCollection:function GeometryCollection(t,e){for(var n=t.geometries,r=-1,i=n.length;++r<i;){Sm(n[r],e);}}};function Tm(t,e,n){var r,i=-1,o=t.length-n;for(e.lineStart();++i<o;){r=t[i],e.point(r[0],r[1],r[2]);}e.lineEnd();}function Nm(t,e){var n=-1,r=t.length;for(e.polygonStart();++n<r;){Tm(t[n],e,1);}e.polygonEnd();}var Im=function Im(t,e){t&&Dm.hasOwnProperty(t.type)?Dm[t.type](t,e):Sm(t,e);};var Rm=/*#__PURE__*/function(){function Rm(){_classCallCheck(this,Rm);this._partials=new Float64Array(32),this._n=0;}_createClass(Rm,[{key:"add",value:function add(t){var e=this._partials;var n=0;for(var _r60=0;_r60<this._n&&_r60<32;_r60++){var _i41=e[_r60],_o19=t+_i41,_a27=Math.abs(t)<Math.abs(_i41)?t-(_o19-_i41):_i41-(_o19-t);_a27&&(e[n++]=_a27),t=_o19;}return e[n]=t,this._n=n+1,this;}},{key:"valueOf",value:function valueOf(){var t=this._partials;var e,n,r,i=this._n,o=0;if(i>0){for(o=t[--i];i>0&&(e=o,!(r=(n=t[--i])-((o=e+n)-e)));){}i>0&&(r<0&&t[i-1]<0||r>0&&t[i-1]>0)&&(n=2*r)==(e=o+n)-o&&(o=e);}return o;}}]);return Rm;}();var Mm=1e-6,jm=Math.PI,Bm=jm/2,Pm=jm/4,Lm=2*jm,zm=180/jm,Um=jm/180,Wm=Math.abs,Vm=Math.atan,qm=Math.atan2,$m=Math.cos,Hm=Math.ceil,Gm=Math.exp,Km=(Math.hypot),Xm=Math.log,Ym=Math.pow,Jm=Math.sin,Qm=Math.sign||function(t){return t>0?1:t<0?-1:0;},Zm=Math.sqrt,tg=Math.tan;function eg(t){return t>1?0:t<-1?jm:Math.acos(t);}function ng(t){return t>1?Bm:t<-1?-Bm:Math.asin(t);}function rg(){}var ig,og,ag,sg,ug=new Rm(),cg=new Rm(),lg={point:rg,lineStart:rg,lineEnd:rg,polygonStart:function polygonStart(){lg.lineStart=fg,lg.lineEnd=pg;},polygonEnd:function polygonEnd(){lg.lineStart=lg.lineEnd=lg.point=rg,ug.add(Wm(cg)),cg=new Rm();},result:function result(){var t=ug/2;return ug=new Rm(),t;}};function fg(){lg.point=hg;}function hg(t,e){lg.point=dg,ig=ag=t,og=sg=e;}function dg(t,e){cg.add(sg*t-ag*e),ag=t,sg=e;}function pg(){dg(ig,og);}var mg=lg,gg=1/0,vg=gg,yg=-gg,bg=yg;var xg,wg,kg,Eg,Cg={point:function point(t,e){t<gg&&(gg=t);t>yg&&(yg=t);e<vg&&(vg=e);e>bg&&(bg=e);},lineStart:rg,lineEnd:rg,polygonStart:rg,polygonEnd:rg,result:function result(){var t=[[gg,vg],[yg,bg]];return yg=bg=-(vg=gg=1/0),t;}},Ag=0,Og=0,_g=0,Sg=0,Dg=0,Fg=0,Tg=0,Ng=0,Ig=0,Rg={point:Mg,lineStart:jg,lineEnd:Lg,polygonStart:function polygonStart(){Rg.lineStart=zg,Rg.lineEnd=Ug;},polygonEnd:function polygonEnd(){Rg.point=Mg,Rg.lineStart=jg,Rg.lineEnd=Lg;},result:function result(){var t=Ig?[Tg/Ig,Ng/Ig]:Fg?[Sg/Fg,Dg/Fg]:_g?[Ag/_g,Og/_g]:[NaN,NaN];return Ag=Og=_g=Sg=Dg=Fg=Tg=Ng=Ig=0,t;}};function Mg(t,e){Ag+=t,Og+=e,++_g;}function jg(){Rg.point=Bg;}function Bg(t,e){Rg.point=Pg,Mg(kg=t,Eg=e);}function Pg(t,e){var n=t-kg,r=e-Eg,i=Zm(n*n+r*r);Sg+=i*(kg+t)/2,Dg+=i*(Eg+e)/2,Fg+=i,Mg(kg=t,Eg=e);}function Lg(){Rg.point=Mg;}function zg(){Rg.point=Wg;}function Ug(){Vg(xg,wg);}function Wg(t,e){Rg.point=Vg,Mg(xg=kg=t,wg=Eg=e);}function Vg(t,e){var n=t-kg,r=e-Eg,i=Zm(n*n+r*r);Sg+=i*(kg+t)/2,Dg+=i*(Eg+e)/2,Fg+=i,Tg+=(i=Eg*t-kg*e)*(kg+t),Ng+=i*(Eg+e),Ig+=3*i,Mg(kg=t,Eg=e);}var qg=Rg;function $g(t){this._context=t;}$g.prototype={_radius:4.5,pointRadius:function pointRadius(t){return this._radius=t,this;},polygonStart:function polygonStart(){this._line=0;},polygonEnd:function polygonEnd(){this._line=NaN;},lineStart:function lineStart(){this._point=0;},lineEnd:function lineEnd(){0===this._line&&this._context.closePath(),this._point=NaN;},point:function point(t,e){switch(this._point){case 0:this._context.moveTo(t,e),this._point=1;break;case 1:this._context.lineTo(t,e);break;default:this._context.moveTo(t+this._radius,e),this._context.arc(t,e,this._radius,0,Lm);}},result:rg};var Hg,Gg,Kg,Xg,Yg,Jg=new Rm(),Qg={point:rg,lineStart:function lineStart(){Qg.point=Zg;},lineEnd:function lineEnd(){Hg&&tv(Gg,Kg),Qg.point=rg;},polygonStart:function polygonStart(){Hg=!0;},polygonEnd:function polygonEnd(){Hg=null;},result:function result(){var t=+Jg;return Jg=new Rm(),t;}};function Zg(t,e){Qg.point=tv,Gg=Xg=t,Kg=Yg=e;}function tv(t,e){Xg-=t,Yg-=e,Jg.add(Zm(Xg*Xg+Yg*Yg)),Xg=t,Yg=e;}var ev=Qg;function nv(){this._string=[];}function rv(t){return "m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z";}nv.prototype={_radius:4.5,_circle:rv(4.5),pointRadius:function pointRadius(t){return (t=+t)!==this._radius&&(this._radius=t,this._circle=null),this;},polygonStart:function polygonStart(){this._line=0;},polygonEnd:function polygonEnd(){this._line=NaN;},lineStart:function lineStart(){this._point=0;},lineEnd:function lineEnd(){0===this._line&&this._string.push("Z"),this._point=NaN;},point:function point(t,e){switch(this._point){case 0:this._string.push("M",t,",",e),this._point=1;break;case 1:this._string.push("L",t,",",e);break;default:null==this._circle&&(this._circle=rv(this._radius)),this._string.push("M",t,",",e,this._circle);}},result:function result(){if(this._string.length){var t=this._string.join("");return this._string=[],t;}return null;}};var iv=function iv(t,e){var n,r,i=4.5;function o(t){return t&&("function"==typeof i&&r.pointRadius(+i.apply(this,arguments)),Im(t,n(r))),r.result();}return o.area=function(t){return Im(t,n(mg)),mg.result();},o.measure=function(t){return Im(t,n(ev)),ev.result();},o.bounds=function(t){return Im(t,n(Cg)),Cg.result();},o.centroid=function(t){return Im(t,n(qg)),qg.result();},o.projection=function(e){return arguments.length?(n=null==e?(t=null,_m):(t=e).stream,o):t;},o.context=function(t){return arguments.length?(r=null==t?(e=null,new nv()):new $g(e=t),"function"!=typeof i&&r.pointRadius(i),o):e;},o.pointRadius=function(t){return arguments.length?(i="function"==typeof t?t:(r.pointRadius(+t),+t),o):i;},o.projection(t).context(e);},ov=function ov(){var t,e=[];return {point:function point(e,n,r){t.push([e,n,r]);},lineStart:function lineStart(){e.push(t=[]);},lineEnd:rg,rejoin:function rejoin(){e.length>1&&e.push(e.pop().concat(e.shift()));},result:function result(){var n=e;return e=[],t=null,n;}};},av=function av(t,e){return Wm(t[0]-e[0])<Mm&&Wm(t[1]-e[1])<Mm;};function sv(t,e,n,r){this.x=t,this.z=e,this.o=n,this.e=r,this.v=!1,this.n=this.p=null;}var uv=function uv(t,e,n,r,i){var o,a,s=[],u=[];if(t.forEach(function(t){if(!((e=t.length-1)<=0)){var e,n,r=t[0],a=t[e];if(av(r,a)){if(!r[2]&&!a[2]){for(i.lineStart(),o=0;o<e;++o){i.point((r=t[o])[0],r[1]);}return void i.lineEnd();}a[0]+=2*Mm;}s.push(n=new sv(r,t,null,!0)),u.push(n.o=new sv(r,null,n,!1)),s.push(n=new sv(a,t,null,!1)),u.push(n.o=new sv(a,null,n,!0));}}),s.length){for(u.sort(e),cv(s),cv(u),o=0,a=u.length;o<a;++o){u[o].e=n=!n;}for(var c,l,f=s[0];;){for(var h=f,d=!0;h.v;){if((h=h.n)===f)return;}c=h.z,i.lineStart();do{if(h.v=h.o.v=!0,h.e){if(d)for(o=0,a=c.length;o<a;++o){i.point((l=c[o])[0],l[1]);}else r(h.x,h.n.x,1,i);h=h.n;}else {if(d)for(c=h.p.z,o=c.length-1;o>=0;--o){i.point((l=c[o])[0],l[1]);}else r(h.x,h.p.x,-1,i);h=h.p;}c=(h=h.o).z,d=!d;}while(!h.v);i.lineEnd();}}};function cv(t){if(e=t.length){for(var e,n,r=0,i=t[0];++r<e;){i.n=n=t[r],n.p=i,i=n;}i.n=n=t[0],n.p=i;}}function lv(t){return [qm(t[1],t[0]),ng(t[2])];}function fv(t){var e=t[0],n=t[1],r=$m(n);return [r*$m(e),r*Jm(e),Jm(n)];}function hv(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2];}function dv(t,e){return [t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]];}function pv(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2];}function mv(t,e){return [t[0]*e,t[1]*e,t[2]*e];}function gv(t){var e=Zm(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e;}function vv(t){return Wm(t[0])<=jm?t[0]:Qm(t[0])*((Wm(t[0])+jm)%Lm-jm);}function yv(t){return Array.from(/*#__PURE__*/regeneratorRuntime.mark(function _callee12(t){var _iterator22,_step22,_e63;return regeneratorRuntime.wrap(function _callee12$(_context13){while(1){switch(_context13.prev=_context13.next){case 0:_iterator22=_createForOfIteratorHelper(t);_context13.prev=1;_iterator22.s();case 3:if((_step22=_iterator22.n()).done){_context13.next=8;break;}_e63=_step22.value;return _context13.delegateYield(_e63,"t0",6);case 6:_context13.next=3;break;case 8:_context13.next=13;break;case 10:_context13.prev=10;_context13.t1=_context13["catch"](1);_iterator22.e(_context13.t1);case 13:_context13.prev=13;_iterator22.f();return _context13.finish(13);case 16:case"end":return _context13.stop();}}},_callee12,null,[[1,10,13,16]]);})(t));}var bv=function bv(t,e,n,r){return function(i){var o,a,s,u=e(i),c=ov(),l=e(c),f=!1,h={point:d,lineStart:m,lineEnd:g,polygonStart:function polygonStart(){h.point=v,h.lineStart=y,h.lineEnd=b,a=[],o=[];},polygonEnd:function polygonEnd(){h.point=d,h.lineStart=m,h.lineEnd=g,a=yv(a);var t=function(t,e){var n=vv(e),r=e[1],i=Jm(r),o=[Jm(n),-$m(n),0],a=0,s=0,u=new Rm();1===i?r=Bm+Mm:-1===i&&(r=-Bm-Mm);for(var c=0,l=t.length;c<l;++c){if(h=(f=t[c]).length)for(var f,h,d=f[h-1],p=vv(d),m=d[1]/2+Pm,g=Jm(m),v=$m(m),y=0;y<h;++y,p=x,g=k,v=E,d=b){var b=f[y],x=vv(b),w=b[1]/2+Pm,k=Jm(w),E=$m(w),C=x-p,A=C>=0?1:-1,O=A*C,_=O>jm,S=g*k;if(u.add(qm(S*A*Jm(O),v*E+S*$m(O))),a+=_?C+A*Lm:C,_^p>=n^x>=n){var D=dv(fv(d),fv(b));gv(D);var F=dv(o,D);gv(F);var T=(_^C>=0?-1:1)*ng(F[2]);(r>T||r===T&&(D[0]||D[1]))&&(s+=_^C>=0?1:-1);}}}return (a<-Mm||a<Mm&&u<-1e-12)^1&s;}(o,r);a.length?(f||(i.polygonStart(),f=!0),uv(a,wv,t,n,i)):t&&(f||(i.polygonStart(),f=!0),i.lineStart(),n(null,null,1,i),i.lineEnd()),f&&(i.polygonEnd(),f=!1),a=o=null;},sphere:function sphere(){i.polygonStart(),i.lineStart(),n(null,null,1,i),i.lineEnd(),i.polygonEnd();}};function d(e,n){t(e,n)&&i.point(e,n);}function p(t,e){u.point(t,e);}function m(){h.point=p,u.lineStart();}function g(){h.point=d,u.lineEnd();}function v(t,e){s.push([t,e]),l.point(t,e);}function y(){l.lineStart(),s=[];}function b(){v(s[0][0],s[0][1]),l.lineEnd();var t,e,n,r,u=l.clean(),h=c.result(),d=h.length;if(s.pop(),o.push(s),s=null,d)if(1&u){if((e=(n=h[0]).length-1)>0){for(f||(i.polygonStart(),f=!0),i.lineStart(),t=0;t<e;++t){i.point((r=n[t])[0],r[1]);}i.lineEnd();}}else d>1&&2&u&&h.push(h.pop().concat(h.shift())),a.push(h.filter(xv));}return h;};};function xv(t){return t.length>1;}function wv(t,e){return ((t=t.x)[0]<0?t[1]-Bm-Mm:Bm-t[1])-((e=e.x)[0]<0?e[1]-Bm-Mm:Bm-e[1]);}var kv=bv(function(){return !0;},function(t){var e,n=NaN,r=NaN,i=NaN;return {lineStart:function lineStart(){t.lineStart(),e=1;},point:function point(o,a){var s=o>0?jm:-jm,u=Wm(o-n);Wm(u-jm)<Mm?(t.point(n,r=(r+a)/2>0?Bm:-Bm),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),t.point(o,r),e=0):i!==s&&u>=jm&&(Wm(n-i)<Mm&&(n-=i*Mm),Wm(o-s)<Mm&&(o-=s*Mm),r=function(t,e,n,r){var i,o,a=Jm(t-n);return Wm(a)>Mm?Vm((Jm(e)*(o=$m(r))*Jm(n)-Jm(r)*(i=$m(e))*Jm(t))/(i*o*a)):(e+r)/2;}(n,r,o,a),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),e=0),t.point(n=o,r=a),i=s;},lineEnd:function lineEnd(){t.lineEnd(),n=r=NaN;},clean:function clean(){return 2-e;}};},function(t,e,n,r){var i;if(null==t)i=n*Bm,r.point(-jm,i),r.point(0,i),r.point(jm,i),r.point(jm,0),r.point(jm,-i),r.point(0,-i),r.point(-jm,-i),r.point(-jm,0),r.point(-jm,i);else if(Wm(t[0]-e[0])>Mm){var o=t[0]<e[0]?jm:-jm;i=n*o/2,r.point(-o,i),r.point(0,i),r.point(o,i);}else r.point(e[0],e[1]);},[-jm,-Bm]);var Ev=function Ev(t,e){function n(n,r){return n=t(n,r),e(n[0],n[1]);}return t.invert&&e.invert&&(n.invert=function(n,r){return (n=e.invert(n,r))&&t.invert(n[0],n[1]);}),n;};function Cv(t,e){return [Wm(t)>jm?t+Math.round(-t/Lm)*Lm:t,e];}function Av(t,e,n){return (t%=Lm)?e||n?Ev(_v(t),Sv(e,n)):_v(t):e||n?Sv(e,n):Cv;}function Ov(t){return function(e,n){return [(e+=t)>jm?e-Lm:e<-jm?e+Lm:e,n];};}function _v(t){var e=Ov(t);return e.invert=Ov(-t),e;}function Sv(t,e){var n=$m(t),r=Jm(t),i=$m(e),o=Jm(e);function a(t,e){var a=$m(e),s=$m(t)*a,u=Jm(t)*a,c=Jm(e),l=c*n+s*r;return [qm(u*i-l*o,s*n-c*r),ng(l*i+u*o)];}return a.invert=function(t,e){var a=$m(e),s=$m(t)*a,u=Jm(t)*a,c=Jm(e),l=c*i-u*o;return [qm(u*i+c*o,s*n+l*r),ng(l*n-s*r)];},a;}Cv.invert=Cv;var Dv=function Dv(t){function e(e){return (e=t(e[0]*Um,e[1]*Um))[0]*=zm,e[1]*=zm,e;}return t=Av(t[0]*Um,t[1]*Um,t.length>2?t[2]*Um:0),e.invert=function(e){return (e=t.invert(e[0]*Um,e[1]*Um))[0]*=zm,e[1]*=zm,e;},e;};function Fv(t,e,n,r,i,o){if(n){var a=$m(e),s=Jm(e),u=r*n;null==i?(i=e+r*Lm,o=e-u/2):(i=Tv(a,i),o=Tv(a,o),(r>0?i<o:i>o)&&(i+=r*Lm));for(var c,l=i;r>0?l>o:l<o;l-=u){c=lv([a,-s*$m(l),-s*Jm(l)]),t.point(c[0],c[1]);}}}function Tv(t,e){(e=fv(e))[0]-=t,gv(e);var n=eg(-e[1]);return ((-e[2]<0?-n:n)+Lm-Mm)%Lm;}var Nv=function Nv(t){var e=$m(t),n=6*Um,r=e>0,i=Wm(e)>Mm;function o(t,n){return $m(t)*$m(n)>e;}function a(t,n,r){var i=[1,0,0],o=dv(fv(t),fv(n)),a=hv(o,o),s=o[0],u=a-s*s;if(!u)return !r&&t;var c=e*a/u,l=-e*s/u,f=dv(i,o),h=mv(i,c);pv(h,mv(o,l));var d=f,p=hv(h,d),m=hv(d,d),g=p*p-m*(hv(h,h)-1);if(!(g<0)){var v=Zm(g),y=mv(d,(-p-v)/m);if(pv(y,h),y=lv(y),!r)return y;var b,x=t[0],w=n[0],k=t[1],E=n[1];w<x&&(b=x,x=w,w=b);var C=w-x,A=Wm(C-jm)<Mm;if(!A&&E<k&&(b=k,k=E,E=b),A||C<Mm?A?k+E>0^y[1]<(Wm(y[0]-x)<Mm?k:E):k<=y[1]&&y[1]<=E:C>jm^(x<=y[0]&&y[0]<=w)){var O=mv(d,(-p+v)/m);return pv(O,h),[y,lv(O)];}}}function s(e,n){var i=r?t:jm-t,o=0;return e<-i?o|=1:e>i&&(o|=2),n<-i?o|=4:n>i&&(o|=8),o;}return bv(o,function(t){var e,n,u,c,l;return {lineStart:function lineStart(){c=u=!1,l=1;},point:function point(f,h){var d,p=[f,h],m=o(f,h),g=r?m?0:s(f,h):m?s(f+(f<0?jm:-jm),h):0;if(!e&&(c=u=m)&&t.lineStart(),m!==u&&(!(d=a(e,p))||av(e,d)||av(p,d))&&(p[2]=1),m!==u)l=0,m?(t.lineStart(),d=a(p,e),t.point(d[0],d[1])):(d=a(e,p),t.point(d[0],d[1],2),t.lineEnd()),e=d;else if(i&&e&&r^m){var v;g&n||!(v=a(p,e,!0))||(l=0,r?(t.lineStart(),t.point(v[0][0],v[0][1]),t.point(v[1][0],v[1][1]),t.lineEnd()):(t.point(v[1][0],v[1][1]),t.lineEnd(),t.lineStart(),t.point(v[0][0],v[0][1],3)));}!m||e&&av(e,p)||t.point(p[0],p[1]),e=p,u=m,n=g;},lineEnd:function lineEnd(){u&&t.lineEnd(),e=null;},clean:function clean(){return l|(c&&u)<<1;}};},function(e,r,i,o){Fv(o,t,n,i,e,r);},r?[0,-t]:[-jm,t-jm]);},Iv=function Iv(t,e,n,r,i,o){var a,s=t[0],u=t[1],c=0,l=1,f=e[0]-s,h=e[1]-u;if(a=n-s,f||!(a>0)){if(a/=f,f<0){if(a<c)return;a<l&&(l=a);}else if(f>0){if(a>l)return;a>c&&(c=a);}if(a=i-s,f||!(a<0)){if(a/=f,f<0){if(a>l)return;a>c&&(c=a);}else if(f>0){if(a<c)return;a<l&&(l=a);}if(a=r-u,h||!(a>0)){if(a/=h,h<0){if(a<c)return;a<l&&(l=a);}else if(h>0){if(a>l)return;a>c&&(c=a);}if(a=o-u,h||!(a<0)){if(a/=h,h<0){if(a>l)return;a>c&&(c=a);}else if(h>0){if(a<c)return;a<l&&(l=a);}return c>0&&(t[0]=s+c*f,t[1]=u+c*h),l<1&&(e[0]=s+l*f,e[1]=u+l*h),!0;}}}}},Rv=1e9,Mv=-Rv;function jv(t,e,n,r){function i(i,o){return t<=i&&i<=n&&e<=o&&o<=r;}function o(i,o,s,c){var l=0,f=0;if(null==i||(l=a(i,s))!==(f=a(o,s))||u(i,o)<0^s>0)do{c.point(0===l||3===l?t:n,l>1?r:e);}while((l=(l+s+4)%4)!==f);else c.point(o[0],o[1]);}function a(r,i){return Wm(r[0]-t)<Mm?i>0?0:3:Wm(r[0]-n)<Mm?i>0?2:1:Wm(r[1]-e)<Mm?i>0?1:0:i>0?3:2;}function s(t,e){return u(t.x,e.x);}function u(t,e){var n=a(t,1),r=a(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0];}return function(a){var u,c,l,f,h,d,p,m,g,v,y,b=a,x=ov(),w={point:k,lineStart:function lineStart(){w.point=E,c&&c.push(l=[]);v=!0,g=!1,p=m=NaN;},lineEnd:function lineEnd(){u&&(E(f,h),d&&g&&x.rejoin(),u.push(x.result()));w.point=k,g&&b.lineEnd();},polygonStart:function polygonStart(){b=x,u=[],c=[],y=!0;},polygonEnd:function polygonEnd(){var e=function(){for(var e=0,n=0,i=c.length;n<i;++n){for(var o,a,s=c[n],u=1,l=s.length,f=s[0],h=f[0],d=f[1];u<l;++u){o=h,a=d,f=s[u],h=f[0],d=f[1],a<=r?d>r&&(h-o)*(r-a)>(d-a)*(t-o)&&++e:d<=r&&(h-o)*(r-a)<(d-a)*(t-o)&&--e;}}return e;}(),n=y&&e,i=(u=yv(u)).length;(n||i)&&(a.polygonStart(),n&&(a.lineStart(),o(null,null,1,a),a.lineEnd()),i&&uv(u,s,e,o,a),a.polygonEnd());b=a,u=c=l=null;}};function k(t,e){i(t,e)&&b.point(t,e);}function E(o,a){var s=i(o,a);if(c&&l.push([o,a]),v)f=o,h=a,d=s,v=!1,s&&(b.lineStart(),b.point(o,a));else if(s&&g)b.point(o,a);else {var u=[p=Math.max(Mv,Math.min(Rv,p)),m=Math.max(Mv,Math.min(Rv,m))],x=[o=Math.max(Mv,Math.min(Rv,o)),a=Math.max(Mv,Math.min(Rv,a))];Iv(u,x,t,e,n,r)?(g||(b.lineStart(),b.point(u[0],u[1])),b.point(x[0],x[1]),s||b.lineEnd(),y=!1):s&&(b.lineStart(),b.point(o,a),y=!1);}p=o,m=a,g=s;}return w;};}function Bv(t){return function(e){var n=new Pv();for(var r in t){n[r]=t[r];}return n.stream=e,n;};}function Pv(){}function Lv(t,e,n){var r=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),null!=r&&t.clipExtent(null),Im(n,t.stream(Cg)),e(Cg.result()),null!=r&&t.clipExtent(r),t;}function zv(t,e,n){return Lv(t,function(n){var r=e[1][0]-e[0][0],i=e[1][1]-e[0][1],o=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),a=+e[0][0]+(r-o*(n[1][0]+n[0][0]))/2,s=+e[0][1]+(i-o*(n[1][1]+n[0][1]))/2;t.scale(150*o).translate([a,s]);},n);}function Uv(t,e,n){return zv(t,[[0,0],e],n);}function Wv(t,e,n){return Lv(t,function(n){var r=+e,i=r/(n[1][0]-n[0][0]),o=(r-i*(n[1][0]+n[0][0]))/2,a=-i*n[0][1];t.scale(150*i).translate([o,a]);},n);}function Vv(t,e,n){return Lv(t,function(n){var r=+e,i=r/(n[1][1]-n[0][1]),o=-i*n[0][0],a=(r-i*(n[1][1]+n[0][1]))/2;t.scale(150*i).translate([o,a]);},n);}Pv.prototype={constructor:Pv,point:function point(t,e){this.stream.point(t,e);},sphere:function sphere(){this.stream.sphere();},lineStart:function lineStart(){this.stream.lineStart();},lineEnd:function lineEnd(){this.stream.lineEnd();},polygonStart:function polygonStart(){this.stream.polygonStart();},polygonEnd:function polygonEnd(){this.stream.polygonEnd();}};var qv=16,$v=$m(30*Um),Hv=function Hv(t,e){return +e?function(t,e){function n(r,i,o,a,s,u,c,l,f,h,d,p,m,g){var v=c-r,y=l-i,b=v*v+y*y;if(b>4*e&&m--){var x=a+h,w=s+d,k=u+p,E=Zm(x*x+w*w+k*k),C=ng(k/=E),A=Wm(Wm(k)-1)<Mm||Wm(o-f)<Mm?(o+f)/2:qm(w,x),O=t(A,C),_=O[0],S=O[1],D=_-r,F=S-i,T=y*D-v*F;(T*T/b>e||Wm((v*D+y*F)/b-.5)>.3||a*h+s*d+u*p<$v)&&(n(r,i,o,a,s,u,_,S,A,x/=E,w/=E,k,m,g),g.point(_,S),n(_,S,A,x,w,k,c,l,f,h,d,p,m,g));}}return function(e){var r,i,o,a,s,u,c,l,f,h,d,p,m={point:g,lineStart:v,lineEnd:b,polygonStart:function polygonStart(){e.polygonStart(),m.lineStart=x;},polygonEnd:function polygonEnd(){e.polygonEnd(),m.lineStart=v;}};function g(n,r){n=t(n,r),e.point(n[0],n[1]);}function v(){l=NaN,m.point=y,e.lineStart();}function y(r,i){var o=fv([r,i]),a=t(r,i);n(l,f,c,h,d,p,l=a[0],f=a[1],c=r,h=o[0],d=o[1],p=o[2],qv,e),e.point(l,f);}function b(){m.point=g,e.lineEnd();}function x(){v(),m.point=w,m.lineEnd=k;}function w(t,e){y(r=t,e),i=l,o=f,a=h,s=d,u=p,m.point=y;}function k(){n(l,f,c,h,d,p,i,o,r,a,s,u,qv,e),m.lineEnd=b,b();}return m;};}(t,e):function(t){return Bv({point:function point(e,n){e=t(e,n),this.stream.point(e[0],e[1]);}});}(t);};var Gv=Bv({point:function point(t,e){this.stream.point(t*Um,e*Um);}});function Kv(t,e,n,r,i,o){if(!o)return function(t,e,n,r,i){function o(o,a){return [e+t*(o*=r),n-t*(a*=i)];}return o.invert=function(o,a){return [(o-e)/t*r,(n-a)/t*i];},o;}(t,e,n,r,i);var a=$m(o),s=Jm(o),u=a*t,c=s*t,l=a/t,f=s/t,h=(s*n-a*e)/t,d=(s*e+a*n)/t;function p(t,o){return [u*(t*=r)-c*(o*=i)+e,n-c*t-u*o];}return p.invert=function(t,e){return [r*(l*t-f*e+h),i*(d-f*t-l*e)];},p;}function Xv(t){return Yv(function(){return t;})();}function Yv(t){var e,n,r,i,o,a,s,u,c,l,f=150,h=480,d=250,p=0,m=0,g=0,v=0,y=0,b=0,x=1,w=1,k=null,E=kv,C=null,A=_m,O=.5;function _(t){return u(t[0]*Um,t[1]*Um);}function S(t){return (t=u.invert(t[0],t[1]))&&[t[0]*zm,t[1]*zm];}function D(){var t=Kv(f,0,0,x,w,b).apply(null,e(p,m)),r=Kv(f,h-t[0],d-t[1],x,w,b);return n=Av(g,v,y),s=Ev(e,r),u=Ev(n,s),a=Hv(s,O),F();}function F(){return c=l=null,_;}return _.stream=function(t){return c&&l===t?c:c=Gv(function(t){return Bv({point:function point(e,n){var r=t(e,n);return this.stream.point(r[0],r[1]);}});}(n)(E(a(A(l=t)))));},_.preclip=function(t){return arguments.length?(E=t,k=void 0,F()):E;},_.postclip=function(t){return arguments.length?(A=t,C=r=i=o=null,F()):A;},_.clipAngle=function(t){return arguments.length?(E=+t?Nv(k=t*Um):(k=null,kv),F()):k*zm;},_.clipExtent=function(t){return arguments.length?(A=null==t?(C=r=i=o=null,_m):jv(C=+t[0][0],r=+t[0][1],i=+t[1][0],o=+t[1][1]),F()):null==C?null:[[C,r],[i,o]];},_.scale=function(t){return arguments.length?(f=+t,D()):f;},_.translate=function(t){return arguments.length?(h=+t[0],d=+t[1],D()):[h,d];},_.center=function(t){return arguments.length?(p=t[0]%360*Um,m=t[1]%360*Um,D()):[p*zm,m*zm];},_.rotate=function(t){return arguments.length?(g=t[0]%360*Um,v=t[1]%360*Um,y=t.length>2?t[2]%360*Um:0,D()):[g*zm,v*zm,y*zm];},_.angle=function(t){return arguments.length?(b=t%360*Um,D()):b*zm;},_.reflectX=function(t){return arguments.length?(x=t?-1:1,D()):x<0;},_.reflectY=function(t){return arguments.length?(w=t?-1:1,D()):w<0;},_.precision=function(t){return arguments.length?(a=Hv(s,O=t*t),F()):Zm(O);},_.fitExtent=function(t,e){return zv(_,t,e);},_.fitSize=function(t,e){return Uv(_,t,e);},_.fitWidth=function(t,e){return Wv(_,t,e);},_.fitHeight=function(t,e){return Vv(_,t,e);},function(){return e=t.apply(this,arguments),_.invert=e.invert&&S,D();};}function Jv(t){var e=0,n=jm/3,r=Yv(t),i=r(e,n);return i.parallels=function(t){return arguments.length?r(e=t[0]*Um,n=t[1]*Um):[e*zm,n*zm];},i;}function Qv(t,e){var n=Jm(t),r=(n+Jm(e))/2;if(Wm(r)<Mm)return function(t){var e=$m(t);function n(t,n){return [t*e,Jm(n)/e];}return n.invert=function(t,n){return [t/e,ng(n*e)];},n;}(t);var i=1+n*(2*r-n),o=Zm(i)/r;function a(t,e){var n=Zm(i-2*r*Jm(e))/r;return [n*Jm(t*=r),o-n*$m(t)];}return a.invert=function(t,e){var n=o-e,a=qm(t,Wm(n))*Qm(n);return n*r<0&&(a-=jm*Qm(t)*Qm(n)),[a/r,ng((i-(t*t+n*n)*r*r)/(2*r))];},a;}var Zv=function Zv(){return Jv(Qv).scale(155.424).center([0,33.6442]);},ty=function ty(){return Zv().parallels([29.5,45.5]).scale(1070).translate([480,250]).rotate([96,0]).center([-.6,38.7]);};function ey(t){return function(e,n){var r=$m(e),i=$m(n),o=t(r*i);return o===1/0?[2,0]:[o*i*Jm(e),o*Jm(n)];};}function ny(t){return function(e,n){var r=Zm(e*e+n*n),i=t(r),o=Jm(i),a=$m(i);return [qm(e*o,r*a),ng(r&&n*o/r)];};}var ry=ey(function(t){return Zm(2/(1+t));});ry.invert=ny(function(t){return 2*ng(t/2);});var iy=ey(function(t){return (t=eg(t))&&t/Jm(t);});iy.invert=ny(function(t){return t;});function oy(t,e){return [t,Xm(tg((Bm+e)/2))];}oy.invert=function(t,e){return [t,2*Vm(Gm(e))-Bm];};function ay(t){var e,n,r,i=Xv(t),o=i.center,a=i.scale,s=i.translate,u=i.clipExtent,c=null;function l(){var o=jm*a(),s=i(Dv(i.rotate()).invert([0,0]));return u(null==c?[[s[0]-o,s[1]-o],[s[0]+o,s[1]+o]]:t===oy?[[Math.max(s[0]-o,c),e],[Math.min(s[0]+o,n),r]]:[[c,Math.max(s[1]-o,e)],[n,Math.min(s[1]+o,r)]]);}return i.scale=function(t){return arguments.length?(a(t),l()):a();},i.translate=function(t){return arguments.length?(s(t),l()):s();},i.center=function(t){return arguments.length?(o(t),l()):o();},i.clipExtent=function(t){return arguments.length?(null==t?c=e=n=r=null:(c=+t[0][0],e=+t[0][1],n=+t[1][0],r=+t[1][1]),l()):null==c?null:[[c,e],[n,r]];},l();}function sy(t){return tg((Bm+t)/2);}function uy(t,e){var n=$m(t),r=t===e?Jm(t):Xm(n/$m(e))/Xm(sy(e)/sy(t)),i=n*Ym(sy(t),r)/r;if(!r)return oy;function o(t,e){i>0?e<-Bm+Mm&&(e=-Bm+Mm):e>Bm-Mm&&(e=Bm-Mm);var n=i/Ym(sy(e),r);return [n*Jm(r*t),i-n*$m(r*t)];}return o.invert=function(t,e){var n=i-e,o=Qm(r)*Zm(t*t+n*n),a=qm(t,Wm(n))*Qm(n);return n*r<0&&(a-=jm*Qm(t)*Qm(n)),[a/r,2*Vm(Ym(i/o,1/r))-Bm];},o;}function cy(t,e){return [t,e];}cy.invert=cy;function ly(t,e){var n=$m(t),r=t===e?Jm(t):(n-$m(e))/(e-t),i=n/r+t;if(Wm(r)<Mm)return cy;function o(t,e){var n=i-e,o=r*t;return [n*Jm(o),i-n*$m(o)];}return o.invert=function(t,e){var n=i-e,o=qm(t,Wm(n))*Qm(n);return n*r<0&&(o-=jm*Qm(t)*Qm(n)),[o/r,i-Qm(r)*Zm(t*t+n*n)];},o;}var fy=1.340264,hy=-.081106,dy=893e-6,py=.003796,my=Zm(3)/2;function gy(t,e){var n=ng(my*Jm(e)),r=n*n,i=r*r*r;return [t*$m(n)/(my*(fy+3*hy*r+i*(7*dy+9*py*r))),n*(fy+hy*r+i*(dy+py*r))];}gy.invert=function(t,e){for(var n,r=e,i=r*r,o=i*i*i,a=0;a<12&&(o=(i=(r-=n=(r*(fy+hy*i+o*(dy+py*i))-e)/(fy+3*hy*i+o*(7*dy+9*py*i)))*r)*i*i,!(Wm(n)<1e-12));++a){}return [my*t*(fy+3*hy*i+o*(7*dy+9*py*i))/$m(r),ng(Jm(r)/my)];};function vy(t,e){var n=$m(e),r=$m(t)*n;return [n*Jm(t)/r,Jm(e)/r];}vy.invert=ny(Vm);function yy(t,e){var n=e*e,r=n*n;return [t*(.8707-.131979*n+r*(r*(.003971*n-.001529*r)-.013791)),e*(1.007226+n*(.015085+r*(.028874*n-.044475-.005916*r)))];}yy.invert=function(t,e){var n,r=e,i=25;do{var o=r*r,a=o*o;r-=n=(r*(1.007226+o*(.015085+a*(.028874*o-.044475-.005916*a)))-e)/(1.007226+o*(.045255+a*(.259866*o-.311325-.005916*11*a)));}while(Wm(n)>Mm&&--i>0);return [t/(.8707+(o=r*r)*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979)),r];};function by(t,e){return [$m(e)*Jm(t),Jm(e)];}by.invert=ny(ng);function xy(t,e){var n=$m(e),r=1+$m(t)*n;return [n*Jm(t)/r,Jm(e)/r];}xy.invert=ny(function(t){return 2*Vm(t);});function wy(t,e){return [Xm(tg((Bm+e)/2)),-t];}wy.invert=function(t,e){return [-e,2*Vm(Gm(t))-Bm];};var ky=Math.abs,Ey=(Math.cos),Cy=(Math.sin),Ay=(1e-6),Oy=Math.PI,_y=Oy/2,Sy=(Fy(2));function Dy(t){return t>1?_y:t<-1?-_y:Math.asin(t);}function Fy(t){return t>0?Math.sqrt(t):0;}var Ty=function(t,e,n){function r(r,i){return [t*r*Ey(i=function(t,e){var n,r=t*Cy(e),i=30;do{e-=n=(e+Cy(e)-r)/(1+Ey(e));}while(ky(n)>Ay&&--i>0);return e/2;}(n,i)),e*Cy(i)];}return r.invert=function(r,i){return i=Dy(i/e),[r/(t*Ey(i)),Dy((2*i+Cy(2*i))/n)];},r;}(Sy/_y,Sy,Oy);var Ny=iv(),Iy=["clipAngle","clipExtent","scale","translate","center","rotate","parallels","precision","reflectX","reflectY","coefficient","distance","fraction","lobes","parallel","radius","ratio","spacing","tilt"];function Ry(t,e){if(!t||"string"!=typeof t)throw new Error("Projection type must be a name string.");return t=t.toLowerCase(),arguments.length>1?(jy[t]=function(t,e){return function n(){var r=e();return r.type=t,r.path=iv().projection(r),r.copy=r.copy||function(){var t=n();return Iy.forEach(function(e){r[e]&&t[e](r[e]());}),t.path.pointRadius(r.path.pointRadius()),t;},r;};}(t,e),this):jy[t]||null;}function My(t){return t&&t.path||Ny;}var jy={albers:ty,albersusa:function albersusa(){var t,e,n,r,i,o,a=ty(),s=Zv().rotate([154,0]).center([-2,58.5]).parallels([55,65]),u=Zv().rotate([157,0]).center([-3,19.9]).parallels([8,18]),c={point:function point(t,e){o=[t,e];}};function l(t){var e=t[0],a=t[1];return o=null,n.point(e,a),o||(r.point(e,a),o)||(i.point(e,a),o);}function f(){return t=e=null,l;}return l.invert=function(t){var e=a.scale(),n=a.translate(),r=(t[0]-n[0])/e,i=(t[1]-n[1])/e;return (i>=.12&&i<.234&&r>=-.425&&r<-.214?s:i>=.166&&i<.234&&r>=-.214&&r<-.115?u:a).invert(t);},l.stream=function(n){return t&&e===n?t:t=function(t){var e=t.length;return {point:function point(n,r){for(var i=-1;++i<e;){t[i].point(n,r);}},sphere:function sphere(){for(var n=-1;++n<e;){t[n].sphere();}},lineStart:function lineStart(){for(var n=-1;++n<e;){t[n].lineStart();}},lineEnd:function lineEnd(){for(var n=-1;++n<e;){t[n].lineEnd();}},polygonStart:function polygonStart(){for(var n=-1;++n<e;){t[n].polygonStart();}},polygonEnd:function polygonEnd(){for(var n=-1;++n<e;){t[n].polygonEnd();}}};}([a.stream(e=n),s.stream(n),u.stream(n)]);},l.precision=function(t){return arguments.length?(a.precision(t),s.precision(t),u.precision(t),f()):a.precision();},l.scale=function(t){return arguments.length?(a.scale(t),s.scale(.35*t),u.scale(t),l.translate(a.translate())):a.scale();},l.translate=function(t){if(!arguments.length)return a.translate();var e=a.scale(),o=+t[0],l=+t[1];return n=a.translate(t).clipExtent([[o-.455*e,l-.238*e],[o+.455*e,l+.238*e]]).stream(c),r=s.translate([o-.307*e,l+.201*e]).clipExtent([[o-.425*e+Mm,l+.12*e+Mm],[o-.214*e-Mm,l+.234*e-Mm]]).stream(c),i=u.translate([o-.205*e,l+.212*e]).clipExtent([[o-.214*e+Mm,l+.166*e+Mm],[o-.115*e-Mm,l+.234*e-Mm]]).stream(c),f();},l.fitExtent=function(t,e){return zv(l,t,e);},l.fitSize=function(t,e){return Uv(l,t,e);},l.fitWidth=function(t,e){return Wv(l,t,e);},l.fitHeight=function(t,e){return Vv(l,t,e);},l.scale(1070);},azimuthalequalarea:function azimuthalequalarea(){return Xv(ry).scale(124.75).clipAngle(179.999);},azimuthalequidistant:function azimuthalequidistant(){return Xv(iy).scale(79.4188).clipAngle(179.999);},conicconformal:function conicconformal(){return Jv(uy).scale(109.5).parallels([30,30]);},conicequalarea:Zv,conicequidistant:function conicequidistant(){return Jv(ly).scale(131.154).center([0,13.9389]);},equalEarth:function equalEarth(){return Xv(gy).scale(177.158);},equirectangular:function equirectangular(){return Xv(cy).scale(152.63);},gnomonic:function gnomonic(){return Xv(vy).scale(144.049).clipAngle(60);},identity:function identity(){var t,e,n,r,i,o,a,s=1,u=0,c=0,l=1,f=1,h=0,d=null,p=1,m=1,g=Bv({point:function point(t,e){var n=b([t,e]);this.stream.point(n[0],n[1]);}}),v=_m;function y(){return p=s*l,m=s*f,o=a=null,b;}function b(n){var r=n[0]*p,i=n[1]*m;if(h){var o=i*t-r*e;r=r*t+i*e,i=o;}return [r+u,i+c];}return b.invert=function(n){var r=n[0]-u,i=n[1]-c;if(h){var o=i*t+r*e;r=r*t-i*e,i=o;}return [r/p,i/m];},b.stream=function(t){return o&&a===t?o:o=g(v(a=t));},b.postclip=function(t){return arguments.length?(v=t,d=n=r=i=null,y()):v;},b.clipExtent=function(t){return arguments.length?(v=null==t?(d=n=r=i=null,_m):jv(d=+t[0][0],n=+t[0][1],r=+t[1][0],i=+t[1][1]),y()):null==d?null:[[d,n],[r,i]];},b.scale=function(t){return arguments.length?(s=+t,y()):s;},b.translate=function(t){return arguments.length?(u=+t[0],c=+t[1],y()):[u,c];},b.angle=function(n){return arguments.length?(e=Jm(h=n%360*Um),t=$m(h),y()):h*zm;},b.reflectX=function(t){return arguments.length?(l=t?-1:1,y()):l<0;},b.reflectY=function(t){return arguments.length?(f=t?-1:1,y()):f<0;},b.fitExtent=function(t,e){return zv(b,t,e);},b.fitSize=function(t,e){return Uv(b,t,e);},b.fitWidth=function(t,e){return Wv(b,t,e);},b.fitHeight=function(t,e){return Vv(b,t,e);},b;},mercator:function mercator(){return ay(oy).scale(961/Lm);},mollweide:function mollweide(){return Xv(Ty).scale(169.529);},naturalEarth1:function naturalEarth1(){return Xv(yy).scale(175.295);},orthographic:function orthographic(){return Xv(by).scale(249.5).clipAngle(90+Mm);},stereographic:function stereographic(){return Xv(xy).scale(250).clipAngle(142);},transversemercator:function transversemercator(){var t=ay(wy),e=t.center,n=t.rotate;return t.center=function(t){return arguments.length?e([-t[1],t[0]]):[(t=e())[1],-t[0]];},t.rotate=function(t){return arguments.length?n([t[0],t[1],t.length>2?t[2]+90:90]):[(t=n())[0],t[1],t[2]-90];},n([0,0,90]).scale(159.155);}};for(var _t64 in jy){Ry(_t64,jy[_t64]);}function By(t,e,n){var r=Ge(t,e-Mm,n).concat(e);return function(t){return r.map(function(e){return [t,e];});};}function Py(t,e,n){var r=Ge(t,e-Mm,n).concat(e);return function(t){return r.map(function(e){return [e,t];});};}function Ly(){var t,e,n,r,i,o,a,s,u,c,l,f,h=10,d=h,p=90,m=360,g=2.5;function v(){return {type:"MultiLineString",coordinates:y()};}function y(){return Ge(Hm(r/p)*p,n,p).map(l).concat(Ge(Hm(s/m)*m,a,m).map(f)).concat(Ge(Hm(e/h)*h,t,h).filter(function(t){return Wm(t%p)>Mm;}).map(u)).concat(Ge(Hm(o/d)*d,i,d).filter(function(t){return Wm(t%m)>Mm;}).map(c));}return v.lines=function(){return y().map(function(t){return {type:"LineString",coordinates:t};});},v.outline=function(){return {type:"Polygon",coordinates:[l(r).concat(f(a).slice(1),l(n).reverse().slice(1),f(s).reverse().slice(1))]};},v.extent=function(t){return arguments.length?v.extentMajor(t).extentMinor(t):v.extentMinor();},v.extentMajor=function(t){return arguments.length?(r=+t[0][0],n=+t[1][0],s=+t[0][1],a=+t[1][1],r>n&&(t=r,r=n,n=t),s>a&&(t=s,s=a,a=t),v.precision(g)):[[r,s],[n,a]];},v.extentMinor=function(n){return arguments.length?(e=+n[0][0],t=+n[1][0],o=+n[0][1],i=+n[1][1],e>t&&(n=e,e=t,t=n),o>i&&(n=o,o=i,i=n),v.precision(g)):[[e,o],[t,i]];},v.step=function(t){return arguments.length?v.stepMajor(t).stepMinor(t):v.stepMinor();},v.stepMajor=function(t){return arguments.length?(p=+t[0],m=+t[1],v):[p,m];},v.stepMinor=function(t){return arguments.length?(h=+t[0],d=+t[1],v):[h,d];},v.precision=function(h){return arguments.length?(g=+h,u=By(o,i,90),c=Py(e,t,g),l=By(s,a,90),f=Py(r,n,g),v):g;},v.extentMajor([[-180,-90+Mm],[180,90-Mm]]).extentMinor([[-180,-80-Mm],[180,80+Mm]]);}function zy(){}var Uy=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function Wy(){var t=1,e=1,n=a;function r(t,e){return e.map(function(e){return i(t,e);});}function i(r,i){var a=[],s=[];return function(n,r,i){var a,s,u,c,l,f,h=new Array(),d=new Array();a=s=-1,c=n[0]>=r,Uy[c<<1].forEach(p);for(;++a<t-1;){u=c,c=n[a+1]>=r,Uy[u|c<<1].forEach(p);}Uy[c<<0].forEach(p);for(;++s<e-1;){for(a=-1,c=n[s*t+t]>=r,l=n[s*t]>=r,Uy[c<<1|l<<2].forEach(p);++a<t-1;){u=c,c=n[s*t+t+a+1]>=r,f=l,l=n[s*t+a+1]>=r,Uy[u|c<<1|l<<2|f<<3].forEach(p);}Uy[c|l<<3].forEach(p);}a=-1,l=n[s*t]>=r,Uy[l<<2].forEach(p);for(;++a<t-1;){f=l,l=n[s*t+a+1]>=r,Uy[l<<2|f<<3].forEach(p);}function p(t){var e,n,r=[t[0][0]+a,t[0][1]+s],u=[t[1][0]+a,t[1][1]+s],c=o(r),l=o(u);(e=d[c])?(n=h[l])?(delete d[e.end],delete h[n.start],e===n?(e.ring.push(u),i(e.ring)):h[e.start]=d[n.end]={start:e.start,end:n.end,ring:e.ring.concat(n.ring)}):(delete d[e.end],e.ring.push(u),d[e.end=l]=e):(e=h[l])?(n=d[c])?(delete h[e.start],delete d[n.end],e===n?(e.ring.push(u),i(e.ring)):h[n.start]=d[e.end]={start:n.start,end:e.end,ring:n.ring.concat(e.ring)}):(delete h[e.start],e.ring.unshift(r),h[e.start=c]=e):h[c]=d[l]={start:c,end:l,ring:[r,u]};}Uy[l<<3].forEach(p);}(r,i,function(t){n(t,r,i),function(t){var e=0,n=t.length,r=t[n-1][1]*t[0][0]-t[n-1][0]*t[0][1];for(;++e<n;){r+=t[e-1][1]*t[e][0]-t[e-1][0]*t[e][1];}return r;}(t)>0?a.push([t]):s.push(t);}),s.forEach(function(t){for(var e,n=0,r=a.length;n<r;++n){if(-1!==Vy((e=a[n])[0],t))return void e.push(t);}}),{type:"MultiPolygon",value:i,coordinates:a};}function o(e){return 2*e[0]+e[1]*(t+1)*4;}function a(n,r,i){n.forEach(function(n){var o,a=n[0],s=n[1],u=0|a,c=0|s,l=r[c*t+u];a>0&&a<t&&u===a&&(o=r[c*t+u-1],n[0]=a+(i-o)/(l-o)-.5),s>0&&s<e&&c===s&&(o=r[(c-1)*t+u],n[1]=s+(i-o)/(l-o)-.5);});}return r.contour=i,r.size=function(n){if(!arguments.length)return [t,e];var i=Math.floor(n[0]),o=Math.floor(n[1]);return i>=0&&o>=0||Object(Z.o)("invalid size"),t=i,e=o,r;},r.smooth=function(t){return arguments.length?(n=t?a:zy,r):n===a;},r;}function Vy(t,e){for(var n,r=-1,i=e.length;++r<i;){if(n=qy(t,e[r]))return n;}return 0;}function qy(t,e){for(var n=e[0],r=e[1],i=-1,o=0,a=t.length,s=a-1;o<a;s=o++){var u=t[o],c=u[0],l=u[1],f=t[s],h=f[0],d=f[1];if($y(u,f,e))return 0;l>r!=d>r&&n<(h-c)*(r-l)/(d-l)+c&&(i=-i);}return i;}function $y(t,e,n){var r;return function(t,e,n){return (e[0]-t[0])*(n[1]-t[1])==(n[0]-t[0])*(e[1]-t[1]);}(t,e,n)&&function(t,e,n){return t<=e&&e<=n||n<=e&&e<=t;}(t[r=+(t[0]===e[0])],n[r],e[r]);}function Hy(t,e,n){return function(r){var i=Object(Z.q)(r),o=n?Math.min(i[0],0):i[0],a=i[1],s=a-o,u=e?Object(Hi.c)(o,a,t):s/(t+1);return Ge(o+u,a,u);};}function Gy(t){zt.call(this,null,t);}function Ky(t,e,n,r,i){var o=t.x1||0,a=t.y1||0,s=e*n<0;function u(t){t.forEach(c);}function c(t){s&&t.reverse(),t.forEach(l);}function l(t){t[0]=(t[0]-o)*e+r,t[1]=(t[1]-a)*n+i;}return function(t){return t.coordinates.forEach(u),t;};}function Xy(t,e,n){var r=t>=0?t:ee(e,n);return Math.round((Math.sqrt(4*r*r+1)-1)/2);}function Yy(t){return Object(Z.E)(t)?t:Object(Z.m)(+t);}function Jy(){var t=function t(_t65){return _t65[0];},e=function e(t){return t[1];},n=Z.Q,r=[-1,-1],i=960,o=500,a=2;function s(s,u){var c=Xy(r[0],s,t)>>a,l=Xy(r[1],s,e)>>a,f=c?c+2:0,h=l?l+2:0,d=2*f+(i>>a),p=2*h+(o>>a),m=new Float32Array(d*p),g=new Float32Array(d*p);var v=m;s.forEach(function(r){var i=f+(+t(r)>>a),o=h+(+e(r)>>a);i>=0&&i<d&&o>=0&&o<p&&(m[i+o*d]+=+n(r));}),c>0&&l>0?(Qy(d,p,m,g,c),Zy(d,p,g,m,l),Qy(d,p,m,g,c),Zy(d,p,g,m,l),Qy(d,p,m,g,c),Zy(d,p,g,m,l)):c>0?(Qy(d,p,m,g,c),Qy(d,p,g,m,c),Qy(d,p,m,g,c),v=g):l>0&&(Zy(d,p,m,g,l),Zy(d,p,g,m,l),Zy(d,p,m,g,l),v=g);var y=u?Math.pow(2,-2*a):1/Qp(v);for(var _t66=0,_e64=d*p;_t66<_e64;++_t66){v[_t66]*=y;}return {values:v,scale:1<<a,width:d,height:p,x1:f,y1:h,x2:f+(i>>a),y2:h+(o>>a)};}return s.x=function(e){return arguments.length?(t=Yy(e),s):t;},s.y=function(t){return arguments.length?(e=Yy(t),s):e;},s.weight=function(t){return arguments.length?(n=Yy(t),s):n;},s.size=function(t){if(!arguments.length)return [i,o];var e=+t[0],n=+t[1];return e>=0&&n>=0||Object(Z.o)("invalid size"),i=e,o=n,s;},s.cellSize=function(t){return arguments.length?((t=+t)>=1||Object(Z.o)("invalid cell size"),a=Math.floor(Math.log(t)/Math.LN2),s):1<<a;},s.bandwidth=function(t){return arguments.length?(1===(t=Object(Z.i)(t)).length&&(t=[+t[0],+t[0]]),2!==t.length&&Object(Z.o)("invalid bandwidth"),r=t,s):r;},s;}function Qy(t,e,n,r,i){var o=1+(i<<1);for(var _a28=0;_a28<e;++_a28){for(var _e65=0,_s22=0;_e65<t+i;++_e65){_e65<t&&(_s22+=n[_e65+_a28*t]),_e65>=i&&(_e65>=o&&(_s22-=n[_e65-o+_a28*t]),r[_e65-i+_a28*t]=_s22/Math.min(_e65+1,t-1+o-_e65,o));}}}function Zy(t,e,n,r,i){var o=1+(i<<1);for(var _a29=0;_a29<t;++_a29){for(var _s23=0,_u12=0;_s23<e+i;++_s23){_s23<e&&(_u12+=n[_a29+_s23*t]),_s23>=i&&(_s23>=o&&(_u12-=n[_a29+(_s23-o)*t]),r[_a29+(_s23-i)*t]=_u12/Math.min(_s23+1,e-1+o-_s23,o));}}}function tb(t){zt.call(this,null,t);}Gy.Definition={type:"Isocontour",metadata:{generates:!0},params:[{name:"field",type:"field"},{name:"thresholds",type:"number",array:!0},{name:"levels",type:"number"},{name:"nice",type:"boolean",default:!1},{name:"resolve",type:"enum",values:["shared","independent"],default:"independent"},{name:"zero",type:"boolean",default:!0},{name:"smooth",type:"boolean",default:!0},{name:"scale",type:"number",expr:!0},{name:"translate",type:"number",array:!0,expr:!0},{name:"as",type:"string",null:!0,default:"contour"}]},Object(Z.z)(Gy,zt,{transform:function transform(t,e){if(this.value&&!e.changed()&&!t.modified())return e.StopPropagation;var n=e.fork(e.NO_SOURCE|e.NO_FIELDS),r=e.materialize(e.SOURCE).source,i=t.field||Z.y,o=Wy().smooth(!1!==t.smooth),a=t.thresholds||function(t,e,n){var r=Hy(n.levels||10,n.nice,!1!==n.zero);return "shared"!==n.resolve?r:r(t.map(function(t){return $t(e(t).values);}));}(r,i,t),s=null===t.as?null:t.as||"contour",u=[];return r.forEach(function(e){var n=i(e),r=o.size([n.width,n.height])(n.values,Object(Z.B)(a)?a:a(n.values));!function(t,e,n,r){var i=r.scale||e.scale,o=r.translate||e.translate;Object(Z.E)(i)&&(i=i(n,r));Object(Z.E)(o)&&(o=o(n,r));if((1===i||null==i)&&!o)return;var a=(Object(Z.G)(i)?i:i[0])||1,s=(Object(Z.G)(i)?i:i[1])||1,u=o&&o[0]||0,c=o&&o[1]||0;t.forEach(Ky(e,a,s,u,c));}(r,n,e,t),r.forEach(function(t){u.push(ft(e,ct(null!=s?_defineProperty({},s,t):t)));});}),this.value&&(n.rem=this.value),this.value=n.source=n.add=u,n;}}),tb.Definition={type:"KDE2D",metadata:{generates:!0},params:[{name:"size",type:"number",array:!0,length:2,required:!0},{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"weight",type:"field"},{name:"groupby",type:"field",array:!0},{name:"cellSize",type:"number"},{name:"bandwidth",type:"number",array:!0,length:2},{name:"counts",type:"boolean",default:!1},{name:"as",type:"string",default:"grid"}]};var eb=["x","y","weight","size","cellSize","bandwidth"];function nb(t,e){return eb.forEach(function(n){return null!=e[n]?t[n](e[n]):0;}),t;}function rb(t){zt.call(this,null,t);}Object(Z.z)(tb,zt,{transform:function transform(t,e){if(this.value&&!e.changed()&&!t.modified())return e.StopPropagation;var n,r=e.fork(e.NO_SOURCE|e.NO_FIELDS),i=function(t,e){var n,r,i,o,a,s,u=[],c=function c(t){return t(o);};if(null==e)u.push(t);else for(n={},r=0,i=t.length;r<i;++r){o=t[r],a=e.map(c),(s=n[a])||(n[a]=s=[],s.dims=a,u.push(s)),s.push(o);}return u;}(e.materialize(e.SOURCE).source,t.groupby),o=(t.groupby||[]).map(Z.h),a=nb(Jy(),t),s=t.as||"grid";return n=i.map(function(e){return ct(function(t,e){for(var _n53=0;_n53<o.length;++_n53){t[o[_n53]]=e[_n53];}return t;}(_defineProperty({},s,a(e,t.counts)),e.dims));}),this.value&&(r.rem=this.value),this.value=r.source=r.add=n,r;}}),rb.Definition={type:"Contour",metadata:{generates:!0},params:[{name:"size",type:"number",array:!0,length:2,required:!0},{name:"values",type:"number",array:!0},{name:"x",type:"field"},{name:"y",type:"field"},{name:"weight",type:"field"},{name:"cellSize",type:"number"},{name:"bandwidth",type:"number"},{name:"count",type:"number"},{name:"nice",type:"boolean",default:!1},{name:"thresholds",type:"number",array:!0},{name:"smooth",type:"boolean",default:!0}]},Object(Z.z)(rb,zt,{transform:function transform(t,e){if(this.value&&!e.changed()&&!t.modified())return e.StopPropagation;var n,r,i=e.fork(e.NO_SOURCE|e.NO_FIELDS),o=Wy().smooth(!1!==t.smooth),a=t.values,s=t.thresholds||Hy(t.count||10,t.nice,!!a),u=t.size;return a||(a=e.materialize(e.SOURCE).source,r=Ky(n=nb(Jy(),t)(a,!0),n.scale||1,n.scale||1,0,0),u=[n.width,n.height],a=n.values),s=Object(Z.B)(s)?s:s(a),a=o.size(u)(a,s),r&&a.forEach(r),this.value&&(i.rem=this.value),this.value=i.source=i.add=(a||[]).map(ct),i;}});var ib="Feature",ob="FeatureCollection";function ab(t){zt.call(this,null,t);}function sb(t){zt.call(this,null,t);}function ub(t){zt.call(this,null,t);}function cb(t){zt.call(this,null,t);}function lb(t){zt.call(this,[],t),this.generator=Ly();}function fb(t){zt.call(this,null,t);}function hb(t){if(!Object(Z.E)(t))return !1;var e=Object(Z.Fa)(Object(Z.g)(t));return e.$x||e.$y||e.$value||e.$max;}function db(t){zt.call(this,null,t),this.modified(!0);}function pb(t,e,n){Object(Z.E)(t[e])&&t[e](n);}ab.Definition={type:"GeoJSON",metadata:{},params:[{name:"fields",type:"field",array:!0,length:2},{name:"geojson",type:"field"}]},Object(Z.z)(ab,zt,{transform:function transform(t,e){var n,r=this._features,i=this._points,o=t.fields,a=o&&o[0],s=o&&o[1],u=t.geojson||!o&&Z.y,c=e.ADD;n=t.modified()||e.changed(e.REM)||e.modified(Object(Z.g)(u))||a&&e.modified(Object(Z.g)(a))||s&&e.modified(Object(Z.g)(s)),this.value&&!n||(c=e.SOURCE,this._features=r=[],this._points=i=[]),u&&e.visit(c,function(t){return r.push(u(t));}),a&&s&&(e.visit(c,function(t){var e=a(t),n=s(t);null!=e&&null!=n&&(e=+e)===e&&(n=+n)===n&&i.push([e,n]);}),r=r.concat({type:ib,geometry:{type:"MultiPoint",coordinates:i}})),this.value={type:ob,features:r};}}),sb.Definition={type:"GeoPath",metadata:{modifies:!0},params:[{name:"projection",type:"projection"},{name:"field",type:"field"},{name:"pointRadius",type:"number",expr:!0},{name:"as",type:"string",default:"path"}]},Object(Z.z)(sb,zt,{transform:function transform(t,e){var n=e.fork(e.ALL),r=this.value,i=t.field||Z.y,o=t.as||"path",a=n.SOURCE;!r||t.modified()?(this.value=r=My(t.projection),n.materialize().reflow()):a=i===Z.y||e.modified(i.fields)?n.ADD_MOD:n.ADD;var s=function(t,e){var n=t.pointRadius();t.context(null),null!=e&&t.pointRadius(e);return n;}(r,t.pointRadius);return n.visit(a,function(t){return t[o]=r(i(t));}),r.pointRadius(s),n.modifies(o);}}),ub.Definition={type:"GeoPoint",metadata:{modifies:!0},params:[{name:"projection",type:"projection",required:!0},{name:"fields",type:"field",array:!0,required:!0,length:2},{name:"as",type:"string",array:!0,length:2,default:["x","y"]}]},Object(Z.z)(ub,zt,{transform:function transform(t,e){var n,r=t.projection,i=t.fields[0],o=t.fields[1],a=t.as||["x","y"],s=a[0],u=a[1];function c(t){var e=r([i(t),o(t)]);e?(t[s]=e[0],t[u]=e[1]):(t[s]=void 0,t[u]=void 0);}return t.modified()?e=e.materialize().reflow(!0).visit(e.SOURCE,c):(n=e.modified(i.fields)||e.modified(o.fields),e.visit(n?e.ADD_MOD:e.ADD,c)),e.modifies(a);}}),cb.Definition={type:"GeoShape",metadata:{modifies:!0,nomod:!0},params:[{name:"projection",type:"projection"},{name:"field",type:"field",default:"datum"},{name:"pointRadius",type:"number",expr:!0},{name:"as",type:"string",default:"shape"}]},Object(Z.z)(cb,zt,{transform:function transform(t,e){var n=e.fork(e.ALL),r=this.value,i=t.as||"shape",o=n.ADD;return r&&!t.modified()||(this.value=r=function(t,e,n){var r=null==n?function(n){return t(e(n));}:function(r){var i=t.pointRadius(),o=t.pointRadius(n)(e(r));return t.pointRadius(i),o;};return r.context=function(e){return t.context(e),r;},r;}(My(t.projection),t.field||Object(Z.u)("datum"),t.pointRadius),n.materialize().reflow(),o=n.SOURCE),n.visit(o,function(t){return t[i]=r;}),n.modifies(i);}}),lb.Definition={type:"Graticule",metadata:{changes:!0,generates:!0},params:[{name:"extent",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"extentMajor",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"extentMinor",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"step",type:"number",array:!0,length:2},{name:"stepMajor",type:"number",array:!0,length:2,default:[90,360]},{name:"stepMinor",type:"number",array:!0,length:2,default:[10,10]},{name:"precision",type:"number",default:2.5}]},Object(Z.z)(lb,zt,{transform:function transform(t,e){var n,r=this.value,i=this.generator;if(!r.length||t.modified())for(var _e66 in t){Object(Z.E)(i[_e66])&&i[_e66](t[_e66]);}return n=i(),r.length?e.mod.push(ht(r[0],n)):e.add.push(ct(n)),r[0]=n,e;}}),fb.Definition={type:"heatmap",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"color",type:"string",expr:!0},{name:"opacity",type:"number",expr:!0},{name:"resolve",type:"enum",values:["shared","independent"],default:"independent"},{name:"as",type:"string",default:"image"}]},Object(Z.z)(fb,zt,{transform:function transform(t,e){if(!e.changed()&&!t.modified())return e.StopPropagation;var n=e.materialize(e.SOURCE).source,r="shared"===t.resolve,i=t.field||Z.y,o=function(t,e){var n;Object(Z.E)(t)?(n=function n(_n54){return t(_n54,e);}).dep=hb(t):t?n=Object(Z.m)(t):(n=function n(t){return t.$value/t.$max||0;}).dep=!0;return n;}(t.opacity,t),a=function(t,e){var n;Object(Z.E)(t)?(n=function n(_n55){return go(t(_n55,e));}).dep=hb(t):n=Object(Z.m)(go(t||"#888"));return n;}(t.color,t),s=t.as||"image",u={$x:0,$y:0,$value:0,$max:r?$t(n.map(function(t){return $t(i(t).values);})):0};return n.forEach(function(t){var e=i(t),n=Object(Z.p)({},t,u);r||(n.$max=$t(e.values||[])),t[s]=function(t,e,n,r){var i=t.width,o=t.height,a=t.x1||0,s=t.y1||0,u=t.x2||i,c=t.y2||o,l=t.values,f=l?function(t){return l[t];}:Z.Ma,h=ji(u-a,c-s),d=h.getContext("2d"),p=d.getImageData(0,0,u-a,c-s),m=p.data;for(var _t67=s,_o20=0;_t67<c;++_t67){e.$y=_t67-s;for(var _s24=a,_c7=_t67*i;_s24<u;++_s24,_o20+=4){e.$x=_s24-a,e.$value=f(_s24+_c7);var _t68=n(e);m[_o20+0]=_t68.r,m[_o20+1]=_t68.g,m[_o20+2]=_t68.b,m[_o20+3]=~~(255*r(e));}}return d.putImageData(p,0,0),h;}(e,n,a.dep?a:Object(Z.m)(a(n)),o.dep?o:Object(Z.m)(o(n)));}),e.reflow(!0).modifies(s);}}),Object(Z.z)(db,zt,{transform:function transform(t,e){var n=this.value;return !n||t.modified("type")?(this.value=n=function(t){var e=Ry((t||"mercator").toLowerCase());e||Object(Z.o)("Unrecognized projection type: "+t);return e();}(t.type),Iy.forEach(function(e){null!=t[e]&&pb(n,e,t[e]);})):Iy.forEach(function(e){t.modified(e)&&pb(n,e,t[e]);}),null!=t.pointRadius&&n.path.pointRadius(t.pointRadius),t.fit&&function(t,e){var n=function(t){return 1===(t=Object(Z.i)(t)).length?t[0]:{type:ob,features:t.reduce(function(t,e){return t.concat(function(t){return t.type===ob?t.features:Object(Z.i)(t).filter(function(t){return null!=t;}).map(function(t){return t.type===ib?t:{type:ib,geometry:t};});}(e));},[])};}(e.fit);e.extent?t.fitExtent(e.extent,n):e.size&&t.fitSize(e.size,n);}(n,t),e.fork(e.NO_SOURCE|e.NO_FIELDS);}});function mb(t,e,n,r){if(isNaN(e)||isNaN(n))return t;var i,o,a,s,u,c,l,f,h,d=t._root,p={data:r},m=t._x0,g=t._y0,v=t._x1,y=t._y1;if(!d)return t._root=p,t;for(;d.length;){if((c=e>=(o=(m+v)/2))?m=o:v=o,(l=n>=(a=(g+y)/2))?g=a:y=a,i=d,!(d=d[f=l<<1|c]))return i[f]=p,t;}if(s=+t._x.call(null,d.data),u=+t._y.call(null,d.data),e===s&&n===u)return p.next=d,i?i[f]=p:t._root=p,t;do{i=i?i[f]=new Array(4):t._root=new Array(4),(c=e>=(o=(m+v)/2))?m=o:v=o,(l=n>=(a=(g+y)/2))?g=a:y=a;}while((f=l<<1|c)==(h=(u>=a)<<1|s>=o));return i[h]=d,i[f]=p,t;}var gb=function gb(t,e,n,r,i){this.node=t,this.x0=e,this.y0=n,this.x1=r,this.y1=i;};function vb(t){return t[0];}function yb(t){return t[1];}function bb(t,e,n){var r=new xb(null==e?vb:e,null==n?yb:n,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t);}function xb(t,e,n,r,i,o){this._x=t,this._y=e,this._x0=n,this._y0=r,this._x1=i,this._y1=o,this._root=void 0;}function wb(t){for(var e={data:t.data},n=e;t=t.next;){n=n.next={data:t.data};}return e;}var kb=bb.prototype=xb.prototype;kb.copy=function(){var t,e,n=new xb(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return n;if(!r.length)return n._root=wb(r),n;for(t=[{source:r,target:n._root=new Array(4)}];r=t.pop();){for(var i=0;i<4;++i){(e=r.source[i])&&(e.length?t.push({source:e,target:r.target[i]=new Array(4)}):r.target[i]=wb(e));}}return n;},kb.add=function(t){var e=+this._x.call(null,t),n=+this._y.call(null,t);return mb(this.cover(e,n),e,n,t);},kb.addAll=function(t){var e,n,r,i,o=t.length,a=new Array(o),s=new Array(o),u=1/0,c=1/0,l=-1/0,f=-1/0;for(n=0;n<o;++n){isNaN(r=+this._x.call(null,e=t[n]))||isNaN(i=+this._y.call(null,e))||(a[n]=r,s[n]=i,r<u&&(u=r),r>l&&(l=r),i<c&&(c=i),i>f&&(f=i));}if(u>l||c>f)return this;for(this.cover(u,c).cover(l,f),n=0;n<o;++n){mb(this,a[n],s[n],t[n]);}return this;},kb.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var n=this._x0,r=this._y0,i=this._x1,o=this._y1;if(isNaN(n))i=(n=Math.floor(t))+1,o=(r=Math.floor(e))+1;else {for(var a,s,u=i-n||1,c=this._root;n>t||t>=i||r>e||e>=o;){switch(s=(e<r)<<1|t<n,(a=new Array(4))[s]=c,c=a,u*=2,s){case 0:i=n+u,o=r+u;break;case 1:n=i-u,o=r+u;break;case 2:i=n+u,r=o-u;break;case 3:n=i-u,r=o-u;}}this._root&&this._root.length&&(this._root=c);}return this._x0=n,this._y0=r,this._x1=i,this._y1=o,this;},kb.data=function(){var t=[];return this.visit(function(e){if(!e.length)do{t.push(e.data);}while(e=e.next);}),t;},kb.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]];},kb.find=function(t,e,n){var r,i,o,a,s,u,c,l=this._x0,f=this._y0,h=this._x1,d=this._y1,p=[],m=this._root;for(m&&p.push(new gb(m,l,f,h,d)),null==n?n=1/0:(l=t-n,f=e-n,h=t+n,d=e+n,n*=n);u=p.pop();){if(!(!(m=u.node)||(i=u.x0)>h||(o=u.y0)>d||(a=u.x1)<l||(s=u.y1)<f))if(m.length){var g=(i+a)/2,v=(o+s)/2;p.push(new gb(m[3],g,v,a,s),new gb(m[2],i,v,g,s),new gb(m[1],g,o,a,v),new gb(m[0],i,o,g,v)),(c=(e>=v)<<1|t>=g)&&(u=p[p.length-1],p[p.length-1]=p[p.length-1-c],p[p.length-1-c]=u);}else {var y=t-+this._x.call(null,m.data),b=e-+this._y.call(null,m.data),x=y*y+b*b;if(x<n){var w=Math.sqrt(n=x);l=t-w,f=e-w,h=t+w,d=e+w,r=m.data;}}}return r;},kb.remove=function(t){if(isNaN(o=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t)))return this;var e,n,r,i,o,a,s,u,c,l,f,h,d=this._root,p=this._x0,m=this._y0,g=this._x1,v=this._y1;if(!d)return this;if(d.length)for(;;){if((c=o>=(s=(p+g)/2))?p=s:g=s,(l=a>=(u=(m+v)/2))?m=u:v=u,e=d,!(d=d[f=l<<1|c]))return this;if(!d.length)break;(e[f+1&3]||e[f+2&3]||e[f+3&3])&&(n=e,h=f);}for(;d.data!==t;){if(r=d,!(d=d.next))return this;}return (i=d.next)&&delete d.next,r?(i?r.next=i:delete r.next,this):e?(i?e[f]=i:delete e[f],(d=e[0]||e[1]||e[2]||e[3])&&d===(e[3]||e[2]||e[1]||e[0])&&!d.length&&(n?n[h]=d:this._root=d),this):(this._root=i,this);},kb.removeAll=function(t){for(var e=0,n=t.length;e<n;++e){this.remove(t[e]);}return this;},kb.root=function(){return this._root;},kb.size=function(){var t=0;return this.visit(function(e){if(!e.length)do{++t;}while(e=e.next);}),t;},kb.visit=function(t){var e,n,r,i,o,a,s=[],u=this._root;for(u&&s.push(new gb(u,this._x0,this._y0,this._x1,this._y1));e=s.pop();){if(!t(u=e.node,r=e.x0,i=e.y0,o=e.x1,a=e.y1)&&u.length){var c=(r+o)/2,l=(i+a)/2;(n=u[3])&&s.push(new gb(n,c,l,o,a)),(n=u[2])&&s.push(new gb(n,r,l,c,a)),(n=u[1])&&s.push(new gb(n,c,i,o,l)),(n=u[0])&&s.push(new gb(n,r,i,c,l));}}return this;},kb.visitAfter=function(t){var e,n=[],r=[];for(this._root&&n.push(new gb(this._root,this._x0,this._y0,this._x1,this._y1));e=n.pop();){var i=e.node;if(i.length){var o,a=e.x0,s=e.y0,u=e.x1,c=e.y1,l=(a+u)/2,f=(s+c)/2;(o=i[0])&&n.push(new gb(o,a,s,l,f)),(o=i[1])&&n.push(new gb(o,l,s,u,f)),(o=i[2])&&n.push(new gb(o,a,f,l,c)),(o=i[3])&&n.push(new gb(o,l,f,u,c));}r.push(e);}for(;e=r.pop();){t(e.node,e.x0,e.y0,e.x1,e.y1);}return this;},kb.x=function(t){return arguments.length?(this._x=t,this):this._x;},kb.y=function(t){return arguments.length?(this._y=t,this):this._y;};var Eb=function Eb(t){return function(){return t;};},Cb=function Cb(t){return 1e-6*(t()-.5);};function Ab(t){return t.x+t.vx;}function Ob(t){return t.y+t.vy;}var _b={value:function value(){}};function Sb(){for(var t,e=0,n=arguments.length,r={};e<n;++e){if(!(t=arguments[e]+"")||t in r||/[\s.]/.test(t))throw new Error("illegal type: "+t);r[t]=[];}return new Db(r);}function Db(t){this._=t;}function Fb(t,e){for(var n,r=0,i=t.length;r<i;++r){if((n=t[r]).name===e)return n.value;}}function Tb(t,e,n){for(var r=0,i=t.length;r<i;++r){if(t[r].name===e){t[r]=_b,t=t.slice(0,r).concat(t.slice(r+1));break;}}return null!=n&&t.push({name:e,value:n}),t;}Db.prototype=Sb.prototype={constructor:Db,on:function on(t,e){var n,r=this._,i=function(t,e){return t.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");if(r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return {type:t,name:n};});}(t+"",r),o=-1,a=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++o<a;){if(n=(t=i[o]).type)r[n]=Tb(r[n],t.name,e);else if(null==e)for(n in r){r[n]=Tb(r[n],t.name,null);}}return this;}for(;++o<a;){if((n=(t=i[o]).type)&&(n=Fb(r[n],t.name)))return n;}},copy:function copy(){var t={},e=this._;for(var n in e){t[n]=e[n].slice();}return new Db(t);},call:function call(t,e){if((n=arguments.length-2)>0)for(var n,r,i=new Array(n),o=0;o<n;++o){i[o]=arguments[o+2];}if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(o=0,n=(r=this._[t]).length;o<n;++o){r[o].value.apply(e,i);}},apply:function apply(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var r=this._[t],i=0,o=r.length;i<o;++i){r[i].value.apply(e,n);}}};var Nb,Ib,Rb=Sb,Mb=0,jb=0,Bb=0,Pb=1e3,Lb=0,zb=0,Ub=0,Wb="object"==(typeof performance==="undefined"?"undefined":_typeof$1(performance))&&performance.now?performance:Date,Vb="object"==(typeof window==="undefined"?"undefined":_typeof$1(window))&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17);};function qb(){return zb||(Vb($b),zb=Wb.now()+Ub);}function $b(){zb=0;}function Hb(){this._call=this._time=this._next=null;}function Gb(t,e,n){var r=new Hb();return r.restart(t,e,n),r;}function Kb(){zb=(Lb=Wb.now())+Ub,Mb=jb=0;try{!function(){qb(),++Mb;for(var t,e=Nb;e;){(t=zb-e._time)>=0&&e._call.call(null,t),e=e._next;}--Mb;}();}finally{Mb=0,function(){var t,e,n=Nb,r=1/0;for(;n;){n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Nb=e);}Ib=t,Yb(r);}(),zb=0;}}function Xb(){var t=Wb.now(),e=t-Lb;e>Pb&&(Ub-=e,Lb=t);}function Yb(t){Mb||(jb&&(jb=clearTimeout(jb)),t-zb>24?(t<1/0&&(jb=setTimeout(Kb,t-Wb.now()-Ub)),Bb&&(Bb=clearInterval(Bb))):(Bb||(Lb=Wb.now(),Bb=setInterval(Xb,Pb)),Mb=1,Vb(Kb)));}Hb.prototype=Gb.prototype={constructor:Hb,restart:function restart(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?qb():+n)+(null==e?0:+e),this._next||Ib===this||(Ib?Ib._next=this:Nb=this,Ib=this),this._call=t,this._time=n,Yb();},stop:function stop(){this._call&&(this._call=null,this._time=1/0,Yb());}};function Jb(t){return t.x;}function Qb(t){return t.y;}var Zb=10,tx=Math.PI*(3-Math.sqrt(5)),ex=function ex(t){var e,n=1,r=.001,i=1-Math.pow(r,1/300),o=0,a=.6,s=new Map(),u=Gb(f),c=Rb("tick","end"),l=function(){var t=1;return function(){return (t=(1664525*t+1013904223)%4294967296)/4294967296;};}();function f(){h(),c.call("tick",e),n<r&&(u.stop(),c.call("end",e));}function h(r){var u,c,l=t.length;void 0===r&&(r=1);for(var f=0;f<r;++f){for(n+=(o-n)*i,s.forEach(function(t){t(n);}),u=0;u<l;++u){null==(c=t[u]).fx?c.x+=c.vx*=a:(c.x=c.fx,c.vx=0),null==c.fy?c.y+=c.vy*=a:(c.y=c.fy,c.vy=0);}}return e;}function d(){for(var e,n=0,r=t.length;n<r;++n){if((e=t[n]).index=n,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var i=Zb*Math.sqrt(.5+n),o=n*tx;e.x=i*Math.cos(o),e.y=i*Math.sin(o);}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0);}}function p(e){return e.initialize&&e.initialize(t,l),e;}return null==t&&(t=[]),d(),e={tick:h,restart:function restart(){return u.restart(f),e;},stop:function stop(){return u.stop(),e;},nodes:function nodes(n){return arguments.length?(t=n,d(),s.forEach(p),e):t;},alpha:function alpha(t){return arguments.length?(n=+t,e):n;},alphaMin:function alphaMin(t){return arguments.length?(r=+t,e):r;},alphaDecay:function alphaDecay(t){return arguments.length?(i=+t,e):+i;},alphaTarget:function alphaTarget(t){return arguments.length?(o=+t,e):o;},velocityDecay:function velocityDecay(t){return arguments.length?(a=1-t,e):1-a;},randomSource:function randomSource(t){return arguments.length?(l=t,s.forEach(p),e):l;},force:function force(t,n){return arguments.length>1?(null==n?s.delete(t):s.set(t,p(n)),e):s.get(t);},find:function find(e,n,r){var i,o,a,s,u,c=0,l=t.length;for(null==r?r=1/0:r*=r,c=0;c<l;++c){(a=(i=e-(s=t[c]).x)*i+(o=n-s.y)*o)<r&&(u=s,r=a);}return u;},on:function on(t,n){return arguments.length>1?(c.on(t,n),e):c.on(t);}};};function nx(t){return t.index;}function rx(t,e){var n=t.get(e);if(!n)throw new Error("node not found: "+e);return n;}var ix={center:function center(t,e){var n,r=1;function i(){var i,o,a=n.length,s=0,u=0;for(i=0;i<a;++i){s+=(o=n[i]).x,u+=o.y;}for(s=(s/a-t)*r,u=(u/a-e)*r,i=0;i<a;++i){(o=n[i]).x-=s,o.y-=u;}}return null==t&&(t=0),null==e&&(e=0),i.initialize=function(t){n=t;},i.x=function(e){return arguments.length?(t=+e,i):t;},i.y=function(t){return arguments.length?(e=+t,i):e;},i.strength=function(t){return arguments.length?(r=+t,i):r;},i;},collide:function collide(t){var e,n,r,i=1,o=1;function a(){for(var t,a,u,c,l,f,h,d=e.length,p=0;p<o;++p){for(a=bb(e,Ab,Ob).visitAfter(s),t=0;t<d;++t){u=e[t],f=n[u.index],h=f*f,c=u.x+u.vx,l=u.y+u.vy,a.visit(m);}}function m(t,e,n,o,a){var s=t.data,d=t.r,p=f+d;if(!s)return e>c+p||o<c-p||n>l+p||a<l-p;if(s.index>u.index){var m=c-s.x-s.vx,g=l-s.y-s.vy,v=m*m+g*g;v<p*p&&(0===m&&(v+=(m=Cb(r))*m),0===g&&(v+=(g=Cb(r))*g),v=(p-(v=Math.sqrt(v)))/v*i,u.vx+=(m*=v)*(p=(d*=d)/(h+d)),u.vy+=(g*=v)*p,s.vx-=m*(p=1-p),s.vy-=g*p);}}}function s(t){if(t.data)return t.r=n[t.data.index];for(var e=t.r=0;e<4;++e){t[e]&&t[e].r>t.r&&(t.r=t[e].r);}}function u(){if(e){var r,i,o=e.length;for(n=new Array(o),r=0;r<o;++r){i=e[r],n[i.index]=+t(i,r,e);}}}return "function"!=typeof t&&(t=Eb(null==t?1:+t)),a.initialize=function(t,n){e=t,r=n,u();},a.iterations=function(t){return arguments.length?(o=+t,a):o;},a.strength=function(t){return arguments.length?(i=+t,a):i;},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:Eb(+e),u(),a):t;},a;},nbody:function nbody(){var t,e,n,r,i,o=Eb(-30),a=1,s=1/0,u=.81;function c(n){var i,o=t.length,a=bb(t,Jb,Qb).visitAfter(f);for(r=n,i=0;i<o;++i){e=t[i],a.visit(h);}}function l(){if(t){var e,n,r=t.length;for(i=new Array(r),e=0;e<r;++e){n=t[e],i[n.index]=+o(n,e,t);}}}function f(t){var e,n,r,o,a,s=0,u=0;if(t.length){for(r=o=a=0;a<4;++a){(e=t[a])&&(n=Math.abs(e.value))&&(s+=e.value,u+=n,r+=n*e.x,o+=n*e.y);}t.x=r/u,t.y=o/u;}else {(e=t).x=e.data.x,e.y=e.data.y;do{s+=i[e.data.index];}while(e=e.next);}t.value=s;}function h(t,o,c,l){if(!t.value)return !0;var f=t.x-e.x,h=t.y-e.y,d=l-o,p=f*f+h*h;if(d*d/u<p)return p<s&&(0===f&&(p+=(f=Cb(n))*f),0===h&&(p+=(h=Cb(n))*h),p<a&&(p=Math.sqrt(a*p)),e.vx+=f*t.value*r/p,e.vy+=h*t.value*r/p),!0;if(!(t.length||p>=s)){(t.data!==e||t.next)&&(0===f&&(p+=(f=Cb(n))*f),0===h&&(p+=(h=Cb(n))*h),p<a&&(p=Math.sqrt(a*p)));do{t.data!==e&&(d=i[t.data.index]*r/p,e.vx+=f*d,e.vy+=h*d);}while(t=t.next);}}return c.initialize=function(e,r){t=e,n=r,l();},c.strength=function(t){return arguments.length?(o="function"==typeof t?t:Eb(+t),l(),c):o;},c.distanceMin=function(t){return arguments.length?(a=t*t,c):Math.sqrt(a);},c.distanceMax=function(t){return arguments.length?(s=t*t,c):Math.sqrt(s);},c.theta=function(t){return arguments.length?(u=t*t,c):Math.sqrt(u);},c;},link:function link(t){var e,n,r,i,o,a,s=nx,u=function u(t){return 1/Math.min(i[t.source.index],i[t.target.index]);},c=Eb(30),l=1;function f(r){for(var i=0,s=t.length;i<l;++i){for(var u,c,f,h,d,p,m,g=0;g<s;++g){c=(u=t[g]).source,h=(f=u.target).x+f.vx-c.x-c.vx||Cb(a),d=f.y+f.vy-c.y-c.vy||Cb(a),h*=p=((p=Math.sqrt(h*h+d*d))-n[g])/p*r*e[g],d*=p,f.vx-=h*(m=o[g]),f.vy-=d*m,c.vx+=h*(m=1-m),c.vy+=d*m;}}}function h(){if(r){var a,u,c=r.length,l=t.length,f=new Map(r.map(function(t,e){return [s(t,e,r),t];}));for(a=0,i=new Array(c);a<l;++a){(u=t[a]).index=a,"object"!=_typeof$1(u.source)&&(u.source=rx(f,u.source)),"object"!=_typeof$1(u.target)&&(u.target=rx(f,u.target)),i[u.source.index]=(i[u.source.index]||0)+1,i[u.target.index]=(i[u.target.index]||0)+1;}for(a=0,o=new Array(l);a<l;++a){u=t[a],o[a]=i[u.source.index]/(i[u.source.index]+i[u.target.index]);}e=new Array(l),d(),n=new Array(l),p();}}function d(){if(r)for(var n=0,i=t.length;n<i;++n){e[n]=+u(t[n],n,t);}}function p(){if(r)for(var e=0,i=t.length;e<i;++e){n[e]=+c(t[e],e,t);}}return null==t&&(t=[]),f.initialize=function(t,e){r=t,a=e,h();},f.links=function(e){return arguments.length?(t=e,h(),f):t;},f.id=function(t){return arguments.length?(s=t,f):s;},f.iterations=function(t){return arguments.length?(l=+t,f):l;},f.strength=function(t){return arguments.length?(u="function"==typeof t?t:Eb(+t),d(),f):u;},f.distance=function(t){return arguments.length?(c="function"==typeof t?t:Eb(+t),p(),f):c;},f;},x:function x(t){var e,n,r,i=Eb(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o){(i=e[o]).vx+=(r[o]-i.x)*n[o]*t;}}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o){n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e);}}}return "function"!=typeof t&&(t=Eb(null==t?0:+t)),o.initialize=function(t){e=t,a();},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Eb(+t),a(),o):i;},o.x=function(e){return arguments.length?(t="function"==typeof e?e:Eb(+e),a(),o):t;},o;},y:function y(t){var e,n,r,i=Eb(.1);function o(t){for(var i,o=0,a=e.length;o<a;++o){(i=e[o]).vy+=(r[o]-i.y)*n[o]*t;}}function a(){if(e){var o,a=e.length;for(n=new Array(a),r=new Array(a),o=0;o<a;++o){n[o]=isNaN(r[o]=+t(e[o],o,e))?0:+i(e[o],o,e);}}}return "function"!=typeof t&&(t=Eb(null==t?0:+t)),o.initialize=function(t){e=t,a();},o.strength=function(t){return arguments.length?(i="function"==typeof t?t:Eb(+t),a(),o):i;},o.y=function(e){return arguments.length?(t="function"==typeof e?e:Eb(+e),a(),o):t;},o;}},ox="forces",ax=["alpha","alphaMin","alphaTarget","velocityDecay","forces"],sx=["static","iterations"],ux=["x","y","vx","vy"];function cx(t){zt.call(this,null,t);}function lx(t,e,n,r){var i,o,a,s,u=Object(Z.i)(e.forces);for(i=0,o=ax.length;i<o;++i){(a=ax[i])!==ox&&e.modified(a)&&t[a](e[a]);}for(i=0,o=u.length;i<o;++i){s=ox+i,(a=n||e.modified(ox,i)?hx(u[i]):r&&fx(u[i],r)?t.force(s):null)&&t.force(s,a);}for(o=t.numForces||0;i<o;++i){t.force(ox+i,null);}return t.numForces=u.length,t;}function fx(t,e){var n,r;for(n in t){if(Object(Z.E)(r=t[n])&&e.modified(Object(Z.g)(r)))return 1;}return 0;}function hx(t){var e,n;for(n in Object(Z.w)(ix,t.force)||Object(Z.o)("Unrecognized force: "+t.force),e=ix[t.force](),t){Object(Z.E)(e[n])&&dx(e[n],t[n],t);}return e;}function dx(t,e,n){t(Object(Z.E)(e)?function(t){return e(t,n);}:e);}function px(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;){e+=n[r].value;}else e=1;t.value=e;}cx.Definition={type:"Force",metadata:{modifies:!0},params:[{name:"static",type:"boolean",default:!1},{name:"restart",type:"boolean",default:!1},{name:"iterations",type:"number",default:300},{name:"alpha",type:"number",default:1},{name:"alphaMin",type:"number",default:.001},{name:"alphaTarget",type:"number",default:0},{name:"velocityDecay",type:"number",default:.4},{name:"forces",type:"param",array:!0,params:[{key:{force:"center"},params:[{name:"x",type:"number",default:0},{name:"y",type:"number",default:0}]},{key:{force:"collide"},params:[{name:"radius",type:"number",expr:!0},{name:"strength",type:"number",default:.7},{name:"iterations",type:"number",default:1}]},{key:{force:"nbody"},params:[{name:"strength",type:"number",default:-30},{name:"theta",type:"number",default:.9},{name:"distanceMin",type:"number",default:1},{name:"distanceMax",type:"number"}]},{key:{force:"link"},params:[{name:"links",type:"data"},{name:"id",type:"field"},{name:"distance",type:"number",default:30,expr:!0},{name:"strength",type:"number",expr:!0},{name:"iterations",type:"number",default:1}]},{key:{force:"x"},params:[{name:"strength",type:"number",default:.1},{name:"x",type:"field"}]},{key:{force:"y"},params:[{name:"strength",type:"number",default:.1},{name:"y",type:"field"}]}]},{name:"as",type:"string",array:!0,modify:!1,default:ux}]},Object(Z.z)(cx,zt,{transform:function transform(t,e){var n=this.value,r=e.changed(e.ADD_REM),i=t.modified(ax),o=t.iterations||300;if(n?(r&&(e.modifies("index"),n.nodes(e.source)),(i||e.changed(e.MOD))&&lx(n,t,0,e)):(this.value=n=function(t,e){var n=ex(t),r=n.stop,i=n.restart;var o=!1;return n.stopped=function(){return o;},n.restart=function(){return o=!1,i();},n.stop=function(){return o=!0,r();},lx(n,e,!0).on("end",function(){return o=!0;});}(e.source,t),n.on("tick",function(t,e){return function(){return t.touch(e).run();};}(e.dataflow,this)),t.static||(r=!0,n.tick()),e.modifies("index")),i||r||t.modified(sx)||e.changed()&&t.restart)if(n.alpha(Math.max(n.alpha(),t.alpha||1)).alphaDecay(1-Math.pow(n.alphaMin(),1/o)),t.static)for(n.stop();--o>=0;){n.tick();}else if(n.stopped()&&n.restart(),!r)return e.StopPropagation;return this.finish(t,e);},finish:function finish(t,e){var n=e.dataflow;for(var _t69,_e67=this._argops,_s25=0,_u13=_e67.length;_s25<_u13;++_s25){if((_t69=_e67[_s25]).name===ox&&"link"===_t69.op._argval.force)for(var r,i=_t69.op._argops,o=0,a=i.length;o<a;++o){if("links"===i[o].name&&(r=i[o].op.source)){n.pulse(r,n.changeset().reflow());break;}}}return e.reflow(t.modified()).modifies(ux);}});function mx(t,e){t instanceof Map?(t=[void 0,t],void 0===e&&(e=vx)):void 0===e&&(e=gx);for(var n,r,i,o,a,s=new xx(t),u=[s];n=u.pop();){if((i=e(n.data))&&(a=(i=Array.from(i)).length))for(n.children=i,o=a-1;o>=0;--o){u.push(r=i[o]=new xx(i[o])),r.parent=n,r.depth=n.depth+1;}}return s.eachBefore(bx);}function gx(t){return t.children;}function vx(t){return Array.isArray(t)?t[1]:null;}function yx(t){void 0!==t.data.value&&(t.value=t.data.value),t.data=t.data.data;}function bx(t){var e=0;do{t.height=e;}while((t=t.parent)&&t.height<++e);}function xx(t){this.data=t,this.depth=this.height=0,this.parent=null;}xx.prototype=mx.prototype=_defineProperty({constructor:xx,count:function count(){return this.eachAfter(px);},each:function each(t,e){var n=-1;var _iterator23=_createForOfIteratorHelper(this),_step23;try{for(_iterator23.s();!(_step23=_iterator23.n()).done;){var _r61=_step23.value;t.call(e,_r61,++n,this);}}catch(err){_iterator23.e(err);}finally{_iterator23.f();}return this;},eachAfter:function eachAfter(t,e){for(var n,r,i,o=this,a=[o],s=[],u=-1;o=a.pop();){if(s.push(o),n=o.children)for(r=0,i=n.length;r<i;++r){a.push(n[r]);}}for(;o=s.pop();){t.call(e,o,++u,this);}return this;},eachBefore:function eachBefore(t,e){for(var n,r,i=this,o=[i],a=-1;i=o.pop();){if(t.call(e,i,++a,this),n=i.children)for(r=n.length-1;r>=0;--r){o.push(n[r]);}}return this;},find:function find(t,e){var n=-1;var _iterator24=_createForOfIteratorHelper(this),_step24;try{for(_iterator24.s();!(_step24=_iterator24.n()).done;){var _r62=_step24.value;if(t.call(e,_r62,++n,this))return _r62;}}catch(err){_iterator24.e(err);}finally{_iterator24.f();}},sum:function sum(t){return this.eachAfter(function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;){n+=r[i].value;}e.value=n;});},sort:function sort(t){return this.eachBefore(function(e){e.children&&e.children.sort(t);});},path:function path(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;for(t=n.pop(),e=r.pop();t===e;){i=t,t=n.pop(),e=r.pop();}return i;}(e,t),r=[e];e!==n;){e=e.parent,r.push(e);}for(var i=r.length;t!==n;){r.splice(i,0,t),t=t.parent;}return r;},ancestors:function ancestors(){for(var t=this,e=[t];t=t.parent;){e.push(t);}return e;},descendants:function descendants(){return Array.from(this);},leaves:function leaves(){var t=[];return this.eachBefore(function(e){e.children||t.push(e);}),t;},links:function links(){var t=this,e=[];return t.each(function(n){n!==t&&e.push({source:n.parent,target:n});}),e;},copy:function copy(){return mx(this).eachBefore(yx);}},Symbol.iterator,/*#__PURE__*/regeneratorRuntime.mark(function _callee13(){var t,e,n,r,i,o;return regeneratorRuntime.wrap(function _callee13$(_context14){while(1){switch(_context14.prev=_context14.next){case 0:i=this,o=[i];case 1:t=o.reverse(),o=[];case 2:if(!(i=t.pop())){_context14.next=9;break;}_context14.next=5;return i;case 5:if(!(e=i.children)){_context14.next=7;break;}for(n=0,r=e.length;n<r;++n){o.push(e[n]);}case 7:_context14.next=2;break;case 9:if(o.length){_context14.next=1;break;}case 10:case"end":return _context14.stop();}}},_callee13,this);}));var wx=function wx(t){return "object"==_typeof$1(t)&&"length"in t?t:Array.from(t);};var kx=function kx(t){for(var e,n,r=0,i=(t=function(t){for(var e,n,r=t.length;r;){n=Math.random()*r--|0,e=t[r],t[r]=t[n],t[n]=e;}return t;}(Array.from(t))).length,o=[];r<i;){e=t[r],n&&Ax(n,e)?++r:(n=_x(o=Ex(o,e)),r=0);}return n;};function Ex(t,e){var n,r;if(Ox(e,t))return [e];for(n=0;n<t.length;++n){if(Cx(e,t[n])&&Ox(Sx(t[n],e),t))return [t[n],e];}for(n=0;n<t.length-1;++n){for(r=n+1;r<t.length;++r){if(Cx(Sx(t[n],t[r]),e)&&Cx(Sx(t[n],e),t[r])&&Cx(Sx(t[r],e),t[n])&&Ox(Dx(t[n],t[r],e),t))return [t[n],t[r],e];}}throw new Error();}function Cx(t,e){var n=t.r-e.r,r=e.x-t.x,i=e.y-t.y;return n<0||n*n<r*r+i*i;}function Ax(t,e){var n=t.r-e.r+1e-9*Math.max(t.r,e.r,1),r=e.x-t.x,i=e.y-t.y;return n>0&&n*n>r*r+i*i;}function Ox(t,e){for(var n=0;n<e.length;++n){if(!Ax(t,e[n]))return !1;}return !0;}function _x(t){switch(t.length){case 1:return function(t){return {x:t.x,y:t.y,r:t.r};}(t[0]);case 2:return Sx(t[0],t[1]);case 3:return Dx(t[0],t[1],t[2]);}}function Sx(t,e){var n=t.x,r=t.y,i=t.r,o=e.x,a=e.y,s=e.r,u=o-n,c=a-r,l=s-i,f=Math.sqrt(u*u+c*c);return {x:(n+o+u/f*l)/2,y:(r+a+c/f*l)/2,r:(f+i+s)/2};}function Dx(t,e,n){var r=t.x,i=t.y,o=t.r,a=e.x,s=e.y,u=e.r,c=n.x,l=n.y,f=n.r,h=r-a,d=r-c,p=i-s,m=i-l,g=u-o,v=f-o,y=r*r+i*i-o*o,b=y-a*a-s*s+u*u,x=y-c*c-l*l+f*f,w=d*p-h*m,k=(p*x-m*b)/(2*w)-r,E=(m*g-p*v)/w,C=(d*b-h*x)/(2*w)-i,A=(h*v-d*g)/w,O=E*E+A*A-1,_=2*(o+k*E+C*A),S=k*k+C*C-o*o,D=-(O?(_+Math.sqrt(_*_-4*O*S))/(2*O):S/_);return {x:r+k+E*D,y:i+C+A*D,r:D};}function Fx(t,e,n){var r,i,o,a,s=t.x-e.x,u=t.y-e.y,c=s*s+u*u;c?(i=e.r+n.r,i*=i,a=t.r+n.r,i>(a*=a)?(r=(c+a-i)/(2*c),o=Math.sqrt(Math.max(0,a/c-r*r)),n.x=t.x-r*s-o*u,n.y=t.y-r*u+o*s):(r=(c+i-a)/(2*c),o=Math.sqrt(Math.max(0,i/c-r*r)),n.x=e.x+r*s-o*u,n.y=e.y+r*u+o*s)):(n.x=e.x+n.r,n.y=e.y);}function Tx(t,e){var n=t.r+e.r-1e-6,r=e.x-t.x,i=e.y-t.y;return n>0&&n*n>r*r+i*i;}function Nx(t){var e=t._,n=t.next._,r=e.r+n.r,i=(e.x*n.r+n.x*e.r)/r,o=(e.y*n.r+n.y*e.r)/r;return i*i+o*o;}function Ix(t){this._=t,this.next=null,this.previous=null;}function Rx(t){if(!(i=(t=wx(t)).length))return 0;var e,n,r,i,o,a,s,u,c,l,f;if((e=t[0]).x=0,e.y=0,!(i>1))return e.r;if(n=t[1],e.x=-n.r,n.x=e.r,n.y=0,!(i>2))return e.r+n.r;Fx(n,e,r=t[2]),e=new Ix(e),n=new Ix(n),r=new Ix(r),e.next=r.previous=n,n.next=e.previous=r,r.next=n.previous=e;t:for(s=3;s<i;++s){Fx(e._,n._,r=t[s]),r=new Ix(r),u=n.next,c=e.previous,l=n._.r,f=e._.r;do{if(l<=f){if(Tx(u._,r._)){n=u,e.next=n,n.previous=e,--s;continue t;}l+=u._.r,u=u.next;}else {if(Tx(c._,r._)){(e=c).next=n,n.previous=e,--s;continue t;}f+=c._.r,c=c.previous;}}while(u!==c.next);for(r.previous=e,r.next=n,e.next=n.previous=n=r,o=Nx(e);(r=r.next)!==n;){(a=Nx(r))<o&&(e=r,o=a);}n=e.next;}for(e=[n._],r=n;(r=r.next)!==n;){e.push(r._);}for(r=kx(e),s=0;s<i;++s){(e=t[s]).x-=r.x,e.y-=r.y;}return r.r;}function Mx(t){if("function"!=typeof t)throw new Error();return t;}function jx(){return 0;}var Bx=function Bx(t){return function(){return t;};};function Px(t){return Math.sqrt(t.value);}function Lx(t){return function(e){e.children||(e.r=Math.max(0,+t(e)||0));};}function zx(t,e){return function(n){if(r=n.children){var r,i,o,a=r.length,s=t(n)*e||0;if(s)for(i=0;i<a;++i){r[i].r+=s;}if(o=Rx(r),s)for(i=0;i<a;++i){r[i].r-=s;}n.r=o+s;}};}function Ux(t){return function(e){var n=e.parent;e.r*=t,n&&(e.x=n.x+t*e.x,e.y=n.y+t*e.y);};}var Wx=function Wx(t){t.x0=Math.round(t.x0),t.y0=Math.round(t.y0),t.x1=Math.round(t.x1),t.y1=Math.round(t.y1);},Vx=function Vx(t,e,n,r,i){for(var o,a=t.children,s=-1,u=a.length,c=t.value&&(r-e)/t.value;++s<u;){(o=a[s]).y0=n,o.y1=i,o.x0=e,o.x1=e+=o.value*c;}},qx={depth:-1},$x={};function Hx(t){return t.id;}function Gx(t){return t.parentId;}var Kx=function Kx(){var t=Hx,e=Gx;function n(n){var r,i,o,a,s,u,c,l=Array.from(n),f=l.length,h=new Map();for(i=0;i<f;++i){r=l[i],s=l[i]=new xx(r),null!=(u=t(r,i,n))&&(u+="")&&(c=s.id=u,h.set(c,h.has(c)?$x:s)),null!=(u=e(r,i,n))&&(u+="")&&(s.parent=u);}for(i=0;i<f;++i){if(u=(s=l[i]).parent){if(!(a=h.get(u)))throw new Error("missing: "+u);if(a===$x)throw new Error("ambiguous: "+u);a.children?a.children.push(s):a.children=[s],s.parent=a;}else {if(o)throw new Error("multiple roots");o=s;}}if(!o)throw new Error("no root");if(o.parent=qx,o.eachBefore(function(t){t.depth=t.parent.depth+1,--f;}).eachBefore(bx),o.parent=null,f>0)throw new Error("cycle");return o;}return n.id=function(e){return arguments.length?(t=Mx(e),n):t;},n.parentId=function(t){return arguments.length?(e=Mx(t),n):e;},n;};function Xx(t,e){return t.parent===e.parent?1:2;}function Yx(t){var e=t.children;return e?e[0]:t.t;}function Jx(t){var e=t.children;return e?e[e.length-1]:t.t;}function Qx(t,e,n){var r=n/(e.i-t.i);e.c-=r,e.s+=n,t.c+=r,e.z+=n,e.m+=n;}function Zx(t,e,n){return t.a.parent===e.parent?t.a:n;}function tw(t,e){this._=t,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=e;}tw.prototype=Object.create(xx.prototype);function ew(t,e){return t.parent===e.parent?1:2;}function nw(t,e){return t+e.x;}function rw(t,e){return Math.max(t,e.y);}var iw=function iw(t,e,n,r,i){for(var o,a=t.children,s=-1,u=a.length,c=t.value&&(i-n)/t.value;++s<u;){(o=a[s]).x0=e,o.x1=r,o.y0=n,o.y1=n+=o.value*c;}},ow=(1+Math.sqrt(5))/2;function aw(t,e,n,r,i,o){for(var a,s,u,c,l,f,h,d,p,m,g,v=[],y=e.children,b=0,x=0,w=y.length,k=e.value;b<w;){u=i-n,c=o-r;do{l=y[x++].value;}while(!l&&x<w);for(f=h=l,g=l*l*(m=Math.max(c/u,u/c)/(k*t)),p=Math.max(h/g,g/f);x<w;++x){if(l+=s=y[x].value,s<f&&(f=s),s>h&&(h=s),g=l*l*m,(d=Math.max(h/g,g/f))>p){l-=s;break;}p=d;}v.push(a={value:l,dice:u<c,children:y.slice(b,x)}),a.dice?Vx(a,n,r,i,k?r+=c*l/k:o):iw(a,n,r,k?n+=u*l/k:i,o),k-=l,b=x;}return v;}var sw=function t(e){function n(t,n,r,i,o){aw(e,t,n,r,i,o);}return n.ratio=function(e){return t((e=+e)>1?e:1);},n;}(ow),uw=function t(e){function n(t,n,r,i,o){if((a=t._squarify)&&a.ratio===e)for(var a,s,u,c,l,f=-1,h=a.length,d=t.value;++f<h;){for(u=(s=a[f]).children,c=s.value=0,l=u.length;c<l;++c){s.value+=u[c].value;}s.dice?Vx(s,n,r,i,d?r+=(o-r)*s.value/d:o):iw(s,n,r,d?n+=(i-n)*s.value/d:i,o),d-=s.value;}else t._squarify=a=aw(e,t,n,r,i,o),a.ratio=e;}return n.ratio=function(e){return t((e=+e)>1?e:1);},n;}(ow);function cw(t,e,n){var r={};return t.each(function(t){var i=t.data;n(i)&&(r[e(i)]=t);}),t.lookup=r,t;}function lw(t){zt.call(this,null,t);}lw.Definition={type:"Nest",metadata:{treesource:!0,changes:!0},params:[{name:"keys",type:"field",array:!0},{name:"generate",type:"boolean"}]};var fw=function fw(t){return t.values;};function hw(t){zt.call(this,null,t);}Object(Z.z)(lw,zt,{transform:function transform(t,e){e.source||Object(Z.o)("Nest transform requires an upstream data source.");var n=t.generate,r=t.modified(),i=e.clone(),o=this.value;return (!o||r||e.changed())&&(o&&o.each(function(t){t.children&&at(t.data)&&i.rem.push(t.data);}),this.value=o=mx({values:Object(Z.i)(t.keys).reduce(function(t,e){return t.key(e),t;},function(){var t=[],e={entries:function entries(e){return function e(n,r){if(++r>t.length)return n;var i=[];for(var _t70 in n){i.push({key:_t70,values:e(n[_t70],r)});}return i;}(function e(n,r){if(r>=t.length)return n;var i=n.length,o=t[r++],a={},s={};var u,c,l,f=-1;for(;++f<i;){u=o(c=n[f])+"",(l=a[u])?l.push(c):a[u]=[c];}for(u in a){s[u]=e(a[u],r);}return s;}(e,0),0);},key:function key(n){return t.push(n),e;}};return e;}()).entries(i.source)},fw),n&&o.each(function(t){t.children&&(t=ct(t.data),i.add.push(t),i.source.push(t));}),cw(o,st,st)),i.source.root=o,i;}});var dw=function dw(t,e){return t.parent===e.parent?1:2;};Object(Z.z)(hw,zt,{transform:function transform(t,e){e.source&&e.source.root||Object(Z.o)(this.constructor.name+" transform requires a backing tree data source.");var n=this.layout(t.method),r=this.fields,i=e.source.root,o=t.as||r;t.field?i.sum(t.field):i.count(),t.sort&&i.sort(dt(t.sort,function(t){return t.data;})),function(t,e,n){for(var _r63,_i42=0,_o21=e.length;_i42<_o21;++_i42){(_r63=e[_i42])in n&&t[_r63](n[_r63]);}}(n,this.params,t),n.separation&&n.separation(!1!==t.separation?dw:Z.Q);try{this.value=n(i);}catch(t){Object(Z.o)(t);}return i.each(function(t){return function(t,e,n){var r=t.data,i=e.length-1;for(var _o22=0;_o22<i;++_o22){r[n[_o22]]=t[e[_o22]];}r[n[i]]=t.children?t.children.length:0;}(t,r,o);}),e.reflow(t.modified()).modifies(o).modifies("leaf");}});var pw=["x","y","r","depth","children"];function mw(t){hw.call(this,t);}mw.Definition={type:"Pack",metadata:{tree:!0,modifies:!0},params:[{name:"field",type:"field"},{name:"sort",type:"compare"},{name:"padding",type:"number",default:0},{name:"radius",type:"field",default:null},{name:"size",type:"number",array:!0,length:2},{name:"as",type:"string",array:!0,length:pw.length,default:pw}]},Object(Z.z)(mw,hw,{layout:function layout(){var t=null,e=1,n=1,r=jx;function i(i){return i.x=e/2,i.y=n/2,t?i.eachBefore(Lx(t)).eachAfter(zx(r,.5)).eachBefore(Ux(1)):i.eachBefore(Lx(Px)).eachAfter(zx(jx,1)).eachAfter(zx(r,i.r/Math.min(e,n))).eachBefore(Ux(Math.min(e,n)/(2*i.r))),i;}return i.radius=function(e){return arguments.length?(t=function(t){return null==t?null:Mx(t);}(e),i):t;},i.size=function(t){return arguments.length?(e=+t[0],n=+t[1],i):[e,n];},i.padding=function(t){return arguments.length?(r="function"==typeof t?t:Bx(+t),i):r;},i;},params:["radius","size","padding"],fields:pw});var gw=["x0","y0","x1","y1","depth","children"];function vw(t){hw.call(this,t);}function yw(t){zt.call(this,null,t);}vw.Definition={type:"Partition",metadata:{tree:!0,modifies:!0},params:[{name:"field",type:"field"},{name:"sort",type:"compare"},{name:"padding",type:"number",default:0},{name:"round",type:"boolean",default:!1},{name:"size",type:"number",array:!0,length:2},{name:"as",type:"string",array:!0,length:gw.length,default:gw}]},Object(Z.z)(vw,hw,{layout:function layout(){var t=1,e=1,n=0,r=!1;function i(i){var o=i.height+1;return i.x0=i.y0=n,i.x1=t,i.y1=e/o,i.eachBefore(function(t,e){return function(r){r.children&&Vx(r,r.x0,t*(r.depth+1)/e,r.x1,t*(r.depth+2)/e);var i=r.x0,o=r.y0,a=r.x1-n,s=r.y1-n;a<i&&(i=a=(i+a)/2),s<o&&(o=s=(o+s)/2),r.x0=i,r.y0=o,r.x1=a,r.y1=s;};}(e,o)),r&&i.eachBefore(Wx),i;}return i.round=function(t){return arguments.length?(r=!!t,i):r;},i.size=function(n){return arguments.length?(t=+n[0],e=+n[1],i):[t,e];},i.padding=function(t){return arguments.length?(n=+t,i):n;},i;},params:["size","round","padding"],fields:gw}),yw.Definition={type:"Stratify",metadata:{treesource:!0},params:[{name:"key",type:"field",required:!0},{name:"parentKey",type:"field",required:!0}]},Object(Z.z)(yw,zt,{transform:function transform(t,e){e.source||Object(Z.o)("Stratify transform requires an upstream data source.");var n=this.value;var r=t.modified(),i=e.fork(e.ALL).materialize(e.SOURCE),o=!n||r||e.changed(e.ADD_REM)||e.modified(t.key.fields)||e.modified(t.parentKey.fields);return i.source=i.source.slice(),o&&(n=i.source.length?cw(Kx().id(t.key).parentId(t.parentKey)(i.source),t.key,Z.Ia):cw(Kx()([{}]),t.key,t.key)),i.source.root=this.value=n,i;}});var bw={tidy:function tidy(){var t=Xx,e=1,n=1,r=null;function i(i){var u=function(t){for(var e,n,r,i,o,a=new tw(t,0),s=[a];e=s.pop();){if(r=e._.children)for(e.children=new Array(o=r.length),i=o-1;i>=0;--i){s.push(n=e.children[i]=new tw(r[i],i)),n.parent=e;}}return (a.parent=new tw(null,0)).children=[a],a;}(i);if(u.eachAfter(o),u.parent.m=-u.z,u.eachBefore(a),r)i.eachBefore(s);else {var c=i,l=i,f=i;i.eachBefore(function(t){t.x<c.x&&(c=t),t.x>l.x&&(l=t),t.depth>f.depth&&(f=t);});var h=c===l?1:t(c,l)/2,d=h-c.x,p=e/(l.x+h+d),m=n/(f.depth||1);i.eachBefore(function(t){t.x=(t.x+d)*p,t.y=t.depth*m;});}return i;}function o(e){var n=e.children,r=e.parent.children,i=e.i?r[e.i-1]:null;if(n){!function(t){for(var e,n=0,r=0,i=t.children,o=i.length;--o>=0;){(e=i[o]).z+=n,e.m+=n,n+=e.s+(r+=e.c);}}(e);var o=(n[0].z+n[n.length-1].z)/2;i?(e.z=i.z+t(e._,i._),e.m=e.z-o):e.z=o;}else i&&(e.z=i.z+t(e._,i._));e.parent.A=function(e,n,r){if(n){for(var i,o=e,a=e,s=n,u=o.parent.children[0],c=o.m,l=a.m,f=s.m,h=u.m;s=Jx(s),o=Yx(o),s&&o;){u=Yx(u),(a=Jx(a)).a=e,(i=s.z+f-o.z-c+t(s._,o._))>0&&(Qx(Zx(s,e,r),e,i),c+=i,l+=i),f+=s.m,c+=o.m,h+=u.m,l+=a.m;}s&&!Jx(a)&&(a.t=s,a.m+=f-l),o&&!Yx(u)&&(u.t=o,u.m+=c-h,r=e);}return r;}(e,i,e.parent.A||r[0]);}function a(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m;}function s(t){t.x*=e,t.y=t.depth*n;}return i.separation=function(e){return arguments.length?(t=e,i):t;},i.size=function(t){return arguments.length?(r=!1,e=+t[0],n=+t[1],i):r?null:[e,n];},i.nodeSize=function(t){return arguments.length?(r=!0,e=+t[0],n=+t[1],i):r?[e,n]:null;},i;},cluster:function cluster(){var t=ew,e=1,n=1,r=!1;function i(i){var o,a=0;i.eachAfter(function(e){var n=e.children;n?(e.x=function(t){return t.reduce(nw,0)/t.length;}(n),e.y=function(t){return 1+t.reduce(rw,0);}(n)):(e.x=o?a+=t(e,o):0,e.y=0,o=e);});var s=function(t){for(var e;e=t.children;){t=e[0];}return t;}(i),u=function(t){for(var e;e=t.children;){t=e[e.length-1];}return t;}(i),c=s.x-t(s,u)/2,l=u.x+t(u,s)/2;return i.eachAfter(r?function(t){t.x=(t.x-i.x)*e,t.y=(i.y-t.y)*n;}:function(t){t.x=(t.x-c)/(l-c)*e,t.y=(1-(i.y?t.y/i.y:1))*n;});}return i.separation=function(e){return arguments.length?(t=e,i):t;},i.size=function(t){return arguments.length?(r=!1,e=+t[0],n=+t[1],i):r?null:[e,n];},i.nodeSize=function(t){return arguments.length?(r=!0,e=+t[0],n=+t[1],i):r?[e,n]:null;},i;}},xw=["x","y","depth","children"];function ww(t){hw.call(this,t);}function kw(t){zt.call(this,[],t);}ww.Definition={type:"Tree",metadata:{tree:!0,modifies:!0},params:[{name:"field",type:"field"},{name:"sort",type:"compare"},{name:"method",type:"enum",default:"tidy",values:["tidy","cluster"]},{name:"size",type:"number",array:!0,length:2},{name:"nodeSize",type:"number",array:!0,length:2},{name:"separation",type:"boolean",default:!0},{name:"as",type:"string",array:!0,length:xw.length,default:xw}]},Object(Z.z)(ww,hw,{layout:function layout(t){var e=t||"tidy";if(Object(Z.w)(bw,e))return bw[e]();Object(Z.o)("Unrecognized Tree layout method: "+e);},params:["size","nodeSize"],fields:xw}),kw.Definition={type:"TreeLinks",metadata:{tree:!0,generates:!0,changes:!0},params:[]},Object(Z.z)(kw,zt,{transform:function transform(t,e){var n=this.value,r=e.source&&e.source.root,i=e.fork(e.NO_SOURCE),o={};return r||Object(Z.o)("TreeLinks transform requires a tree data source."),e.changed(e.ADD_REM)?(i.rem=n,e.visit(e.SOURCE,function(t){return o[st(t)]=1;}),r.each(function(t){var e=t.data,n=t.parent&&t.parent.data;n&&o[st(e)]&&o[st(n)]&&i.add.push(ct({source:n,target:e}));}),this.value=i.add):e.changed(e.MOD)&&(e.visit(e.MOD,function(t){return o[st(t)]=1;}),n.forEach(function(t){(o[st(t.source)]||o[st(t.target)])&&i.mod.push(t);})),i;}});var Ew={binary:function binary(t,e,n,r,i){var o,a,s=t.children,u=s.length,c=new Array(u+1);for(c[0]=a=o=0;o<u;++o){c[o+1]=a+=s[o].value;}!function t(e,n,r,i,o,a,u){if(e>=n-1){var l=s[e];return l.x0=i,l.y0=o,l.x1=a,void(l.y1=u);}for(var f=c[e],h=r/2+f,d=e+1,p=n-1;d<p;){var m=d+p>>>1;c[m]<h?d=m+1:p=m;}h-c[d-1]<c[d]-h&&e+1<d&&--d;var g=c[d]-f,v=r-g;if(a-i>u-o){var y=r?(i*v+a*g)/r:a;t(e,d,g,i,o,y,u),t(d,n,v,y,o,a,u);}else {var b=r?(o*v+u*g)/r:u;t(e,d,g,i,o,a,b),t(d,n,v,i,b,a,u);}}(0,u,t.value,e,n,r,i);},dice:Vx,slice:iw,slicedice:function slicedice(t,e,n,r,i){(1&t.depth?iw:Vx)(t,e,n,r,i);},squarify:sw,resquarify:uw},Cw=["x0","y0","x1","y1","depth","children"];function Aw(t){hw.call(this,t);}Aw.Definition={type:"Treemap",metadata:{tree:!0,modifies:!0},params:[{name:"field",type:"field"},{name:"sort",type:"compare"},{name:"method",type:"enum",default:"squarify",values:["squarify","resquarify","binary","dice","slice","slicedice"]},{name:"padding",type:"number",default:0},{name:"paddingInner",type:"number",default:0},{name:"paddingOuter",type:"number",default:0},{name:"paddingTop",type:"number",default:0},{name:"paddingRight",type:"number",default:0},{name:"paddingBottom",type:"number",default:0},{name:"paddingLeft",type:"number",default:0},{name:"ratio",type:"number",default:1.618033988749895},{name:"round",type:"boolean",default:!1},{name:"size",type:"number",array:!0,length:2},{name:"as",type:"string",array:!0,length:Cw.length,default:Cw}]},Object(Z.z)(Aw,hw,{layout:function layout(){var t=function(){var t=sw,e=!1,n=1,r=1,i=[0],o=jx,a=jx,s=jx,u=jx,c=jx;function l(t){return t.x0=t.y0=0,t.x1=n,t.y1=r,t.eachBefore(f),i=[0],e&&t.eachBefore(Wx),t;}function f(e){var n=i[e.depth],r=e.x0+n,l=e.y0+n,f=e.x1-n,h=e.y1-n;f<r&&(r=f=(r+f)/2),h<l&&(l=h=(l+h)/2),e.x0=r,e.y0=l,e.x1=f,e.y1=h,e.children&&(n=i[e.depth+1]=o(e)/2,r+=c(e)-n,l+=a(e)-n,f-=s(e)-n,h-=u(e)-n,f<r&&(r=f=(r+f)/2),h<l&&(l=h=(l+h)/2),t(e,r,l,f,h));}return l.round=function(t){return arguments.length?(e=!!t,l):e;},l.size=function(t){return arguments.length?(n=+t[0],r=+t[1],l):[n,r];},l.tile=function(e){return arguments.length?(t=Mx(e),l):t;},l.padding=function(t){return arguments.length?l.paddingInner(t).paddingOuter(t):l.paddingInner();},l.paddingInner=function(t){return arguments.length?(o="function"==typeof t?t:Bx(+t),l):o;},l.paddingOuter=function(t){return arguments.length?l.paddingTop(t).paddingRight(t).paddingBottom(t).paddingLeft(t):l.paddingTop();},l.paddingTop=function(t){return arguments.length?(a="function"==typeof t?t:Bx(+t),l):a;},l.paddingRight=function(t){return arguments.length?(s="function"==typeof t?t:Bx(+t),l):s;},l.paddingBottom=function(t){return arguments.length?(u="function"==typeof t?t:Bx(+t),l):u;},l.paddingLeft=function(t){return arguments.length?(c="function"==typeof t?t:Bx(+t),l):c;},l;}();return t.ratio=function(e){var n=t.tile();n.ratio&&t.tile(n.ratio(e));},t.method=function(e){Object(Z.w)(Ew,e)?t.tile(Ew[e]):Object(Z.o)("Unrecognized Treemap layout method: "+e);},t;},params:["method","ratio","size","round","padding","paddingInner","paddingOuter","paddingTop","paddingRight","paddingBottom","paddingLeft"],fields:Cw});var Ow=4278190080,_w=268435456,Sw=.0625;function Dw(t,e,n,r){var i=t.width,o=t.height,a=n||r,s=ji(i,o).getContext("2d");e.forEach(function(t){return function t(e,n,r){if(!n.length)return;var i=n[0].mark.marktype;"group"===i?n.forEach(function(n){n.items.forEach(function(n){return t(e,n.items,r);});}):nh[i].draw(e,{items:r?n.map(Fw):n});}(s,t,a);});var u=new Uint32Array(s.getImageData(0,0,i,o).data.buffer),c=t.bitmap(),l=a&&t.bitmap();var f,h,d,p,m;for(h=0;h<o;++h){for(f=0;f<i;++f){(m=u[h*i+f]&Ow)&&(d=t(f),p=t(h),r||c.set(d,p),a&&m^_w&&l.set(d,p));}}return [c,l];}function Fw(t){var e=ft(t,{});return e.stroke&&(e.strokeOpacity=1),e.fill&&(e.fillOpacity=Sw,e.stroke="#000",e.strokeOpacity=1,e.strokeWidth=2),e;}var Tw=5,Nw=31,Iw=32,Rw=new Uint32Array(Iw+1),Mw=new Uint32Array(Iw+1);Mw[0]=0,Rw[0]=~Mw[0];for(var _t71=1;_t71<=Iw;++_t71){Mw[_t71]=Mw[_t71-1]<<1|1,Rw[_t71]=~Mw[_t71];}function jw(t,e,n){var r=Math.max(1,Math.sqrt(t*e/1e6)),i=~~((t+2*n+r)/r),o=~~((e+2*n+r)/r),a=function a(t){return ~~((t+n)/r);};return a.invert=function(t){return t*r-n;},a.bitmap=function(){return function(t,e){var n=new Uint32Array(~~((t*e+Iw)/Iw));function r(t,e){n[t]|=e;}function i(t,e){n[t]&=e;}return {array:n,get:function get(e,r){var i=r*t+e;return n[i>>>Tw]&1<<(i&Nw);},set:function set(e,n){var i=n*t+e;r(i>>>Tw,1<<(i&Nw));},clear:function clear(e,n){var r=n*t+e;i(r>>>Tw,~(1<<(r&Nw)));},getRange:function getRange(e,r,i,o){var a,s,u,c,l=o;for(;l>=r;--l){if((u=(a=l*t+e)>>>Tw)==(c=(s=l*t+i)>>>Tw)){if(n[u]&Rw[a&Nw]&Mw[1+(s&Nw)])return !0;}else {if(n[u]&Rw[a&Nw])return !0;if(n[c]&Mw[1+(s&Nw)])return !0;for(var _t72=u+1;_t72<c;++_t72){if(n[_t72])return !0;}}}return !1;},setRange:function setRange(e,n,i,o){var a,s,u,c,l;for(;n<=o;++n){if((u=(a=n*t+e)>>>Tw)==(c=(s=n*t+i)>>>Tw))r(u,Rw[a&Nw]&Mw[1+(s&Nw)]);else for(r(u,Rw[a&Nw]),r(c,Mw[1+(s&Nw)]),l=u+1;l<c;++l){r(l,4294967295);}}},clearRange:function clearRange(e,n,r,o){var a,s,u,c,l;for(;n<=o;++n){if((u=(a=n*t+e)>>>Tw)==(c=(s=n*t+r)>>>Tw))i(u,Mw[a&Nw]|Rw[1+(s&Nw)]);else for(i(u,Mw[a&Nw]),i(c,Rw[1+(s&Nw)]),l=u+1;l<c;++l){i(l,0);}}},outOfBounds:function outOfBounds(n,r,i,o){return n<0||r<0||o>=e||i>=t;}};}(i,o);},a.ratio=r,a.padding=n,a.width=t,a.height=e,a;}function Bw(t,e,n,r,i,o){var a=n/2;return t-a<0||t+a>i||e-(a=r/2)<0||e+a>o;}function Pw(t,e,n,r,i,o,a,s){var u=i*o/(2*r),c=t(e-u),l=t(e+u),f=t(n-(o/=2)),h=t(n+o);return a.outOfBounds(c,f,l,h)||a.getRange(c,f,l,h)||s&&s.getRange(c,f,l,h);}var Lw=[-1,-1,1,1],zw=[-1,1,-1,1];var Uw=["right","center","left"],Ww=["bottom","middle","top"];function Vw(t,e,n,r,i,o,a,s,u,c,l,f){return !(i.outOfBounds(t,n,e,r)||(f&&o?o.getRange(t,n,e,r)||!function(t,e,n,r,i){return i[0]<=t&&n<=i[2]&&i[3]<=e&&r<=i[5];}(a,u,s,c,l):i.getRange(t,n,e,r)));}var qw={"top-left":0,top:1,"top-right":2,left:4,middle:5,right:6,"bottom-left":8,bottom:9,"bottom-right":10},$w={naive:function naive(t,e,n,r){var i=t.width,o=t.height;return function(t){var e=t.datum.datum.items[r].items,n=e.length,a=t.datum.fontSize,s=Pf.width(t.datum,t.datum.text);var u,c,l,f,h,d,p,m=0;for(var _r64=0;_r64<n;++_r64){u=e[_r64].x,l=e[_r64].y,h=(u+(c=void 0===e[_r64].x2?u:e[_r64].x2))/2,d=(l+(f=void 0===e[_r64].y2?l:e[_r64].y2))/2,(p=Math.abs(c-u+f-l))>=m&&(m=p,t.x=h,t.y=d);}return h=s/2,d=a/2,u=t.x-h,c=t.x+h,l=t.y-d,f=t.y+d,t.align="center",u<0&&c<=i?t.align="left":0<=u&&i<c&&(t.align="right"),t.baseline="middle",l<0&&f<=o?t.baseline="top":0<=l&&o<f&&(t.baseline="bottom"),!0;};},"reduced-search":function reducedSearch(t,e,n,r){var i=t.width,o=t.height,a=e[0],s=e[1];function u(e,n,r,u,c){var l=t.invert(e),f=t.invert(n);var h,d=r,p=o;if(!Bw(l,f,u,c,i,o)&&!Pw(t,l,f,c,u,d,a,s)&&!Pw(t,l,f,c,u,c,a,null)){for(;p-d>=1;){Pw(t,l,f,c,u,h=(d+p)/2,a,s)?p=h:d=h;}if(d>r)return [l,f,d,!0];}}return function(e){var s=e.datum.datum.items[r].items,c=s.length,l=e.datum.fontSize,f=Pf.width(e.datum,e.datum.text);var h,d,p,m,g,v,y,b,x,w,k,E,C,A,O,_,S,D=n?l:0,F=!1,T=!1,N=0;for(var _r65=0;_r65<c;++_r65){for(h=s[_r65].x,p=s[_r65].y,d=void 0===s[_r65].x2?h:s[_r65].x2,m=void 0===s[_r65].y2?p:s[_r65].y2,h>d&&(S=h,h=d,d=S),p>m&&(S=p,p=m,m=S),w=~~(((x=t(h))+(k=t(d)))/2),C=~~(((E=t(p))+(A=t(m)))/2),y=w;y>=x;--y){for(b=C;b>=E;--b){var _ref10,_ref11;(_=u(y,b,D,f,l))&&(_ref10=_,_ref11=_slicedToArray(_ref10,4),e.x=_ref11[0],e.y=_ref11[1],D=_ref11[2],F=_ref11[3],_ref10);}}for(y=w;y<=k;++y){for(b=C;b<=A;++b){var _ref12,_ref13;(_=u(y,b,D,f,l))&&(_ref12=_,_ref13=_slicedToArray(_ref12,4),e.x=_ref13[0],e.y=_ref13[1],D=_ref13[2],F=_ref13[3],_ref12);}}F||n||(g=(h+d)/2,v=(p+m)/2,(O=Math.abs(d-h+m-p))>=N&&!Bw(g,v,f,l,i,o)&&!Pw(t,g,v,l,f,l,a,null)&&(N=O,e.x=g,e.y=v,T=!0));}return !(!F&&!T||(g=f/2,v=l/2,a.setRange(t(e.x-g),t(e.y-v),t(e.x+g),t(e.y+v)),e.align="center",e.baseline="middle",0));};},floodfill:function floodfill(t,e,n,r){var i=t.width,o=t.height,a=e[0],s=e[1],u=t.bitmap();return function(e){var c=e.datum.datum.items[r].items,l=c.length,f=e.datum.fontSize,h=Pf.width(e.datum,e.datum.text),d=[];var p,m,g,v,y,b,x,w,k,E,C,A,O=n?f:0,_=!1,S=!1,D=0;for(var _r66=0;_r66<l;++_r66){for(p=c[_r66].x,g=c[_r66].y,m=void 0===c[_r66].x2?p:c[_r66].x2,v=void 0===c[_r66].y2?g:c[_r66].y2,d.push([t((p+m)/2),t((g+v)/2)]);d.length;){var _d$pop,_d$pop2;if((_d$pop=d.pop(),_d$pop2=_slicedToArray(_d$pop,2),x=_d$pop2[0],w=_d$pop2[1],_d$pop),!(a.get(x,w)||s.get(x,w)||u.get(x,w))){u.set(x,w);for(var _t73=0;_t73<4;++_t73){y=x+Lw[_t73],b=w+zw[_t73],u.outOfBounds(y,b,y,b)||d.push([y,b]);}if(y=t.invert(x),b=t.invert(w),k=O,E=o,!Bw(y,b,h,f,i,o)&&!Pw(t,y,b,f,h,k,a,s)&&!Pw(t,y,b,f,h,f,a,null)){for(;E-k>=1;){Pw(t,y,b,f,h,C=(k+E)/2,a,s)?E=C:k=C;}k>O&&(e.x=y,e.y=b,O=k,_=!0);}}}_||n||(y=(p+m)/2,b=(g+v)/2,(A=Math.abs(m-p+v-g))>=D&&!Bw(y,b,h,f,i,o)&&!Pw(t,y,b,f,h,f,a,null)&&(D=A,e.x=y,e.y=b,S=!0));}return !(!_&&!S||(y=h/2,b=f/2,a.setRange(t(e.x-y),t(e.y-b),t(e.x+y),t(e.y+b)),e.align="center",e.baseline="middle",0));};}};function Hw(t,e,n,r,i,o,a,s,u,c,l){if(!t.length)return t;var f=Math.max(r.length,i.length),h=function(t,e){var n=new Float64Array(e),r=t.length;for(var _e68=0;_e68<r;++_e68){n[_e68]=t[_e68]||0;}for(var _t74=r;_t74<e;++_t74){n[_t74]=n[r-1];}return n;}(r,f),d=function(t,e){var n=new Int8Array(e),r=t.length;for(var _e69=0;_e69<r;++_e69){n[_e69]|=qw[t[_e69]];}for(var _t75=r;_t75<e;++_t75){n[_t75]=n[r-1];}return n;}(i,f),p=function(t){return t&&t.mark&&t.mark.marktype;}(t[0].datum),m="group"===p&&t[0].datum.items[u].marktype,g="area"===m,v=function(t,e,n,r){var i=function i(t){return [t.x,t.x,t.x,t.y,t.y,t.y];};return t?"line"===t||"area"===t?function(t){return i(t.datum);}:"line"===e?function(t){var e=t.datum.items[r].items;return i(e.length?e["start"===n?0:e.length-1]:{x:NaN,y:NaN});}:function(t){var e=t.datum.bounds;return [e.x1,(e.x1+e.x2)/2,e.x2,e.y1,(e.y1+e.y2)/2,e.y2];}:i;}(p,m,s,u),y=jw(e[0],e[1],c),b=g&&"naive"===l,x=t.map(function(t){return {datum:t,opacity:0,x:void 0,y:void 0,align:void 0,baseline:void 0,boundary:v(t)};});var w;if(!b){n&&x.sort(function(t,e){return n(t.datum,e.datum);});var _e70=!1;for(var _t76=0;_t76<d.length&&!_e70;++_t76){_e70=5===d[_t76]||h[_t76]<0;}p&&(a||g)&&(o=[t.map(function(t){return t.datum;})].concat(o)),w=o.length?Dw(y,o,_e70,g):function(t,e){var n=t.bitmap();return (e||[]).forEach(function(e){return n.set(t(e.boundary[0]),t(e.boundary[3]));}),[n,void 0];}(y,a&&x);}var k=g?$w[l](y,w,a,u):function(t,e,n,r){var i=t.width,o=t.height,a=e[0],s=e[1],u=r.length;return function(e){var c=e.boundary,l=e.datum.fontSize;if(c[2]<0||c[5]<0||c[0]>i||c[3]>o)return !1;var f,h,d,p,m,g,v,y,b,x,w,k,E,C,A,O=0;for(var _i43=0;_i43<u;++_i43){if(f=(3&n[_i43])-1,h=(n[_i43]>>>2&3)-1,d=0===f&&0===h||r[_i43]<0,p=f&&h?Math.SQRT1_2:1,m=r[_i43]<0?-1:1,g=c[1+f]+r[_i43]*f*p,y=(w=c[4+h]+m*l*h/2+r[_i43]*h*p)-l/2,b=w+l/2,k=t(g),C=t(y),A=t(b),!O){if(!Vw(k,k,C,A,a,s,g,g,y,b,c,d))continue;O=Pf.width(e.datum,e.datum.text);}if(v=(x=g+m*O*f/2)+O/2,Vw(k=t(g=x-O/2),E=t(v),C,A,a,s,g,v,y,b,c,d))return e.x=f?f*m<0?v:g:x,e.y=h?h*m<0?b:y:w,e.align=Uw[f*m+1],e.baseline=Ww[h*m+1],a.setRange(k,C,E,A),!0;}return !1;};}(y,w,d,h);return x.forEach(function(t){return t.opacity=+k(t);}),x;}var Gw=["x","y","opacity","align","baseline"],Kw=["top-left","left","bottom-left","top","bottom","top-right","right","bottom-right"];function Xw(t){zt.call(this,null,t);}function Yw(t,e){var n,r,i,o,a,s,u=[],c=function c(t){return t(o);};if(null==e)u.push(t);else for(n={},r=0,i=t.length;r<i;++r){o=t[r],(s=n[a=e.map(c)])||(n[a]=s=[],s.dims=a,u.push(s)),s.push(o);}return u;}function Jw(t){zt.call(this,null,t);}Xw.Definition={type:"Label",metadata:{modifies:!0},params:[{name:"size",type:"number",array:!0,length:2,required:!0},{name:"sort",type:"compare"},{name:"anchor",type:"string",array:!0,default:Kw},{name:"offset",type:"number",array:!0,default:[1]},{name:"padding",type:"number",default:0},{name:"lineAnchor",type:"string",values:["start","end"],default:"end"},{name:"markIndex",type:"number",default:0},{name:"avoidBaseMark",type:"boolean",default:!0},{name:"avoidMarks",type:"data",array:!0},{name:"method",type:"string",default:"naive"},{name:"as",type:"string",array:!0,length:Gw.length,default:Gw}]},Object(Z.z)(Xw,zt,{transform:function transform(t,e){var n=t.modified();if(!(n||e.changed(e.ADD_REM)||function(n){var r=t[n];return Object(Z.E)(r)&&e.modified(r.fields);}("sort")))return;t.size&&2===t.size.length||Object(Z.o)("Size parameter should be specified as a [width, height] array.");var r=t.as||Gw;return Hw(e.materialize(e.SOURCE).source,t.size,t.sort,Object(Z.i)(t.offset||1),Object(Z.i)(t.anchor||Kw),t.avoidMarks||[],!1!==t.avoidBaseMark,t.lineAnchor||"end",t.markIndex||0,t.padding||0,t.method||"naive").forEach(function(t){var e=t.datum;e[r[0]]=t.x,e[r[1]]=t.y,e[r[2]]=t.opacity,e[r[3]]=t.align,e[r[4]]=t.baseline;}),e.reflow(n).modifies(r);}}),Jw.Definition={type:"Loess",metadata:{generates:!0},params:[{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"bandwidth",type:"number",default:.3},{name:"as",type:"string",array:!0}]},Object(Z.z)(Jw,zt,{transform:function transform(t,e){var n=e.fork(e.NO_SOURCE|e.NO_FIELDS);if(!this.value||e.changed()||t.modified()){var _r67=Yw(e.materialize(e.SOURCE).source,t.groupby),_i44=(t.groupby||[]).map(Z.h),_o23=_i44.length,_a30=t.as||[Object(Z.h)(t.x),Object(Z.h)(t.y)],_s26=[];_r67.forEach(function(e){Ue(e,t.x,t.y,t.bandwidth||.3).forEach(function(t){var n={};for(var _t77=0;_t77<_o23;++_t77){n[_i44[_t77]]=e.dims[_t77];}n[_a30[0]]=t[0],n[_a30[1]]=t[1],_s26.push(ct(n));});}),this.value&&(n.rem=this.value),this.value=n.add=n.source=_s26;}return n;}});var Qw={linear:Ie,log:Re,exp:Me,pow:je,quad:Be,poly:Pe};function Zw(t){zt.call(this,null,t);}Zw.Definition={type:"Regression",metadata:{generates:!0},params:[{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"string",default:"linear",values:Object.keys(Qw)},{name:"order",type:"number",default:3},{name:"extent",type:"number",array:!0,length:2},{name:"params",type:"boolean",default:!1},{name:"as",type:"string",array:!0}]},Object(Z.z)(Zw,zt,{transform:function transform(t,e){var n=e.fork(e.NO_SOURCE|e.NO_FIELDS);if(!this.value||e.changed()||t.modified()){var _r68=Yw(e.materialize(e.SOURCE).source,t.groupby),_i45=(t.groupby||[]).map(Z.h),_o24=t.method||"linear",_a31=t.order||3,_s27=function(t,e){return "poly"===t?e:"quad"===t?2:1;}(_o24,_a31),_u14=t.as||[Object(Z.h)(t.x),Object(Z.h)(t.y)],_c8=Qw[_o24],_l5=[];var _f4=t.extent;Object(Z.w)(Qw,_o24)||Object(Z.o)("Invalid regression method: "+_o24),null!=_f4&&"log"===_o24&&_f4[0]<=0&&(e.dataflow.warn("Ignoring extent with values <= 0 for log regression."),_f4=null),_r68.forEach(function(n){if(n.length<=_s27)return void e.dataflow.warn("Skipping regression with more parameters than data points.");var r=_c8(n,t.x,t.y,_a31);if(t.params)return void _l5.push(ct({keys:n.dims,coef:r.coef,rSquared:r.rSquared}));var h=_f4||Object(Z.q)(n,t.x),d=function d(t){var e={};for(var _t78=0;_t78<_i45.length;++_t78){e[_i45[_t78]]=n.dims[_t78];}e[_u14[0]]=t[0],e[_u14[1]]=t[1],_l5.push(ct(e));};"linear"===_o24?h.forEach(function(t){return d([t,r.predict(t)]);}):$e(r.predict,h,25,200).forEach(d);}),this.value&&(n.rem=this.value),this.value=n.add=n.source=_l5;}return n;}});var tk=Math.pow(2,-52),ek=new Uint32Array(512);var nk=/*#__PURE__*/function(){function nk(t){_classCallCheck(this,nk);var e=t.length>>1;if(e>0&&"number"!=typeof t[0])throw new Error("Expected coords to contain numbers.");this.coords=t;var n=Math.max(2*e-5,0);this._triangles=new Uint32Array(3*n),this._halfedges=new Int32Array(3*n),this._hashSize=Math.ceil(Math.sqrt(e)),this._hullPrev=new Uint32Array(e),this._hullNext=new Uint32Array(e),this._hullTri=new Uint32Array(e),this._hullHash=new Int32Array(this._hashSize).fill(-1),this._ids=new Uint32Array(e),this._dists=new Float64Array(e),this.update();}_createClass(nk,[{key:"update",value:function update(){var t=this.coords,e=this._hullPrev,n=this._hullNext,r=this._hullTri,i=this._hullHash,o=t.length>>1;var a=1/0,s=1/0,u=-1/0,c=-1/0;for(var _e71=0;_e71<o;_e71++){var _n56=t[2*_e71],_r69=t[2*_e71+1];_n56<a&&(a=_n56),_r69<s&&(s=_r69),_n56>u&&(u=_n56),_r69>c&&(c=_r69),this._ids[_e71]=_e71;}var l=(a+u)/2,f=(s+c)/2;var h,d,p,m=1/0;for(var _e72=0;_e72<o;_e72++){var _n57=rk(l,f,t[2*_e72],t[2*_e72+1]);_n57<m&&(h=_e72,m=_n57);}var g=t[2*h],v=t[2*h+1];m=1/0;for(var _e73=0;_e73<o;_e73++){if(_e73===h)continue;var _n58=rk(g,v,t[2*_e73],t[2*_e73+1]);_n58<m&&_n58>0&&(d=_e73,m=_n58);}var y=t[2*d],b=t[2*d+1],x=1/0;for(var _e74=0;_e74<o;_e74++){if(_e74===h||_e74===d)continue;var _n59=sk(g,v,y,b,t[2*_e74],t[2*_e74+1]);_n59<x&&(p=_e74,x=_n59);}var w=t[2*p],k=t[2*p+1];if(x===1/0){for(var _e76=0;_e76<o;_e76++){this._dists[_e76]=t[2*_e76]-t[0]||t[2*_e76+1]-t[1];}uk(this._ids,this._dists,0,o-1);var _e75=new Uint32Array(o);var _n60=0;for(var _t79=0,_r70=-1/0;_t79<o;_t79++){var _i46=this._ids[_t79];this._dists[_i46]>_r70&&(_e75[_n60++]=_i46,_r70=this._dists[_i46]);}return this.hull=_e75.subarray(0,_n60),this.triangles=new Uint32Array(0),void(this.halfedges=new Uint32Array(0));}if(ok(g,v,y,b,w,k)){var _t80=d,_e77=y,_n61=b;d=p,y=w,b=k,p=_t80,w=_e77,k=_n61;}var E=function(t,e,n,r,i,o){var a=n-t,s=r-e,u=i-t,c=o-e,l=a*a+s*s,f=u*u+c*c,h=.5/(a*c-s*u);return {x:t+(c*l-s*f)*h,y:e+(a*f-u*l)*h};}(g,v,y,b,w,k);this._cx=E.x,this._cy=E.y;for(var _e78=0;_e78<o;_e78++){this._dists[_e78]=rk(t[2*_e78],t[2*_e78+1],E.x,E.y);}uk(this._ids,this._dists,0,o-1),this._hullStart=h;var C=3;n[h]=e[p]=d,n[d]=e[h]=p,n[p]=e[d]=h,r[h]=0,r[d]=1,r[p]=2,i.fill(-1),i[this._hashKey(g,v)]=h,i[this._hashKey(y,b)]=d,i[this._hashKey(w,k)]=p,this.trianglesLen=0,this._addTriangle(h,d,p,-1,-1,-1);for(var _o25,_a32,_s28=0;_s28<this._ids.length;_s28++){var _u15=this._ids[_s28],_c9=t[2*_u15],_l6=t[2*_u15+1];if(_s28>0&&Math.abs(_c9-_o25)<=tk&&Math.abs(_l6-_a32)<=tk)continue;if(_o25=_c9,_a32=_l6,_u15===h||_u15===d||_u15===p)continue;var _f5=0;for(var _t81=0,_e79=this._hashKey(_c9,_l6);_t81<this._hashSize&&(-1===(_f5=i[(_e79+_t81)%this._hashSize])||_f5===n[_f5]);_t81++){}var _m3=void 0,_g3=_f5=e[_f5];for(;_m3=n[_g3],!ok(_c9,_l6,t[2*_g3],t[2*_g3+1],t[2*_m3],t[2*_m3+1]);){if((_g3=_m3)===_f5){_g3=-1;break;}}if(-1===_g3)continue;var _v3=this._addTriangle(_g3,_u15,n[_g3],-1,-1,r[_g3]);r[_u15]=this._legalize(_v3+2),r[_g3]=_v3,C++;var _y3=n[_g3];for(;_m3=n[_y3],ok(_c9,_l6,t[2*_y3],t[2*_y3+1],t[2*_m3],t[2*_m3+1]);){_v3=this._addTriangle(_y3,_u15,_m3,r[_u15],-1,r[_y3]),r[_u15]=this._legalize(_v3+2),n[_y3]=_y3,C--,_y3=_m3;}if(_g3===_f5)for(;ok(_c9,_l6,t[2*(_m3=e[_g3])],t[2*_m3+1],t[2*_g3],t[2*_g3+1]);){_v3=this._addTriangle(_m3,_u15,_g3,-1,r[_g3],r[_m3]),this._legalize(_v3+2),r[_m3]=_v3,n[_g3]=_g3,C--,_g3=_m3;}this._hullStart=e[_u15]=_g3,n[_g3]=e[_y3]=_u15,n[_u15]=_y3,i[this._hashKey(_c9,_l6)]=_u15,i[this._hashKey(t[2*_g3],t[2*_g3+1])]=_g3;}this.hull=new Uint32Array(C);for(var _t82=0,_e80=this._hullStart;_t82<C;_t82++){this.hull[_t82]=_e80,_e80=n[_e80];}this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen);}},{key:"_hashKey",value:function _hashKey(t,e){return Math.floor(function(t,e){var n=t/(Math.abs(t)+Math.abs(e));return (e>0?3-n:1+n)/4;}(t-this._cx,e-this._cy)*this._hashSize)%this._hashSize;}},{key:"_legalize",value:function _legalize(t){var e=this._triangles,n=this._halfedges,r=this.coords;var i=0,o=0;for(;;){var _a33=n[t],_s29=t-t%3;if(o=_s29+(t+2)%3,-1===_a33){if(0===i)break;t=ek[--i];continue;}var _u16=_a33-_a33%3,_c10=_s29+(t+1)%3,_l7=_u16+(_a33+2)%3,_f6=e[o],_h4=e[t],_d3=e[_c10],_p3=e[_l7];if(ak(r[2*_f6],r[2*_f6+1],r[2*_h4],r[2*_h4+1],r[2*_d3],r[2*_d3+1],r[2*_p3],r[2*_p3+1])){e[t]=_p3,e[_a33]=_f6;var _r71=n[_l7];if(-1===_r71){var _e81=this._hullStart;do{if(this._hullTri[_e81]===_l7){this._hullTri[_e81]=t;break;}_e81=this._hullPrev[_e81];}while(_e81!==this._hullStart);}this._link(t,_r71),this._link(_a33,n[o]),this._link(o,_l7);var _s30=_u16+(_a33+1)%3;i<ek.length&&(ek[i++]=_s30);}else {if(0===i)break;t=ek[--i];}}return o;}},{key:"_link",value:function _link(t,e){this._halfedges[t]=e,-1!==e&&(this._halfedges[e]=t);}},{key:"_addTriangle",value:function _addTriangle(t,e,n,r,i,o){var a=this.trianglesLen;return this._triangles[a]=t,this._triangles[a+1]=e,this._triangles[a+2]=n,this._link(a,r),this._link(a+1,i),this._link(a+2,o),this.trianglesLen+=3,a;}}],[{key:"from",value:function from(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(t){return t[0];};var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:function(t){return t[1];};var r=t.length,i=new Float64Array(2*r);for(var _o26=0;_o26<r;_o26++){var _r72=t[_o26];i[2*_o26]=e(_r72),i[2*_o26+1]=n(_r72);}return new nk(i);}}]);return nk;}();function rk(t,e,n,r){var i=t-n,o=e-r;return i*i+o*o;}function ik(t,e,n,r,i,o){var a=(r-e)*(i-t),s=(n-t)*(o-e);return Math.abs(a-s)>=3.3306690738754716e-16*Math.abs(a+s)?a-s:0;}function ok(t,e,n,r,i,o){return (ik(i,o,t,e,n,r)||ik(t,e,n,r,i,o)||ik(n,r,i,o,t,e))<0;}function ak(t,e,n,r,i,o,a,s){var u=t-a,c=e-s,l=n-a,f=r-s,h=i-a,d=o-s,p=l*l+f*f,m=h*h+d*d;return u*(f*m-p*d)-c*(l*m-p*h)+(u*u+c*c)*(l*d-f*h)<0;}function sk(t,e,n,r,i,o){var a=n-t,s=r-e,u=i-t,c=o-e,l=a*a+s*s,f=u*u+c*c,h=.5/(a*c-s*u),d=(c*l-s*f)*h,p=(a*f-u*l)*h;return d*d+p*p;}function uk(t,e,n,r){if(r-n<=20)for(var _i47=n+1;_i47<=r;_i47++){var _r73=t[_i47],_o27=e[_r73];var _a34=_i47-1;for(;_a34>=n&&e[t[_a34]]>_o27;){t[_a34+1]=t[_a34--];}t[_a34+1]=_r73;}else {var _i48=n+1,_o28=r;ck(t,n+r>>1,_i48),e[t[n]]>e[t[r]]&&ck(t,n,r),e[t[_i48]]>e[t[r]]&&ck(t,_i48,r),e[t[n]]>e[t[_i48]]&&ck(t,n,_i48);var _a35=t[_i48],_s31=e[_a35];for(;;){do{_i48++;}while(e[t[_i48]]<_s31);do{_o28--;}while(e[t[_o28]]>_s31);if(_o28<_i48)break;ck(t,_i48,_o28);}t[n+1]=t[_o28],t[_o28]=_a35,r-_i48+1>=_o28-n?(uk(t,e,_i48,r),uk(t,e,n,_o28-1)):(uk(t,e,n,_o28-1),uk(t,e,_i48,r));}}function ck(t,e,n){var r=t[e];t[e]=t[n],t[n]=r;}var lk=1e-6;var fk=/*#__PURE__*/function(){function fk(){_classCallCheck(this,fk);this._x0=this._y0=this._x1=this._y1=null,this._="";}_createClass(fk,[{key:"moveTo",value:function moveTo(t,e){this._+="M".concat(this._x0=this._x1=+t,",").concat(this._y0=this._y1=+e);}},{key:"closePath",value:function closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z");}},{key:"lineTo",value:function lineTo(t,e){this._+="L".concat(this._x1=+t,",").concat(this._y1=+e);}},{key:"arc",value:function arc(t,e,n){var r=(t=+t)+(n=+n),i=e=+e;if(n<0)throw new Error("negative radius");null===this._x1?this._+="M".concat(r,",").concat(i):(Math.abs(this._x1-r)>lk||Math.abs(this._y1-i)>lk)&&(this._+="L"+r+","+i),n&&(this._+="A".concat(n,",").concat(n,",0,1,1,").concat(t-n,",").concat(e,"A").concat(n,",").concat(n,",0,1,1,").concat(this._x1=r,",").concat(this._y1=i));}},{key:"rect",value:function rect(t,e,n,r){this._+="M".concat(this._x0=this._x1=+t,",").concat(this._y0=this._y1=+e,"h").concat(+n,"v").concat(+r,"h").concat(-n,"Z");}},{key:"value",value:function value(){return this._||null;}}]);return fk;}();var hk=/*#__PURE__*/function(){function hk(){_classCallCheck(this,hk);this._=[];}_createClass(hk,[{key:"moveTo",value:function moveTo(t,e){this._.push([t,e]);}},{key:"closePath",value:function closePath(){this._.push(this._[0].slice());}},{key:"lineTo",value:function lineTo(t,e){this._.push([t,e]);}},{key:"value",value:function value(){return this._.length?this._:null;}}]);return hk;}();var dk=/*#__PURE__*/function(){function dk(t){var _ref14=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[0,0,960,500],_ref15=_slicedToArray(_ref14,4),e=_ref15[0],n=_ref15[1],r=_ref15[2],i=_ref15[3];_classCallCheck(this,dk);if(!((r=+r)>=(e=+e)&&(i=+i)>=(n=+n)))throw new Error("invalid bounds");this.delaunay=t,this._circumcenters=new Float64Array(2*t.points.length),this.vectors=new Float64Array(2*t.points.length),this.xmax=r,this.xmin=e,this.ymax=i,this.ymin=n,this._init();}_createClass(dk,[{key:"update",value:function update(){return this.delaunay.update(),this._init(),this;}},{key:"_init",value:function _init(){var _this$delaunay=this.delaunay,t=_this$delaunay.points,e=_this$delaunay.hull,n=_this$delaunay.triangles,r=this.vectors,i=this.circumcenters=this._circumcenters.subarray(0,n.length/3*2);for(var _e82,_r74,_o29=0,_a36=0,_s32=n.length;_o29<_s32;_o29+=3,_a36+=2){var _s33=2*n[_o29],_u17=2*n[_o29+1],_c11=2*n[_o29+2],_l8=t[_s33],_f7=t[_s33+1],_h5=t[_u17],_d4=t[_u17+1],_p4=t[_c11],_m4=t[_c11+1],_g4=_h5-_l8,_v4=_d4-_f7,_y4=_p4-_l8,_b2=_m4-_f7,_x21=_g4*_g4+_v4*_v4,_w2=_y4*_y4+_b2*_b2,_k2=2*(_g4*_b2-_v4*_y4);if(_k2){if(Math.abs(_k2)<1e-8)_e82=(_l8+_p4)/2,_r74=(_f7+_m4)/2;else {var _t83=1/_k2;_e82=_l8+(_b2*_x21-_v4*_w2)*_t83,_r74=_f7+(_g4*_w2-_y4*_x21)*_t83;}}else _e82=(_l8+_p4)/2-1e8*_b2,_r74=(_f7+_m4)/2+1e8*_y4;i[_a36]=_e82,i[_a36+1]=_r74;}var o,a,s,u=e[e.length-1],c=4*u,l=t[2*u],f=t[2*u+1];r.fill(0);for(var _n62=0;_n62<e.length;++_n62){o=c,a=l,s=f,c=4*(u=e[_n62]),l=t[2*u],f=t[2*u+1],r[o+2]=r[c]=s-f,r[o+3]=r[c+1]=l-a;}}},{key:"render",value:function render(t){var e=null==t?t=new fk():void 0,_this$delaunay2=this.delaunay,n=_this$delaunay2.halfedges,r=_this$delaunay2.inedges,i=_this$delaunay2.hull,o=this.circumcenters,a=this.vectors;if(i.length<=1)return null;for(var _e83=0,_r75=n.length;_e83<_r75;++_e83){var _r76=n[_e83];if(_r76<_e83)continue;var _i49=2*Math.floor(_e83/3),_a37=2*Math.floor(_r76/3),_s34=o[_i49],_u18=o[_i49+1],_c12=o[_a37],_l9=o[_a37+1];this._renderSegment(_s34,_u18,_c12,_l9,t);}var s,u=i[i.length-1];for(var _e84=0;_e84<i.length;++_e84){s=u,u=i[_e84];var _n63=2*Math.floor(r[u]/3),_c13=o[_n63],_l10=o[_n63+1],_f8=4*s,_h6=this._project(_c13,_l10,a[_f8+2],a[_f8+3]);_h6&&this._renderSegment(_c13,_l10,_h6[0],_h6[1],t);}return e&&e.value();}},{key:"renderBounds",value:function renderBounds(t){var e=null==t?t=new fk():void 0;return t.rect(this.xmin,this.ymin,this.xmax-this.xmin,this.ymax-this.ymin),e&&e.value();}},{key:"renderCell",value:function renderCell(t,e){var n=null==e?e=new fk():void 0,r=this._clip(t);if(null===r||!r.length)return;e.moveTo(r[0],r[1]);var i=r.length;for(;r[0]===r[i-2]&&r[1]===r[i-1]&&i>1;){i-=2;}for(var _t84=2;_t84<i;_t84+=2){r[_t84]===r[_t84-2]&&r[_t84+1]===r[_t84-1]||e.lineTo(r[_t84],r[_t84+1]);}return e.closePath(),n&&n.value();}},{key:"cellPolygons",value:/*#__PURE__*/regeneratorRuntime.mark(function cellPolygons(){var t,_e85,_n64,_t85;return regeneratorRuntime.wrap(function cellPolygons$(_context15){while(1){switch(_context15.prev=_context15.next){case 0:t=this.delaunay.points;_e85=0,_n64=t.length/2;case 2:if(!(_e85<_n64)){_context15.next=12;break;}_t85=this.cellPolygon(_e85);_context15.t0=_t85;if(!_context15.t0){_context15.next=9;break;}_t85.index=_e85;_context15.next=9;return _t85;case 9:++_e85;_context15.next=2;break;case 12:case"end":return _context15.stop();}}},cellPolygons,this);})},{key:"cellPolygon",value:function cellPolygon(t){var e=new hk();return this.renderCell(t,e),e.value();}},{key:"_renderSegment",value:function _renderSegment(t,e,n,r,i){var o;var a=this._regioncode(t,e),s=this._regioncode(n,r);0===a&&0===s?(i.moveTo(t,e),i.lineTo(n,r)):(o=this._clipSegment(t,e,n,r,a,s))&&(i.moveTo(o[0],o[1]),i.lineTo(o[2],o[3]));}},{key:"contains",value:function contains(t,e,n){return (e=+e)==e&&(n=+n)==n&&this.delaunay._step(t,e,n)===t;}},{key:"neighbors",value:/*#__PURE__*/regeneratorRuntime.mark(function neighbors(t){var e,_iterator25,_step25,_n65,_t86,_r77,_i50,_o30,_a38;return regeneratorRuntime.wrap(function neighbors$(_context16){while(1){switch(_context16.prev=_context16.next){case 0:e=this._clip(t);if(!e){_context16.next=33;break;}_iterator25=_createForOfIteratorHelper(this.delaunay.neighbors(t));_context16.prev=3;_iterator25.s();case 5:if((_step25=_iterator25.n()).done){_context16.next=25;break;}_n65=_step25.value;_t86=this._clip(_n65);if(!_t86){_context16.next=23;break;}_r77=0,_i50=e.length;case 10:if(!(_r77<_i50)){_context16.next=23;break;}_o30=0,_a38=_t86.length;case 12:if(!(_o30<_a38)){_context16.next=20;break;}if(!(e[_r77]==_t86[_o30]&&e[_r77+1]==_t86[_o30+1]&&e[(_r77+2)%_i50]==_t86[(_o30+_a38-2)%_a38]&&e[(_r77+3)%_i50]==_t86[(_o30+_a38-1)%_a38])){_context16.next=17;break;}_context16.next=16;return _n65;case 16:return _context16.abrupt("break",23);case 17:_o30+=2;_context16.next=12;break;case 20:_r77+=2;_context16.next=10;break;case 23:_context16.next=5;break;case 25:_context16.next=30;break;case 27:_context16.prev=27;_context16.t0=_context16["catch"](3);_iterator25.e(_context16.t0);case 30:_context16.prev=30;_iterator25.f();return _context16.finish(30);case 33:case"end":return _context16.stop();}}},neighbors,this,[[3,27,30,33]]);})},{key:"_cell",value:function _cell(t){var e=this.circumcenters,_this$delaunay3=this.delaunay,n=_this$delaunay3.inedges,r=_this$delaunay3.halfedges,i=_this$delaunay3.triangles,o=n[t];if(-1===o)return null;var a=[];var s=o;do{var _n66=Math.floor(s/3);if(a.push(e[2*_n66],e[2*_n66+1]),i[s=s%3==2?s-2:s+1]!==t)break;s=r[s];}while(s!==o&&-1!==s);return a;}},{key:"_clip",value:function _clip(t){if(0===t&&1===this.delaunay.hull.length)return [this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];var e=this._cell(t);if(null===e)return null;var n=this.vectors,r=4*t;return n[r]||n[r+1]?this._clipInfinite(t,e,n[r],n[r+1],n[r+2],n[r+3]):this._clipFinite(t,e);}},{key:"_clipFinite",value:function _clipFinite(t,e){var n=e.length;var r,i,o,a,s,u=null,c=e[n-2],l=e[n-1],f=this._regioncode(c,l);for(var _h7=0;_h7<n;_h7+=2){if(r=c,i=l,c=e[_h7],l=e[_h7+1],o=f,f=this._regioncode(c,l),0===o&&0===f)a=s,s=0,u?u.push(c,l):u=[c,l];else {var _e86=void 0,_n67=void 0,_h8=void 0,_d5=void 0,_p5=void 0;if(0===o){if(null===(_e86=this._clipSegment(r,i,c,l,o,f)))continue;var _e87=_e86;var _e88=_slicedToArray(_e87,4);_n67=_e88[0];_h8=_e88[1];_d5=_e88[2];_p5=_e88[3];}else {var _e89,_e90;if(null===(_e86=this._clipSegment(c,l,r,i,f,o)))continue;(_e89=_e86,_e90=_slicedToArray(_e89,4),_d5=_e90[0],_p5=_e90[1],_n67=_e90[2],_h8=_e90[3],_e89),a=s,s=this._edgecode(_n67,_h8),a&&s&&this._edge(t,a,s,u,u.length),u?u.push(_n67,_h8):u=[_n67,_h8];}a=s,s=this._edgecode(_d5,_p5),a&&s&&this._edge(t,a,s,u,u.length),u?u.push(_d5,_p5):u=[_d5,_p5];}}if(u)a=s,s=this._edgecode(u[0],u[1]),a&&s&&this._edge(t,a,s,u,u.length);else if(this.contains(t,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2))return [this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax,this.xmin,this.ymin];return u;}},{key:"_clipSegment",value:function _clipSegment(t,e,n,r,i,o){for(;;){if(0===i&&0===o)return [t,e,n,r];if(i&o)return null;var _a39=void 0,_s35=void 0,_u19=i||o;8&_u19?(_a39=t+(n-t)*(this.ymax-e)/(r-e),_s35=this.ymax):4&_u19?(_a39=t+(n-t)*(this.ymin-e)/(r-e),_s35=this.ymin):2&_u19?(_s35=e+(r-e)*(this.xmax-t)/(n-t),_a39=this.xmax):(_s35=e+(r-e)*(this.xmin-t)/(n-t),_a39=this.xmin),i?(t=_a39,e=_s35,i=this._regioncode(t,e)):(n=_a39,r=_s35,o=this._regioncode(n,r));}}},{key:"_clipInfinite",value:function _clipInfinite(t,e,n,r,i,o){var a,s=Array.from(e);if((a=this._project(s[0],s[1],n,r))&&s.unshift(a[0],a[1]),(a=this._project(s[s.length-2],s[s.length-1],i,o))&&s.push(a[0],a[1]),s=this._clipFinite(t,s))for(var _e91,_n68=0,_r78=s.length,_i51=this._edgecode(s[_r78-2],s[_r78-1]);_n68<_r78;_n68+=2){_e91=_i51,_i51=this._edgecode(s[_n68],s[_n68+1]),_e91&&_i51&&(_n68=this._edge(t,_e91,_i51,s,_n68),_r78=s.length);}else this.contains(t,(this.xmin+this.xmax)/2,(this.ymin+this.ymax)/2)&&(s=[this.xmin,this.ymin,this.xmax,this.ymin,this.xmax,this.ymax,this.xmin,this.ymax]);return s;}},{key:"_edge",value:function _edge(t,e,n,r,i){for(;e!==n;){var _n69=void 0,_o31=void 0;switch(e){case 5:e=4;continue;case 4:e=6,_n69=this.xmax,_o31=this.ymin;break;case 6:e=2;continue;case 2:e=10,_n69=this.xmax,_o31=this.ymax;break;case 10:e=8;continue;case 8:e=9,_n69=this.xmin,_o31=this.ymax;break;case 9:e=1;continue;case 1:e=5,_n69=this.xmin,_o31=this.ymin;}r[i]===_n69&&r[i+1]===_o31||!this.contains(t,_n69,_o31)||(r.splice(i,0,_n69,_o31),i+=2);}if(r.length>4)for(var _t87=0;_t87<r.length;_t87+=2){var _e92=(_t87+2)%r.length,_n70=(_t87+4)%r.length;(r[_t87]===r[_e92]&&r[_e92]===r[_n70]||r[_t87+1]===r[_e92+1]&&r[_e92+1]===r[_n70+1])&&(r.splice(_e92,2),_t87-=2);}return i;}},{key:"_project",value:function _project(t,e,n,r){var i,o,a,s=1/0;if(r<0){if(e<=this.ymin)return null;(i=(this.ymin-e)/r)<s&&(a=this.ymin,o=t+(s=i)*n);}else if(r>0){if(e>=this.ymax)return null;(i=(this.ymax-e)/r)<s&&(a=this.ymax,o=t+(s=i)*n);}if(n>0){if(t>=this.xmax)return null;(i=(this.xmax-t)/n)<s&&(o=this.xmax,a=e+(s=i)*r);}else if(n<0){if(t<=this.xmin)return null;(i=(this.xmin-t)/n)<s&&(o=this.xmin,a=e+(s=i)*r);}return [o,a];}},{key:"_edgecode",value:function _edgecode(t,e){return (t===this.xmin?1:t===this.xmax?2:0)|(e===this.ymin?4:e===this.ymax?8:0);}},{key:"_regioncode",value:function _regioncode(t,e){return (t<this.xmin?1:t>this.xmax?2:0)|(e<this.ymin?4:e>this.ymax?8:0);}}]);return dk;}();var pk=2*Math.PI,mk=Math.pow;function gk(t,e,n){return [t+Math.sin(t+e)*n,e+Math.cos(t-e)*n];}var vk=/*#__PURE__*/function(){function vk(t){_classCallCheck(this,vk);this._delaunator=new nk(t),this.inedges=new Int32Array(t.length/2),this._hullIndex=new Int32Array(t.length/2),this.points=this._delaunator.coords,this._init();}_createClass(vk,[{key:"update",value:function update(){return this._delaunator.update(),this._init(),this;}},{key:"_init",value:function _init(){var t=this._delaunator,e=this.points;if(t.hull&&t.hull.length>2&&function(t){var e=t.triangles,n=t.coords;for(var _t88=0;_t88<e.length;_t88+=3){var _r79=2*e[_t88],_i52=2*e[_t88+1],_o32=2*e[_t88+2];if((n[_o32]-n[_r79])*(n[_i52+1]-n[_r79+1])-(n[_i52]-n[_r79])*(n[_o32+1]-n[_r79+1])>1e-10)return !1;}return !0;}(t)){this.collinear=Int32Array.from({length:e.length/2},function(t,e){return e;}).sort(function(t,n){return e[2*t]-e[2*n]||e[2*t+1]-e[2*n+1];});var _t89=this.collinear[0],_n71=this.collinear[this.collinear.length-1],_r80=[e[2*_t89],e[2*_t89+1],e[2*_n71],e[2*_n71+1]],_i53=1e-8*Math.hypot(_r80[3]-_r80[1],_r80[2]-_r80[0]);for(var _t90=0,_n72=e.length/2;_t90<_n72;++_t90){var _n73=gk(e[2*_t90],e[2*_t90+1],_i53);e[2*_t90]=_n73[0],e[2*_t90+1]=_n73[1];}this._delaunator=new nk(e);}else delete this.collinear;var n=this.halfedges=this._delaunator.halfedges,r=this.hull=this._delaunator.hull,i=this.triangles=this._delaunator.triangles,o=this.inedges.fill(-1),a=this._hullIndex.fill(-1);for(var _t91=0,_e93=n.length;_t91<_e93;++_t91){var _e94=i[_t91%3==2?_t91-2:_t91+1];-1!==n[_t91]&&-1!==o[_e94]||(o[_e94]=_t91);}for(var _t92=0,_e95=r.length;_t92<_e95;++_t92){a[r[_t92]]=_t92;}r.length<=2&&r.length>0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],this.triangles[1]=r[1],this.triangles[2]=r[1],o[r[0]]=1,2===r.length&&(o[r[1]]=0));}},{key:"voronoi",value:function voronoi(t){return new dk(this,t);}},{key:"neighbors",value:/*#__PURE__*/regeneratorRuntime.mark(function neighbors(t){var e,n,r,i,o,a,_e96,s,u,c,_e97;return regeneratorRuntime.wrap(function neighbors$(_context17){while(1){switch(_context17.prev=_context17.next){case 0:e=this.inedges,n=this.hull,r=this._hullIndex,i=this.halfedges,o=this.triangles,a=this.collinear;if(!a){_context17.next=13;break;}_e96=a.indexOf(t);_context17.t0=_e96>0;if(!_context17.t0){_context17.next=7;break;}_context17.next=7;return a[_e96-1];case 7:_context17.t1=_e96<a.length-1;if(!_context17.t1){_context17.next=12;break;}_context17.next=11;return a[_e96+1];case 11:_context17.t1=_context17.sent;case 12:return _context17.abrupt("return",void _context17.t1);case 13:s=e[t];if(!(-1===s)){_context17.next=16;break;}return _context17.abrupt("return");case 16:u=s,c=-1;case 17:_context17.next=19;return c=o[u];case 19:if(!(o[u=u%3==2?u-2:u+1]!==t)){_context17.next=21;break;}return _context17.abrupt("return");case 21:if(!(-1===(u=i[u]))){_context17.next=29;break;}_e97=n[(r[t]+1)%n.length];_context17.t2=_e97!==c;if(!_context17.t2){_context17.next=28;break;}_context17.next=27;return _e97;case 27:_context17.t2=_context17.sent;case 28:return _context17.abrupt("return",void _context17.t2);case 29:if(u!==s){_context17.next=17;break;}case 30:case"end":return _context17.stop();}}},neighbors,this);})},{key:"find",value:function find(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:0;if((t=+t)!=t||(e=+e)!=e)return -1;var r=n;var i;for(;(i=this._step(n,t,e))>=0&&i!==n&&i!==r;){n=i;}return i;}},{key:"_step",value:function _step(t,e,n){var r=this.inedges,i=this.hull,o=this._hullIndex,a=this.halfedges,s=this.triangles,u=this.points;if(-1===r[t]||!u.length)return (t+1)%(u.length>>1);var c=t,l=mk(e-u[2*t],2)+mk(n-u[2*t+1],2);var f=r[t];var h=f;do{var _r81=s[h];var _f9=mk(e-u[2*_r81],2)+mk(n-u[2*_r81+1],2);if(_f9<l&&(l=_f9,c=_r81),s[h=h%3==2?h-2:h+1]!==t)break;if(-1===(h=a[h])){if((h=i[(o[t]+1)%i.length])!==_r81&&mk(e-u[2*h],2)+mk(n-u[2*h+1],2)<l)return h;break;}}while(h!==f);return c;}},{key:"render",value:function render(t){var e=null==t?t=new fk():void 0,n=this.points,r=this.halfedges,i=this.triangles;for(var _e98=0,_o33=r.length;_e98<_o33;++_e98){var _o34=r[_e98];if(_o34<_e98)continue;var _a40=2*i[_e98],_s36=2*i[_o34];t.moveTo(n[_a40],n[_a40+1]),t.lineTo(n[_s36],n[_s36+1]);}return this.renderHull(t),e&&e.value();}},{key:"renderPoints",value:function renderPoints(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:2;var n=null==t?t=new fk():void 0,r=this.points;for(var _n74=0,_i54=r.length;_n74<_i54;_n74+=2){var _i55=r[_n74],_o35=r[_n74+1];t.moveTo(_i55+e,_o35),t.arc(_i55,_o35,e,0,pk);}return n&&n.value();}},{key:"renderHull",value:function renderHull(t){var e=null==t?t=new fk():void 0,n=this.hull,r=this.points,i=2*n[0],o=n.length;t.moveTo(r[i],r[i+1]);for(var _e99=1;_e99<o;++_e99){var _i56=2*n[_e99];t.lineTo(r[_i56],r[_i56+1]);}return t.closePath(),e&&e.value();}},{key:"hullPolygon",value:function hullPolygon(){var t=new hk();return this.renderHull(t),t.value();}},{key:"renderTriangle",value:function renderTriangle(t,e){var n=null==e?e=new fk():void 0,r=this.points,i=this.triangles,o=2*i[t*=3],a=2*i[t+1],s=2*i[t+2];return e.moveTo(r[o],r[o+1]),e.lineTo(r[a],r[a+1]),e.lineTo(r[s],r[s+1]),e.closePath(),n&&n.value();}},{key:"trianglePolygons",value:/*#__PURE__*/regeneratorRuntime.mark(function trianglePolygons(){var t,_e100,_n75;return regeneratorRuntime.wrap(function trianglePolygons$(_context18){while(1){switch(_context18.prev=_context18.next){case 0:t=this.triangles;_e100=0,_n75=t.length/3;case 2:if(!(_e100<_n75)){_context18.next=8;break;}_context18.next=5;return this.trianglePolygon(_e100);case 5:++_e100;_context18.next=2;break;case 8:case"end":return _context18.stop();}}},trianglePolygons,this);})},{key:"trianglePolygon",value:function trianglePolygon(t){var e=new hk();return this.renderTriangle(t,e),e.value();}}],[{key:"from",value:function from(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(t){return t[0];};var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:function(t){return t[1];};var r=arguments.length>3?arguments[3]:undefined;return new vk("length"in t?function(t,e,n,r){var i=t.length,o=new Float64Array(2*i);for(var _a41=0;_a41<i;++_a41){var _i57=t[_a41];o[2*_a41]=e.call(r,_i57,_a41,t),o[2*_a41+1]=n.call(r,_i57,_a41,t);}return o;}(t,e,n,r):Float64Array.from(/*#__PURE__*/regeneratorRuntime.mark(function _callee14(t,e,n,r){var i,_iterator26,_step26,_o36;return regeneratorRuntime.wrap(function _callee14$(_context19){while(1){switch(_context19.prev=_context19.next){case 0:i=0;_iterator26=_createForOfIteratorHelper(t);_context19.prev=2;_iterator26.s();case 4:if((_step26=_iterator26.n()).done){_context19.next=13;break;}_o36=_step26.value;_context19.next=8;return e.call(r,_o36,i,t);case 8:_context19.next=10;return n.call(r,_o36,i,t);case 10:++i;case 11:_context19.next=4;break;case 13:_context19.next=18;break;case 15:_context19.prev=15;_context19.t0=_context19["catch"](2);_iterator26.e(_context19.t0);case 18:_context19.prev=18;_iterator26.f();return _context19.finish(18);case 21:case"end":return _context19.stop();}}},_callee14,null,[[2,15,18,21]]);})(t,e,n,r)));}}]);return vk;}();function yk(t){zt.call(this,null,t);}yk.Definition={type:"Voronoi",metadata:{modifies:!0},params:[{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"size",type:"number",array:!0,length:2},{name:"extent",type:"array",array:!0,length:2,default:[[-1e5,-1e5],[1e5,1e5]],content:{type:"number",array:!0,length:2}},{name:"as",type:"string",default:"path"}]};var bk=[-1e5,-1e5,1e5,1e5];function xk(t){var e=t[0][0],n=t[0][1];var r=t.length-1;for(;t[r][0]===e&&t[r][1]===n;--r){}return "M"+t.slice(0,r+1).join("L")+"Z";}Object(Z.z)(yk,zt,{transform:function transform(t,e){var n=t.as||"path",r=e.source;if(!r||!r.length)return e;var i=t.size;i=i?[0,0,i[0],i[1]]:(i=t.extent)?[i[0][0],i[0][1],i[1][0],i[1][1]]:bk;var o=this.value=vk.from(r,t.x,t.y).voronoi(i);for(var _t93=0,_e101=r.length;_t93<_e101;++_t93){var _e102=o.cellPolygon(_t93);r[_t93][n]=_e102?xk(_e102):null;}return e.reflow(t.modified()).modifies(n);}});var wk=Math.PI/180,kk=64,Ek=2048;function Ck(){var t,e,n,r,i,o,a,s=[256,256],u=Dk,c=[],l=Math.random,f={};function h(t,e,n){for(var r,i,o,a=e.x,c=e.y,f=Math.sqrt(s[0]*s[0]+s[1]*s[1]),h=u(s),d=l()<.5?1:-1,p=-d;(r=h(p+=d))&&(i=~~r[0],o=~~r[1],!(Math.min(Math.abs(i),Math.abs(o))>=f));){if(e.x=a+i,e.y=c+o,!(e.x+e.x0<0||e.y+e.y0<0||e.x+e.x1>s[0]||e.y+e.y1>s[1])&&(!n||!Ok(e,t,s[0]))&&(!n||Sk(e,n))){for(var m,g=e.sprite,v=e.width>>5,y=s[0]>>5,b=e.x-(v<<4),x=127&b,w=32-x,k=e.y1-e.y0,E=(e.y+e.y0)*y+(b>>5),C=0;C<k;C++){m=0;for(var A=0;A<=v;A++){t[E+A]|=m<<w|(A<v?(m=g[C*v+A])>>>x:0);}E+=y;}return e.sprite=null,!0;}}return !1;}return f.layout=function(){for(var u=function(t){t.width=t.height=1;var e=Math.sqrt(t.getContext("2d").getImageData(0,0,1,1).data.length>>2);t.width=(kk<<5)/e,t.height=Ek/e;var n=t.getContext("2d");return n.fillStyle=n.strokeStyle="red",n.textAlign="center",{context:n,ratio:e};}(ji()),f=function(t){var e=[],n=-1;for(;++n<t;){e[n]=0;}return e;}((s[0]>>5)*s[1]),d=null,p=c.length,m=-1,g=[],v=c.map(function(s){return {text:t(s),font:e(s),style:r(s),weight:i(s),rotate:o(s),size:~~(n(s)+1e-14),padding:a(s),xoff:0,yoff:0,x1:0,y1:0,x0:0,y0:0,hasText:!1,sprite:null,datum:s};}).sort(function(t,e){return e.size-t.size;});++m<p;){var y=v[m];y.x=s[0]*(l()+.5)>>1,y.y=s[1]*(l()+.5)>>1,Ak(u,y,v,m),y.hasText&&h(f,y,d)&&(g.push(y),d?_k(d,y):d=[{x:y.x+y.x0,y:y.y+y.y0},{x:y.x+y.x1,y:y.y+y.y1}],y.x-=s[0]>>1,y.y-=s[1]>>1);}return g;},f.words=function(t){return arguments.length?(c=t,f):c;},f.size=function(t){return arguments.length?(s=[+t[0],+t[1]],f):s;},f.font=function(t){return arguments.length?(e=Fk(t),f):e;},f.fontStyle=function(t){return arguments.length?(r=Fk(t),f):r;},f.fontWeight=function(t){return arguments.length?(i=Fk(t),f):i;},f.rotate=function(t){return arguments.length?(o=Fk(t),f):o;},f.text=function(e){return arguments.length?(t=Fk(e),f):t;},f.spiral=function(t){return arguments.length?(u=Tk[t]||t,f):u;},f.fontSize=function(t){return arguments.length?(n=Fk(t),f):n;},f.padding=function(t){return arguments.length?(a=Fk(t),f):a;},f.random=function(t){return arguments.length?(l=t,f):l;},f;}function Ak(t,e,n,r){if(!e.sprite){var i=t.context,o=t.ratio;i.clearRect(0,0,(kk<<5)/o,Ek/o);var a,s,u,c,l,f=0,h=0,d=0,p=n.length;for(--r;++r<p;){if(e=n[r],i.save(),i.font=e.style+" "+e.weight+" "+~~((e.size+1)/o)+"px "+e.font,a=i.measureText(e.text+"m").width*o,u=e.size<<1,e.rotate){var m=Math.sin(e.rotate*wk),g=Math.cos(e.rotate*wk),v=a*g,y=a*m,b=u*g,x=u*m;a=Math.max(Math.abs(v+x),Math.abs(v-x))+31>>5<<5,u=~~Math.max(Math.abs(y+b),Math.abs(y-b));}else a=a+31>>5<<5;if(u>d&&(d=u),f+a>=kk<<5&&(f=0,h+=d,d=0),h+u>=Ek)break;i.translate((f+(a>>1))/o,(h+(u>>1))/o),e.rotate&&i.rotate(e.rotate*wk),i.fillText(e.text,0,0),e.padding&&(i.lineWidth=2*e.padding,i.strokeText(e.text,0,0)),i.restore(),e.width=a,e.height=u,e.xoff=f,e.yoff=h,e.x1=a>>1,e.y1=u>>1,e.x0=-e.x1,e.y0=-e.y1,e.hasText=!0,f+=a;}for(var w=i.getImageData(0,0,(kk<<5)/o,Ek/o).data,k=[];--r>=0;){if((e=n[r]).hasText){for(s=(a=e.width)>>5,u=e.y1-e.y0,c=0;c<u*s;c++){k[c]=0;}if(null==(f=e.xoff))return;h=e.yoff;var E=0,C=-1;for(l=0;l<u;l++){for(c=0;c<a;c++){var A=s*l+(c>>5),O=w[(h+l)*(kk<<5)+(f+c)<<2]?1<<31-c%32:0;k[A]|=O,E|=O;}E?C=l:(e.y0++,u--,l--,h++);}e.y1=e.y0+C,e.sprite=k.slice(0,(e.y1-e.y0)*s);}}}}function Ok(t,e,n){n>>=5;for(var r,i=t.sprite,o=t.width>>5,a=t.x-(o<<4),s=127&a,u=32-s,c=t.y1-t.y0,l=(t.y+t.y0)*n+(a>>5),f=0;f<c;f++){r=0;for(var h=0;h<=o;h++){if((r<<u|(h<o?(r=i[f*o+h])>>>s:0))&e[l+h])return !0;}l+=n;}return !1;}function _k(t,e){var n=t[0],r=t[1];e.x+e.x0<n.x&&(n.x=e.x+e.x0),e.y+e.y0<n.y&&(n.y=e.y+e.y0),e.x+e.x1>r.x&&(r.x=e.x+e.x1),e.y+e.y1>r.y&&(r.y=e.y+e.y1);}function Sk(t,e){return t.x+t.x1>e[0].x&&t.x+t.x0<e[1].x&&t.y+t.y1>e[0].y&&t.y+t.y0<e[1].y;}function Dk(t){var e=t[0]/t[1];return function(t){return [e*(t*=.1)*Math.cos(t),t*Math.sin(t)];};}function Fk(t){return "function"==typeof t?t:function(){return t;};}var Tk={archimedean:Dk,rectangular:function rectangular(t){var e=4*t[0]/t[1],n=0,r=0;return function(t){var i=t<0?-1:1;switch(Math.sqrt(1+4*i*t)-i&3){case 0:n+=e;break;case 1:r+=4;break;case 2:n-=e;break;default:r-=4;}return [n,r];};}};var Nk=["x","y","font","fontSize","fontStyle","fontWeight","angle"],Ik=["text","font","rotate","fontSize","fontStyle","fontWeight"];function Rk(t){zt.call(this,Ck(),t);}Rk.Definition={type:"Wordcloud",metadata:{modifies:!0},params:[{name:"size",type:"number",array:!0,length:2},{name:"font",type:"string",expr:!0,default:"sans-serif"},{name:"fontStyle",type:"string",expr:!0,default:"normal"},{name:"fontWeight",type:"string",expr:!0,default:"normal"},{name:"fontSize",type:"number",expr:!0,default:14},{name:"fontSizeRange",type:"number",array:"nullable",default:[10,50]},{name:"rotate",type:"number",expr:!0,default:0},{name:"text",type:"field"},{name:"spiral",type:"string",values:["archimedean","rectangular"]},{name:"padding",type:"number",expr:!0},{name:"as",type:"string",array:!0,length:7,default:Nk}]},Object(Z.z)(Rk,zt,{transform:function transform(t,e){!t.size||t.size[0]&&t.size[1]||Object(Z.o)("Wordcloud size dimensions must be non-zero.");var n=t.modified();if(!(n||e.changed(e.ADD_REM)||Ik.some(function(n){var r=t[n];return Object(Z.E)(r)&&e.modified(r.fields);})))return;var r=e.materialize(e.SOURCE).source,i=this.value,o=t.as||Nk;var a,s=t.fontSize||14;if(Object(Z.E)(s)?a=t.fontSizeRange:s=Object(Z.m)(s),a){var _t94=s,_e103=ku("sqrt")().domain(Object(Z.q)(r,_t94)).range(a);s=function s(n){return _e103(_t94(n));};}r.forEach(function(t){t[o[0]]=NaN,t[o[1]]=NaN,t[o[3]]=0;});var u=i.words(r).text(t.text).size(t.size||[500,500]).padding(t.padding||1).spiral(t.spiral||"archimedean").rotate(t.rotate||0).font(t.font||"sans-serif").fontStyle(t.fontStyle||"normal").fontWeight(t.fontWeight||"normal").fontSize(s).random(re).layout(),c=i.size(),l=c[0]>>1,f=c[1]>>1,h=u.length;for(var _t95,_e104,_n76=0;_n76<h;++_n76){(_e104=(_t95=u[_n76]).datum)[o[0]]=_t95.x+l,_e104[o[1]]=_t95.y+f,_e104[o[2]]=_t95.font,_e104[o[3]]=_t95.size,_e104[o[4]]=_t95.style,_e104[o[5]]=_t95.weight,_e104[o[6]]=_t95.rotate;}return e.reflow(n).modifies(o);}});var Mk=function Mk(t,e){return Array.from(e,function(e){return t[e];});};var jk=function jk(t){return new Uint8Array(t);},Bk=function Bk(t){return new Uint16Array(t);},Pk=function Pk(t){return new Uint32Array(t);};function Lk(t,e,n){var r=(e<257?jk:e<65537?Bk:Pk)(t);return n&&r.set(n),r;}function zk(t,e,n){var r=1<<e;return {one:r,zero:~r,range:n.slice(),bisect:t.bisect,index:t.index,size:t.size,onAdd:function onAdd(t,e){var n=this.bisect(this.range,t.value),i=t.index,o=n[0],a=n[1],s=i.length;var u;for(u=0;u<o;++u){e[i[u]]|=r;}for(u=a;u<s;++u){e[i[u]]|=r;}return this;}};}function Uk(){var t=Pk(0),e=[],n=0;return {insert:function insert(r,i,o){if(!i.length)return [];var a=n,s=i.length,u=Pk(s);var c,l,f,h=Array(s);for(f=0;f<s;++f){h[f]=r(i[f]),u[f]=f;}if(h=function(t,e){return t.sort.call(e,function(e,n){var r=t[e],i=t[n];return r<i?-1:r>i?1:0;}),Mk(t,e);}(h,u),a)c=e,l=t,e=Array(a+s),t=Pk(a+s),function(t,e,n,r,i,o,a,s,u){var c,l=0,f=0;for(c=0;l<r&&f<a;++c){e[l]<i[f]?(s[c]=e[l],u[c]=n[l++]):(s[c]=i[f],u[c]=o[f++]+t);}for(;l<r;++l,++c){s[c]=e[l],u[c]=n[l];}for(;f<a;++f,++c){s[c]=i[f],u[c]=o[f]+t;}}(o,c,l,a,h,u,s,e,t);else {if(o>0)for(f=0;f<s;++f){u[f]+=o;}e=h,t=u;}return n=a+s,{index:u,value:h};},remove:function remove(r,i){var o=n;var a,s,u;for(s=0;!i[t[s]]&&s<o;++s){}for(u=s;s<o;++s){i[a=t[s]]||(t[u]=a,e[u]=e[s],++u);}n=o-r;},bisect:function bisect(t,r){var i;return r?i=r.length:(r=e,i=n),[zi(r,t[0],0,i),Li(r,t[1],0,i)];},reindex:function reindex(e){for(var _r82=0,_i58=n;_r82<_i58;++_r82){t[_r82]=e[t[_r82]];}},index:function index(){return t;},size:function size(){return n;}};}function Wk(t){zt.call(this,function(){var t=8,e=[],n=Pk(0),r=Lk(0,t),i=Lk(0,t);return {data:function data(){return e;},seen:function seen(){return n=function(t,e,n){return t.length>=e?t:((n=n||new t.constructor(e)).set(t),n);}(n,e.length);},add:function add(t){for(var _n77,_r83=0,_i59=e.length,_o37=t.length;_r83<_o37;++_r83){(_n77=t[_r83])._index=_i59++,e.push(_n77);}},remove:function remove(t,n){var o=e.length,a=Array(o-t),s=e;var u,c,l;for(c=0;!n[c]&&c<o;++c){a[c]=e[c],s[c]=c;}for(l=c;c<o;++c){u=e[c],n[c]?s[c]=-1:(s[c]=l,r[l]=r[c],i[l]=i[c],a[l]=u,u._index=l++),r[c]=0;}return e=a,s;},size:function size(){return e.length;},curr:function curr(){return r;},prev:function prev(){return i;},reset:function reset(t){return i[t]=r[t];},all:function all(){return t<257?255:t<65537?65535:4294967295;},set:function set(t,e){r[t]|=e;},clear:function clear(t,e){r[t]&=~e;},resize:function resize(e,n){(e>r.length||n>t)&&(t=Math.max(n,t),r=Lk(e,t,r),i=Lk(e,t));}};}(),t),this._indices=null,this._dims=null;}function Vk(t){zt.call(this,null,t);}Wk.Definition={type:"CrossFilter",metadata:{},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"query",type:"array",array:!0,required:!0,content:{type:"number",array:!0,length:2}}]},Object(Z.z)(Wk,zt,{transform:function transform(t,e){return this._dims?t.modified("fields")||t.fields.some(function(t){return e.modified(t.fields);})?this.reinit(t,e):this.eval(t,e):this.init(t,e);},init:function init(t,e){var n=t.fields,r=t.query,i=this._indices={},o=this._dims=[],a=r.length;var s,u,c=0;for(;c<a;++c){u=i[s=n[c].fname]||(i[s]=Uk()),o.push(zk(u,c,r[c]));}return this.eval(t,e);},reinit:function reinit(t,e){var n=e.materialize().fork(),r=t.fields,i=t.query,o=this._indices,a=this._dims,s=this.value,u=s.curr(),c=s.prev(),l=s.all(),f=n.rem=n.add,h=n.mod,d=i.length,p={};var m,g,v,y,b,x,w,k,E;if(c.set(u),e.rem.length&&(b=this.remove(t,e,n)),e.add.length&&s.add(e.add),e.mod.length)for(x={},w=0,k=(y=e.mod).length;w<k;++w){x[y[w]._index]=1;}for(w=0;w<d;++w){E=r[w],(!a[w]||t.modified("fields",w)||e.modified(E.fields))&&((m=p[v=E.fname])||(o[v]=g=Uk(),p[v]=m=g.insert(E,e.source,0)),a[w]=zk(g,w,i[w]).onAdd(m,u));}for(w=0,k=s.data().length;w<k;++w){b[w]||(c[w]!==u[w]?f.push(w):x[w]&&u[w]!==l&&h.push(w));}return s.mask=(1<<d)-1,n;},eval:function _eval(t,e){var n=e.materialize().fork(),r=this._dims.length;var i=0;return e.rem.length&&(this.remove(t,e,n),i|=(1<<r)-1),t.modified("query")&&!t.modified("fields")&&(i|=this.update(t,e,n)),e.add.length&&(this.insert(t,e,n),i|=(1<<r)-1),e.mod.length&&(this.modify(e,n),i|=(1<<r)-1),this.value.mask=i,n;},insert:function insert(t,e,n){var r=e.add,i=this.value,o=this._dims,a=this._indices,s=t.fields,u={},c=n.add,l=i.size()+r.length,f=o.length;var h,d,p,m=i.size();i.resize(l,f),i.add(r);var g=i.curr(),v=i.prev(),y=i.all();for(h=0;h<f;++h){p=u[d=s[h].fname]||(u[d]=a[d].insert(s[h],r,m)),o[h].onAdd(p,g);}for(;m<l;++m){v[m]=y,g[m]!==y&&c.push(m);}},modify:function modify(t,e){var n=e.mod,r=this.value,i=r.curr(),o=r.all(),a=t.mod;var s,u,c;for(s=0,u=a.length;s<u;++s){i[c=a[s]._index]!==o&&n.push(c);}},remove:function remove(t,e,n){var r=this._indices,i=this.value,o=i.curr(),a=i.prev(),s=i.all(),u={},c=n.rem,l=e.rem;var f,h,d,p;for(f=0,h=l.length;f<h;++f){u[d=l[f]._index]=1,a[d]=p=o[d],o[d]=s,p!==s&&c.push(d);}for(d in r){r[d].remove(h,u);}return this.reindex(e,h,u),u;},reindex:function reindex(t,e,n){var r=this._indices,i=this.value;t.runAfter(function(){var t=i.remove(e,n);for(var _e105 in r){r[_e105].reindex(t);}});},update:function update(t,e,n){var r=this._dims,i=t.query,o=e.stamp,a=r.length;var s,u,c=0;for(n.filters=0,u=0;u<a;++u){t.modified("query",u)&&(s=u,++c);}if(1===c)c=r[s].one,this.incrementOne(r[s],i[s],n.add,n.rem);else for(u=0,c=0;u<a;++u){t.modified("query",u)&&(c|=r[u].one,this.incrementAll(r[u],i[u],o,n.add),n.rem=n.add);}return c;},incrementAll:function incrementAll(t,e,n,r){var i=this.value,o=i.seen(),a=i.curr(),s=i.prev(),u=t.index(),c=t.bisect(t.range),l=t.bisect(e),f=l[0],h=l[1],d=c[0],p=c[1],m=t.one;var g,v,y;if(f<d)for(g=f,v=Math.min(d,h);g<v;++g){o[y=u[g]]!==n&&(s[y]=a[y],o[y]=n,r.push(y)),a[y]^=m;}else if(f>d)for(g=d,v=Math.min(f,p);g<v;++g){o[y=u[g]]!==n&&(s[y]=a[y],o[y]=n,r.push(y)),a[y]^=m;}if(h>p)for(g=Math.max(f,p),v=h;g<v;++g){o[y=u[g]]!==n&&(s[y]=a[y],o[y]=n,r.push(y)),a[y]^=m;}else if(h<p)for(g=Math.max(d,h),v=p;g<v;++g){o[y=u[g]]!==n&&(s[y]=a[y],o[y]=n,r.push(y)),a[y]^=m;}t.range=e.slice();},incrementOne:function incrementOne(t,e,n,r){var i=this.value.curr(),o=t.index(),a=t.bisect(t.range),s=t.bisect(e),u=s[0],c=s[1],l=a[0],f=a[1],h=t.one;var d,p,m;if(u<l)for(d=u,p=Math.min(l,c);d<p;++d){i[m=o[d]]^=h,n.push(m);}else if(u>l)for(d=l,p=Math.min(u,f);d<p;++d){i[m=o[d]]^=h,r.push(m);}if(c>f)for(d=Math.max(u,f),p=c;d<p;++d){i[m=o[d]]^=h,n.push(m);}else if(c<f)for(d=Math.max(l,c),p=f;d<p;++d){i[m=o[d]]^=h,r.push(m);}t.range=e.slice();}}),Vk.Definition={type:"ResolveFilter",metadata:{},params:[{name:"ignore",type:"number",required:!0,description:"A bit mask indicating which filters to ignore."},{name:"filter",type:"object",required:!0,description:"Per-tuple filter bitmaps from a CrossFilter transform."}]},Object(Z.z)(Vk,zt,{transform:function transform(t,e){var n=~(t.ignore||0),r=t.filter,i=r.mask;if(0==(i&n))return e.StopPropagation;var o=e.fork(e.ALL),a=r.data(),s=r.curr(),u=r.prev(),c=function c(t){return s[t]&n?null:a[t];};return o.filter(o.MOD,c),i&i-1?(o.filter(o.ADD,function(t){var e=s[t]&n;return !e&&e^u[t]&n?a[t]:null;}),o.filter(o.REM,function(t){var e=s[t]&n;return e&&!(e^e^u[t]&n)?a[t]:null;})):(o.filter(o.ADD,c),o.filter(o.REM,function(t){return (s[t]&n)===i?a[t]:null;})),o.filter(o.SOURCE,function(t){return c(t._index);});}});var qk="RawCode",$k="Literal",Hk="Property",Gk="Identifier",Kk="ArrayExpression",Xk="BinaryExpression",Yk="CallExpression",Jk="ConditionalExpression",Qk="LogicalExpression",Zk="MemberExpression",tE="ObjectExpression",eE="UnaryExpression";function nE(t){this.type=t;}var rE,iE,oE,aE,sE;nE.prototype.visit=function(t){var e,n,r;if(t(this))return 1;for(n=0,r=(e=function(t){switch(t.type){case Kk:return t.elements;case Xk:case Qk:return [t.left,t.right];case Yk:return [t.callee].concat(t.arguments);case Jk:return [t.test,t.consequent,t.alternate];case Zk:return [t.object,t.property];case tE:return t.properties;case Hk:return [t.key,t.value];case eE:return [t.argument];case Gk:case $k:case qk:default:return [];}}(this)).length;n<r;++n){if(e[n].visit(t))return 1;}};var uE=1,cE=2,lE=3,fE=4,hE=5,dE=6,pE=7,mE=8;(rE={})[uE]="Boolean",rE[cE]="<end>",rE[lE]="Identifier",rE[fE]="Keyword",rE[hE]="Null",rE[dE]="Numeric",rE[pE]="Punctuator",rE[mE]="String",rE[9]="RegularExpression";var gE="ArrayExpression",vE="BinaryExpression",yE="CallExpression",bE="ConditionalExpression",xE="Identifier",wE="Literal",kE="LogicalExpression",EE="MemberExpression",CE="ObjectExpression",AE="Property",OE="UnaryExpression",_E="Unexpected token %0",SE="Unexpected number",DE="Unexpected string",FE="Unexpected identifier",TE="Unexpected reserved word",NE="Unexpected end of input",IE="Invalid regular expression",RE="Invalid regular expression: missing /",ME="Octal literals are not allowed in strict mode.",jE="Duplicate data property in object literal not allowed in strict mode",BE="ILLEGAL",PE="Disabled.",LE=new RegExp("[\\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\\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-\\u08B2\\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\\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-\\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-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\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-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\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-\\uAB5F\\uAB64\\uAB65\\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\\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]"),zE=new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C81-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\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\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\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\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\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-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\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-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]");function UE(t,e){if(!t)throw new Error("ASSERT: "+e);}function WE(t){return t>=48&&t<=57;}function VE(t){return "0123456789abcdefABCDEF".indexOf(t)>=0;}function qE(t){return "01234567".indexOf(t)>=0;}function $E(t){return 32===t||9===t||11===t||12===t||160===t||t>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(t)>=0;}function HE(t){return 10===t||13===t||8232===t||8233===t;}function GE(t){return 36===t||95===t||t>=65&&t<=90||t>=97&&t<=122||92===t||t>=128&&LE.test(String.fromCharCode(t));}function KE(t){return 36===t||95===t||t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||92===t||t>=128&&zE.test(String.fromCharCode(t));}var XE={if:1,in:1,do:1,var:1,for:1,new:1,try:1,let:1,this:1,else:1,case:1,void:1,with:1,enum:1,while:1,break:1,catch:1,throw:1,const:1,yield:1,class:1,super:1,return:1,typeof:1,delete:1,switch:1,export:1,import:1,public:1,static:1,default:1,finally:1,extends:1,package:1,private:1,function:1,continue:1,debugger:1,interface:1,protected:1,instanceof:1,implements:1};function YE(){for(;oE<aE;){var _t96=iE.charCodeAt(oE);if(!$E(_t96)&&!HE(_t96))break;++oE;}}function JE(t){var e,n,r,i=0;for(n="u"===t?4:2,e=0;e<n;++e){oE<aE&&VE(iE[oE])?(r=iE[oE++],i=16*i+"0123456789abcdef".indexOf(r.toLowerCase())):dC({},_E,BE);}return String.fromCharCode(i);}function QE(){var t,e,n,r;for(e=0,"}"===(t=iE[oE])&&dC({},_E,BE);oE<aE&&VE(t=iE[oE++]);){e=16*e+"0123456789abcdef".indexOf(t.toLowerCase());}return (e>1114111||"}"!==t)&&dC({},_E,BE),e<=65535?String.fromCharCode(e):(n=55296+(e-65536>>10),r=56320+(e-65536&1023),String.fromCharCode(n,r));}function ZE(){var t,e;for(t=iE.charCodeAt(oE++),e=String.fromCharCode(t),92===t&&(117!==iE.charCodeAt(oE)&&dC({},_E,BE),++oE,(t=JE("u"))&&"\\"!==t&&GE(t.charCodeAt(0))||dC({},_E,BE),e=t);oE<aE&&KE(t=iE.charCodeAt(oE));){++oE,e+=String.fromCharCode(t),92===t&&(e=e.substr(0,e.length-1),117!==iE.charCodeAt(oE)&&dC({},_E,BE),++oE,(t=JE("u"))&&"\\"!==t&&KE(t.charCodeAt(0))||dC({},_E,BE),e+=t);}return e;}function tC(){var t,e;return t=oE,{type:1===(e=92===iE.charCodeAt(oE)?ZE():function(){var t,e;for(t=oE++;oE<aE;){if(92===(e=iE.charCodeAt(oE)))return oE=t,ZE();if(!KE(e))break;++oE;}return iE.slice(t,oE);}()).length?lE:XE.hasOwnProperty(e)?fE:"null"===e?hE:"true"===e||"false"===e?uE:lE,value:e,start:t,end:oE};}function eC(){var t,e,n,r,i=oE,o=iE.charCodeAt(oE),a=iE[oE];switch(o){case 46:case 40:case 41:case 59:case 44:case 123:case 125:case 91:case 93:case 58:case 63:case 126:return ++oE,{type:pE,value:String.fromCharCode(o),start:i,end:oE};default:if(61===(t=iE.charCodeAt(oE+1)))switch(o){case 43:case 45:case 47:case 60:case 62:case 94:case 124:case 37:case 38:case 42:return oE+=2,{type:pE,value:String.fromCharCode(o)+String.fromCharCode(t),start:i,end:oE};case 33:case 61:return oE+=2,61===iE.charCodeAt(oE)&&++oE,{type:pE,value:iE.slice(i,oE),start:i,end:oE};}}return ">>>="===(r=iE.substr(oE,4))?{type:pE,value:r,start:i,end:oE+=4}:">>>"===(n=r.substr(0,3))||"<<="===n||">>="===n?{type:pE,value:n,start:i,end:oE+=3}:a===(e=n.substr(0,2))[1]&&"+-<>&|".indexOf(a)>=0||"=>"===e?{type:pE,value:e,start:i,end:oE+=2}:("//"===e&&dC({},_E,BE),"<>=!+-*%&|^/".indexOf(a)>=0?{type:pE,value:a,start:i,end:++oE}:void dC({},_E,BE));}function nC(){var t,e,n;if(UE(WE((n=iE[oE]).charCodeAt(0))||"."===n,"Numeric literal must start with a decimal digit or a decimal point"),e=oE,t="","."!==n){if(t=iE[oE++],n=iE[oE],"0"===t){if("x"===n||"X"===n)return ++oE,function(t){var e="";for(;oE<aE&&VE(iE[oE]);){e+=iE[oE++];}return 0===e.length&&dC({},_E,BE),GE(iE.charCodeAt(oE))&&dC({},_E,BE),{type:dE,value:parseInt("0x"+e,16),start:t,end:oE};}(e);if(qE(n))return function(t){var e="0"+iE[oE++];for(;oE<aE&&qE(iE[oE]);){e+=iE[oE++];}return (GE(iE.charCodeAt(oE))||WE(iE.charCodeAt(oE)))&&dC({},_E,BE),{type:dE,value:parseInt(e,8),octal:!0,start:t,end:oE};}(e);n&&WE(n.charCodeAt(0))&&dC({},_E,BE);}for(;WE(iE.charCodeAt(oE));){t+=iE[oE++];}n=iE[oE];}if("."===n){for(t+=iE[oE++];WE(iE.charCodeAt(oE));){t+=iE[oE++];}n=iE[oE];}if("e"===n||"E"===n)if(t+=iE[oE++],"+"!==(n=iE[oE])&&"-"!==n||(t+=iE[oE++]),WE(iE.charCodeAt(oE)))for(;WE(iE.charCodeAt(oE));){t+=iE[oE++];}else dC({},_E,BE);return GE(iE.charCodeAt(oE))&&dC({},_E,BE),{type:dE,value:parseFloat(t),start:e,end:oE};}function rC(){var t,e,n,r;return sE=null,YE(),t=oE,e=function(){var t,e,n,r;for(UE("/"===(t=iE[oE]),"Regular expression literal must start with a slash"),e=iE[oE++],n=!1,r=!1;oE<aE;){if(e+=t=iE[oE++],"\\"===t)HE((t=iE[oE++]).charCodeAt(0))&&dC({},RE),e+=t;else if(HE(t.charCodeAt(0)))dC({},RE);else if(n)"]"===t&&(n=!1);else {if("/"===t){r=!0;break;}"["===t&&(n=!0);}}return r||dC({},RE),{value:e.substr(1,e.length-2),literal:e};}(),n=function(){var t,e,n;for(e="",n="";oE<aE&&KE((t=iE[oE]).charCodeAt(0));){++oE,"\\"===t&&oE<aE?dC({},_E,BE):(n+=t,e+=t);}return n.search(/[^gimuy]/g)>=0&&dC({},IE,n),{value:n,literal:e};}(),r=function(t,e){var n=t;e.indexOf("u")>=0&&(n=n.replace(/\\u\{([0-9a-fA-F]+)\}/g,function(t,e){if(parseInt(e,16)<=1114111)return "x";dC({},IE);}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"x"));try{new RegExp(n);}catch(t){dC({},IE);}try{return new RegExp(t,e);}catch(t){return null;}}(e.value,n.value),{literal:e.literal+n.literal,value:r,regex:{pattern:e.value,flags:n.value},start:t,end:oE};}function iC(){if(YE(),oE>=aE)return {type:cE,start:oE,end:oE};var t=iE.charCodeAt(oE);return GE(t)?tC():40===t||41===t||59===t?eC():39===t||34===t?function(){var t,e,n,r,i="",o=!1;for(UE("'"===(t=iE[oE])||'"'===t,"String literal must starts with a quote"),e=oE,++oE;oE<aE;){if((n=iE[oE++])===t){t="";break;}if("\\"===n){if((n=iE[oE++])&&HE(n.charCodeAt(0)))"\r"===n&&"\n"===iE[oE]&&++oE;else switch(n){case"u":case"x":"{"===iE[oE]?(++oE,i+=QE()):i+=JE(n);break;case"n":i+="\n";break;case"r":i+="\r";break;case"t":i+="\t";break;case"b":i+="\b";break;case"f":i+="\f";break;case"v":i+="\v";break;default:qE(n)?(0!==(r="01234567".indexOf(n))&&(o=!0),oE<aE&&qE(iE[oE])&&(o=!0,r=8*r+"01234567".indexOf(iE[oE++]),"0123".indexOf(n)>=0&&oE<aE&&qE(iE[oE])&&(r=8*r+"01234567".indexOf(iE[oE++]))),i+=String.fromCharCode(r)):i+=n;}}else {if(HE(n.charCodeAt(0)))break;i+=n;}}return ""!==t&&dC({},_E,BE),{type:mE,value:i,octal:o,start:e,end:oE};}():46===t?WE(iE.charCodeAt(oE+1))?nC():eC():WE(t)?nC():eC();}function oC(){var t=sE;return oE=t.end,sE=iC(),oE=t.end,t;}function aC(){var t=oE;sE=iC(),oE=t;}function sC(t,e,n){var r=new nE("||"===t||"&&"===t?kE:vE);return r.operator=t,r.left=e,r.right=n,r;}function uC(t,e){var n=new nE(yE);return n.callee=t,n.arguments=e,n;}function cC(t){var e=new nE(xE);return e.name=t,e;}function lC(t){var e=new nE(wE);return e.value=t.value,e.raw=iE.slice(t.start,t.end),t.regex&&("//"===e.raw&&(e.raw="/(?:)/"),e.regex=t.regex),e;}function fC(t,e,n){var r=new nE(EE);return r.computed="["===t,r.object=e,r.property=n,r.computed||(n.member=!0),r;}function hC(t,e,n){var r=new nE(AE);return r.key=e,r.value=n,r.kind=t,r;}function dC(t,e){var n,r=Array.prototype.slice.call(arguments,2),i=e.replace(/%(\d)/g,function(t,e){return UE(e<r.length,"Message reference must be in range"),r[e];});throw (n=new Error(i)).index=oE,n.description=i,n;}function pC(t){t.type===cE&&dC(t,NE),t.type===dE&&dC(t,SE),t.type===mE&&dC(t,DE),t.type===lE&&dC(t,FE),t.type===fE&&dC(t,TE),dC(t,_E,t.value);}function mC(t){var e=oC();e.type===pE&&e.value===t||pC(e);}function gC(t){return sE.type===pE&&sE.value===t;}function vC(t){return sE.type===fE&&sE.value===t;}function yC(){var t=[];for(oE=sE.start,mC("[");!gC("]");){gC(",")?(oC(),t.push(null)):(t.push(FC()),gC("]")||mC(","));}return oC(),function(t){var e=new nE(gE);return e.elements=t,e;}(t);}function bC(){oE=sE.start;var t=oC();return t.type===mE||t.type===dE?(t.octal&&dC(t,ME),lC(t)):cC(t.value);}function xC(){var t,e,n;return oE=sE.start,(t=sE).type===lE?(n=bC(),mC(":"),hC("init",n,FC())):t.type!==cE&&t.type!==pE?(e=bC(),mC(":"),hC("init",e,FC())):void pC(t);}function wC(){var t,e,n=[],r={},i=String;for(oE=sE.start,mC("{");!gC("}");){e="$"+((t=xC()).key.type===xE?t.key.name:i(t.key.value)),Object.prototype.hasOwnProperty.call(r,e)?dC({},jE):r[e]=!0,n.push(t),gC("}")||mC(",");}return mC("}"),function(t){var e=new nE(CE);return e.properties=t,e;}(n);}var kC={if:1};function EC(){var t,e,n;if(gC("("))return function(){mC("(");var t=TC();return mC(")"),t;}();if(gC("["))return yC();if(gC("{"))return wC();if(t=sE.type,oE=sE.start,t===lE||kC[sE.value])n=cC(oC().value);else if(t===mE||t===dE)sE.octal&&dC(sE,ME),n=lC(oC());else {if(t===fE)throw new Error(PE);t===uE?((e=oC()).value="true"===e.value,n=lC(e)):t===hE?((e=oC()).value=null,n=lC(e)):gC("/")||gC("/=")?(n=lC(rC()),aC()):pC(oC());}return n;}function CC(){var t=[];if(mC("("),!gC(")"))for(;oE<aE&&(t.push(FC()),!gC(")"));){mC(",");}return mC(")"),t;}function AC(){oE=sE.start;var t=oC();return function(t){return t.type===lE||t.type===fE||t.type===uE||t.type===hE;}(t)||pC(t),cC(t.value);}function OC(){mC("[");var t=TC();return mC("]"),t;}function _C(){var t=function(){var t;for(t=EC();;){if(gC("."))mC("."),t=fC(".",t,AC());else if(gC("("))t=uC(t,CC());else {if(!gC("["))break;t=fC("[",t,OC());}}return t;}();if(sE.type===pE&&(gC("++")||gC("--")))throw new Error(PE);return t;}function SC(){var t,e;if(sE.type!==pE&&sE.type!==fE)e=_C();else {if(gC("++")||gC("--"))throw new Error(PE);if(gC("+")||gC("-")||gC("~")||gC("!"))t=oC(),e=SC(),e=function(t,e){var n=new nE(OE);return n.operator=t,n.argument=e,n.prefix=!0,n;}(t.value,e);else {if(vC("delete")||vC("void")||vC("typeof"))throw new Error(PE);e=_C();}}return e;}function DC(t){var e=0;if(t.type!==pE&&t.type!==fE)return 0;switch(t.value){case"||":e=1;break;case"&&":e=2;break;case"|":e=3;break;case"^":e=4;break;case"&":e=5;break;case"==":case"!=":case"===":case"!==":e=6;break;case"<":case">":case"<=":case">=":case"instanceof":case"in":e=7;break;case"<<":case">>":case">>>":e=8;break;case"+":case"-":e=9;break;case"*":case"/":case"%":e=11;}return e;}function FC(){var t,e;return t=function(){var t,e,n,r,i,o,a,s,u,c;if(t=sE,u=SC(),0===(i=DC(r=sE)))return u;for(r.prec=i,oC(),e=[t,sE],o=[u,r,a=SC()];(i=DC(sE))>0;){for(;o.length>2&&i<=o[o.length-2].prec;){a=o.pop(),s=o.pop().value,u=o.pop(),e.pop(),n=sC(s,u,a),o.push(n);}(r=oC()).prec=i,o.push(r),e.push(sE),n=SC(),o.push(n);}for(n=o[c=o.length-1],e.pop();c>1;){e.pop(),n=sC(o[c-1].value,o[c-2],n),c-=2;}return n;}(),gC("?")&&(oC(),e=FC(),mC(":"),t=function(t,e,n){var r=new nE(bE);return r.test=t,r.consequent=e,r.alternate=n,r;}(t,e,FC())),t;}function TC(){var t=FC();if(gC(","))throw new Error(PE);return t;}var NC={NaN:"NaN",E:"Math.E",LN2:"Math.LN2",LN10:"Math.LN10",LOG2E:"Math.LOG2E",LOG10E:"Math.LOG10E",PI:"Math.PI",SQRT1_2:"Math.SQRT1_2",SQRT2:"Math.SQRT2",MIN_VALUE:"Number.MIN_VALUE",MAX_VALUE:"Number.MAX_VALUE"};function IC(t){function e(e,n,r){return function(i){return function(e,n,r,i){var o=t(n[0]);return r&&(o=r+"("+o+")",0===r.lastIndexOf("new ",0)&&(o="("+o+")")),o+"."+e+(i<0?"":0===i?"()":"("+n.slice(1).map(t).join(",")+")");}(e,i,n,r);};}var n="new Date";return {isNaN:"Number.isNaN",isFinite:"Number.isFinite",abs:"Math.abs",acos:"Math.acos",asin:"Math.asin",atan:"Math.atan",atan2:"Math.atan2",ceil:"Math.ceil",cos:"Math.cos",exp:"Math.exp",floor:"Math.floor",log:"Math.log",max:"Math.max",min:"Math.min",pow:"Math.pow",random:"Math.random",round:"Math.round",sin:"Math.sin",sqrt:"Math.sqrt",tan:"Math.tan",clamp:function clamp(e){e.length<3&&Object(Z.o)("Missing arguments to clamp function."),e.length>3&&Object(Z.o)("Too many arguments to clamp function.");var n=e.map(t);return "Math.max("+n[1]+", Math.min("+n[2]+","+n[0]+"))";},now:"Date.now",utc:"Date.UTC",datetime:n,date:e("getDate",n,0),day:e("getDay",n,0),year:e("getFullYear",n,0),month:e("getMonth",n,0),hours:e("getHours",n,0),minutes:e("getMinutes",n,0),seconds:e("getSeconds",n,0),milliseconds:e("getMilliseconds",n,0),time:e("getTime",n,0),timezoneoffset:e("getTimezoneOffset",n,0),utcdate:e("getUTCDate",n,0),utcday:e("getUTCDay",n,0),utcyear:e("getUTCFullYear",n,0),utcmonth:e("getUTCMonth",n,0),utchours:e("getUTCHours",n,0),utcminutes:e("getUTCMinutes",n,0),utcseconds:e("getUTCSeconds",n,0),utcmilliseconds:e("getUTCMilliseconds",n,0),length:e("length",null,-1),parseFloat:"parseFloat",parseInt:"parseInt",upper:e("toUpperCase","String",0),lower:e("toLowerCase","String",0),substring:e("substring","String"),split:e("split","String"),trim:e("trim","String",0),regexp:"RegExp",test:e("test","RegExp"),if:function _if(e){e.length<3&&Object(Z.o)("Missing arguments to if function."),e.length>3&&Object(Z.o)("Too many arguments to if function.");var n=e.map(t);return "("+n[0]+"?"+n[1]+":"+n[2]+")";}};}var RC,MC,jC,BC,PC,LC=new Rm(),zC=new Rm(),UC={point:rg,lineStart:rg,lineEnd:rg,polygonStart:function polygonStart(){LC=new Rm(),UC.lineStart=WC,UC.lineEnd=VC;},polygonEnd:function polygonEnd(){var t=+LC;zC.add(t<0?Lm+t:t),this.lineStart=this.lineEnd=this.point=rg;},sphere:function sphere(){zC.add(Lm);}};function WC(){UC.point=qC;}function VC(){$C(RC,MC);}function qC(t,e){UC.point=$C,RC=t,MC=e,jC=t*=Um,BC=$m(e=(e*=Um)/2+Pm),PC=Jm(e);}function $C(t,e){e=(e*=Um)/2+Pm;var n=(t*=Um)-jC,r=n>=0?1:-1,i=r*n,o=$m(e),a=Jm(e),s=PC*a,u=BC*o+s*$m(i),c=s*r*Jm(i);LC.add(qm(c,u)),jC=t,BC=o,PC=a;}var HC,GC,KC,XC,YC,JC,QC,ZC,tA,eA,nA,rA={point:iA,lineStart:aA,lineEnd:sA,polygonStart:function polygonStart(){rA.point=uA,rA.lineStart=cA,rA.lineEnd=lA,tA=new Rm(),UC.polygonStart();},polygonEnd:function polygonEnd(){UC.polygonEnd(),rA.point=iA,rA.lineStart=aA,rA.lineEnd=sA,LC<0?(HC=-(KC=180),GC=-(XC=90)):tA>Mm?XC=90:tA<-Mm&&(GC=-90),nA[0]=HC,nA[1]=KC;},sphere:function sphere(){HC=-(KC=180),GC=-(XC=90);}};function iA(t,e){eA.push(nA=[HC=t,KC=t]),e<GC&&(GC=e),e>XC&&(XC=e);}function oA(t,e){var n=fv([t*Um,e*Um]);if(ZC){var r=dv(ZC,n),i=dv([r[1],-r[0],0],r);gv(i),i=lv(i);var o,a=t-YC,s=a>0?1:-1,u=i[0]*zm*s,c=Wm(a)>180;c^(s*YC<u&&u<s*t)?(o=i[1]*zm)>XC&&(XC=o):c^(s*YC<(u=(u+360)%360-180)&&u<s*t)?(o=-i[1]*zm)<GC&&(GC=o):(e<GC&&(GC=e),e>XC&&(XC=e)),c?t<YC?fA(HC,t)>fA(HC,KC)&&(KC=t):fA(t,KC)>fA(HC,KC)&&(HC=t):KC>=HC?(t<HC&&(HC=t),t>KC&&(KC=t)):t>YC?fA(HC,t)>fA(HC,KC)&&(KC=t):fA(t,KC)>fA(HC,KC)&&(HC=t);}else eA.push(nA=[HC=t,KC=t]);e<GC&&(GC=e),e>XC&&(XC=e),ZC=n,YC=t;}function aA(){rA.point=oA;}function sA(){nA[0]=HC,nA[1]=KC,rA.point=iA,ZC=null;}function uA(t,e){if(ZC){var n=t-YC;tA.add(Wm(n)>180?n+(n>0?360:-360):n);}else JC=t,QC=e;UC.point(t,e),oA(t,e);}function cA(){UC.lineStart();}function lA(){uA(JC,QC),UC.lineEnd(),Wm(tA)>Mm&&(HC=-(KC=180)),nA[0]=HC,nA[1]=KC,ZC=null;}function fA(t,e){return (e-=t)<0?e+360:e;}function hA(t,e){return t[0]-e[0];}function dA(t,e){return t[0]<=t[1]?t[0]<=e&&e<=t[1]:e<t[0]||t[1]<e;}var pA,mA,gA,vA,yA,bA,xA,wA,kA,EA,CA,AA,OA,_A,SA,DA,FA={sphere:rg,point:TA,lineStart:IA,lineEnd:jA,polygonStart:function polygonStart(){FA.lineStart=BA,FA.lineEnd=PA;},polygonEnd:function polygonEnd(){FA.lineStart=IA,FA.lineEnd=jA;}};function TA(t,e){t*=Um;var n=$m(e*=Um);NA(n*$m(t),n*Jm(t),Jm(e));}function NA(t,e,n){gA+=(t-gA)/++pA,vA+=(e-vA)/pA,yA+=(n-yA)/pA;}function IA(){FA.point=RA;}function RA(t,e){t*=Um;var n=$m(e*=Um);_A=n*$m(t),SA=n*Jm(t),DA=Jm(e),FA.point=MA,NA(_A,SA,DA);}function MA(t,e){t*=Um;var n=$m(e*=Um),r=n*$m(t),i=n*Jm(t),o=Jm(e),a=qm(Zm((a=SA*o-DA*i)*a+(a=DA*r-_A*o)*a+(a=_A*i-SA*r)*a),_A*r+SA*i+DA*o);mA+=a,bA+=a*(_A+(_A=r)),xA+=a*(SA+(SA=i)),wA+=a*(DA+(DA=o)),NA(_A,SA,DA);}function jA(){FA.point=TA;}function BA(){FA.point=LA;}function PA(){zA(AA,OA),FA.point=TA;}function LA(t,e){AA=t,OA=e,t*=Um,e*=Um,FA.point=zA;var n=$m(e);_A=n*$m(t),SA=n*Jm(t),DA=Jm(e),NA(_A,SA,DA);}function zA(t,e){t*=Um;var n=$m(e*=Um),r=n*$m(t),i=n*Jm(t),o=Jm(e),a=SA*o-DA*i,s=DA*r-_A*o,u=_A*i-SA*r,c=Km(a,s,u),l=ng(c),f=c&&-l/c;kA.add(f*a),EA.add(f*s),CA.add(f*u),mA+=l,bA+=l*(_A+(_A=r)),xA+=l*(SA+(SA=i)),wA+=l*(DA+(DA=o)),NA(_A,SA,DA);}var WA="Literal";var tO;var eO=1,nO=2,rO=3,iO=4,oO=5,aO=6,sO=7,uO=8;(tO={})[eO]="Boolean",tO[nO]="<end>",tO[rO]="Identifier",tO[iO]="Keyword",tO[oO]="Null",tO[aO]="Numeric",tO[sO]="Punctuator",tO[uO]="String",tO[9]="RegularExpression";var cO="intersect",lO="union",fO="vlMulti",hO="vlPoint",dO="or",pO="and",mO="E",gO="R",vO="R-E",yO="R-LE",bO="R-RE",xO="index:unit";function wO(t,e){for(var n,r,i=e.fields,o=e.values,a=i.length,s=0;s<a;++s){if((r=i[s]).getter=Z.u.getter||Object(Z.u)(r.field),n=r.getter(t),Object(Z.D)(n)&&(n=Object(Z.Ea)(n)),Object(Z.D)(o[s])&&(o[s]=Object(Z.Ea)(o[s])),Object(Z.D)(o[s][0])&&(o[s]=o[s].map(Z.Ea)),r.type===mO){if(Object(Z.B)(o[s])?o[s].indexOf(n)<0:n!==o[s])return !1;}else if(r.type===gO){if(!Object(Z.A)(n,o[s]))return !1;}else if(r.type===bO){if(!Object(Z.A)(n,o[s],!0,!1))return !1;}else if(r.type===vO){if(!Object(Z.A)(n,o[s],!1,!1))return !1;}else if(r.type===yO&&!Object(Z.A)(n,o[s],!1,!0))return !1;}return !0;}var kO=Object(Z.u)("_vgsid_"),EO=function(t){var e=t,n=t;function r(t,e,r,i){for(null==r&&(r=0),null==i&&(i=t.length);r<i;){var _o38=r+i>>>1;n(t[_o38],e)<0?r=_o38+1:i=_o38;}return r;}return 1===t.length&&(e=function e(_e106,n){return t(_e106)-n;},n=function(t){return function(e,n){return function(t,e){return t<e?-1:t>e?1:t>=e?0:NaN;}(t(e),n);};}(t)),{left:r,center:function center(t,n,i,o){null==i&&(i=0),null==o&&(o=t.length);var a=r(t,n,i,o-1);return a>i&&e(t[a-1],n)>-e(t[a],n)?a-1:a;},right:function right(t,e,r,i){for(null==r&&(r=0),null==i&&(i=t.length);r<i;){var _o39=r+i>>>1;n(t[_o39],e)>0?i=_o39:r=_o39+1;}return r;}};}(kO),CO=EO.left,AO=EO.right;var OO={E_union:function E_union(t,e){if(!t.length)return e;for(var n=0,r=e.length;n<r;++n){t.indexOf(e[n])<0&&t.push(e[n]);}return t;},E_intersect:function E_intersect(t,e){return t.length?t.filter(function(t){return e.indexOf(t)>=0;}):e;},R_union:function R_union(t,e){var n=Object(Z.Ea)(e[0]),r=Object(Z.Ea)(e[1]);return n>r&&(n=e[1],r=e[0]),t.length?(t[0]>n&&(t[0]=n),t[1]<r&&(t[1]=r),t):[n,r];},R_intersect:function R_intersect(t,e){var n=Object(Z.Ea)(e[0]),r=Object(Z.Ea)(e[1]);return n>r&&(n=e[1],r=e[0]),t.length?r<t[0]||t[1]<n?[]:(t[0]<n&&(t[0]=n),t[1]>r&&(t[1]=r),t):[n,r];}};var _O=":",SO="@";function DO(t,e,n,r){e[0].type!==WA&&Object(Z.o)("First argument to selection functions must be a string literal.");var i=e[0].value,o=e.length>=2&&Object(Z.W)(e).value,a=SO+"unit",s=_O+i;o!==cO||Object(Z.w)(r,a)||(r[a]=n.getData(i).indataRef(n,"unit")),Object(Z.w)(r,s)||(r[s]=n.getData(i).tuplesRef());}function FO(t){var e=this.context.data[t];return e?e.values.value:[];}var TO=function TO(t){return function(e,n){return this.context.dataflow.locale()[t](n)(e);};},NO=TO("format"),IO=TO("timeFormat"),RO=TO("utcFormat"),MO=TO("timeParse"),jO=TO("utcParse"),BO=new Date(2e3,0,1);function PO(t,e,n){return Number.isInteger(t)&&Number.isInteger(e)?(BO.setYear(2e3),BO.setMonth(t),BO.setDate(e),IO.call(this,BO,n)):"";}var LO=":",zO="@",UO="%",WO="$";function VO(t,e,n,r){e[0].type!==$k&&Object(Z.o)("First argument to data functions must be a string literal.");var i=e[0].value,o=LO+i;if(!Object(Z.w)(o,r))try{r[o]=n.getData(i).tuplesRef();}catch(t){}}function qO(t,e,n,r){if(e[0].type===$k)$O(n,r,e[0].value);else for(t in n.scales){$O(n,r,t);}}function $O(t,e,n){var r=UO+n;if(!Object(Z.w)(e,r))try{e[r]=t.scaleRef(n);}catch(t){}}function HO(t,e){var n;return Object(Z.E)(t)?t:Object(Z.J)(t)?(n=e.scales[t])&&n.value:void 0;}function GO(t,e){return function(n,r,i){if(n){var _e107=HO(n,(i||this).context);return _e107&&_e107.path[t](r);}return e(r);};}var KO=GO("area",function(t){return zC=new Rm(),Im(t,UC),2*zC;}),XO=GO("bounds",function(t){var e,n,r,i,o,a,s;if(XC=KC=-(HC=GC=1/0),eA=[],Im(t,rA),n=eA.length){for(eA.sort(hA),e=1,o=[r=eA[0]];e<n;++e){dA(r,(i=eA[e])[0])||dA(r,i[1])?(fA(r[0],i[1])>fA(r[0],r[1])&&(r[1]=i[1]),fA(i[0],r[1])>fA(r[0],r[1])&&(r[0]=i[0])):o.push(r=i);}for(a=-1/0,e=0,r=o[n=o.length-1];e<=n;r=i,++e){i=o[e],(s=fA(r[1],i[0]))>a&&(a=s,HC=i[0],KC=r[1]);}}return eA=nA=null,HC===1/0||GC===1/0?[[NaN,NaN],[NaN,NaN]]:[[HC,GC],[KC,XC]];}),YO=GO("centroid",function(t){pA=mA=gA=vA=yA=bA=xA=wA=0,kA=new Rm(),EA=new Rm(),CA=new Rm(),Im(t,FA);var e=+kA,n=+EA,r=+CA,i=Km(e,n,r);return i<1e-12&&(e=bA,n=xA,r=wA,mA<Mm&&(e=gA,n=vA,r=yA),(i=Km(e,n,r))<1e-12)?[NaN,NaN]:[qm(n,e)*zm,ng(r/i)*zm];});function JO(t,e,n){try{t[e].apply(t,["EXPRESSION"].concat([].slice.call(n)));}catch(e){t.warn(e);}return n[n.length-1];}function QO(t){var e=t/255;return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4);}function ZO(t){var e=go(t);return .2126*QO(e.r)+.7152*QO(e.g)+.0722*QO(e.b);}function t_(t,e){return t===e||t!=t&&e!=e||(Object(Z.B)(t)?!(!Object(Z.B)(e)||t.length!==e.length)&&function(t,e){for(var _n78=0,_r84=t.length;_n78<_r84;++_n78){if(!t_(t[_n78],e[_n78]))return !1;}return !0;}(t,e):!(!Object(Z.H)(t)||!Object(Z.H)(e))&&e_(t,e));}function e_(t,e){for(var _n79 in t){if(!t_(t[_n79],e[_n79]))return !1;}return !0;}function n_(t){return function(e){return e_(t,e);};}var r_={};function i_(t){return Object(Z.B)(t)||ArrayBuffer.isView(t)?t:null;}function o_(t){return i_(t)||(Object(Z.J)(t)?t:null);}var a_=function a_(t){return t.data;};function s_(t,e){var n=FO.call(e,t);return n.root&&n.root.lookup||{};}var u_=function u_(){return "undefined"!=typeof window&&window||null;};var c_={random:function random(){return re();},cumulativeNormal:pe,cumulativeLogNormal:xe,cumulativeUniform:Oe,densityNormal:de,densityLogNormal:be,densityUniform:Ae,quantileNormal:me,quantileLogNormal:we,quantileUniform:_e,sampleNormal:he,sampleLogNormal:ye,sampleUniform:Ce,isArray:Z.B,isBoolean:Z.C,isDate:Z.D,isDefined:function isDefined(t){return void 0!==t;},isNumber:Z.G,isObject:Z.H,isRegExp:Z.I,isString:Z.J,isTuple:at,isValid:function isValid(t){return null!=t&&t==t;},toBoolean:Z.Ca,toDate:Z.Da,toNumber:Z.Ea,toString:Z.Ga,indexof:function indexof(t){var _o_;for(var _len3=arguments.length,e=new Array(_len3>1?_len3-1:0),_key3=1;_key3<_len3;_key3++){e[_key3-1]=arguments[_key3];}return (_o_=o_(t)).indexOf.apply(_o_,e);},join:function join(t){var _i_;for(var _len4=arguments.length,e=new Array(_len4>1?_len4-1:0),_key4=1;_key4<_len4;_key4++){e[_key4-1]=arguments[_key4];}return (_i_=i_(t)).join.apply(_i_,e);},lastindexof:function lastindexof(t){var _o_2;for(var _len5=arguments.length,e=new Array(_len5>1?_len5-1:0),_key5=1;_key5<_len5;_key5++){e[_key5-1]=arguments[_key5];}return (_o_2=o_(t)).lastIndexOf.apply(_o_2,e);},replace:function replace(t,e,n){return Object(Z.E)(n)&&Object(Z.o)("Function argument passed to replace."),String(t).replace(e,n);},reverse:function reverse(t){return i_(t).slice().reverse();},slice:function slice(t){var _o_3;for(var _len6=arguments.length,e=new Array(_len6>1?_len6-1:0),_key6=1;_key6<_len6;_key6++){e[_key6-1]=arguments[_key6];}return (_o_3=o_(t)).slice.apply(_o_3,e);},flush:Z.v,lerp:Z.L,merge:function merge(){var t=[].slice.call(arguments);return t.unshift({}),Object(Z.p).apply(void 0,_toConsumableArray(t));},pad:Z.R,peek:Z.W,pluck:function pluck(t,e){var n=r_[e]||(r_[e]=Object(Z.u)(e));return Object(Z.B)(t)?t.map(n):n(t);},span:Z.Z,inrange:Z.A,truncate:Z.Ha,rgb:go,lab:Cs,hcl:Ts,hsl:Eo,luminance:ZO,contrast:function contrast(t,e){var n=ZO(t),r=ZO(e);return (Math.max(n,r)+.05)/(Math.min(n,r)+.05);},sequence:Ge,format:NO,utcFormat:RO,utcParse:jO,utcOffset:Xe.w,utcSequence:Xe.x,timeFormat:IO,timeParse:MO,timeOffset:Xe.q,timeSequence:Xe.r,timeUnitSpecifier:Xe.s,monthFormat:function monthFormat(t){return PO.call(this,t,1,"%B");},monthAbbrevFormat:function monthAbbrevFormat(t){return PO.call(this,t,1,"%b");},dayFormat:function dayFormat(t){return PO.call(this,0,2+t,"%A");},dayAbbrevFormat:function dayAbbrevFormat(t){return PO.call(this,0,2+t,"%a");},quarter:Z.X,utcquarter:Z.Ja,week:Xe.A,utcweek:Xe.z,dayofyear:Xe.m,utcdayofyear:Xe.y,warn:function warn(){return JO(this.context.dataflow,"warn",arguments);},info:function info(){return JO(this.context.dataflow,"info",arguments);},debug:function debug(){return JO(this.context.dataflow,"debug",arguments);},extent:Z.q,inScope:function inScope(t){var e=this.context.group;var n=!1;if(e)for(;t;){if(t===e){n=!0;break;}t=t.mark.group;}return n;},intersect:function intersect(t,e,n){if(!t)return [];var _t97=_slicedToArray(t,2),r=_t97[0],i=_t97[1],o=new sl().set(r[0],r[1],i[0],i[1]);return Cd(n||this.context.dataflow.scenegraph().root,o,function(t){var e=null;if(t){var _n80=Object(Z.i)(t.marktype),_r85=Object(Z.i)(t.markname);e=function e(t){return (!_n80.length||_n80.some(function(e){return t.marktype===e;}))&&(!_r85.length||_r85.some(function(e){return t.name===e;}));};}return e;}(e));},clampRange:Z.k,pinchDistance:function pinchDistance(t){var e=t.touches,n=e[0].clientX-e[1].clientX,r=e[0].clientY-e[1].clientY;return Math.sqrt(n*n+r*r);},pinchAngle:function pinchAngle(t){var e=t.touches;return Math.atan2(e[0].clientY-e[1].clientY,e[0].clientX-e[1].clientX);},screen:function screen(){var t=u_();return t?t.screen:{};},containerSize:function containerSize(){var t=this.context.dataflow,e=t.container&&t.container();return e?[e.clientWidth,e.clientHeight]:[void 0,void 0];},windowSize:function windowSize(){var t=u_();return t?[t.innerWidth,t.innerHeight]:[void 0,void 0];},bandspace:function bandspace(t,e,n){return Ys(t||0,e||0,n||0);},setdata:function setdata(t,e){var n=this.context.dataflow,r=this.context.data[t].input;return n.pulse(r,n.changeset().remove(Z.Ia).insert(e)),1;},pathShape:function pathShape(t){var e=null;return function(n){return n?Tc(n,e=e||bc(t)):t;};},panLinear:Z.S,panLog:Z.T,panPow:Z.U,panSymlog:Z.V,zoomLinear:Z.Na,zoomLog:Z.Oa,zoomPow:Z.Pa,zoomSymlog:Z.Qa,encode:function encode(t,e,n){if(t){var _n81=this.context.dataflow,_r86=t.mark.source;_n81.pulse(_r86,_n81.changeset().encode(t,e));}return void 0!==n?n:t;},modify:function modify(t,e,n,r,i,o){var a=this.context.dataflow,s=this.context.data[t],u=s.input,c=a.stamp();var l,f,h=s.changes;if(!1===a._trigger||!(u.value.length||e||r))return 0;if((!h||h.stamp<c)&&(s.changes=h=a.changeset(),h.stamp=c,a.runAfter(function(){s.modified=!0,a.pulse(u,h).run();},!0,1)),n&&(l=!0===n?Z.Ia:Object(Z.B)(n)||at(n)?n:n_(n),h.remove(l)),e&&h.insert(e),r&&(l=n_(r),u.value.some(l)?h.remove(l):h.insert(r)),i)for(f in o){h.modify(i,f,o[f]);}return 1;}},l_=["view","item","group","xy","x","y"],f_="event.vega.",h_="this.",d_={},p_={forbidden:["_"],allowed:["datum","event","item"],fieldvar:"datum",globalvar:function globalvar(t){return "_[".concat(Object(Z.Ba)(WO+t),"]");},functions:function functions(t){var e=IC(t);l_.forEach(function(t){return e[t]=f_+t;});for(var _t98 in c_){e[_t98]=h_+_t98;}return Object(Z.p)(e,function(t,e,n){e.__bandwidth=function(t){return t&&t.bandwidth?t.bandwidth():0;},n._bandwidth=qO,n._range=qO,n._scale=qO;var r=function r(e){return "_["+(e.type===$k?Object(Z.Ba)(UO+e.value):Object(Z.Ba)(UO)+"+"+t(e))+"]";};return {_bandwidth:function _bandwidth(t){return "this.__bandwidth(".concat(r(t[0]),")");},_range:function _range(t){return "".concat(r(t[0]),".range()");},_scale:function _scale(e){return "".concat(r(e[0]),"(").concat(t(e[1]),")");}};}(t,c_,d_)),e;},constants:NC,visitors:d_},m_=function(t){var e=(t=t||{}).allowed?Object(Z.Fa)(t.allowed):{},n=t.forbidden?Object(Z.Fa)(t.forbidden):{},r=t.constants||NC,i=(t.functions||IC)(f),o=t.globalvar,a=t.fieldvar,s=Object(Z.E)(o)?o:function(t){return "".concat(o,"[\"").concat(t,"\"]");};var u={},c={},l=0;function f(t){if(Object(Z.J)(t))return t;var e=h[t.type];return null==e&&Object(Z.o)("Unsupported type: "+t.type),e(t);}var h={Literal:function Literal(t){return t.raw;},Identifier:function Identifier(t){var i=t.name;return l>0?i:Object(Z.w)(n,i)?Object(Z.o)("Illegal identifier: "+i):Object(Z.w)(r,i)?r[i]:Object(Z.w)(e,i)?i:(u[i]=1,s(i));},MemberExpression:function MemberExpression(t){var e=!t.computed,n=f(t.object);e&&(l+=1);var r=f(t.property);return n===a&&(c[function(t){var e=t&&t.length-1;return e&&('"'===t[0]&&'"'===t[e]||"'"===t[0]&&"'"===t[e])?t.slice(1,-1):t;}(r)]=1),e&&(l-=1),n+(e?"."+r:"["+r+"]");},CallExpression:function CallExpression(t){"Identifier"!==t.callee.type&&Object(Z.o)("Illegal callee type: "+t.callee.type);var e=t.callee.name,n=t.arguments,r=Object(Z.w)(i,e)&&i[e];return r||Object(Z.o)("Unrecognized function: "+e),Object(Z.E)(r)?r(n):r+"("+n.map(f).join(",")+")";},ArrayExpression:function ArrayExpression(t){return "["+t.elements.map(f).join(",")+"]";},BinaryExpression:function BinaryExpression(t){return "("+f(t.left)+" "+t.operator+" "+f(t.right)+")";},UnaryExpression:function UnaryExpression(t){return "("+t.operator+f(t.argument)+")";},ConditionalExpression:function ConditionalExpression(t){return "("+f(t.test)+"?"+f(t.consequent)+":"+f(t.alternate)+")";},LogicalExpression:function LogicalExpression(t){return "("+f(t.left)+t.operator+f(t.right)+")";},ObjectExpression:function ObjectExpression(t){return "{"+t.properties.map(f).join(",")+"}";},Property:function Property(t){l+=1;var e=f(t.key);return l-=1,e+":"+f(t.value);}};function d(t){var e={code:f(t),globals:Object.keys(u),fields:Object.keys(c)};return u={},c={},e;}return d.functions=i,d.constants=r,d;}(p_);function g_(t,e,n){return 1===arguments.length?c_[t]:(c_[t]=e,n&&(d_[t]=n),m_&&(m_.functions[t]=h_+t),this);}function v_(t,e){var n={};var r;try{r=function(t){oE=0,aE=(iE=t).length,sE=null,aC();var e=TC();if(sE.type!==cE)throw new Error("Unexpect token after expression.");return e;}(t=Object(Z.J)(t)?t:Object(Z.Ba)(t)+"");}catch(e){Object(Z.o)("Expression parse error: "+t);}r.visit(function(t){if(t.type!==Yk)return;var r=t.callee.name,i=p_.visitors[r];i&&i(r,t.arguments,e,n);});var i=m_(r);return i.globals.forEach(function(t){var r=WO+t;!Object(Z.w)(n,r)&&e.getSignal(t)&&(n[r]=e.signalRef(t));}),{$expr:Object(Z.p)({code:i.code},e.options.ast?{ast:r}:null),$fields:i.fields,$params:n};}g_("bandwidth",function(t,e){var n=HO(t,(e||this).context);return n&&n.bandwidth?n.bandwidth():0;},qO),g_("copy",function(t,e){var n=HO(t,(e||this).context);return n?n.copy():void 0;},qO),g_("domain",function(t,e){var n=HO(t,(e||this).context);return n?n.domain():[];},qO),g_("range",function(t,e){var n=HO(t,(e||this).context);return n&&n.range?n.range():[];},qO),g_("invert",function(t,e,n){var r=HO(t,(n||this).context);return r?Object(Z.B)(e)?(r.invertRange||r.invert)(e):(r.invert||r.invertExtent)(e):void 0;},qO),g_("scale",function(t,e,n){var r=HO(t,(n||this).context);return r?r(e):void 0;},qO),g_("gradient",function(t,e,n,r,i){t=HO(t,(i||this).context);var o=pc(e,n);var a=t.domain(),s=a[0],u=Object(Z.W)(a),c=Z.y;return u-s?c=Mu(t,s,u):t=(t.interpolator?ku("sequential")().interpolator(t.interpolator()):ku("linear")().interpolate(t.interpolate()).range(t.range())).domain([s=0,u=1]),t.ticks&&(s!==(a=t.ticks(+r||15))[0]&&a.unshift(s),u!==Object(Z.W)(a)&&a.push(u)),a.forEach(function(e){return o.stop(c(e),t(e));}),o;},qO),g_("geoArea",KO,qO),g_("geoBounds",XO,qO),g_("geoCentroid",YO,qO),g_("geoShape",function(t,e,n){var r=HO(t,(n||this).context);return function(t){return r?r.path.context(t)(e):"";};},qO),g_("indata",function(t,e,n){var r=this.context.data[t]["index:"+e],i=r?r.value.get(n):void 0;return i?i.count:i;},function(t,e,n,r){e[0].type!==$k&&Object(Z.o)("First argument to indata must be a string literal."),e[1].type!==$k&&Object(Z.o)("Second argument to indata must be a string literal.");var i=e[0].value,o=e[1].value,a=zO+o;Object(Z.w)(a,r)||(r[a]=n.getData(i).indataRef(n,o));}),g_("data",FO,VO),g_("treePath",function(t,e,n){var r=s_(t,this),i=r[e],o=r[n];return i&&o?i.path(o).map(a_):void 0;},VO),g_("treeAncestors",function(t,e){var n=s_(t,this)[e];return n?n.ancestors().map(a_):void 0;},VO),g_("vlSelectionTest",function(t,e,n){for(var r,i,o,a,s,u=this.context.data[t],c=u?u.values.value:[],l=u?u[xO]&&u[xO].value:void 0,f=n===cO,h=c.length,d=0;d<h;++d){if(r=c[d],l&&f){if(-1===(o=(i=i||{})[a=r.unit]||0))continue;if(s=wO(e,r),i[a]=s?-1:++o,s&&1===l.size)return !0;if(!s&&o===l.get(a).count)return !1;}else if(f^(s=wO(e,r)))return s;}return h&&f;},DO),g_("vlSelectionIdTest",function(t,e,n){var r=this.context.data[t],i=r?r.values.value:[],o=r?r[xO]&&r[xO].value:void 0,a=n===cO,s=kO(e),u=CO(i,s);if(u===i.length)return !1;if(kO(i[u])!==s)return !1;if(o&&a){if(1===o.size)return !0;if(AO(i,s)-u<o.size)return !1;}return !0;},DO),g_("vlSelectionResolve",function(t,e,n,r){for(var i,o,a,s,u,c,l,f,h,d,p,m=this.context.data[t],g=m?m.values.value:[],v={},y={},b={},x=g.length,w=0;w<x;++w){for(s=(i=g[w]).unit,o=i.fields,a=i.values,d=0,p=o.length;d<p;++d){u=o[d],l=(c=v[u.field]||(v[u.field]={}))[s]||(c[s]=[]),b[u.field]=f=u.type.charAt(0),h=OO[f+"_union"],c[s]=h(l,Object(Z.i)(a[d]));}n&&(l=y[s]||(y[s]=[])).push(Object(Z.i)(a).reduce(function(t,e,n){return t[o[n].field]=e,t;},{}));}e=e||lO,Object.keys(v).forEach(function(t){v[t]=Object.keys(v[t]).map(function(e){return v[t][e];}).reduce(function(n,r){return void 0===n?r:OO[b[t]+"_"+e](n,r);});}),g=Object.keys(y),n&&g.length&&(v[r?hO:fO]=e===lO?_defineProperty({},dO,g.reduce(function(t,e){return t.push.apply(t,_toConsumableArray(y[e])),t;},[])):_defineProperty({},pO,g.map(function(t){return _defineProperty({},dO,y[t]);})));return v;},DO),g_("vlSelectionTuples",function(t,e){return t.map(function(t){return Object(Z.p)({values:e.fields.map(function(e){return (e.getter||(e.getter=Object(Z.u)(e.field)))(t.datum);})},e);});});var y_=Object(Z.Fa)(["rule"]),b_=Object(Z.Fa)(["group","image","rect"]);function x_(t){return (t+"").toLowerCase();}function w_(t,e,n){";"!==n[n.length-1]&&(n="return("+n+");");var r=Function.apply(void 0,_toConsumableArray(e.concat(n)));return t&&t.functions?r.bind(t.functions):r;}var k_={operator:function operator(t,e){return w_(t,["_"],e.code);},parameter:function parameter(t,e){return w_(t,["datum","_"],e.code);},event:function event(t,e){return w_(t,["event"],e.code);},handler:function handler(t,e){return w_(t,["_","event"],"var datum=event.item&&event.item.datum;return ".concat(e.code,";"));},encode:function encode(t,e){var n=e.marktype,r=e.channels;var i="var o=item,datum=o.datum,m=0,$;";for(var _t99 in r){var _e108="o["+Object(Z.Ba)(_t99)+"]";i+="$=".concat(r[_t99].code,";if(").concat(_e108,"!==$)").concat(_e108,"=$,m=1;");}return i+=function(t,e){var n="";return y_[e]?n:(t.x2&&(t.x?(b_[e]&&(n+="if(o.x>o.x2)$=o.x,o.x=o.x2,o.x2=$;"),n+="o.width=o.x2-o.x;"):n+="o.x=o.x2-(o.width||0);"),t.xc&&(n+="o.x=o.xc-(o.width||0)/2;"),t.y2&&(t.y?(b_[e]&&(n+="if(o.y>o.y2)$=o.y,o.y=o.y2,o.y2=$;"),n+="o.height=o.y2-o.y;"):n+="o.y=o.y2-(o.height||0);"),t.yc&&(n+="o.y=o.yc-(o.height||0)/2;"),n);}(r,n),w_(t,["item","_"],i+="return m;");},codegen:{get:function get(t){var e="[".concat(t.map(Z.Ba).join("]["),"]"),n=Function("_","return _".concat(e,";"));return n.path=e,n;},comparator:function comparator(t,e){var n;var r=Function("a","b","var u, v; return "+t.map(function(t,r){var i=e[r];var o,a;return t.path?(o="a".concat(t.path),a="b".concat(t.path)):((n=n||{})["f"+r]=t,o="this.f".concat(r,"(a)"),a="this.f".concat(r,"(b)")),function(t,e,n,r){return "((u = ".concat(t,") < (v = ").concat(e,") || u == null) && v != null ? ").concat(n,"\n  : (u > v || v == null) && u != null ? ").concat(r,"\n  : ((v = v instanceof Date ? +v : v), (u = u instanceof Date ? +u : u)) !== u && v === v ? ").concat(n,"\n  : v !== v && u === u ? ").concat(r," : ");}(o,a,-i,i);}).join("")+"0;");return n?r.bind(n):r;}}};function E_(t,e,n){if(!t||!Object(Z.H)(t))return t;for(var _r87,_i60=0,_o40=C_.length;_i60<_o40;++_i60){if(_r87=C_[_i60],Object(Z.w)(t,_r87.key))return _r87.parse(t,e,n);}return t;}var C_=[{key:"$ref",parse:function parse(t,e){return e.get(t.$ref)||Object(Z.o)("Operator not defined: "+t.$ref);}},{key:"$key",parse:function parse(t,e){var n="k:"+t.$key+"_"+!!t.$flat;return e.fn[n]||(e.fn[n]=Object(Z.K)(t.$key,t.$flat,e.expr.codegen));}},{key:"$expr",parse:function parse(t,e,n){t.$params&&e.parseParameters(t.$params,n);var r="e:"+t.$expr.code+"_"+t.$name;return e.fn[r]||(e.fn[r]=Object(Z.f)(e.parameterExpression(t.$expr),t.$fields,t.$name));}},{key:"$field",parse:function parse(t,e){if(!t.$field)return null;var n="f:"+t.$field+"_"+t.$name;return e.fn[n]||(e.fn[n]=Object(Z.u)(t.$field,t.$name,e.expr.codegen));}},{key:"$encode",parse:function parse(t,e){var n=t.$encode,r={};for(var _t100 in n){var _i61=n[_t100];r[_t100]=Object(Z.f)(e.encodeExpression(_i61.$expr),_i61.$fields),r[_t100].output=_i61.$output;}return r;}},{key:"$compare",parse:function parse(t,e){var n="c:"+t.$compare+"_"+t.$order,r=Object(Z.i)(t.$compare).map(function(t){return t&&t.$tupleid?st:t;});return e.fn[n]||(e.fn[n]=Object(Z.l)(r,t.$order,e.expr.codegen));}},{key:"$context",parse:function parse(t,e){return e;}},{key:"$subflow",parse:function parse(t,e){var n=t.$subflow;return function(t,r,i){var o=e.fork().parse(n),a=o.get(n.operators[0].id),s=o.signals.parent;return s&&s.set(i),a.detachSubflow=function(){return e.detach(o);},a;};}},{key:"$tupleid",parse:function parse(){return st;}}];var A_={skip:!0};function O_(t,e,n,r){return new __(t,e,n,r);}function __(t,e,n,r){this.dataflow=t,this.transforms=e,this.events=t.events.bind(t),this.expr=r||k_,this.signals={},this.scales={},this.nodes={},this.data={},this.fn={},n&&(this.functions=Object.create(n),this.functions.context=this);}function S_(t){this.dataflow=t.dataflow,this.transforms=t.transforms,this.events=t.events,this.expr=t.expr,this.signals=Object.create(t.signals),this.scales=Object.create(t.scales),this.nodes=Object.create(t.nodes),this.data=Object.create(t.data),this.fn=Object.create(t.fn),t.functions&&(this.functions=Object.create(t.functions),this.functions.context=this);}__.prototype=S_.prototype={fork:function fork(){var t=new S_(this);return (this.subcontext||(this.subcontext=[])).push(t),t;},detach:function detach(t){this.subcontext=this.subcontext.filter(function(e){return e!==t;});var e=Object.keys(t.nodes);for(var _i62=0,_e109=e;_i62<_e109.length;_i62++){var _n82=_e109[_i62];t.nodes[_n82]._targets=null;}for(var _i63=0,_e110=e;_i63<_e110.length;_i63++){var _n83=_e110[_i63];t.nodes[_n83].detach();}t.nodes=null;},get:function get(t){return this.nodes[t];},set:function set(t,e){return this.nodes[t]=e;},add:function add(t,e){var n=this,r=n.dataflow,i=t.value;if(n.set(t.id,e),function(t){return "collect"===x_(t);}(t.type)&&i&&(i.$ingest?r.ingest(e,i.$ingest,i.$format):i.$request?r.preload(e,i.$request,i.$format):r.pulse(e,r.changeset().insert(i))),t.root&&(n.root=e),t.parent){var _i64=n.get(t.parent.$ref);_i64?(r.connect(_i64,[e]),e.targets().add(_i64)):(n.unresolved=n.unresolved||[]).push(function(){_i64=n.get(t.parent.$ref),r.connect(_i64,[e]),e.targets().add(_i64);});}if(t.signal&&(n.signals[t.signal]=e),t.scale&&(n.scales[t.scale]=e),t.data){var _loop=function _loop(_r88){var i=n.data[_r88]||(n.data[_r88]={});t.data[_r88].forEach(function(t){return i[t]=e;});};for(var _r88 in t.data){_loop(_r88);}}},resolve:function resolve(){return (this.unresolved||[]).forEach(function(t){return t();}),delete this.unresolved,this;},operator:function operator(t,e){this.add(t,this.dataflow.add(t.value,e));},transform:function transform(t,e){this.add(t,this.dataflow.add(this.transforms[x_(e)]));},stream:function stream(t,e){this.set(t.id,e);},update:function update(t,e,n,r,i){this.dataflow.on(e,n,r,i,t.options);},operatorExpression:function operatorExpression(t){return this.expr.operator(this,t);},parameterExpression:function parameterExpression(t){return this.expr.parameter(this,t);},eventExpression:function eventExpression(t){return this.expr.event(this,t);},handlerExpression:function handlerExpression(t){return this.expr.handler(this,t);},encodeExpression:function encodeExpression(t){return this.expr.encode(this,t);},parse:function parse(t){var e=this,n=t.operators||[];return t.background&&(e.background=t.background),t.eventConfig&&(e.eventConfig=t.eventConfig),t.locale&&(e.locale=t.locale),n.forEach(function(t){return e.parseOperator(t);}),n.forEach(function(t){return e.parseOperatorParameters(t);}),(t.streams||[]).forEach(function(t){return e.parseStream(t);}),(t.updates||[]).forEach(function(t){return e.parseUpdate(t);}),e.resolve();},parseOperator:function parseOperator(t){var e=this;!function(t){return "operator"===x_(t);}(t.type)&&t.type?e.transform(t,t.type):e.operator(t,t.update?e.operatorExpression(t.update):null);},parseOperatorParameters:function parseOperatorParameters(t){var e=this;if(t.params){var _n84=e.get(t.id);_n84||Object(Z.o)("Invalid operator id: "+t.id),e.dataflow.connect(_n84,_n84.parameters(e.parseParameters(t.params),t.react,t.initonly));}},parseParameters:function parseParameters(t,e){e=e||{};var n=this;for(var _r89 in t){var _i65=t[_r89];e[_r89]=Object(Z.B)(_i65)?_i65.map(function(t){return E_(t,n,e);}):E_(_i65,n,e);}return e;},parseStream:function parseStream(t){var e,n=this,r=null!=t.filter?n.eventExpression(t.filter):void 0,i=null!=t.stream?n.get(t.stream):void 0;t.source?i=n.events(t.source,t.type,r):t.merge&&(i=(e=t.merge.map(function(t){return n.get(t);}))[0].merge.apply(e[0],e.slice(1))),t.between&&(e=t.between.map(function(t){return n.get(t);}),i=i.between(e[0],e[1])),t.filter&&(i=i.filter(r)),null!=t.throttle&&(i=i.throttle(+t.throttle)),null!=t.debounce&&(i=i.debounce(+t.debounce)),null==i&&Object(Z.o)("Invalid stream definition: "+JSON.stringify(t)),t.consume&&i.consume(!0),n.stream(t,i);},parseUpdate:function parseUpdate(t){var e,n=Object(Z.H)(n=t.source)?n.$ref:n,r=this.get(n),i=t.update,o=void 0;r||Object(Z.o)("Source not defined: "+t.source),e=t.target&&t.target.$expr?this.eventExpression(t.target.$expr):this.get(t.target),i&&i.$expr&&(i.$params&&(o=this.parseParameters(i.$params)),i=this.handlerExpression(i.$expr)),this.update(t,r,e,i,o);},getState:function getState(t){var e=this,n={};if(t.signals){var r=n.signals={};Object.keys(e.signals).forEach(function(n){var i=e.signals[n];t.signals(n,i)&&(r[n]=i.value);});}if(t.data){var i=n.data={};Object.keys(e.data).forEach(function(n){var r=e.data[n];t.data(n,r)&&(i[n]=r.input.value);});}return e.subcontext&&!1!==t.recurse&&(n.subcontext=e.subcontext.map(function(e){return e.getState(t);})),n;},setState:function setState(t){var e=this,n=e.dataflow,r=t.data,i=t.signals;Object.keys(i||{}).forEach(function(t){n.update(e.signals[t],i[t],A_);}),Object.keys(r||{}).forEach(function(t){n.pulse(e.data[t].input,n.changeset().remove(Z.Ia).insert(r[t]));}),(t.subcontext||[]).forEach(function(t,n){var r=e.subcontext[n];r&&r.setState(t);});}};var D_=function D_(t,e,n){var r=new Hb(),i=e;return null==e?(r.restart(t,e,n),r):(r._restart=r.restart,r.restart=function(t,e,n){e=+e,n=null==n?qb():+n,r._restart(function o(a){a+=i,r._restart(o,i+=e,n),t(a);},e,n);},r.restart(t,e,n),r);};function F_(t,e){t&&(null==e?t.removeAttribute("aria-label"):t.setAttribute("aria-label",e));}var T_="default";function N_(t,e){var n=t.globalCursor()?"undefined"!=typeof document&&document.body:t.container();if(n)return null==e?n.style.removeProperty("cursor"):n.style.cursor=e;}function I_(t,e){var n=t._runtime.data;return Object(Z.w)(n,e)||Object(Z.o)("Unrecognized data set: "+e),n[e];}function R_(t,e){pt(e)||Object(Z.o)("Second argument to changes must be a changeset.");var n=I_(this,t);return n.modified=!0,this.pulse(n.input,e);}function M_(t){var e=t.padding();return Math.max(0,t._viewWidth+e.left+e.right);}function j_(t){var e=t.padding();return Math.max(0,t._viewHeight+e.top+e.bottom);}function B_(t){var e=t.padding(),n=t._origin;return [e.left+n[0],e.top+n[1]];}function P_(t,e,n){var r,i,o=t._renderer,a=o&&o.canvas();return a&&(i=B_(t),(r=gh(e.changedTouches?e.changedTouches[0]:e,a))[0]-=i[0],r[1]-=i[1]),e.dataflow=t,e.item=n,e.vega=function(t,e,n){var r=e?"group"===e.mark.marktype?e:e.mark.group:null;function i(t){var n,i=r;if(t)for(n=e;n;n=n.mark.group){if(n.mark.name===t){i=n;break;}}return i&&i.mark&&i.mark.interactive?i:{};}function o(t){if(!t)return n;Object(Z.J)(t)&&(t=i(t));var e=n.slice();for(;t;){e[0]-=t.x||0,e[1]-=t.y||0,t=t.mark&&t.mark.group;}return e;}return {view:Object(Z.m)(t),item:Object(Z.m)(e||{}),group:i,xy:o,x:function x(t){return o(t)[0];},y:function y(t){return o(t)[1];}};}(t,n,r),e;}var L_="view",z_="timer",U_="window",W_={trap:!1};function V_(t,e,n,r){t._eventListeners.push({type:n,sources:Object(Z.i)(e),handler:r});}function q_(t,e,n){var r=t._eventConfig&&t._eventConfig[e];return !(!1===r||Object(Z.H)(r)&&!r[n])||(t.warn("Blocked ".concat(e," ").concat(n," event listener.")),!1);}function $_(t){return t.item;}function H_(t){return t.item.mark.source;}function G_(t){return function(e,n){return n.vega.view().changeset().encode(n.item,t);};}function K_(t,e,n){var r=document.createElement(t);for(var _t101 in e){r.setAttribute(_t101,e[_t101]);}return null!=n&&(r.textContent=n),r;}var X_="vega-bind",Y_="vega-bind-name",J_="vega-bind-radio";function Q_(t,e,n,r){var i=n.event||"input",o=function o(){return t.update(e.value);};r.signal(n.signal,e.value),e.addEventListener(i,o),V_(r,e,i,o),t.set=function(t){e.value=t,e.dispatchEvent(function(t){return "undefined"!=typeof Event?new Event(t):{type:t};}(i));};}function Z_(t,e,n,r){var i=r.signal(n.signal),o=K_("div",{class:X_}),a="radio"===n.input?o:o.appendChild(K_("label"));a.appendChild(K_("span",{class:Y_},n.name||n.signal)),e.appendChild(o);var s=tS;switch(n.input){case"checkbox":s=eS;break;case"select":s=nS;break;case"radio":s=rS;break;case"range":s=iS;}s(t,a,n,i);}function tS(t,e,n,r){var i=K_("input");for(var _t102 in n){"signal"!==_t102&&"element"!==_t102&&i.setAttribute("input"===_t102?"type":_t102,n[_t102]);}i.setAttribute("name",n.signal),i.value=r,e.appendChild(i),i.addEventListener("input",function(){return t.update(i.value);}),t.elements=[i],t.set=function(t){return i.value=t;};}function eS(t,e,n,r){var i={type:"checkbox",name:n.signal};r&&(i.checked=!0);var o=K_("input",i);e.appendChild(o),o.addEventListener("change",function(){return t.update(o.checked);}),t.elements=[o],t.set=function(t){return o.checked=!!t||null;};}function nS(t,e,n,r){var i=K_("select",{name:n.signal}),o=n.labels||[];n.options.forEach(function(t,e){var n={value:t};oS(t,r)&&(n.selected=!0),i.appendChild(K_("option",n,(o[e]||t)+""));}),e.appendChild(i),i.addEventListener("change",function(){t.update(n.options[i.selectedIndex]);}),t.elements=[i],t.set=function(t){for(var _e111=0,_r90=n.options.length;_e111<_r90;++_e111){if(oS(n.options[_e111],t))return void(i.selectedIndex=_e111);}};}function rS(t,e,n,r){var i=K_("span",{class:J_}),o=n.labels||[];e.appendChild(i),t.elements=n.options.map(function(e,a){var s={type:"radio",name:n.signal,value:e};oS(e,r)&&(s.checked=!0);var u=K_("input",s);u.addEventListener("change",function(){return t.update(e);});var c=K_("label",{},(o[a]||e)+"");return c.prepend(u),i.appendChild(c),u;}),t.set=function(e){var n=t.elements,r=n.length;for(var _t103=0;_t103<r;++_t103){oS(n[_t103].value,e)&&(n[_t103].checked=!0);}};}function iS(t,e,n,r){r=void 0!==r?r:(+n.max+ +n.min)/2;var i=null!=n.max?n.max:Math.max(100,+r)||100,o=n.min||Math.min(0,i,+r)||0,a=n.step||Object(Hi.c)(o,i,100),s=K_("input",{type:"range",name:n.signal,min:o,max:i,step:a});s.value=r;var u=K_("span",{},+r);e.appendChild(s),e.appendChild(u);var c=function c(){u.textContent=s.value,t.update(+s.value);};s.addEventListener("input",c),s.addEventListener("change",c),t.elements=[s],t.set=function(t){s.value=t,u.textContent=t;};}function oS(t,e){return t===e||t+""==e+"";}function aS(t,e,n,r,i,o){return (e=e||new r(t.loader())).initialize(n,M_(t),j_(t),B_(t),i,o).background(t.background());}function sS(t,e){return e?function(){try{e.apply(this,arguments);}catch(e){t.error(e);}}:null;}function uS(t,e,n){if("string"==typeof e){if("undefined"==typeof document)return t.error("DOM document instance not found."),null;if(!(e=document.querySelector(e)))return t.error("Signal bind element not found: "+e),null;}if(e&&n)try{e.innerHTML="";}catch(n){e=null,t.error(n);}return e;}var cS=function cS(t){return +t||0;},lS=function lS(t){return {top:t,bottom:t,left:t,right:t};};function fS(t){return Object(Z.H)(t)?{top:cS(t.top),bottom:cS(t.bottom),left:cS(t.left),right:cS(t.right)}:lS(cS(t));}function hS(_x22,_x23,_x24,_x25){return _hS.apply(this,arguments);}function _hS(){_hS=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee24(t,e,n,r){var i,o;return regeneratorRuntime.wrap(function _callee24$(_context29){while(1){switch(_context29.prev=_context29.next){case 0:i=Ed(e),o=i&&i.headless;o||Object(Z.o)("Unrecognized renderer type: "+e);_context29.next=4;return t.runAsync();case 4:return _context29.abrupt("return",aS(t,null,null,o,n,r).renderAsync(t._scenegraph.root));case 5:case"end":return _context29.stop();}}},_callee24);}));return _hS.apply(this,arguments);}var dS="width",pS="height",mS="padding",gS={skip:!0};function vS(t,e){var n=t.autosize(),r=t.padding();return e-(n&&n.contains===mS?r.left+r.right:0);}function yS(t,e){var n=t.autosize(),r=t.padding();return e-(n&&n.contains===mS?r.top+r.bottom:0);}function bS(t,e){return e.modified&&Object(Z.B)(e.input.value)&&t.indexOf("_:vega:_");}function xS(t,e){return !("parent"===t||e instanceof Ut.proxy);}function wS(t,e,n,r){var i=t.element();i&&i.setAttribute("title",function(t){return null==t?"":Object(Z.B)(t)?kS(t):Object(Z.H)(t)&&!Object(Z.D)(t)?function(t){return Object.keys(t).map(function(e){var n=t[e];return e+": "+(Object(Z.B)(n)?kS(n):ES(n));}).join("\n");}(t):t+"";}(r));}function kS(t){return "["+t.map(ES).join(", ")+"]";}function ES(t){return Object(Z.B)(t)?"[…]":Object(Z.H)(t)&&!Object(Z.D)(t)?"{…}":t;}function CS(t,e){var n=this;if(e=e||{},Pt.call(n),e.loader&&n.loader(e.loader),e.logger&&n.logger(e.logger),null!=e.logLevel&&n.logLevel(e.logLevel),e.locale||t.locale){var _r91=Object(Z.p)({},t.locale,e.locale);n.locale(Object(et.b)(_r91.number,_r91.time));}n._el=null,n._elBind=null,n._renderType=e.renderer||wd.Canvas,n._scenegraph=new ch();var r=n._scenegraph.root;n._renderer=null,n._tooltip=e.tooltip||wS,n._redraw=!0,n._handler=new Dh().scene(r),n._globalCursor=!1,n._preventDefault=!1,n._timers=[],n._eventListeners=[],n._resizeListeners=[],n._eventConfig=function(t){var e=Object(Z.p)({defaults:{}},t),n=function n(t,e){e.forEach(function(e){Object(Z.B)(t[e])&&(t[e]=Object(Z.Fa)(t[e]));});};return n(e.defaults,["prevent","allow"]),n(e,["view","window","selector"]),e;}(t.eventConfig),n.globalCursor(n._eventConfig.globalCursor);var i=function(t,e,n){return O_(t,Ut,c_,n).parse(e);}(n,t,e.expr);n._runtime=i,n._signals=i.signals,n._bind=(t.bindings||[]).map(function(t){return {state:null,param:Object(Z.p)({},t)};}),i.root&&i.root.set(r),r.source=i.data.root.input,n.pulse(i.data.root.input,n.changeset().insert(r.items)),n._width=n.width(),n._height=n.height(),n._viewWidth=vS(n,n._width),n._viewHeight=yS(n,n._height),n._origin=[0,0],n._resize=0,n._autosize=1,function(t){var e=t._signals,n=e[dS],r=e[pS],i=e[mS];function o(){t._autosize=t._resize=1;}t._resizeWidth=t.add(null,function(e){t._width=e.size,t._viewWidth=vS(t,e.size),o();},{size:n}),t._resizeHeight=t.add(null,function(e){t._height=e.size,t._viewHeight=yS(t,e.size),o();},{size:r});var a=t.add(null,o,{pad:i});t._resizeWidth.rank=n.rank+1,t._resizeHeight.rank=r.rank+1,a.rank=i.rank+1;}(n),function(t){t.add(null,function(e){return t._background=e.bg,t._resize=1,e.bg;},{bg:t._signals.background});}(n),function(t){var e=t._signals.cursor||(t._signals.cursor=t.add({user:T_,item:null}));t.on(t.events("view","mousemove"),e,function(t,n){var r=e.value,i=r?Object(Z.J)(r)?r:r.user:T_,o=n.item&&n.item.cursor||null;return r&&i===r.user&&o==r.item?r:{user:i,item:o};}),t.add(null,function(e){var n=e.cursor,r=this.value;return Object(Z.J)(n)||(r=n.item,n=n.user),N_(t,n&&n!==T_?n:r||n),r;},{cursor:e});}(n),n.description(t.description),e.hover&&n.hover(),e.container&&n.initialize(e.container,e.bind);}function AS(t,e){return Object(Z.w)(t._signals,e)?t._signals[e]:Object(Z.o)("Unrecognized signal name: "+Object(Z.Ba)(e));}function OS(t,e){var n=(t._targets||[]).filter(function(t){return t._update&&t._update.handler===e;});return n.length?n[0]:null;}function _S(t,e,n,r){var i=OS(n,r);return i||((i=sS(t,function(){return r(e,n.value);})).handler=r,t.on(n,null,i)),t;}function SS(t,e,n){var r=OS(e,n);return r&&e._targets.remove(r),t;}Object(Z.z)(CS,Pt,{evaluate:function evaluate(t,e,n){var _this23=this;return _asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee15(){return regeneratorRuntime.wrap(function _callee15$(_context20){while(1){switch(_context20.prev=_context20.next){case 0:_context20.next=2;return Pt.prototype.evaluate.call(_this23,t,e);case 2:if(!(_this23._redraw||_this23._resize)){_context20.next=15;break;}_context20.prev=3;_context20.t0=_this23._renderer;if(!_context20.t0){_context20.next=9;break;}_this23._resize&&(_this23._resize=0,function(t){var e=B_(t),n=M_(t),r=j_(t);t._renderer.background(t.background()),t._renderer.resize(n,r,e),t._handler.origin(e),t._resizeListeners.forEach(function(e){try{e(n,r);}catch(e){t.error(e);}});}(_this23));_context20.next=9;return _this23._renderer.renderAsync(_this23._scenegraph.root);case 9:_this23._redraw=!1;_context20.next=15;break;case 12:_context20.prev=12;_context20.t1=_context20["catch"](3);_this23.error(_context20.t1);case 15:return _context20.abrupt("return",(n&&rt(_this23,n),_this23));case 16:case"end":return _context20.stop();}}},_callee15,null,[[3,12]]);}))();},dirty:function dirty(t){this._redraw=!0,this._renderer&&this._renderer.dirty(t);},description:function description(t){if(arguments.length){var _e112=null!=t?t+"":null;return _e112!==this._desc&&F_(this._el,this._desc=_e112),this;}return this._desc;},container:function container(){return this._el;},scenegraph:function scenegraph(){return this._scenegraph;},origin:function origin(){return this._origin.slice();},signal:function signal(t,e,n){var r=AS(this,t);return 1===arguments.length?r.value:this.update(r,e,n);},width:function width(t){return arguments.length?this.signal("width",t):this.signal("width");},height:function height(t){return arguments.length?this.signal("height",t):this.signal("height");},padding:function padding(t){return arguments.length?this.signal("padding",fS(t)):fS(this.signal("padding"));},autosize:function autosize(t){return arguments.length?this.signal("autosize",t):this.signal("autosize");},background:function background(t){return arguments.length?this.signal("background",t):this.signal("background");},renderer:function renderer(t){return arguments.length?(Ed(t)||Object(Z.o)("Unrecognized renderer type: "+t),t!==this._renderType&&(this._renderType=t,this._resetRenderer()),this):this._renderType;},tooltip:function tooltip(t){return arguments.length?(t!==this._tooltip&&(this._tooltip=t,this._resetRenderer()),this):this._tooltip;},loader:function loader(t){return arguments.length?(t!==this._loader&&(Pt.prototype.loader.call(this,t),this._resetRenderer()),this):this._loader;},resize:function resize(){return this._autosize=1,this.touch(AS(this,"autosize"));},_resetRenderer:function _resetRenderer(){this._renderer&&(this._renderer=null,this.initialize(this._el,this._elBind));},_resizeView:function _resizeView(t,e,n,r,i,o){this.runAfter(function(a){var s=0;a._autosize=0,a.width()!==n&&(s=1,a.signal(dS,n,gS),a._resizeWidth.skip(!0)),a.height()!==r&&(s=1,a.signal(pS,r,gS),a._resizeHeight.skip(!0)),a._viewWidth!==t&&(a._resize=1,a._viewWidth=t),a._viewHeight!==e&&(a._resize=1,a._viewHeight=e),a._origin[0]===i[0]&&a._origin[1]===i[1]||(a._resize=1,a._origin=i),s&&a.run("enter"),o&&a.runAfter(function(t){return t.resize();});},!1,1);},addEventListener:function addEventListener(t,e,n){var r=e;return n&&!1===n.trap||((r=sS(this,e)).raw=e),this._handler.on(t,r),this;},removeEventListener:function removeEventListener(t,e){for(var n,r,i=this._handler.handlers(t),o=i.length;--o>=0;){if(r=i[o].type,n=i[o].handler,t===r&&(e===n||e===n.raw)){this._handler.off(r,n);break;}}return this;},addResizeListener:function addResizeListener(t){var e=this._resizeListeners;return e.indexOf(t)<0&&e.push(t),this;},removeResizeListener:function removeResizeListener(t){var e=this._resizeListeners,n=e.indexOf(t);return n>=0&&e.splice(n,1),this;},addSignalListener:function addSignalListener(t,e){return _S(this,t,AS(this,t),e);},removeSignalListener:function removeSignalListener(t,e){return SS(this,AS(this,t),e);},addDataListener:function addDataListener(t,e){return _S(this,t,I_(this,t).values,e);},removeDataListener:function removeDataListener(t,e){return SS(this,I_(this,t).values,e);},globalCursor:function globalCursor(t){if(arguments.length){if(this._globalCursor!==!!t){var _e113=N_(this,null);this._globalCursor=!!t,_e113&&N_(this,_e113);}return this;}return this._globalCursor;},preventDefault:function preventDefault(t){return arguments.length?(this._preventDefault=t,this):this._preventDefault;},timer:function timer(t,e){this._timers.push(D_(function(e){t({timestamp:Date.now(),elapsed:e});},e));},events:function events(t,e,n){var r,i=this,o=new Et(n),a=function a(n,r){i.runAsync(null,function(){t===L_&&function(t,e){var n=t._eventConfig.defaults,r=n.prevent,i=n.allow;return !1!==r&&!0!==i&&(!0===r||!1===i||(r?r[e]:i?!i[e]:t.preventDefault()));}(i,e)&&n.preventDefault(),o.receive(P_(i,n,r));});};if(t===z_)q_(i,"timer",e)&&i.timer(a,e);else if(t===L_)q_(i,"view",e)&&i.addEventListener(e,a,W_);else if(t===U_?q_(i,"window",e)&&"undefined"!=typeof window&&(r=[window]):"undefined"!=typeof document&&q_(i,"selector",e)&&(r=document.querySelectorAll(t)),r){for(var s=0,u=r.length;s<u;++s){r[s].addEventListener(e,a);}V_(i,r,e,a);}else i.warn("Can not resolve event source: "+t);return o;},finalize:function finalize(){var t,e,n,r=this._tooltip,i=this._timers,o=this._eventListeners;for(t=i.length;--t>=0;){i[t].stop();}for(t=o.length;--t>=0;){for(e=(n=o[t]).sources.length;--e>=0;){n.sources[e].removeEventListener(n.type,n.handler);}}return r&&r.call(this,this._handler,null,null,null),this;},hover:function hover(t,e){return t=[t||"hover"],e=[e||"update",t[0]],this.on(this.events("view","mouseover",$_),H_,G_(t)),this.on(this.events("view","mouseout",$_),H_,G_(e)),this;},data:function data(t,e){return arguments.length<2?I_(this,t).values.value:R_.call(this,t,mt().remove(Z.Ia).insert(e));},change:R_,insert:function insert(t,e){return R_.call(this,t,mt().insert(e));},remove:function remove(t,e){return R_.call(this,t,mt().remove(e));},scale:function scale(t){var e=this._runtime.scales;return Object(Z.w)(e,t)||Object(Z.o)("Unrecognized scale or projection: "+t),e[t].value;},initialize:function initialize(t,e){var n=this,r=n._renderType,i=n._eventConfig.bind,o=Ed(r);t=n._el=t?uS(n,t,!0):null,function(t){var e=t.container();e&&(e.setAttribute("role","graphics-document"),e.setAttribute("aria-roleDescription","visualization"),F_(e,t.description()));}(n),o||n.error("Unrecognized renderer type: "+r);var a=o.handler||Dh,s=t?o.renderer:o.headless;return n._renderer=s?aS(n,n._renderer,t,s):null,n._handler=function(t,e,n,r){var i=new r(t.loader(),sS(t,t.tooltip())).scene(t.scenegraph().root).initialize(n,B_(t),t);return e&&e.handlers().forEach(function(t){i.on(t.type,t.handler);}),i;}(n,n._handler,t,a),n._redraw=!0,t&&"none"!==i&&(e=e?n._elBind=uS(n,e,!0):t.appendChild(K_("form",{class:"vega-bindings"})),n._bind.forEach(function(t){t.param.element&&"container"!==i&&(t.element=uS(n,t.param.element,!!t.param.input));}),n._bind.forEach(function(t){!function(t,e,n){if(!e)return;var r=n.param;var i=n.state;i||(i=n.state={elements:null,active:!1,set:null,update:function update(e){e!=t.signal(r.signal)&&t.runAsync(null,function(){i.source=!0,t.signal(r.signal,e);});}},r.debounce&&(i.update=Object(Z.n)(r.debounce,i.update))),(null==r.input&&r.element?Q_:Z_)(i,e,r,t),i.active||(t.on(t._signals[r.signal],null,function(){i.source?i.source=!1:i.set(t.signal(r.signal));}),i.active=!0);}(n,t.element||e,t);})),n;},toImageURL:function(){var _toImageURL=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee16(t,e){var n;return regeneratorRuntime.wrap(function _callee16$(_context21){while(1){switch(_context21.prev=_context21.next){case 0:t!==wd.Canvas&&t!==wd.SVG&&t!==wd.PNG&&Object(Z.o)("Unrecognized image type: "+t);_context21.next=3;return hS(this,t,e);case 3:n=_context21.sent;return _context21.abrupt("return",t===wd.SVG?function(t,e){var n=new Blob([t],{type:e});return window.URL.createObjectURL(n);}(n.svg(),"image/svg+xml"):n.canvas().toDataURL("image/png"));case 5:case"end":return _context21.stop();}}},_callee16,this);}));function toImageURL(_x26,_x27){return _toImageURL.apply(this,arguments);}return toImageURL;}(),toCanvas:function(){var _toCanvas=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee17(t,e){return regeneratorRuntime.wrap(function _callee17$(_context22){while(1){switch(_context22.prev=_context22.next){case 0:_context22.next=2;return hS(this,wd.Canvas,t,e);case 2:return _context22.abrupt("return",_context22.sent.canvas());case 3:case"end":return _context22.stop();}}},_callee17,this);}));function toCanvas(_x28,_x29){return _toCanvas.apply(this,arguments);}return toCanvas;}(),toSVG:function(){var _toSVG=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee18(t){return regeneratorRuntime.wrap(function _callee18$(_context23){while(1){switch(_context23.prev=_context23.next){case 0:_context23.next=2;return hS(this,wd.SVG,t);case 2:return _context23.abrupt("return",_context23.sent.svg());case 3:case"end":return _context23.stop();}}},_callee18,this);}));function toSVG(_x30){return _toSVG.apply(this,arguments);}return toSVG;}(),getState:function getState(t){return this._runtime.getState(t||{data:bS,signals:xS,recurse:!0});},setState:function setState(t){return this.runAsync(null,function(e){e._trigger=!1,e._runtime.setState(t);},function(t){t._trigger=!0;}),this;}});var DS="view",FS="[",TS="]",NS="{",IS="}",RS=":",MS=",",jS="@",BS=">",PS=/[[\]{}]/,LS={"*":1,arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1};var zS,US;function WS(t,e,n,r,i){var o=t.length;var a,s=0;for(;e<o;++e){if(a=t[e],!s&&a===n)return e;i&&i.indexOf(a)>=0?--s:r&&r.indexOf(a)>=0&&++s;}return e;}function VS(t){var e=[],n=t.length;var r=0,i=0;for(;i<n;){i=WS(t,i,MS,FS+NS,TS+IS),e.push(t.substring(r,i).trim()),r=++i;}if(0===e.length)throw "Empty event selector: "+t;return e;}function qS(t){return "["===t[0]?function(t){var e=t.length;var n,r=1;if((r=WS(t,r,TS,FS,TS))===e)throw "Empty between selector: "+t;if(2!==(n=VS(t.substring(1,r))).length)throw "Between selector must have two elements: "+t;if((t=t.slice(r+1).trim())[0]!==BS)throw "Expected '>' after between selector: "+t;n=n.map(qS);var i=qS(t.slice(1).trim());if(i.between)return {between:n,stream:i};i.between=n;return i;}(t):function(t){var e={source:zS},n=[];var r,i,o=[0,0],a=0,s=0,u=t.length,c=0;if(t[u-1]===IS){if(!((c=t.lastIndexOf(NS))>=0))throw "Unmatched right brace: "+t;try{o=function(t){var e=t.split(MS);if(!t.length||e.length>2)throw t;return e.map(function(e){var n=+e;if(n!=n)throw t;return n;});}(t.substring(c+1,u-1));}catch(e){throw "Invalid throttle specification: "+t;}t=t.slice(0,c).trim(),u=t.length,c=0;}if(!u)throw t;t[0]===jS&&(a=++c);(r=WS(t,c,RS))<u&&(n.push(t.substring(s,r).trim()),s=c=++r);if((c=WS(t,c,FS))===u)n.push(t.substring(s,u).trim());else if(n.push(t.substring(s,c).trim()),i=[],(s=++c)===u)throw "Unmatched left bracket: "+t;for(;c<u;){if((c=WS(t,c,TS))===u)throw "Unmatched left bracket: "+t;if(i.push(t.substring(s,c).trim()),c<u-1&&t[++c]!==FS)throw "Expected left bracket: "+t;s=++c;}if(!(u=n.length)||PS.test(n[u-1]))throw "Invalid event selector: "+t;u>1?(e.type=n[1],a?e.markname=n[0].slice(1):!function(t){return US[t];}(n[0])?e.source=n[0]:e.marktype=n[0]):e.type=n[0];"!"===e.type.slice(-1)&&(e.consume=!0,e.type=e.type.slice(0,-1));null!=i&&(e.filter=i);o[0]&&(e.throttle=o[0]);o[1]&&(e.debounce=o[1]);return e;}(t);}var $S=function $S(t){return +t||0;},HS=function HS(t){return {top:t,bottom:t,left:t,right:t};};var GS=function GS(t){return Object(Z.H)(t)&&!Object(Z.B)(t)?Object(Z.p)({},t):{value:t};};function KS(t,e,n,r){if(null!=n){return Object(Z.H)(n)&&!Object(Z.B)(n)||Object(Z.B)(n)&&n.length&&Object(Z.H)(n[0])?t.update[e]=n:t[r||"enter"][e]={value:n},1;}return 0;}function XS(t,e,n){for(var _n85 in e){KS(t,_n85,e[_n85]);}for(var _e114 in n){KS(t,_e114,n[_e114],"update");}}function YS(t,e,n){for(var _r92 in e){n&&Object(Z.w)(n,_r92)||(t[_r92]=Object(Z.p)(t[_r92]||{},e[_r92]));}return t;}function JS(t,e){return e&&(e.enter&&e.enter[t]||e.update&&e.update[t]);}var QS="mark",ZS="frame",tD="scope",eD="axis",nD="axis-domain",rD="axis-grid",iD="axis-label",oD="axis-tick",aD="axis-title",sD="legend",uD="legend-band",cD="legend-entry",lD="legend-gradient",fD="legend-label",hD="legend-symbol",dD="legend-title",pD="title",mD="title-text",gD="title-subtitle";function vD(t,e,n){t[e]=n&&n.signal?{signal:n.signal}:{value:n};}var yD=function yD(t){return Object(Z.J)(t)?Object(Z.Ba)(t):t.signal?"(".concat(t.signal,")"):kD(t);};function bD(t){if(null!=t.gradient)return function(t){var e=[t.start,t.stop,t.count].map(function(t){return null==t?null:Object(Z.Ba)(t);});for(;e.length&&null==Object(Z.W)(e);){e.pop();}return e.unshift(yD(t.gradient)),"gradient(".concat(e.join(","),")");}(t);var e=t.signal?"(".concat(t.signal,")"):t.color?function(t){return t.c?xD("hcl",t.h,t.c,t.l):t.h||t.s?xD("hsl",t.h,t.s,t.l):t.l||t.a?xD("lab",t.l,t.a,t.b):t.r||t.g||t.b?xD("rgb",t.r,t.g,t.b):null;}(t.color):null!=t.field?kD(t.field):void 0!==t.value?Object(Z.Ba)(t.value):void 0;return null!=t.scale&&(e=function(t,e){var n=yD(t.scale);null!=t.range?e="lerp(_range(".concat(n,"), ").concat(+t.range,")"):(void 0!==e&&(e="_scale(".concat(n,", ").concat(e,")")),t.band&&(e=(e?e+"+":"")+"_bandwidth(".concat(n,")")+(1==+t.band?"":"*"+wD(t.band)),t.extra&&(e="(datum.extra ? _scale(".concat(n,", datum.extra.value) : ").concat(e,")"))),null==e&&(e="0"));return e;}(t,e)),void 0===e&&(e=null),null!=t.exponent&&(e="pow(".concat(e,",").concat(wD(t.exponent),")")),null!=t.mult&&(e+="*".concat(wD(t.mult))),null!=t.offset&&(e+="+".concat(wD(t.offset))),t.round&&(e="round(".concat(e,")")),e;}var xD=function xD(t,e,n,r){return "(".concat(t,"(").concat([e,n,r].map(bD).join(","),")+'')");};function wD(t){return Object(Z.H)(t)?"("+bD(t)+")":t;}function kD(t){return function t(e){var n,r,i;if(e.signal)n="datum",i=e.signal;else if(e.group||e.parent){for(r=Math.max(1,e.level||1),n="item";r-->0;){n+=".mark.group";}e.parent?(i=e.parent,n+=".datum"):i=e.group;}else e.datum?(n="datum",i=e.datum):Object(Z.o)("Invalid field reference: "+Object(Z.Ba)(e));e.signal||(i=Object(Z.J)(i)?Object(Z.Aa)(i).map(Z.Ba).join("]["):t(i));return n+"["+i+"]";}(Object(Z.H)(t)?t:{datum:t});}function ED(t,e,n,r,i,o){var a={};(o=o||{}).encoders={$encode:a},t=function(t,e,n,r,i){var o={},a={};var s,u,l;for(u in u="lineBreak","text"!==e||null==i[u]||JS(u,t)||vD(o,u,i[u]),("legend"==n||String(n).startsWith("axis"))&&(n=null),l=n===ZS?i.group:n===QS?Object(Z.p)({},i.mark,i[e]):null){(JS(u,t)||("fill"===u||"stroke"===u)&&(JS("fill",t)||JS("stroke",t)))||vD(o,u,l[u]);}for(u in Object(Z.i)(r).forEach(function(e){var n=i.style&&i.style[e];for(var _e115 in n){JS(_e115,t)||vD(o,_e115,n[_e115]);}}),t=Object(Z.p)({},t),o){(l=o[u]).signal?(s=s||{})[u]=l:a[u]=l;}return t.enter=Object(Z.p)(a,t.enter),s&&(t.update=Object(Z.p)(s,t.update)),t;}(t,e,n,r,i.config);for(var _n86 in t){a[_n86]=CD(t[_n86],e,o,i);}return o;}function CD(t,e,n,r){var i={},o={};for(var _e116 in t){null!=t[_e116]&&(i[_e116]=OD(AD(t[_e116]),r,n,o));}return {$expr:{marktype:e,channels:i},$fields:Object.keys(o),$output:Object.keys(t)};}function AD(t){return Object(Z.B)(t)?function(t){var e="";return t.forEach(function(t){var n=bD(t);e+=t.test?"(".concat(t.test,")?").concat(n,":"):n;}),":"===Object(Z.W)(e)&&(e+="null"),e;}(t):bD(t);}function OD(t,e,n,r){var i=v_(t,e);return i.$fields.forEach(function(t){return r[t]=1;}),Object(Z.p)(n,i.$params),i.$expr;}var _D="outer",SD=["value","update","init","react","bind"];function DD(t,e){Object(Z.o)(t+' for "outer" push: '+Object(Z.Ba)(e));}function FD(t,e){var n=t.name;if(t.push===_D)e.signals[n]||DD("No prior signal definition",n),SD.forEach(function(e){void 0!==t[e]&&DD("Invalid property ",e);});else {var _r93=e.addSignal(n,t.value);!1===t.react&&(_r93.react=!1),t.bind&&e.addBinding(n,t.bind);}}function TD(t,e,n,r){this.id=-1,this.type=t,this.value=e,this.params=n,r&&(this.parent=r);}function ND(t,e,n,r){return new TD(t,e,n,r);}function ID(t,e){return ND("operator",t,e);}function RD(t){var e={$ref:t.id};return t.id<0&&(t.refs=t.refs||[]).push(e),e;}function MD(t,e){return e?{$field:t,$name:e}:{$field:t};}var jD=MD("key");function BD(t,e){return {$compare:t,$order:e};}var PD="descending";function LD(t,e){return (t&&t.signal?"$"+t.signal:t||"")+(t&&e?"_":"")+(e&&e.signal?"$"+e.signal:e||"");}var zD="scope",UD="view";function WD(t){return t&&t.signal;}function VD(t){if(WD(t))return !0;if(Object(Z.H)(t))for(var _e117 in t){if(VD(t[_e117]))return !0;}return !1;}function qD(t,e){return null!=t?t:e;}function $D(t){return t&&t.signal||t;}var HD="timer";function GD(t,e){return (t.merge?KD:t.stream?XD:t.type?YD:Object(Z.o)("Invalid stream specification: "+Object(Z.Ba)(t)))(t,e);}function KD(t,e){var n=JD({merge:t.merge.map(function(t){return GD(t,e);})},t,e);return e.addStream(n).id;}function XD(t,e){var n=JD({stream:GD(t.stream,e)},t,e);return e.addStream(n).id;}function YD(t,e){var n;t.type===HD?(n=e.event(HD,t.throttle),t={between:t.between,filter:t.filter}):n=e.event(function(t){return t===zD?UD:t||UD;}(t.source),t.type);var r=JD({stream:n},t,e);return 1===Object.keys(r).length?n:e.addStream(r).id;}function JD(t,e,n){var r=e.between;return r&&(2!==r.length&&Object(Z.o)('Stream "between" parameter must have 2 entries: '+Object(Z.Ba)(e)),t.between=[GD(r[0],n),GD(r[1],n)]),r=e.filter?[].concat(e.filter):[],(e.marktype||e.markname||e.markrole)&&r.push(function(t,e,n){var r="event.item";return r+(t&&"*"!==t?"&&"+r+".mark.marktype==='"+t+"'":"")+(n?"&&"+r+".mark.role==='"+n+"'":"")+(e?"&&"+r+".mark.name==='"+e+"'":"");}(e.marktype,e.markname,e.markrole)),e.source===zD&&r.push("inScope(event.item)"),r.length&&(t.filter=v_("("+r.join(")&&(")+")",n).$expr),null!=(r=e.throttle)&&(t.throttle=+r),null!=(r=e.debounce)&&(t.debounce=+r),e.consume&&(t.consume=!0),t;}var QD={code:"_.$value",ast:{type:"Identifier",value:"value"}};function ZD(t,e,n){var r=t.encode,i={target:n};var o=t.events,a=t.update,s=[];o||Object(Z.o)("Signal update missing events specification."),Object(Z.J)(o)&&(o=function(t,e,n){return zS=e||DS,US=n||LS,VS(t.trim()).map(qS);}(o,e.isSubscope()?zD:UD)),o=Object(Z.i)(o).filter(function(t){return t.signal||t.scale?(s.push(t),0):1;}),s.length>1&&(s=[function(t){return {signal:"["+t.map(function(t){return t.scale?'scale("'+t.scale+'")':t.signal;})+"]"};}(s)]),o.length&&s.push(o.length>1?{merge:o}:o[0]),null!=r&&(a&&Object(Z.o)("Signal encode and update are mutually exclusive."),a="encode(item(),"+Object(Z.Ba)(r)+")"),i.update=Object(Z.J)(a)?v_(a,e):null!=a.expr?v_(a.expr,e):null!=a.value?a.value:null!=a.signal?{$expr:QD,$params:{$value:e.signalRef(a.signal)}}:Object(Z.o)("Invalid signal update specification."),t.force&&(i.options={force:!0}),s.forEach(function(t){return e.addUpdate(Object(Z.p)(function(t,e){return {source:t.signal?e.signalRef(t.signal):t.scale?e.scaleRef(t.scale):GD(t,e)};}(t,e),i));});}var tF=function tF(t){return function(e,n,r){return ND(t,n,e||void 0,r);};},eF=tF("aggregate"),nF=tF("axisticks"),rF=tF("bound"),iF=tF("collect"),oF=tF("compare"),aF=tF("datajoin"),sF=tF("encode"),uF=tF("expression"),cF=tF("facet"),lF=tF("field"),fF=tF("key"),hF=tF("legendentries"),dF=tF("load"),pF=tF("mark"),mF=tF("multiextent"),gF=tF("multivalues"),vF=tF("overlap"),yF=tF("params"),bF=tF("prefacet"),xF=tF("projection"),wF=tF("proxy"),kF=tF("relay"),EF=tF("render"),CF=tF("scale"),AF=tF("sieve"),OF=tF("sortitems"),_F=tF("viewlayout"),SF=tF("values");var DF=0;var FF={min:"min",max:"max",count:"sum"};function TF(t,e){var n=e.getScale(t.name).params;var r;for(r in n.domain=MF(t.domain,t,e),null!=t.range&&(n.range=function t(e,n,r){var i=n.config.range;var o=e.range;if(o.signal)return n.signalRef(o.signal);if(Object(Z.J)(o)){if(i&&Object(Z.w)(i,o))return e=Object(Z.p)({},e,{range:i[o]}),t(e,n,r);"width"===o?o=[0,{signal:"width"}]:"height"===o?o=Ou(e.type)?[0,{signal:"height"}]:[{signal:"height"},0]:Object(Z.o)("Unrecognized scale range value: "+Object(Z.Ba)(o));}else {if(o.scheme)return r.scheme=Object(Z.B)(o.scheme)?IF(o.scheme,n):NF(o.scheme,n),o.extent&&(r.schemeExtent=IF(o.extent,n)),void(o.count&&(r.schemeCount=NF(o.count,n)));if(o.step)return void(r.rangeStep=NF(o.step,n));if(Ou(e.type)&&!Object(Z.B)(o))return MF(o,e,n);Object(Z.B)(o)||Object(Z.o)("Unsupported range type: "+Object(Z.Ba)(o));}return o.map(function(t){return (Object(Z.B)(t)?IF:NF)(t,n);});}(t,e,n)),null!=t.interpolate&&function(t,e){e.interpolate=NF(t.type||t),null!=t.gamma&&(e.interpolateGamma=NF(t.gamma));}(t.interpolate,n),null!=t.nice&&(n.nice=function(t){return Object(Z.H)(t)?{interval:NF(t.interval),step:NF(t.step)}:NF(t);}(t.nice)),null!=t.bins&&(n.bins=function(t,e){return t.signal||Object(Z.B)(t)?IF(t,e):e.objectProperty(t);}(t.bins,e)),t){Object(Z.w)(n,r)||"name"===r||(n[r]=NF(t[r],e));}}function NF(t,e){return Object(Z.H)(t)?t.signal?e.signalRef(t.signal):Object(Z.o)("Unsupported object: "+Object(Z.Ba)(t)):t;}function IF(t,e){return t.signal?e.signalRef(t.signal):t.map(function(t){return NF(t,e);});}function RF(t){Object(Z.o)("Can not find data set: "+Object(Z.Ba)(t));}function MF(t,e,n){if(t)return t.signal?n.signalRef(t.signal):(Object(Z.B)(t)?function(t,e,n){return t.map(function(t){return NF(t,n);});}:t.fields?function(t,e,n){var r=t.data,i=t.fields.reduce(function(t,e){return e=Object(Z.J)(e)?{data:r,field:e}:Object(Z.B)(e)||e.signal?function(t,e){var n="_:vega:_"+DF++,r=iF({});if(Object(Z.B)(t))r.value={$ingest:t};else if(t.signal){var _i66="setdata("+Object(Z.Ba)(n)+","+t.signal+")";r.params.input=e.signalRef(_i66);}return e.addDataPipeline(n,[r,AF({})]),{data:n,field:"data"};}(e,n):e,t.push(e),t;},[]);return (Ou(e.type)?function(t,e,n){var r=jF(t.sort,!0);var i,o;var a=n.map(function(t){var n=e.getData(t.data);return n||RF(t.data),n.countsRef(e,t.field,r);}),s={groupby:jD,pulse:a};r&&(i=r.op||"count",o=r.field?LD(i,r.field):"count",s.ops=[FF[i]],s.fields=[e.fieldRef(o)],s.as=[o]);i=e.add(eF(s));var u=e.add(iF({pulse:RD(i)}));return RD(o=e.add(SF({field:jD,sort:e.sortRef(r),pulse:RD(u)})));}:Fu(e.type)?function(t,e,n){var r=n.map(function(t){var n=e.getData(t.data);return n||RF(t.data),n.domainRef(e,t.field);});return RD(e.add(gF({values:r})));}:function(t,e,n){var r=n.map(function(t){var n=e.getData(t.data);return n||RF(t.data),n.extentRef(e,t.field);});return RD(e.add(mF({extents:r})));})(t,n,i);}:function(t,e,n){var r=n.getData(t.data);r||RF(t.data);return Ou(e.type)?r.valuesRef(n,t.field,jF(t.sort,!1)):Fu(e.type)?r.domainRef(n,t.field):r.extentRef(n,t.field);})(t,e,n);null==e.domainMin&&null==e.domainMax||Object(Z.o)("No scale domain defined for domainMin/domainMax to override.");}function jF(t,e){return t&&(t.field||t.op?t.field||"count"===t.op?e&&t.field&&t.op&&!FF[t.op]&&Object(Z.o)("Multiple domain scales can not be sorted using "+t.op):Object(Z.o)("No field provided for sort aggregate op: "+t.op):Object(Z.H)(t)?t.field="key":t={field:"key"}),t;}function BF(t,e,n){return Object(Z.B)(t)?t.map(function(t){return BF(t,e,n);}):Object(Z.H)(t)?t.signal?n.signalRef(t.signal):"fit"===e?t:Object(Z.o)("Unsupported parameter object: "+Object(Z.Ba)(t)):t;}var PF="top",LF="bottom",zF="vertical",UF="start",WF="end",VF="index",qF="label",$F="offset",HF="perc",GF="perc2",KF="value",XF="guide-label",YF="guide-title",JF="group-title",QF="group-subtitle",ZF="symbol",tT="gradient",eT="discrete",nT="size",rT=[nT,"shape","fill","stroke","strokeWidth","strokeDash","opacity"],iT={name:1,style:1,interactive:1},oT={value:0},aT={value:1},sT="group",uT="rect",cT="rule",lT="symbol",fT="text";function hT(t){return t.type=sT,t.interactive=t.interactive||!1,t;}function dT(t,e){var n=function n(_n87,r){return qD(t[_n87],qD(e[_n87],r));};return n.isVertical=function(n){return zF===qD(t.direction,e.direction||(n?e.symbolDirection:e.gradientDirection));},n.gradientLength=function(){return qD(t.gradientLength,e.gradientLength||e.gradientWidth);},n.gradientThickness=function(){return qD(t.gradientThickness,e.gradientThickness||e.gradientHeight);},n.entryColumns=function(){return qD(t.columns,qD(e.columns,+n.isVertical(!0)));},n;}function pT(t,e){var n=e&&(e.update&&e.update[t]||e.enter&&e.enter[t]);return n&&n.signal?n:n?n.value:null;}function mT(t,e,n){return "item.anchor === '".concat(UF,"' ? ").concat(t," : item.anchor === '").concat(WF,"' ? ").concat(e," : ").concat(n);}var gT=mT(Object(Z.Ba)("left"),Object(Z.Ba)("right"),Object(Z.Ba)("center"));function vT(t,e){return e?(t.name=e.name,t.style=e.style||t.style,t.interactive=!!e.interactive,t.encode=YS(t.encode,e,iT)):t.interactive=!1,t;}var yT="datum.".concat(HF,"<=0?\"left\":datum.").concat(HF,">=1?\"right\":\"center\""),bT="datum.".concat(HF,"<=0?\"").concat(LF,"\":datum.").concat(HF,">=1?\"").concat(PF,"\":\"middle\"");function xT(t,e,n,r){var i=dT(t,e),o=i.isVertical(),a=GS(i.gradientThickness()),s=i.gradientLength();var u,c,l,f,h=i("labelOverlap"),d="";var p={enter:u={opacity:oT},update:c={opacity:aT,text:{field:qF}},exit:{opacity:oT}};return XS(p,{fill:i("labelColor"),fillOpacity:i("labelOpacity"),font:i("labelFont"),fontSize:i("labelFontSize"),fontStyle:i("labelFontStyle"),fontWeight:i("labelFontWeight"),limit:qD(t.labelLimit,e.gradientLabelLimit)}),o?(u.align={value:"left"},u.baseline=c.baseline={signal:bT},l="y",f="x",d="1-"):(u.align=c.align={signal:yT},u.baseline={value:"top"},l="x",f="y"),u[l]=c[l]={signal:d+"datum."+HF,mult:s},u[f]=c[f]=a,a.offset=qD(t.labelOffset,e.gradientLabelOffset)||0,h=h?{separation:i("labelSeparation"),method:h,order:"datum."+VF}:void 0,vT({type:fT,role:fD,style:XF,key:KF,from:r,encode:p,overlap:h},n);}var wT='(item.orient === "left" || item.orient === "right")',kT="datum.vgrad && ".concat(wT),ET=mT('"top"','"bottom"','"middle"'),CT="datum.vgrad && item.orient === \"right\" ? (".concat(mT('"right"','"left"','"center"'),") : (").concat(wT," && !(datum.vgrad && item.orient === \"left\")) ? \"left\" : ").concat(gT),AT="item._anchor || (".concat(wT," ? \"middle\" : \"start\")"),OT="".concat(kT," ? (item.orient === \"left\" ? -90 : 90) : 0"),_T="".concat(wT," ? (datum.vgrad ? (item.orient === \"right\" ? \"bottom\" : \"top\") : ").concat(ET,") : \"top\"");function ST(t){return Object(Z.H)(t)&&t.signal?t.signal:Object(Z.Ba)(t);}function DT(t){var e=t.role||"";return e.indexOf("axis")&&e.indexOf("legend")&&e.indexOf("title")?t.type===sT?tD:e||QS:e;}function FT(t,e){var n=Wt(t.type);n||Object(Z.o)("Unrecognized transform type: "+Object(Z.Ba)(t.type));var r=ND(n.type.toLowerCase(),null,TT(n,t,e));return t.signal&&e.addSignal(t.signal,e.proxy(r)),r.metadata=n.metadata||{},r;}function TT(t,e,n){var r={},i=t.params.length;for(var _o41=0;_o41<i;++_o41){var _i67=t.params[_o41];r[_i67.name]=NT(_i67,e,n);}return r;}function NT(t,e,n){var r=t.type,i=e[t.name];return "index"===r?function(t,e,n){Object(Z.J)(e.from)||Object(Z.o)('Lookup "from" parameter must be a string literal.');return n.getData(e.from).lookupRef(n,e.key);}(0,e,n):void 0!==i?"param"===r?function(t,e,n){var r=e[t.name];return t.array?(Object(Z.B)(r)||Object(Z.o)("Expected an array of sub-parameters. Instead: "+Object(Z.Ba)(r)),r.map(function(e){return RT(t,e,n);})):RT(t,r,n);}(t,e,n):"projection"===r?n.projectionRef(e[t.name]):t.array&&!WD(i)?i.map(function(e){return IT(t,e,n);}):IT(t,i,n):void(t.required&&Object(Z.o)("Missing required "+Object(Z.Ba)(e.type)+" parameter: "+Object(Z.Ba)(t.name)));}function IT(t,e,n){var r=t.type;if(WD(e))return PT(r)?Object(Z.o)("Expression references can not be signals."):LT(r)?n.fieldRef(e):zT(r)?n.compareRef(e):n.signalRef(e.signal);{var _i68=t.expr||LT(r);return _i68&&MT(e)?n.exprRef(e.expr,e.as):_i68&&jT(e)?MD(e.field,e.as):PT(r)?v_(e,n):BT(r)?RD(n.getData(e).values):LT(r)?MD(e):zT(r)?n.compareRef(e):e;}}function RT(t,e,n){var r=t.params.length;var i;for(var _n88=0;_n88<r;++_n88){i=t.params[_n88];for(var _t104 in i.key){if(i.key[_t104]!==e[_t104]){i=null;break;}}if(i)break;}i||Object(Z.o)("Unsupported parameter: "+Object(Z.Ba)(e));var o=Object(Z.p)(TT(i,e,n),i.key);return RD(n.add(yF(o)));}var MT=function MT(t){return t&&t.expr;},jT=function jT(t){return t&&t.field;},BT=function BT(t){return "data"===t;},PT=function PT(t){return "expr"===t;},LT=function LT(t){return "field"===t;},zT=function zT(t){return "compare"===t;};function UT(t,e){return t.$ref?t:t.data&&t.data.$ref?t.data:RD(e.getData(t.data).output);}function WT(t,e,n,r,i){this.scope=t,this.input=e,this.output=n,this.values=r,this.aggregate=i,this.index={};}function VT(t){return Object(Z.J)(t)?t:null;}function qT(t,e,n){var r=LD(n.op,n.field);var i;if(e.ops){for(var _t105=0,_n89=e.as.length;_t105<_n89;++_t105){if(e.as[_t105]===r)return;}}else e.ops=["count"],e.fields=[null],e.as=["count"];n.op&&(e.ops.push((i=n.op.signal)?t.signalRef(i):n.op),e.fields.push(t.fieldRef(n.field)),e.as.push(r));}function $T(t,e,n,r,i,o,a){var s=e[n]||(e[n]={}),u=function(t){return Object(Z.H)(t)?(t.order===PD?"-":"+")+LD(t.op,t.field):"";}(o);var c,l,f=VT(i);if(null!=f&&(t=e.scope,c=s[f+=u?"|"+u:""]),!c){var _n90=o?{field:jD,pulse:e.countsRef(t,i,o)}:{field:t.fieldRef(i),pulse:RD(e.output)};u&&(_n90.sort=t.sortRef(o)),l=t.add(ND(r,void 0,_n90)),a&&(e.index[i]=l),c=RD(l),null!=f&&(s[f]=c);}return c;}function HT(t,e,n){var r=t.remove,i=t.insert,o=t.toggle,a=t.modify,s=t.values,u=e.add(ID()),c=v_("if("+t.trigger+',modify("'+n+'",'+[i,r,o,a,s].map(function(t){return null==t?"null":t;}).join(",")+"),0)",e);u.update=c.$expr,u.params=c.$params;}function GT(t,e){var n=DT(t),r=t.type===sT,i=t.from&&t.from.facet,o=t.overlap;var a,s,u,c,l,f,h,d=t.layout||n===tD||n===ZS;var p=n===QS||d||i,m=function(t,e,n){var r,i,o,a,s;return t?(r=t.facet)&&(e||Object(Z.o)("Only group marks can be faceted."),null!=r.field?a=s=UT(r,n):(t.data?s=RD(n.getData(t.data).aggregate):((o=FT(Object(Z.p)({type:"aggregate",groupby:Object(Z.i)(r.groupby)},r.aggregate),n)).params.key=n.keyRef(r.groupby),o.params.pulse=UT(r,n),a=s=RD(n.add(o))),i=n.keyRef(r.groupby,!0))):a=RD(n.add(iF(null,[{}]))),a||(a=UT(t,n)),{key:i,pulse:a,parent:s};}(t.from,r,e),g=RD(s=e.add(aF({key:m.key||(t.key?MD(t.key):void 0),pulse:m.pulse,clean:!r})));s=u=e.add(iF({pulse:g}));var v=RD(s=e.add(pF({markdef:function(t){return {marktype:t.type,name:t.name||void 0,role:t.role||DT(t),zindex:+t.zindex||void 0,aria:t.aria,description:t.description};}(t),interactive:function(t,e){return t&&t.signal?e.signalRef(t.signal):!1!==t;}(t.interactive,e),clip:function(t,e){var n;return Object(Z.H)(t)&&(t.signal?n=t.signal:t.path?n="pathShape("+ST(t.path)+")":t.sphere&&(n="geoShape("+ST(t.sphere)+', {type: "Sphere"})')),n?e.signalRef(n):!!t;}(t.clip,e),context:{$context:!0},groups:e.lookup(),parent:e.signals.parent?e.signalRef("parent"):null,index:e.markpath(),pulse:RD(s)})));(s=c=e.add(sF(ED(t.encode,t.type,n,t.style,e,{mod:!1,pulse:v})))).params.parent=e.encode(),t.transform&&t.transform.forEach(function(t){var n=FT(t,e),r=n.metadata;(r.generates||r.changes)&&Object(Z.o)("Mark transforms should not generate new data."),r.nomod||(c.params.mod=!0),n.params.pulse=RD(s),e.add(s=n);}),t.sort&&(s=e.add(OF({sort:e.compareRef(t.sort),pulse:RD(s)})));var y=RD(s);(i||d)&&(f=RD(d=e.add(_F({layout:e.objectProperty(t.layout),legends:e.legends,mark:v,pulse:y}))));var b=e.add(rF({mark:v,pulse:f||y}));h=RD(b),r&&(p&&((a=e.operators).pop(),d&&a.pop()),e.pushState(y,f||h,g),i?function(t,e,n){var r=t.from.facet,i=r.name,o=UT(r,e);var a;r.name||Object(Z.o)("Facet must have a name: "+Object(Z.Ba)(r)),r.data||Object(Z.o)("Facet must reference a data set: "+Object(Z.Ba)(r)),r.field?a=e.add(bF({field:e.fieldRef(r.field),pulse:o})):r.groupby?a=e.add(cF({key:e.keyRef(r.groupby),group:RD(e.proxy(n.parent)),pulse:o})):Object(Z.o)("Facet must specify groupby or field: "+Object(Z.Ba)(r));var s=e.fork(),u=s.add(iF()),c=s.add(AF({pulse:RD(u)}));s.addData(i,new WT(s,u,u,c)),s.addSignal("parent",null),a.params.subflow={$subflow:s.parse(t).toRuntime()};}(t,e,m):p?function(t,e,n){var r=e.add(bF({pulse:n.pulse})),i=e.fork();i.add(AF()),i.addSignal("parent",null),r.params.subflow={$subflow:i.parse(t).toRuntime()};}(t,e,m):e.parse(t),e.popState(),p&&(d&&a.push(d),a.push(b))),o&&(h=function(t,e,n){var r=t.method,i=t.bound,o=t.separation,a={separation:WD(o)?n.signalRef(o.signal):o,method:WD(r)?n.signalRef(r.signal):r,pulse:e};t.order&&(a.sort=n.compareRef({field:t.order}));if(i){var _t106=i.tolerance;a.boundTolerance=WD(_t106)?n.signalRef(_t106.signal):+_t106,a.boundScale=n.scaleRef(i.scale),a.boundOrient=i.orient;}return RD(n.add(vF(a)));}(o,h,e));var x=e.add(EF({pulse:h})),w=e.add(AF({pulse:RD(x)},void 0,e.parent()));null!=t.name&&(l=t.name,e.addData(l,new WT(e,u,x,w)),t.on&&t.on.forEach(function(t){(t.insert||t.remove||t.toggle)&&Object(Z.o)("Marks only support modify triggers."),HT(t,e,l);}));}function KT(t,e){var n=e.config.legend,r=t.encode||{},i=dT(t,n),o=r.legend||{},a=o.name||void 0,s=o.interactive,u=o.style,c={};var l,f,h,d=0;rT.forEach(function(e){return t[e]?(c[e]=t[e],d=d||t[e]):0;}),d||Object(Z.o)("Missing valid scale for legend.");var p=function(t,e){var n=t.type||ZF;t.type||1!==function(t){return rT.reduce(function(e,n){return e+(t[n]?1:0);},0);}(t)||!t.fill&&!t.stroke||(n=Au(e)?tT:_u(e)?eT:ZF);return n!==tT?n:_u(e)?eT:tT;}(t,e.scaleType(d)),m={title:null!=t.title,scales:c,type:p,vgrad:"symbol"!==p&&i.isVertical()},g=RD(e.add(iF(null,[m]))),v=RD(e.add(hF(f={type:p,scale:e.scaleRef(d),count:e.objectProperty(i("tickCount")),limit:e.property(i("symbolLimit")),values:e.objectProperty(t.values),minstep:e.property(t.tickMinStep),formatType:e.property(t.formatType),formatSpecifier:e.property(t.format)})));return p===tT?(h=[function(t,e,n,r){var i=dT(t,n),o=i.isVertical(),a=i.gradientThickness(),s=i.gradientLength();var u,c,l,f,h;o?(c=[0,1],l=[0,0],f=a,h=s):(c=[0,0],l=[1,0],f=s,h=a);var d={enter:u={opacity:oT,x:oT,y:oT,width:GS(f),height:GS(h)},update:Object(Z.p)({},u,{opacity:aT,fill:{gradient:e,start:c,stop:l}}),exit:{opacity:oT}};return XS(d,{stroke:i("gradientStrokeColor"),strokeWidth:i("gradientStrokeWidth")},{opacity:i("gradientOpacity")}),vT({type:uT,role:lD,encode:d},r);}(t,d,n,r.gradient),xT(t,n,r.labels,v)],f.count=f.count||e.signalRef("max(2,2*floor((".concat($D(i.gradientLength()),")/100))"))):p===eT?h=[function(t,e,n,r,i){var o=dT(t,n),a=o.isVertical(),s=o.gradientThickness(),u=o.gradientLength();var c,l,f,h,d="";a?(c="y",f="y2",l="x",h="width",d="1-"):(c="x",f="x2",l="y",h="height");var p={opacity:oT,fill:{scale:e,field:KF}};p[c]={signal:d+"datum."+HF,mult:u},p[l]=oT,p[f]={signal:d+"datum."+GF,mult:u},p[h]=GS(s);var m={enter:p,update:Object(Z.p)({},p,{opacity:aT}),exit:{opacity:oT}};return XS(m,{stroke:o("gradientStrokeColor"),strokeWidth:o("gradientStrokeWidth")},{opacity:o("gradientOpacity")}),vT({type:uT,role:uD,key:KF,from:i,encode:m},r);}(t,d,n,r.gradient,v),xT(t,n,r.labels,v)]:(l=function(t,e){var n=dT(t,e);return {align:n("gridAlign"),columns:n.entryColumns(),center:{row:!0,column:!1},padding:{row:n("rowPadding"),column:n("columnPadding")}};}(t,n),h=[function(t,e,n,r,i){var o=dT(t,e),a=n.entries,s=!(!a||!a.interactive),u=a?a.name:void 0,c=o("clipHeight"),l=o("symbolOffset"),f={data:"value"},h="(".concat(i,") ? datum.").concat($F," : datum.").concat(nT),d=c?GS(c):{field:nT},p="datum.".concat(VF),m="max(1, ".concat(i,")");var g,v,y,b,x;d.mult=.5,g={enter:v={opacity:oT,x:{signal:h,mult:.5,offset:l},y:d},update:y={opacity:aT,x:v.x,y:v.y},exit:{opacity:oT}};var w=null,k=null;t.fill||(w=e.symbolBaseFillColor,k=e.symbolBaseStrokeColor),XS(g,{fill:o("symbolFillColor",w),shape:o("symbolType"),size:o("symbolSize"),stroke:o("symbolStrokeColor",k),strokeDash:o("symbolDash"),strokeDashOffset:o("symbolDashOffset"),strokeWidth:o("symbolStrokeWidth")},{opacity:o("symbolOpacity")}),rT.forEach(function(e){t[e]&&(y[e]=v[e]={scale:t[e],field:KF});});var E=vT({type:lT,role:hD,key:KF,from:f,clip:!!c||void 0,encode:g},n.symbols),C=GS(l);C.offset=o("labelOffset"),XS(g={enter:v={opacity:oT,x:{signal:h,offset:C},y:d},update:y={opacity:aT,text:{field:qF},x:v.x,y:v.y},exit:{opacity:oT}},{align:o("labelAlign"),baseline:o("labelBaseline"),fill:o("labelColor"),fillOpacity:o("labelOpacity"),font:o("labelFont"),fontSize:o("labelFontSize"),fontStyle:o("labelFontStyle"),fontWeight:o("labelFontWeight"),limit:o("labelLimit")});var A=vT({type:fT,role:fD,style:XF,key:KF,from:f,encode:g},n.labels);return g={enter:{noBound:{value:!c},width:oT,height:c?GS(c):oT,opacity:oT},exit:{opacity:oT},update:y={opacity:aT,row:{signal:null},column:{signal:null}}},o.isVertical(!0)?(b="ceil(item.mark.items.length / ".concat(m,")"),y.row.signal="".concat(p,"%").concat(b),y.column.signal="floor(".concat(p," / ").concat(b,")"),x={field:["row",p]}):(y.row.signal="floor(".concat(p," / ").concat(m,")"),y.column.signal="".concat(p," % ").concat(m),x={field:p}),y.column.signal="(".concat(i,")?").concat(y.column.signal,":").concat(p),hT({role:tD,from:r={facet:{data:r,name:"value",groupby:VF}},encode:YS(g,a,iT),marks:[E,A],name:u,interactive:s,sort:x});}(t,n,r,v,$D(l.columns))],f.size=function(t,e,n){var r=$D(XT("size",t,n)),i=$D(XT("strokeWidth",t,n)),o=$D(function(t,e,n){return pT("fontSize",t)||function(t,e,n){var r=e.config.style[n];return r&&r[t];}("fontSize",e,n);}(n[1].encode,e,XF));return v_("max(ceil(sqrt(".concat(r,")+").concat(i,"),").concat(o,")"),e);}(t,e,h[0].marks)),h=[hT({role:cD,from:g,encode:{enter:{x:{value:0},y:{value:0}}},marks:h,layout:l,interactive:s})],m.title&&h.push(function(t,e,n,r){var i=dT(t,e),o={enter:{opacity:oT},update:{opacity:aT,x:{field:{group:"padding"}},y:{field:{group:"padding"}}},exit:{opacity:oT}};return XS(o,{orient:i("titleOrient"),_anchor:i("titleAnchor"),anchor:{signal:AT},angle:{signal:OT},align:{signal:CT},baseline:{signal:_T},text:t.title,fill:i("titleColor"),fillOpacity:i("titleOpacity"),font:i("titleFont"),fontSize:i("titleFontSize"),fontStyle:i("titleFontStyle"),fontWeight:i("titleFontWeight"),limit:i("titleLimit"),lineHeight:i("titleLineHeight")},{align:i("titleAlign"),baseline:i("titleBaseline")}),vT({type:fT,role:dD,style:YF,from:r,encode:o},n);}(t,n,r.title,g)),GT(hT({role:sD,from:g,encode:YS(function(t,e,n){var r={enter:{},update:{}};return XS(r,{orient:t("orient"),offset:t("offset"),padding:t("padding"),titlePadding:t("titlePadding"),cornerRadius:t("cornerRadius"),fill:t("fillColor"),stroke:t("strokeColor"),strokeWidth:n.strokeWidth,strokeDash:n.strokeDash,x:t("legendX"),y:t("legendY"),format:e.format,formatType:e.formatType}),r;}(i,t,n),o,iT),marks:h,aria:i("aria"),description:i("description"),zindex:i("zindex"),name:a,interactive:s,style:u}),e);}function XT(t,e,n){return e[t]?"scale(\"".concat(e[t],"\",datum)"):pT(t,n[0].encode);}WT.fromEntries=function(t,e){var n=e.length,r=e[n-1],i=e[n-2];var o=e[0],a=null,s=1;for(o&&"load"===o.type&&(o=e[1]),t.add(e[0]);s<n;++s){e[s].params.pulse=RD(e[s-1]),t.add(e[s]),"aggregate"===e[s].type&&(a=e[s]);}return new WT(t,o,i,r,a);},WT.prototype={countsRef:function countsRef(t,e,n){var r=this,i=r.counts||(r.counts={}),o=VT(e);var a,s,u;return null!=o&&(t=r.scope,a=i[o]),a?n&&n.field&&qT(t,a.agg.params,n):(u={groupby:t.fieldRef(e,"key"),pulse:RD(r.output)},n&&n.field&&qT(t,u,n),a={agg:s=t.add(eF(u)),ref:RD(a=t.add(iF({pulse:RD(s)})))},null!=o&&(i[o]=a)),a.ref;},tuplesRef:function tuplesRef(){return RD(this.values);},extentRef:function extentRef(t,e){return $T(t,this,"extent","extent",e,!1);},domainRef:function domainRef(t,e){return $T(t,this,"domain","values",e,!1);},valuesRef:function valuesRef(t,e,n){return $T(t,this,"vals","values",e,n||!0);},lookupRef:function lookupRef(t,e){return $T(t,this,"lookup","tupleindex",e,!1);},indataRef:function indataRef(t,e){return $T(t,this,"indata","tupleindex",e,!0,!0);}};var YT='item.orient==="left"?-90:item.orient==="right"?90:0';function JT(t,e){var n=dT(t=Object(Z.J)(t)?{text:t}:t,e.config.title),r=t.encode||{},i=r.group||{},o=i.name||void 0,a=i.interactive,s=i.style,u=[],c=RD(e.add(iF(null,[{}])));return u.push(function(t,e,n,r){var i={value:0},o=t.text,a={enter:{opacity:i},update:{opacity:{value:1}},exit:{opacity:i}};return XS(a,{text:o,align:{signal:"item.mark.group.align"},angle:{signal:"item.mark.group.angle"},limit:{signal:"item.mark.group.limit"},baseline:"top",dx:e("dx"),dy:e("dy"),fill:e("color"),font:e("font"),fontSize:e("fontSize"),fontStyle:e("fontStyle"),fontWeight:e("fontWeight"),lineHeight:e("lineHeight")},{align:e("align"),angle:e("angle"),baseline:e("baseline")}),vT({type:fT,role:mD,style:JF,from:r,encode:a},n);}(t,n,function(t){var e=t.encode;return e&&e.title||Object(Z.p)({name:t.name,interactive:t.interactive,style:t.style},e);}(t),c)),t.subtitle&&u.push(function(t,e,n,r){var i={value:0},o=t.subtitle,a={enter:{opacity:i},update:{opacity:{value:1}},exit:{opacity:i}};return XS(a,{text:o,align:{signal:"item.mark.group.align"},angle:{signal:"item.mark.group.angle"},limit:{signal:"item.mark.group.limit"},baseline:"top",dx:e("dx"),dy:e("dy"),fill:e("subtitleColor"),font:e("subtitleFont"),fontSize:e("subtitleFontSize"),fontStyle:e("subtitleFontStyle"),fontWeight:e("subtitleFontWeight"),lineHeight:e("subtitleLineHeight")},{align:e("align"),angle:e("angle"),baseline:e("baseline")}),vT({type:fT,role:gD,style:QF,from:r,encode:a},n);}(t,n,r.subtitle,c)),GT(hT({role:pD,from:c,encode:function(t,e){var n={enter:{},update:{}};return XS(n,{orient:t("orient"),anchor:t("anchor"),align:{signal:gT},angle:{signal:YT},limit:t("limit"),frame:t("frame"),offset:t("offset")||0,padding:t("subtitlePadding")}),YS(n,e,iT);}(n,i),marks:u,aria:n("aria"),description:n("description"),zindex:n("zindex"),name:o,interactive:a,style:s}),e);}function QT(t,e){var n=[];t.transform&&t.transform.forEach(function(t){n.push(FT(t,e));}),t.on&&t.on.forEach(function(n){HT(n,e,t.name);}),e.addDataPipeline(t.name,function(t,e,n){var r=[];var i,o,a,s,u,c=null,l=!1,f=!1;t.values?WD(t.values)||VD(t.format)?(r.push(tN(e,t)),r.push(c=ZT())):r.push(c=ZT({$ingest:t.values,$format:t.format})):t.url?VD(t.url)||VD(t.format)?(r.push(tN(e,t)),r.push(c=ZT())):r.push(c=ZT({$request:t.url,$format:t.format})):t.source&&(c=i=Object(Z.i)(t.source).map(function(t){return RD(e.getData(t).output);}),r.push(null));for(o=0,a=n.length;o<a;++o){s=n[o],u=s.metadata,c||u.source||r.push(c=ZT()),r.push(s),u.generates&&(f=!0),u.modifies&&!f&&(l=!0),u.source?c=s:u.changes&&(c=null);}i&&(a=i.length-1,r[0]=kF({derive:l,pulse:a?i:i[0]}),(l||a)&&r.splice(1,0,ZT()));c||r.push(ZT());return r.push(AF({})),r;}(t,e,n));}function ZT(t){var e=iF({},t);return e.metadata={source:!0},e;}function tN(t,e){return dF({url:e.url?t.property(e.url):void 0,async:e.async?t.property(e.async):void 0,values:e.values?t.property(e.values):void 0,format:t.objectProperty(e.format)});}var eN=function eN(t){return t===LF||t===PF;},nN=function nN(t,e,n){return WD(t)?cN(t.signal,e,n):"left"===t||t===PF?e:n;},rN=function rN(t,e,n){return WD(t)?sN(t.signal,e,n):eN(t)?e:n;},iN=function iN(t,e,n){return WD(t)?uN(t.signal,e,n):eN(t)?n:e;},oN=function oN(t,e,n){return WD(t)?lN(t.signal,e,n):t===PF?{value:e}:{value:n};},aN=function aN(t,e,n){return WD(t)?fN(t.signal,e,n):"right"===t?{value:e}:{value:n};},sN=function sN(t,e,n){return hN("".concat(t," === '").concat(PF,"' || ").concat(t," === '").concat(LF,"'"),e,n);},uN=function uN(t,e,n){return hN("".concat(t," !== '").concat(PF,"' && ").concat(t," !== '").concat(LF,"'"),e,n);},cN=function cN(t,e,n){return pN("".concat(t," === 'left' || ").concat(t," === '").concat(PF,"'"),e,n);},lN=function lN(t,e,n){return pN("".concat(t," === '").concat(PF,"'"),e,n);},fN=function fN(t,e,n){return pN("".concat(t," === 'right'"),e,n);},hN=function hN(t,e,n){return e=null!=e?GS(e):e,n=null!=n?GS(n):n,dN(e)&&dN(n)?{signal:"".concat(t," ? (").concat(e=e?e.signal||Object(Z.Ba)(e.value):null,") : (").concat(n=n?n.signal||Object(Z.Ba)(n.value):null,")")}:[Object(Z.p)({test:t},e)].concat(n||[]);},dN=function dN(t){return null==t||1===Object.keys(t).length;},pN=function pN(t,e,n){return {signal:"".concat(t," ? (").concat(gN(e),") : (").concat(gN(n),")")};},mN=function mN(t,e,n,r,i){return {signal:(null!=r?"".concat(t," === 'left' ? (").concat(gN(r),") : "):"")+(null!=n?"".concat(t," === '").concat(LF,"' ? (").concat(gN(n),") : "):"")+(null!=i?"".concat(t," === 'right' ? (").concat(gN(i),") : "):"")+(null!=e?"".concat(t," === '").concat(PF,"' ? (").concat(gN(e),") : "):"")+"(null)"};},gN=function gN(t){return WD(t)?t.signal:null==t?null:Object(Z.Ba)(t);},vN=function vN(t,e){return 0===e?0:WD(t)?{signal:"(".concat(t.signal,") * ").concat(e)}:{value:t*e};},yN=function yN(t,e){var n=t.signal;return n&&n.endsWith("(null)")?{signal:n.slice(0,-6)+e.signal}:t;};function bN(t,e,n,r){var i;if(e&&Object(Z.w)(e,t))return e[t];if(Object(Z.w)(n,t))return n[t];if(t.startsWith("title")){switch(t){case"titleColor":i="fill";break;case"titleFont":case"titleFontSize":case"titleFontWeight":i=t[5].toLowerCase()+t.slice(6);}return r[YF][i];}if(t.startsWith("label")){switch(t){case"labelColor":i="fill";break;case"labelFont":case"labelFontSize":i=t[5].toLowerCase()+t.slice(6);}return r[XF][i];}return null;}function xN(t){var e={};var _iterator27=_createForOfIteratorHelper(t),_step27;try{for(_iterator27.s();!(_step27=_iterator27.n()).done;){var _n91=_step27.value;if(_n91)for(var _t107 in _n91){e[_t107]=1;}}}catch(err){_iterator27.e(err);}finally{_iterator27.f();}return Object.keys(e);}function wN(t,e){return {scale:t.scale,range:e};}function kN(t,e,n,r,i){var o=dT(t,e),a=t.orient,s=t.gridScale,u=nN(a,1,-1),c=function(t,e){if(1===e);else if(Object(Z.H)(t)){var _n92=t=Object(Z.p)({},t);for(;null!=_n92.mult;){if(!Object(Z.H)(_n92.mult))return _n92.mult=WD(e)?{signal:"(".concat(_n92.mult,") * (").concat(e.signal,")")}:_n92.mult*e,t;_n92=_n92.mult=Object(Z.p)({},_n92.mult);}_n92.mult=e;}else t=WD(e)?{signal:"(".concat(e.signal,") * (").concat(t||0,")")}:e*(t||0);return t;}(t.offset,u);var l,f,h;var d={enter:l={opacity:oT},update:h={opacity:aT},exit:f={opacity:oT}};XS(d,{stroke:o("gridColor"),strokeCap:o("gridCap"),strokeDash:o("gridDash"),strokeDashOffset:o("gridDashOffset"),strokeOpacity:o("gridOpacity"),strokeWidth:o("gridWidth")});var p={scale:t.scale,field:KF,band:i.band,extra:i.extra,offset:i.offset,round:o("tickRound")},m=rN(a,{signal:"height"},{signal:"width"}),g=s?{scale:s,range:0,mult:u,offset:c}:{value:0,offset:c},v=s?{scale:s,range:1,mult:u,offset:c}:Object(Z.p)(m,{mult:u,offset:c});return l.x=h.x=rN(a,p,g),l.y=h.y=iN(a,p,g),l.x2=h.x2=iN(a,v),l.y2=h.y2=rN(a,v),f.x=rN(a,p),f.y=iN(a,p),vT({type:cT,role:rD,key:KF,from:r,encode:d},n);}function EN(t,e,n,r,i){return {signal:'flush(range("'+t+'"), scale("'+t+'", datum.value), '+e+","+n+","+r+","+i+")"};}function CN(t,e,n,r,i,o){var a=dT(t,e),s=t.orient,u=t.scale,c=nN(s,-1,1),l=$D(a("labelFlush")),f=$D(a("labelFlushOffset")),h=a("labelAlign"),d=a("labelBaseline");var p,m=0===l||!!l;var g=GS(i);g.mult=c,g.offset=GS(a("labelPadding")||0),g.offset.mult=c;var v={scale:u,field:KF,band:.5,offset:function t(e,n){return n?e?Object(Z.H)(e)?Object.assign({},e,{offset:t(e.offset,n)}):{value:e,offset:n}:n:e;}(o.offset,a("labelOffset"))},y=rN(s,m?EN(u,l,'"left"','"right"','"center"'):{value:"center"},aN(s,"left","right")),b=rN(s,oN(s,"bottom","top"),m?EN(u,l,'"top"','"bottom"','"middle"'):{value:"middle"}),x=EN(u,l,"-(".concat(f,")"),f,0);m=m&&f;var w={opacity:oT,x:rN(s,v,g),y:iN(s,v,g)},k={enter:w,update:p={opacity:aT,text:{field:qF},x:w.x,y:w.y,align:y,baseline:b},exit:{opacity:oT,x:w.x,y:w.y}};XS(k,{dx:!h&&m?rN(s,x):null,dy:!d&&m?iN(s,x):null}),XS(k,{angle:a("labelAngle"),fill:a("labelColor"),fillOpacity:a("labelOpacity"),font:a("labelFont"),fontSize:a("labelFontSize"),fontWeight:a("labelFontWeight"),fontStyle:a("labelFontStyle"),limit:a("labelLimit"),lineHeight:a("labelLineHeight")},{align:h,baseline:d});var E=a("labelBound");var C=a("labelOverlap");return C=C||E?{separation:a("labelSeparation"),method:C,order:"datum.index",bound:E?{scale:u,orient:s,tolerance:E}:null}:void 0,p.align!==y&&(p.align=yN(p.align,y)),p.baseline!==b&&(p.baseline=yN(p.baseline,b)),vT({type:fT,role:iD,style:XF,key:KF,from:r,encode:k,overlap:C},n);}function AN(t,e,n,r){var i=dT(t,e),o=t.orient,a=nN(o,-1,1);var s,u;var c={enter:s={opacity:oT,anchor:GS(i("titleAnchor",null)),align:{signal:gT}},update:u=Object(Z.p)({},s,{opacity:aT,text:GS(t.title)}),exit:{opacity:oT}},l={signal:"lerp(range(\"".concat(t.scale,"\"), ").concat(mT(0,1,.5),")")};return u.x=rN(o,l),u.y=iN(o,l),s.angle=rN(o,oT,vN(a,90)),s.baseline=rN(o,oN(o,LF,PF),{value:LF}),u.angle=s.angle,u.baseline=s.baseline,XS(c,{fill:i("titleColor"),fillOpacity:i("titleOpacity"),font:i("titleFont"),fontSize:i("titleFontSize"),fontStyle:i("titleFontStyle"),fontWeight:i("titleFontWeight"),limit:i("titleLimit"),lineHeight:i("titleLineHeight")},{align:i("titleAlign"),angle:i("titleAngle"),baseline:i("titleBaseline")}),function(t,e,n,r){var i=function i(t,e){return null!=t?(n.update[e]=yN(GS(t),n.update[e]),!1):!JS(e,r);},o=i(t("titleX"),"x"),a=i(t("titleY"),"y");n.enter.auto=a===o?GS(a):rN(e,GS(a),GS(o));}(i,o,c,n),c.update.align=yN(c.update.align,s.align),c.update.angle=yN(c.update.angle,s.angle),c.update.baseline=yN(c.update.baseline,s.baseline),vT({type:fT,role:aD,style:YF,from:r,encode:c},n);}function ON(t,e){var n=function(t,e){var n,r,i,o=e.config,a=o.style,s=o.axis,u="band"===e.scaleType(t.scale)&&o.axisBand,c=t.orient;if(WD(c)){var _t108=xN([o.axisX,o.axisY]),_e118=xN([o.axisTop,o.axisBottom,o.axisLeft,o.axisRight]);var _iterator28=_createForOfIteratorHelper((n={},_t108)),_step28;try{for(_iterator28.s();!(_step28=_iterator28.n()).done;){i=_step28.value;n[i]=rN(c,bN(i,o.axisX,s,a),bN(i,o.axisY,s,a));}}catch(err){_iterator28.e(err);}finally{_iterator28.f();}var _iterator29=_createForOfIteratorHelper((r={},_e118)),_step29;try{for(_iterator29.s();!(_step29=_iterator29.n()).done;){i=_step29.value;r[i]=mN(c.signal,bN(i,o.axisTop,s,a),bN(i,o.axisBottom,s,a),bN(i,o.axisLeft,s,a),bN(i,o.axisRight,s,a));}}catch(err){_iterator29.e(err);}finally{_iterator29.f();}}else n=c===PF||c===LF?o.axisX:o.axisY,r=o["axis"+c[0].toUpperCase()+c.slice(1)];return n||r||u?Object(Z.p)({},s,n,r,u):s;}(t,e),r=t.encode||{},i=r.axis||{},o=i.name||void 0,a=i.interactive,s=i.style,u=dT(t,n),c=function(t){var e=t("tickBand");var n,r,i=t("tickOffset");return e?e.signal?(n={signal:"(".concat(e.signal,") === 'extent' ? 1 : 0.5")},r={signal:"(".concat(e.signal,") === 'extent'")},Object(Z.H)(i)||(i={signal:"(".concat(e.signal,") === 'extent' ? 0 : ").concat(i)})):"extent"===e?(n=1,r=!0,i=0):(n=.5,r=!1):(n=t("bandPosition"),r=t("tickExtra")),{extra:r,band:n,offset:i};}(u),l={scale:t.scale,ticks:!!u("ticks"),labels:!!u("labels"),grid:!!u("grid"),domain:!!u("domain"),title:null!=t.title},f=RD(e.add(iF({},[l]))),h=RD(e.add(nF({scale:e.scaleRef(t.scale),extra:e.property(c.extra),count:e.objectProperty(t.tickCount),values:e.objectProperty(t.values),minstep:e.property(t.tickMinStep),formatType:e.property(t.formatType),formatSpecifier:e.property(t.format)}))),d=[];var p;return l.grid&&d.push(kN(t,n,r.grid,h,c)),l.ticks&&(p=u("tickSize"),d.push(function(t,e,n,r,i,o){var a=dT(t,e),s=t.orient,u=nN(s,-1,1);var c,l,f;var h={enter:c={opacity:oT},update:f={opacity:aT},exit:l={opacity:oT}};XS(h,{stroke:a("tickColor"),strokeCap:a("tickCap"),strokeDash:a("tickDash"),strokeDashOffset:a("tickDashOffset"),strokeOpacity:a("tickOpacity"),strokeWidth:a("tickWidth")});var d=GS(i);d.mult=u;var p={scale:t.scale,field:KF,band:o.band,extra:o.extra,offset:o.offset,round:a("tickRound")};return f.y=c.y=rN(s,oT,p),f.y2=c.y2=rN(s,d),l.x=rN(s,p),f.x=c.x=iN(s,oT,p),f.x2=c.x2=iN(s,d),l.y=iN(s,p),vT({type:cT,role:oD,key:KF,from:r,encode:h},n);}(t,n,r.ticks,h,p,c))),l.labels&&(p=l.ticks?p:0,d.push(CN(t,n,r.labels,h,p,c))),l.domain&&d.push(function(t,e,n,r){var i=dT(t,e),o=t.orient;var a,s;var u={enter:a={opacity:oT},update:s={opacity:aT},exit:{opacity:oT}};XS(u,{stroke:i("domainColor"),strokeCap:i("domainCap"),strokeDash:i("domainDash"),strokeDashOffset:i("domainDashOffset"),strokeWidth:i("domainWidth"),strokeOpacity:i("domainOpacity")});var c=wN(t,0),l=wN(t,1);return a.x=s.x=rN(o,c,oT),a.x2=s.x2=rN(o,l),a.y=s.y=iN(o,c,oT),a.y2=s.y2=iN(o,l),vT({type:cT,role:nD,from:r,encode:u},n);}(t,n,r.domain,f)),l.title&&d.push(AN(t,n,r.title,f)),GT(hT({role:eD,from:f,encode:YS(function(t,e){var n={enter:{},update:{}};return XS(n,{orient:t("orient"),offset:t("offset")||0,position:qD(e.position,0),titlePadding:t("titlePadding"),minExtent:t("minExtent"),maxExtent:t("maxExtent"),range:{signal:"abs(span(range(\"".concat(e.scale,"\")))")},translate:t("translate"),format:e.format,formatType:e.formatType}),n;}(u,t),i,iT),marks:d,aria:u("aria"),description:u("description"),zindex:u("zindex"),name:o,interactive:a,style:s}),e);}function _N(t,e,n){var r=Object(Z.i)(t.signals),i=Object(Z.i)(t.scales);return n||r.forEach(function(t){return FD(t,e);}),Object(Z.i)(t.projections).forEach(function(t){return function(t,e){var n=e.config.projection||{},r={};for(var _n93 in t){"name"!==_n93&&(r[_n93]=BF(t[_n93],_n93,e));}for(var _t109 in n){null==r[_t109]&&(r[_t109]=BF(n[_t109],_t109,e));}e.addProjection(t.name,r);}(t,e);}),i.forEach(function(t){return function(t,e){var n=t.type||"linear";Eu(n)||Object(Z.o)("Unrecognized scale type: "+Object(Z.Ba)(n)),e.addScale(t.name,{type:n,domain:void 0});}(t,e);}),Object(Z.i)(t.data).forEach(function(t){return QT(t,e);}),i.forEach(function(t){return TF(t,e);}),(n||r).forEach(function(t){return function(t,e){var n=e.getSignal(t.name);var r=t.update;t.init&&(r?Object(Z.o)("Signals can not include both init and update expressions."):(r=t.init,n.initonly=!0)),r&&(r=v_(r,e),n.update=r.$expr,n.params=r.$params),t.on&&t.on.forEach(function(t){return ZD(t,e,n.id);});}(t,e);}),Object(Z.i)(t.axes).forEach(function(t){return ON(t,e);}),Object(Z.i)(t.marks).forEach(function(t){return GT(t,e);}),Object(Z.i)(t.legends).forEach(function(t){return KT(t,e);}),t.title&&JT(t.title,e),e.parseLambdas(),e;}var SN=function SN(t){return YS({enter:{x:{value:0},y:{value:0}},update:{width:{signal:"width"},height:{signal:"height"}}},t);};function DN(t,e){var n=e.config,r=RD(e.root=e.add(ID())),i=function(t,e){var n=function n(_n94){return qD(t[_n94],e[_n94]);},r=[FN("background",n("background")),FN("autosize",function(t){return Object(Z.H)(t)?t:{type:t||"pad"};}(n("autosize"))),FN("padding",function(t){return Object(Z.H)(t)?t.signal?t:{top:$S(t.top),bottom:$S(t.bottom),left:$S(t.left),right:$S(t.right)}:HS($S(t));}(n("padding"))),FN("width",n("width")||0),FN("height",n("height")||0)],i=r.reduce(function(t,e){return t[e.name]=e,t;},{}),o={};return Object(Z.i)(t.signals).forEach(function(t){Object(Z.w)(i,t.name)?t=Object(Z.p)(i[t.name],t):r.push(t),o[t.name]=t;}),Object(Z.i)(e.signals).forEach(function(t){Object(Z.w)(o,t.name)||Object(Z.w)(i,t.name)||r.push(t);}),r;}(t,n);i.forEach(function(t){return FD(t,e);}),e.description=t.description||n.description,e.eventConfig=n.events,e.legends=e.objectProperty(n.legend&&n.legend.layout),e.locale=n.locale;var o=e.add(iF()),a=e.add(sF(ED(SN(t.encode),sT,ZS,t.style,e,{pulse:RD(o)}))),s=e.add(_F({layout:e.objectProperty(t.layout),legends:e.legends,autosize:e.signalRef("autosize"),mark:r,pulse:RD(a)}));e.operators.pop(),e.pushState(RD(a),RD(s),null),_N(t,e,i),e.operators.push(s);var u=e.add(rF({mark:r,pulse:RD(s)}));return u=e.add(EF({pulse:RD(u)})),u=e.add(AF({pulse:RD(u)})),e.addData("root",new WT(e,o,o,u)),e;}function FN(t,e){return e&&e.signal?{name:t,update:e.signal}:{name:t,value:e};}function TN(t,e){this.config=t||{},this.options=e||{},this.bindings=[],this.field={},this.signals={},this.lambdas={},this.scales={},this.events={},this.data={},this.streams=[],this.updates=[],this.operators=[],this.eventConfig=null,this.locale=null,this._id=0,this._subid=0,this._nextsub=[0],this._parent=[],this._encode=[],this._lookup=[],this._markpath=[];}function NN(t){this.config=t.config,this.options=t.options,this.legends=t.legends,this.field=Object.create(t.field),this.signals=Object.create(t.signals),this.lambdas=Object.create(t.lambdas),this.scales=Object.create(t.scales),this.events=Object.create(t.events),this.data=Object.create(t.data),this.streams=[],this.updates=[],this.operators=[],this._id=0,this._subid=++t._nextsub[0],this._nextsub=t._nextsub,this._parent=t._parent.slice(),this._encode=t._encode.slice(),this._lookup=t._lookup.slice(),this._markpath=t._markpath;}function IN(t){return (Object(Z.B)(t)?function(t){var e=t.length;var n="[";for(var _r94=0;_r94<e;++_r94){var _e119=t[_r94];n+=(_r94>0?",":"")+(Object(Z.H)(_e119)?_e119.signal||IN(_e119):Object(Z.Ba)(_e119));}return n+"]";}:function(t){var e,n,r="{",i=0;for(e in t){n=t[e],r+=(++i>1?",":"")+Object(Z.Ba)(e)+":"+(Object(Z.H)(n)?n.signal||IN(n):Object(Z.Ba)(n));}return r+"}";})(t);}function RN(t,e,n){return Object(Z.H)(t)||Object(Z.o)("Input Vega specification must be an object."),DN(t,new TN(e=Object(Z.P)({description:"Vega visualization",padding:0,autosize:"pad",background:null,events:{defaults:{allow:["wheel"]}},group:null,mark:null,arc:{fill:"#4c78a8"},area:{fill:"#4c78a8"},image:null,line:{stroke:"#4c78a8",strokeWidth:2},path:{stroke:"#4c78a8"},rect:{fill:"#4c78a8"},rule:{stroke:"#000"},shape:{stroke:"#4c78a8"},symbol:{fill:"#4c78a8",size:64},text:{fill:"#000",font:"sans-serif",fontSize:11},trail:{fill:"#4c78a8",size:2},style:{"guide-label":{fill:"#000",font:"sans-serif",fontSize:10},"guide-title":{fill:"#000",font:"sans-serif",fontSize:11,fontWeight:"bold"},"group-title":{fill:"#000",font:"sans-serif",fontSize:13,fontWeight:"bold"},"group-subtitle":{fill:"#000",font:"sans-serif",fontSize:12},point:{size:30,strokeWidth:2,shape:"circle"},circle:{size:30,strokeWidth:2},square:{size:30,strokeWidth:2,shape:"square"},cell:{fill:"transparent",stroke:"#ddd"}},title:{orient:"top",anchor:"middle",offset:4,subtitlePadding:3},axis:{minExtent:0,maxExtent:200,bandPosition:.5,domain:!0,domainWidth:1,domainColor:"#888",grid:!1,gridWidth:1,gridColor:"#ddd",labels:!0,labelAngle:0,labelLimit:180,labelOffset:0,labelPadding:2,ticks:!0,tickColor:"#888",tickOffset:0,tickRound:!0,tickSize:5,tickWidth:1,titlePadding:4},axisBand:{tickOffset:-.5},projection:{type:"mercator"},legend:{orient:"right",padding:0,gridAlign:"each",columnPadding:10,rowPadding:2,symbolDirection:"vertical",gradientDirection:"vertical",gradientLength:200,gradientThickness:16,gradientStrokeColor:"#ddd",gradientStrokeWidth:0,gradientLabelOffset:2,labelAlign:"left",labelBaseline:"middle",labelLimit:160,labelOffset:4,labelOverlap:!0,symbolLimit:30,symbolType:"circle",symbolSize:100,symbolOffset:0,symbolStrokeWidth:1.5,symbolBaseFillColor:"transparent",symbolBaseStrokeColor:"#888",titleLimit:180,titleOrient:"top",titlePadding:5,layout:{offset:18,direction:"horizontal",left:{direction:"vertical"},right:{direction:"vertical"}}},range:{category:{scheme:"tableau10"},ordinal:{scheme:"blues"},heatmap:{scheme:"yellowgreenblue"},ramp:{scheme:"blues"},diverging:{scheme:"blueorange",extent:[1,0]},symbol:["circle","square","triangle-up","cross","diamond","triangle-right","triangle-down","triangle-left"]}},e,t.config),n)).toRuntime();}TN.prototype=NN.prototype={parse:function parse(t){return _N(t,this);},fork:function fork(){return new NN(this);},isSubscope:function isSubscope(){return this._subid>0;},toRuntime:function toRuntime(){return this.finish(),{description:this.description,operators:this.operators,streams:this.streams,updates:this.updates,bindings:this.bindings,eventConfig:this.eventConfig,locale:this.locale};},id:function id(){return (this._subid?this._subid+":":0)+this._id++;},add:function add(t){return this.operators.push(t),t.id=this.id(),t.refs&&(t.refs.forEach(function(e){e.$ref=t.id;}),t.refs=null),t;},proxy:function proxy(t){var e=t instanceof TD?RD(t):t;return this.add(wF({value:e}));},addStream:function addStream(t){return this.streams.push(t),t.id=this.id(),t;},addUpdate:function addUpdate(t){return this.updates.push(t),t;},finish:function finish(){var t,e;for(t in this.root&&(this.root.root=!0),this.signals){this.signals[t].signal=t;}for(t in this.scales){this.scales[t].scale=t;}function n(t,e,n){var r;t&&((r=t.data||(t.data={}))[e]||(r[e]=[])).push(n);}for(t in this.data){n((e=this.data[t]).input,t,"input"),n(e.output,t,"output"),n(e.values,t,"values");for(var _r95 in e.index){n(e.index[_r95],t,"index:"+_r95);}}return this;},pushState:function pushState(t,e,n){this._encode.push(RD(this.add(AF({pulse:t})))),this._parent.push(e),this._lookup.push(n?RD(this.proxy(n)):null),this._markpath.push(-1);},popState:function popState(){this._encode.pop(),this._parent.pop(),this._lookup.pop(),this._markpath.pop();},parent:function parent(){return Object(Z.W)(this._parent);},encode:function encode(){return Object(Z.W)(this._encode);},lookup:function lookup(){return Object(Z.W)(this._lookup);},markpath:function markpath(){var t=this._markpath;return ++t[t.length-1];},fieldRef:function fieldRef(t,e){if(Object(Z.J)(t))return MD(t,e);t.signal||Object(Z.o)("Unsupported field reference: "+Object(Z.Ba)(t));var n=t.signal;var r=this.field[n];if(!r){var _t110={name:this.signalRef(n)};e&&(_t110.as=e),this.field[n]=r=RD(this.add(lF(_t110)));}return r;},compareRef:function compareRef(t){var _this24=this;var e=!1;var n=function n(t){return WD(t)?(e=!0,_this24.signalRef(t.signal)):function(t){return t&&t.expr;}(t)?(e=!0,_this24.exprRef(t.expr)):t;},r=Object(Z.i)(t.field).map(n),i=Object(Z.i)(t.order).map(n);return e?RD(this.add(oF({fields:r,orders:i}))):BD(r,i);},keyRef:function keyRef(t,e){var n=!1;var r=this.signals;return t=Object(Z.i)(t).map(function(t){return WD(t)?(n=!0,RD(r[t.signal])):t;}),n?RD(this.add(fF({fields:t,flat:e}))):function(t,e){var n={$key:t};return e&&(n.$flat=!0),n;}(t,e);},sortRef:function sortRef(t){if(!t)return t;var e=LD(t.op,t.field),n=t.order||"ascending";return n.signal?RD(this.add(oF({fields:e,orders:this.signalRef(n.signal)}))):BD(e,n);},event:function event(t,e){var n=t+":"+e;if(!this.events[n]){var _r96=this.id();this.streams.push({id:_r96,source:t,type:e}),this.events[n]=_r96;}return this.events[n];},hasOwnSignal:function hasOwnSignal(t){return Object(Z.w)(this.signals,t);},addSignal:function addSignal(t,e){this.hasOwnSignal(t)&&Object(Z.o)("Duplicate signal name: "+Object(Z.Ba)(t));var n=e instanceof TD?e:this.add(ID(e));return this.signals[t]=n;},getSignal:function getSignal(t){return this.signals[t]||Object(Z.o)("Unrecognized signal name: "+Object(Z.Ba)(t)),this.signals[t];},signalRef:function signalRef(t){return this.signals[t]?RD(this.signals[t]):(Object(Z.w)(this.lambdas,t)||(this.lambdas[t]=this.add(ID(null))),RD(this.lambdas[t]));},parseLambdas:function parseLambdas(){var t=Object.keys(this.lambdas);for(var _e120=0,_n95=t.length;_e120<_n95;++_e120){var _n96=t[_e120],_r97=v_(_n96,this),_i69=this.lambdas[_n96];_i69.params=_r97.$params,_i69.update=_r97.$expr;}},property:function property(t){return t&&t.signal?this.signalRef(t.signal):t;},objectProperty:function objectProperty(t){return t&&Object(Z.H)(t)?this.signalRef(t.signal||IN(t)):t;},exprRef:function exprRef(t,e){var n={expr:v_(t,this)};return e&&(n.expr.$name=e),RD(this.add(uF(n)));},addBinding:function addBinding(t,e){this.bindings||Object(Z.o)("Nested signals do not support binding: "+Object(Z.Ba)(t)),this.bindings.push(Object(Z.p)({signal:t},e));},addScaleProj:function addScaleProj(t,e){Object(Z.w)(this.scales,t)&&Object(Z.o)("Duplicate scale or projection name: "+Object(Z.Ba)(t)),this.scales[t]=this.add(e);},addScale:function addScale(t,e){this.addScaleProj(t,CF(e));},addProjection:function addProjection(t,e){this.addScaleProj(t,xF(e));},getScale:function getScale(t){return this.scales[t]||Object(Z.o)("Unrecognized scale name: "+Object(Z.Ba)(t)),this.scales[t];},scaleRef:function scaleRef(t){return RD(this.getScale(t));},scaleType:function scaleType(t){return this.getScale(t).params.type;},projectionRef:function projectionRef(t){return this.scaleRef(t);},projectionType:function projectionType(t){return this.scaleType(t);},addData:function addData(t,e){return Object(Z.w)(this.data,t)&&Object(Z.o)("Duplicate data set name: "+Object(Z.Ba)(t)),this.data[t]=e;},getData:function getData(t){return this.data[t]||Object(Z.o)("Undefined data set name: "+Object(Z.Ba)(t)),this.data[t];},addDataPipeline:function addDataPipeline(t,e){return Object(Z.w)(this.data,t)&&Object(Z.o)("Duplicate data set name: "+Object(Z.Ba)(t)),this.addData(t,WT.fromEntries(this,e));}};var MN="RawCode",jN="Literal",BN="Property",PN="Identifier",LN="ArrayExpression",zN="BinaryExpression",UN="CallExpression",WN="ConditionalExpression",VN="LogicalExpression",qN="MemberExpression",$N="ObjectExpression",HN="UnaryExpression";function GN(t){this.type=t;}var KN,XN,YN,JN,QN;GN.prototype.visit=function(t){var e,n,r;if(t(this))return 1;for(n=0,r=(e=function(t){switch(t.type){case LN:return t.elements;case zN:case VN:return [t.left,t.right];case UN:return [t.callee].concat(t.arguments);case WN:return [t.test,t.consequent,t.alternate];case qN:return [t.object,t.property];case $N:return t.properties;case BN:return [t.key,t.value];case HN:return [t.argument];case PN:case jN:case MN:default:return [];}}(this)).length;n<r;++n){if(e[n].visit(t))return 1;}};var ZN=1,tI=2,eI=3,nI=4,rI=5,iI=6,oI=7,aI=8;(KN={})[ZN]="Boolean",KN[tI]="<end>",KN[eI]="Identifier",KN[nI]="Keyword",KN[rI]="Null",KN[iI]="Numeric",KN[oI]="Punctuator",KN[aI]="String",KN[9]="RegularExpression";var sI="ArrayExpression",uI="BinaryExpression",cI="CallExpression",lI="ConditionalExpression",fI="Identifier",hI="Literal",dI="LogicalExpression",pI="MemberExpression",mI="ObjectExpression",gI="Property",vI="UnaryExpression",yI="Unexpected token %0",bI="Unexpected number",xI="Unexpected string",wI="Unexpected identifier",kI="Unexpected reserved word",EI="Unexpected end of input",CI="Invalid regular expression",AI="Invalid regular expression: missing /",OI="Octal literals are not allowed in strict mode.",_I="Duplicate data property in object literal not allowed in strict mode",SI="ILLEGAL",DI="Disabled.",FI=new RegExp("[\\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\\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-\\u08B2\\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\\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-\\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-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\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-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\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-\\uAB5F\\uAB64\\uAB65\\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\\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]"),TI=new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C81-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\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\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\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\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\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-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\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-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]");function NI(t,e){if(!t)throw new Error("ASSERT: "+e);}function II(t){return t>=48&&t<=57;}function RI(t){return "0123456789abcdefABCDEF".indexOf(t)>=0;}function MI(t){return "01234567".indexOf(t)>=0;}function jI(t){return 32===t||9===t||11===t||12===t||160===t||t>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(t)>=0;}function BI(t){return 10===t||13===t||8232===t||8233===t;}function PI(t){return 36===t||95===t||t>=65&&t<=90||t>=97&&t<=122||92===t||t>=128&&FI.test(String.fromCharCode(t));}function LI(t){return 36===t||95===t||t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||92===t||t>=128&&TI.test(String.fromCharCode(t));}var zI={if:1,in:1,do:1,var:1,for:1,new:1,try:1,let:1,this:1,else:1,case:1,void:1,with:1,enum:1,while:1,break:1,catch:1,throw:1,const:1,yield:1,class:1,super:1,return:1,typeof:1,delete:1,switch:1,export:1,import:1,public:1,static:1,default:1,finally:1,extends:1,package:1,private:1,function:1,continue:1,debugger:1,interface:1,protected:1,instanceof:1,implements:1};function UI(){for(;YN<JN;){var _t111=XN.charCodeAt(YN);if(!jI(_t111)&&!BI(_t111))break;++YN;}}function WI(t){var e,n,r,i=0;for(n="u"===t?4:2,e=0;e<n;++e){YN<JN&&RI(XN[YN])?(r=XN[YN++],i=16*i+"0123456789abcdef".indexOf(r.toLowerCase())):iR({},yI,SI);}return String.fromCharCode(i);}function VI(){var t,e,n,r;for(e=0,"}"===(t=XN[YN])&&iR({},yI,SI);YN<JN&&RI(t=XN[YN++]);){e=16*e+"0123456789abcdef".indexOf(t.toLowerCase());}return (e>1114111||"}"!==t)&&iR({},yI,SI),e<=65535?String.fromCharCode(e):(n=55296+(e-65536>>10),r=56320+(e-65536&1023),String.fromCharCode(n,r));}function qI(){var t,e;for(t=XN.charCodeAt(YN++),e=String.fromCharCode(t),92===t&&(117!==XN.charCodeAt(YN)&&iR({},yI,SI),++YN,(t=WI("u"))&&"\\"!==t&&PI(t.charCodeAt(0))||iR({},yI,SI),e=t);YN<JN&&LI(t=XN.charCodeAt(YN));){++YN,e+=String.fromCharCode(t),92===t&&(e=e.substr(0,e.length-1),117!==XN.charCodeAt(YN)&&iR({},yI,SI),++YN,(t=WI("u"))&&"\\"!==t&&LI(t.charCodeAt(0))||iR({},yI,SI),e+=t);}return e;}function $I(){var t,e;return t=YN,{type:1===(e=92===XN.charCodeAt(YN)?qI():function(){var t,e;for(t=YN++;YN<JN;){if(92===(e=XN.charCodeAt(YN)))return YN=t,qI();if(!LI(e))break;++YN;}return XN.slice(t,YN);}()).length?eI:zI.hasOwnProperty(e)?nI:"null"===e?rI:"true"===e||"false"===e?ZN:eI,value:e,start:t,end:YN};}function HI(){var t,e,n,r,i=YN,o=XN.charCodeAt(YN),a=XN[YN];switch(o){case 46:case 40:case 41:case 59:case 44:case 123:case 125:case 91:case 93:case 58:case 63:case 126:return ++YN,{type:oI,value:String.fromCharCode(o),start:i,end:YN};default:if(61===(t=XN.charCodeAt(YN+1)))switch(o){case 43:case 45:case 47:case 60:case 62:case 94:case 124:case 37:case 38:case 42:return YN+=2,{type:oI,value:String.fromCharCode(o)+String.fromCharCode(t),start:i,end:YN};case 33:case 61:return YN+=2,61===XN.charCodeAt(YN)&&++YN,{type:oI,value:XN.slice(i,YN),start:i,end:YN};}}return ">>>="===(r=XN.substr(YN,4))?{type:oI,value:r,start:i,end:YN+=4}:">>>"===(n=r.substr(0,3))||"<<="===n||">>="===n?{type:oI,value:n,start:i,end:YN+=3}:a===(e=n.substr(0,2))[1]&&"+-<>&|".indexOf(a)>=0||"=>"===e?{type:oI,value:e,start:i,end:YN+=2}:("//"===e&&iR({},yI,SI),"<>=!+-*%&|^/".indexOf(a)>=0?{type:oI,value:a,start:i,end:++YN}:void iR({},yI,SI));}function GI(){var t,e,n;if(NI(II((n=XN[YN]).charCodeAt(0))||"."===n,"Numeric literal must start with a decimal digit or a decimal point"),e=YN,t="","."!==n){if(t=XN[YN++],n=XN[YN],"0"===t){if("x"===n||"X"===n)return ++YN,function(t){var e="";for(;YN<JN&&RI(XN[YN]);){e+=XN[YN++];}return 0===e.length&&iR({},yI,SI),PI(XN.charCodeAt(YN))&&iR({},yI,SI),{type:iI,value:parseInt("0x"+e,16),start:t,end:YN};}(e);if(MI(n))return function(t){var e="0"+XN[YN++];for(;YN<JN&&MI(XN[YN]);){e+=XN[YN++];}return (PI(XN.charCodeAt(YN))||II(XN.charCodeAt(YN)))&&iR({},yI,SI),{type:iI,value:parseInt(e,8),octal:!0,start:t,end:YN};}(e);n&&II(n.charCodeAt(0))&&iR({},yI,SI);}for(;II(XN.charCodeAt(YN));){t+=XN[YN++];}n=XN[YN];}if("."===n){for(t+=XN[YN++];II(XN.charCodeAt(YN));){t+=XN[YN++];}n=XN[YN];}if("e"===n||"E"===n)if(t+=XN[YN++],"+"!==(n=XN[YN])&&"-"!==n||(t+=XN[YN++]),II(XN.charCodeAt(YN)))for(;II(XN.charCodeAt(YN));){t+=XN[YN++];}else iR({},yI,SI);return PI(XN.charCodeAt(YN))&&iR({},yI,SI),{type:iI,value:parseFloat(t),start:e,end:YN};}function KI(){var t,e,n,r;return QN=null,UI(),t=YN,e=function(){var t,e,n,r;for(NI("/"===(t=XN[YN]),"Regular expression literal must start with a slash"),e=XN[YN++],n=!1,r=!1;YN<JN;){if(e+=t=XN[YN++],"\\"===t)BI((t=XN[YN++]).charCodeAt(0))&&iR({},AI),e+=t;else if(BI(t.charCodeAt(0)))iR({},AI);else if(n)"]"===t&&(n=!1);else {if("/"===t){r=!0;break;}"["===t&&(n=!0);}}return r||iR({},AI),{value:e.substr(1,e.length-2),literal:e};}(),n=function(){var t,e,n;for(e="",n="";YN<JN&&LI((t=XN[YN]).charCodeAt(0));){++YN,"\\"===t&&YN<JN?iR({},yI,SI):(n+=t,e+=t);}return n.search(/[^gimuy]/g)>=0&&iR({},CI,n),{value:n,literal:e};}(),r=function(t,e){var n=t;e.indexOf("u")>=0&&(n=n.replace(/\\u\{([0-9a-fA-F]+)\}/g,function(t,e){if(parseInt(e,16)<=1114111)return "x";iR({},CI);}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"x"));try{new RegExp(n);}catch(t){iR({},CI);}try{return new RegExp(t,e);}catch(t){return null;}}(e.value,n.value),{literal:e.literal+n.literal,value:r,regex:{pattern:e.value,flags:n.value},start:t,end:YN};}function XI(){if(UI(),YN>=JN)return {type:tI,start:YN,end:YN};var t=XN.charCodeAt(YN);return PI(t)?$I():40===t||41===t||59===t?HI():39===t||34===t?function(){var t,e,n,r,i="",o=!1;for(NI("'"===(t=XN[YN])||'"'===t,"String literal must starts with a quote"),e=YN,++YN;YN<JN;){if((n=XN[YN++])===t){t="";break;}if("\\"===n){if((n=XN[YN++])&&BI(n.charCodeAt(0)))"\r"===n&&"\n"===XN[YN]&&++YN;else switch(n){case"u":case"x":"{"===XN[YN]?(++YN,i+=VI()):i+=WI(n);break;case"n":i+="\n";break;case"r":i+="\r";break;case"t":i+="\t";break;case"b":i+="\b";break;case"f":i+="\f";break;case"v":i+="\v";break;default:MI(n)?(0!==(r="01234567".indexOf(n))&&(o=!0),YN<JN&&MI(XN[YN])&&(o=!0,r=8*r+"01234567".indexOf(XN[YN++]),"0123".indexOf(n)>=0&&YN<JN&&MI(XN[YN])&&(r=8*r+"01234567".indexOf(XN[YN++]))),i+=String.fromCharCode(r)):i+=n;}}else {if(BI(n.charCodeAt(0)))break;i+=n;}}return ""!==t&&iR({},yI,SI),{type:aI,value:i,octal:o,start:e,end:YN};}():46===t?II(XN.charCodeAt(YN+1))?GI():HI():II(t)?GI():HI();}function YI(){var t=QN;return YN=t.end,QN=XI(),YN=t.end,t;}function JI(){var t=YN;QN=XI(),YN=t;}function QI(t,e,n){var r=new GN("||"===t||"&&"===t?dI:uI);return r.operator=t,r.left=e,r.right=n,r;}function ZI(t,e){var n=new GN(cI);return n.callee=t,n.arguments=e,n;}function tR(t){var e=new GN(fI);return e.name=t,e;}function eR(t){var e=new GN(hI);return e.value=t.value,e.raw=XN.slice(t.start,t.end),t.regex&&("//"===e.raw&&(e.raw="/(?:)/"),e.regex=t.regex),e;}function nR(t,e,n){var r=new GN(pI);return r.computed="["===t,r.object=e,r.property=n,r.computed||(n.member=!0),r;}function rR(t,e,n){var r=new GN(gI);return r.key=e,r.value=n,r.kind=t,r;}function iR(t,e){var n,r=Array.prototype.slice.call(arguments,2),i=e.replace(/%(\d)/g,function(t,e){return NI(e<r.length,"Message reference must be in range"),r[e];});throw (n=new Error(i)).index=YN,n.description=i,n;}function oR(t){t.type===tI&&iR(t,EI),t.type===iI&&iR(t,bI),t.type===aI&&iR(t,xI),t.type===eI&&iR(t,wI),t.type===nI&&iR(t,kI),iR(t,yI,t.value);}function aR(t){var e=YI();e.type===oI&&e.value===t||oR(e);}function sR(t){return QN.type===oI&&QN.value===t;}function uR(t){return QN.type===nI&&QN.value===t;}function cR(){var t=[];for(YN=QN.start,aR("[");!sR("]");){sR(",")?(YI(),t.push(null)):(t.push(wR()),sR("]")||aR(","));}return YI(),function(t){var e=new GN(sI);return e.elements=t,e;}(t);}function lR(){YN=QN.start;var t=YI();return t.type===aI||t.type===iI?(t.octal&&iR(t,OI),eR(t)):tR(t.value);}function fR(){var t,e,n;return YN=QN.start,(t=QN).type===eI?(n=lR(),aR(":"),rR("init",n,wR())):t.type!==tI&&t.type!==oI?(e=lR(),aR(":"),rR("init",e,wR())):void oR(t);}function hR(){var t,e,n=[],r={},i=String;for(YN=QN.start,aR("{");!sR("}");){e="$"+((t=fR()).key.type===fI?t.key.name:i(t.key.value)),Object.prototype.hasOwnProperty.call(r,e)?iR({},_I):r[e]=!0,n.push(t),sR("}")||aR(",");}return aR("}"),function(t){var e=new GN(mI);return e.properties=t,e;}(n);}var dR={if:1};function pR(){var t,e,n;if(sR("("))return function(){aR("(");var t=kR();return aR(")"),t;}();if(sR("["))return cR();if(sR("{"))return hR();if(t=QN.type,YN=QN.start,t===eI||dR[QN.value])n=tR(YI().value);else if(t===aI||t===iI)QN.octal&&iR(QN,OI),n=eR(YI());else {if(t===nI)throw new Error(DI);t===ZN?((e=YI()).value="true"===e.value,n=eR(e)):t===rI?((e=YI()).value=null,n=eR(e)):sR("/")||sR("/=")?(n=eR(KI()),JI()):oR(YI());}return n;}function mR(){var t=[];if(aR("("),!sR(")"))for(;YN<JN&&(t.push(wR()),!sR(")"));){aR(",");}return aR(")"),t;}function gR(){YN=QN.start;var t=YI();return function(t){return t.type===eI||t.type===nI||t.type===ZN||t.type===rI;}(t)||oR(t),tR(t.value);}function vR(){aR("[");var t=kR();return aR("]"),t;}function yR(){var t=function(){var t;for(t=pR();;){if(sR("."))aR("."),t=nR(".",t,gR());else if(sR("("))t=ZI(t,mR());else {if(!sR("["))break;t=nR("[",t,vR());}}return t;}();if(QN.type===oI&&(sR("++")||sR("--")))throw new Error(DI);return t;}function bR(){var t,e;if(QN.type!==oI&&QN.type!==nI)e=yR();else {if(sR("++")||sR("--"))throw new Error(DI);if(sR("+")||sR("-")||sR("~")||sR("!"))t=YI(),e=bR(),e=function(t,e){var n=new GN(vI);return n.operator=t,n.argument=e,n.prefix=!0,n;}(t.value,e);else {if(uR("delete")||uR("void")||uR("typeof"))throw new Error(DI);e=yR();}}return e;}function xR(t){var e=0;if(t.type!==oI&&t.type!==nI)return 0;switch(t.value){case"||":e=1;break;case"&&":e=2;break;case"|":e=3;break;case"^":e=4;break;case"&":e=5;break;case"==":case"!=":case"===":case"!==":e=6;break;case"<":case">":case"<=":case">=":case"instanceof":case"in":e=7;break;case"<<":case">>":case">>>":e=8;break;case"+":case"-":e=9;break;case"*":case"/":case"%":e=11;}return e;}function wR(){var t,e;return t=function(){var t,e,n,r,i,o,a,s,u,c;if(t=QN,u=bR(),0===(i=xR(r=QN)))return u;for(r.prec=i,YI(),e=[t,QN],o=[u,r,a=bR()];(i=xR(QN))>0;){for(;o.length>2&&i<=o[o.length-2].prec;){a=o.pop(),s=o.pop().value,u=o.pop(),e.pop(),n=QI(s,u,a),o.push(n);}(r=YI()).prec=i,o.push(r),e.push(QN),n=bR(),o.push(n);}for(n=o[c=o.length-1],e.pop();c>1;){e.pop(),n=QI(o[c-1].value,o[c-2],n),c-=2;}return n;}(),sR("?")&&(YI(),e=wR(),aR(":"),t=function(t,e,n){var r=new GN(lI);return r.test=t,r.consequent=e,r.alternate=n,r;}(t,e,wR())),t;}function kR(){var t=wR();if(sR(","))throw new Error(DI);return t;}function ER(t){YN=0,JN=(XN=t).length,QN=null,JI();var e=kR();if(QN.type!==tI)throw new Error("Unexpect token after expression.");return e;}var CR={NaN:"NaN",E:"Math.E",LN2:"Math.LN2",LN10:"Math.LN10",LOG2E:"Math.LOG2E",LOG10E:"Math.LOG10E",PI:"Math.PI",SQRT1_2:"Math.SQRT1_2",SQRT2:"Math.SQRT2",MIN_VALUE:"Number.MIN_VALUE",MAX_VALUE:"Number.MAX_VALUE"};function AR(t){function e(e,n,r){return function(i){return function(e,n,r,i){var o=t(n[0]);return r&&(o=r+"("+o+")",0===r.lastIndexOf("new ",0)&&(o="("+o+")")),o+"."+e+(i<0?"":0===i?"()":"("+n.slice(1).map(t).join(",")+")");}(e,i,n,r);};}var n="new Date";return {isNaN:"Number.isNaN",isFinite:"Number.isFinite",abs:"Math.abs",acos:"Math.acos",asin:"Math.asin",atan:"Math.atan",atan2:"Math.atan2",ceil:"Math.ceil",cos:"Math.cos",exp:"Math.exp",floor:"Math.floor",log:"Math.log",max:"Math.max",min:"Math.min",pow:"Math.pow",random:"Math.random",round:"Math.round",sin:"Math.sin",sqrt:"Math.sqrt",tan:"Math.tan",clamp:function clamp(e){e.length<3&&Object(Z.o)("Missing arguments to clamp function."),e.length>3&&Object(Z.o)("Too many arguments to clamp function.");var n=e.map(t);return "Math.max("+n[1]+", Math.min("+n[2]+","+n[0]+"))";},now:"Date.now",utc:"Date.UTC",datetime:n,date:e("getDate",n,0),day:e("getDay",n,0),year:e("getFullYear",n,0),month:e("getMonth",n,0),hours:e("getHours",n,0),minutes:e("getMinutes",n,0),seconds:e("getSeconds",n,0),milliseconds:e("getMilliseconds",n,0),time:e("getTime",n,0),timezoneoffset:e("getTimezoneOffset",n,0),utcdate:e("getUTCDate",n,0),utcday:e("getUTCDay",n,0),utcyear:e("getUTCFullYear",n,0),utcmonth:e("getUTCMonth",n,0),utchours:e("getUTCHours",n,0),utcminutes:e("getUTCMinutes",n,0),utcseconds:e("getUTCSeconds",n,0),utcmilliseconds:e("getUTCMilliseconds",n,0),length:e("length",null,-1),parseFloat:"parseFloat",parseInt:"parseInt",upper:e("toUpperCase","String",0),lower:e("toLowerCase","String",0),substring:e("substring","String"),split:e("split","String"),trim:e("trim","String",0),regexp:"RegExp",test:e("test","RegExp"),if:function _if(e){e.length<3&&Object(Z.o)("Missing arguments to if function."),e.length>3&&Object(Z.o)("Too many arguments to if function.");var n=e.map(t);return "("+n[0]+"?"+n[1]+":"+n[2]+")";}};}function OR(t){var e=(t=t||{}).allowed?Object(Z.Fa)(t.allowed):{},n=t.forbidden?Object(Z.Fa)(t.forbidden):{},r=t.constants||CR,i=(t.functions||AR)(f),o=t.globalvar,a=t.fieldvar,s=Object(Z.E)(o)?o:function(t){return "".concat(o,'["').concat(t,'"]');};var u={},c={},l=0;function f(t){if(Object(Z.J)(t))return t;var e=h[t.type];return null==e&&Object(Z.o)("Unsupported type: "+t.type),e(t);}var h={Literal:function Literal(t){return t.raw;},Identifier:function Identifier(t){var i=t.name;return l>0?i:Object(Z.w)(n,i)?Object(Z.o)("Illegal identifier: "+i):Object(Z.w)(r,i)?r[i]:Object(Z.w)(e,i)?i:(u[i]=1,s(i));},MemberExpression:function MemberExpression(t){var e=!t.computed,n=f(t.object);e&&(l+=1);var r=f(t.property);return n===a&&(c[function(t){var e=t&&t.length-1;return e&&('"'===t[0]&&'"'===t[e]||"'"===t[0]&&"'"===t[e])?t.slice(1,-1):t;}(r)]=1),e&&(l-=1),n+(e?"."+r:"["+r+"]");},CallExpression:function CallExpression(t){"Identifier"!==t.callee.type&&Object(Z.o)("Illegal callee type: "+t.callee.type);var e=t.callee.name,n=t.arguments,r=Object(Z.w)(i,e)&&i[e];return r||Object(Z.o)("Unrecognized function: "+e),Object(Z.E)(r)?r(n):r+"("+n.map(f).join(",")+")";},ArrayExpression:function ArrayExpression(t){return "["+t.elements.map(f).join(",")+"]";},BinaryExpression:function BinaryExpression(t){return "("+f(t.left)+" "+t.operator+" "+f(t.right)+")";},UnaryExpression:function UnaryExpression(t){return "("+t.operator+f(t.argument)+")";},ConditionalExpression:function ConditionalExpression(t){return "("+f(t.test)+"?"+f(t.consequent)+":"+f(t.alternate)+")";},LogicalExpression:function LogicalExpression(t){return "("+f(t.left)+t.operator+f(t.right)+")";},ObjectExpression:function ObjectExpression(t){return "{"+t.properties.map(f).join(",")+"}";},Property:function Property(t){l+=1;var e=f(t.key);return l-=1,e+":"+f(t.value);}};function d(t){var e={code:f(t),globals:Object.keys(u),fields:Object.keys(c)};return u={},c={},e;}return d.functions=i,d.constants=r,d;}var _R="view",SR="[",DR="]",FR="{",TR="}",NR=":",IR=",",RR="@",MR=">",jR=/[[\]{}]/,BR={"*":1,arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1};var PR,LR;function zR(t,e,n){return PR=e||_R,LR=n||BR,WR(t.trim()).map(VR);}function UR(t,e,n,r,i){var o=t.length;var a,s=0;for(;e<o;++e){if(a=t[e],!s&&a===n)return e;i&&i.indexOf(a)>=0?--s:r&&r.indexOf(a)>=0&&++s;}return e;}function WR(t){var e=[],n=t.length;var r=0,i=0;for(;i<n;){i=UR(t,i,IR,SR+FR,DR+TR),e.push(t.substring(r,i).trim()),r=++i;}if(0===e.length)throw "Empty event selector: "+t;return e;}function VR(t){return "["===t[0]?function(t){var e=t.length;var n,r=1;if((r=UR(t,r,DR,SR,DR))===e)throw "Empty between selector: "+t;if(2!==(n=WR(t.substring(1,r))).length)throw "Between selector must have two elements: "+t;if((t=t.slice(r+1).trim())[0]!==MR)throw "Expected '>' after between selector: "+t;n=n.map(VR);var i=VR(t.slice(1).trim());if(i.between)return {between:n,stream:i};i.between=n;return i;}(t):function(t){var e={source:PR},n=[];var r,i,o=[0,0],a=0,s=0,u=t.length,c=0;if(t[u-1]===TR){if(!((c=t.lastIndexOf(FR))>=0))throw "Unmatched right brace: "+t;try{o=function(t){var e=t.split(IR);if(!t.length||e.length>2)throw t;return e.map(function(e){var n=+e;if(n!=n)throw t;return n;});}(t.substring(c+1,u-1));}catch(e){throw "Invalid throttle specification: "+t;}t=t.slice(0,c).trim(),u=t.length,c=0;}if(!u)throw t;t[0]===RR&&(a=++c);(r=UR(t,c,NR))<u&&(n.push(t.substring(s,r).trim()),s=c=++r);if((c=UR(t,c,SR))===u)n.push(t.substring(s,u).trim());else if(n.push(t.substring(s,c).trim()),i=[],(s=++c)===u)throw "Unmatched left bracket: "+t;for(;c<u;){if((c=UR(t,c,DR))===u)throw "Unmatched left bracket: "+t;if(i.push(t.substring(s,c).trim()),c<u-1&&t[++c]!==SR)throw "Expected left bracket: "+t;s=++c;}if(!(u=n.length)||jR.test(n[u-1]))throw "Invalid event selector: "+t;u>1?(e.type=n[1],a?e.markname=n[0].slice(1):!function(t){return LR[t];}(n[0])?e.source=n[0]:e.marktype=n[0]):e.type=n[0];"!"===e.type.slice(-1)&&(e.consume=!0,e.type=e.type.slice(0,-1));null!=i&&(e.filter=i);o[0]&&(e.throttle=o[0]);o[1]&&(e.debounce=o[1]);return e;}(t);}var qR="5.20.0";Object(Z.p)(Ut,o,s,u,c,l,h,f,d,p,m,g);var $R=qR;var HR=n(245),GR=function GR(t,e,n){return t.fields=e||[],t.fname=n,t;};var KR=function KR(t){return 1===t.length?XR(t[0]):YR(t);};var XR=function XR(t){return function(e){return e[t];};},YR=function YR(t){var e=t.length;return function(n){for(var _r98=0;_r98<e;++_r98){n=n[t[_r98]];}return n;};};var JR=function JR(t){throw Error(t);},QR=function QR(t){var e,n,r,i=[],o=null,a=0,s=t.length,u="";function c(){i.push(u+t.substring(e,n)),u="",e=n+1;}for(t+="",e=n=0;n<s;++n){if("\\"===(r=t[n]))u+=t.substring(e,n),u+=t.substring(++n,++n),e=n;else if(r===o)c(),o=null,a=-1;else {if(o)continue;e===a&&'"'===r?(e=n+1,o=r):e===a&&"'"===r?(e=n+1,o=r):"."!==r||a?"["===r?(n>e&&c(),a=e=n+1):"]"===r&&(a||JR("Access path missing open bracket: "+t),a>0&&c(),a=0,e=n+1):n>e?c():e=n+1;}}return a&&JR("Access path missing closing bracket: "+t),o&&JR("Access path missing closing quote: "+t),n>e&&(n++,c()),i;},ZR=function ZR(t,e,n){var r=QR(t);return t=1===r.length?r[0]:t,GR((n&&n.get||KR)(r),[t],e||t);},tM=[],eM=(ZR("id"),GR(function(t){return t;},tM,"identity"));GR(function(){return 0;},tM,"zero"),GR(function(){return 1;},tM,"one"),GR(function(){return !0;},tM,"true"),GR(function(){return !1;},tM,"false");function nM(t,e,n){var r=[e].concat([].slice.call(n));console[t].apply(console,r);}var rM=Array.isArray,iM=function iM(t){return t===Object(t);};var oM=function oM(t){return "__proto__"!==t;};function aM(){for(var _len7=arguments.length,t=new Array(_len7),_key7=0;_key7<_len7;_key7++){t[_key7]=arguments[_key7];}return t.reduce(function(t,e){for(var n in e){if("signals"===n)t.signals=uM(t.signals,e.signals);else {var r="legend"===n?{layout:1}:"style"===n||null;sM(t,n,e[n],r);}}return t;},{});}function sM(t,e,n,r){var i,o;if(oM(e))if(iM(n)&&!rM(n))for(i in o=iM(t[e])?t[e]:t[e]={},n){r&&(!0===r||r[i])?sM(o,i,n[i]):oM(i)&&(o[i]=n[i]);}else t[e]=n;}function uM(t,e){if(null==t)return e;var n={},r=[];function i(t){n[t.name]||(n[t.name]=1,r.push(t));}return e.forEach(i),t.forEach(i),r;}var cM=function cM(t){return null!=t?rM(t)?t:[t]:[];},lM=function lM(t){return "function"==typeof t;};var fM=Object.prototype.hasOwnProperty;var hM=function hM(t,e){return fM.call(t,e);},dM=function dM(t){return "boolean"==typeof t;},pM=function pM(t){return "number"==typeof t;},mM=function mM(t){return "string"==typeof t;};function gM(t){return rM(t)?"["+t.map(gM)+"]":iM(t)||mM(t)?JSON.stringify(t).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):t;}var vM=function vM(t){for(var e={},n=0,r=t.length;n<r;++n){e[t[n]]=!0;}return e;};function yM(t,e){var n={};for(var r in t){Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);}if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++){e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);}}return n;}Array.prototype.flat||Object.defineProperty(Array.prototype,"flat",{configurable:!0,value:function t(){var e=isNaN(arguments[0])?1:Number(arguments[0]);return e?Array.prototype.reduce.call(this,function(n,r){return Array.isArray(r)?n.push.apply(n,t.call(r,e-1)):n.push(r),n;},[]):Array.prototype.slice.call(this);},writable:!0}),Array.prototype.flatMap||Object.defineProperty(Array.prototype,"flatMap",{configurable:!0,value:function value(t){return Array.prototype.map.apply(this,arguments).flat();},writable:!0});var bM=n(244),xM=n.n(bM),wM=n(243),kM=n.n(wM),EM=n(86),CM=n.n(EM);function AM(t){return !!t.or;}function OM(t){return !!t.and;}function _M(t){return !!t.not;}var SM=kM.a,DM=xM.a;function FM(t,e){var n={};var _iterator30=_createForOfIteratorHelper(e),_step30;try{for(_iterator30.s();!(_step30=_iterator30.n()).done;){var _r99=_step30.value;hM(t,_r99)&&(n[_r99]=t[_r99]);}}catch(err){_iterator30.e(err);}finally{_iterator30.f();}return n;}function TM(t,e){var n=Object.assign({},t);var _iterator31=_createForOfIteratorHelper(e),_step31;try{for(_iterator31.s();!(_step31=_iterator31.n()).done;){var _t112=_step31.value;delete n[_t112];}}catch(err){_iterator31.e(err);}finally{_iterator31.f();}return n;}Set.prototype.toJSON=function(){return "Set(".concat(_toConsumableArray(this).map(function(t){return CM()(t);}).join(","),")");};var NM=CM.a;function IM(t){if(pM(t))return t;var e=mM(t)?t:CM()(t);if(e.length<250)return e;var n=0;for(var _t113=0;_t113<e.length;_t113++){n=(n<<5)-n+e.charCodeAt(_t113),n&=n;}return n;}function RM(t){return !1===t||null===t;}function MM(t,e){return t.indexOf(e)>-1;}function jM(t,e){var n=0;var _iterator32=_createForOfIteratorHelper(t.entries()),_step32;try{for(_iterator32.s();!(_step32=_iterator32.n()).done;){var _step32$value=_slicedToArray(_step32.value,2),_r100=_step32$value[0],_i70=_step32$value[1];if(e(_i70,_r100,n++))return !0;}}catch(err){_iterator32.e(err);}finally{_iterator32.f();}return !1;}function BM(t,e){var n=0;var _iterator33=_createForOfIteratorHelper(t.entries()),_step33;try{for(_iterator33.s();!(_step33=_iterator33.n()).done;){var _step33$value=_slicedToArray(_step33.value,2),_r101=_step33$value[0],_i71=_step33$value[1];if(!e(_i71,_r101,n++))return !1;}}catch(err){_iterator33.e(err);}finally{_iterator33.f();}return !0;}function PM(t,e){var _iterator34=_createForOfIteratorHelper(qM(e)),_step34;try{for(_iterator34.s();!(_step34=_iterator34.n()).done;){var _n97=_step34.value;sM(t,_n97,e[_n97],!0);}}catch(err){_iterator34.e(err);}finally{_iterator34.f();}}function LM(t,e){var n=[],r={};var i;var _iterator35=_createForOfIteratorHelper(t),_step35;try{for(_iterator35.s();!(_step35=_iterator35.n()).done;){var _o42=_step35.value;(i=e(_o42))in r||(r[i]=1,n.push(_o42));}}catch(err){_iterator35.e(err);}finally{_iterator35.f();}return n;}function zM(t,e){var _iterator36=_createForOfIteratorHelper(t),_step36;try{for(_iterator36.s();!(_step36=_iterator36.n()).done;){var _n98=_step36.value;if(e.has(_n98))return !0;}}catch(err){_iterator36.e(err);}finally{_iterator36.f();}return !1;}function UM(t){var e=new Set();var _iterator37=_createForOfIteratorHelper(t),_step37;try{var _loop2=function _loop2(){var n=_step37.value;var t=QR(n).map(function(t,e){return 0===e?t:"[".concat(t,"]");}),r=t.map(function(e,n){return t.slice(0,n+1).join("");});var _iterator38=_createForOfIteratorHelper(r),_step38;try{for(_iterator38.s();!(_step38=_iterator38.n()).done;){var _t114=_step38.value;e.add(_t114);}}catch(err){_iterator38.e(err);}finally{_iterator38.f();}};for(_iterator37.s();!(_step37=_iterator37.n()).done;){_loop2();}}catch(err){_iterator37.e(err);}finally{_iterator37.f();}return e;}function WM(t,e){return void 0===t||void 0===e||zM(UM(t),UM(e));}function VM(t){return 0===qM(t).length;}var qM=Object.keys,$M=Object.values;function HM(t){var e=[];for(var _n99 in t){hM(t,_n99)&&e.push({key:_n99,value:t[_n99]});}return e;}function GM(t){return !0===t||!1===t;}function KM(t){var e=t.replace(/\W/g,"_");return (t.match(/^\d+/)?"_":"")+e;}function XM(t,e){return _M(t)?"!("+XM(t.not,e)+")":OM(t)?"("+t.and.map(function(t){return XM(t,e);}).join(") && (")+")":AM(t)?"("+t.or.map(function(t){return XM(t,e);}).join(") || (")+")":e(t);}function YM(t,e){if(0===e.length)return !0;var n=e.shift();return n in t&&YM(t[n],e)&&delete t[n],VM(t);}function JM(t){return t.charAt(0).toUpperCase()+t.substr(1);}function QM(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"datum";var n=QR(t),r=[];for(var _t115=1;_t115<=n.length;_t115++){var _i72="[".concat(n.slice(0,_t115).map(gM).join("]["),"]");r.push("".concat(e).concat(_i72));}return r.join(" && ");}function ZM(t){return t.replace(/(\[|\]|\.|'|")/g,"\\$1");}function tj(t){return "".concat(QR(t).map(ZM).join("\\."));}function ej(t,e,n){return t.replace(new RegExp(e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"g"),n);}function nj(t){return "".concat(QR(t).join("."));}function rj(t){return t?QR(t).length:0;}function ij(){for(var _len8=arguments.length,t=new Array(_len8),_key8=0;_key8<_len8;_key8++){t[_key8]=arguments[_key8];}for(var _i73=0,_t116=t;_i73<_t116.length;_i73++){var _e121=_t116[_i73];if(void 0!==_e121)return _e121;}}var oj=42;function aj(t){var e=++oj;return t?String(t)+e:e;}function sj(t){if(void 0!==t)return (t%360+360)%360;}function uj(t){return !!pM(t)||!isNaN(t)&&!isNaN(parseFloat(t));}var cj={domainColor:{part:"domain",vgProp:"stroke"},labelAlign:{part:"labels",vgProp:"align"},labelBaseline:{part:"labels",vgProp:"baseline"},labelColor:{part:"labels",vgProp:"fill"},labelFont:{part:"labels",vgProp:"font"},labelFontSize:{part:"labels",vgProp:"fontSize"},labelFontStyle:{part:"labels",vgProp:"fontStyle"},labelFontWeight:{part:"labels",vgProp:"fontWeight"},labelOpacity:{part:"labels",vgProp:"opacity"},labelOffset:null,labelPadding:null,gridColor:{part:"grid",vgProp:"stroke"},gridDash:{part:"grid",vgProp:"strokeDash"},gridDashOffset:{part:"grid",vgProp:"strokeDash"},gridOpacity:{part:"grid",vgProp:"opacity"},gridWidth:{part:"grid",vgProp:"strokeWidth"},tickColor:{part:"ticks",vgProp:"stroke"},tickDash:{part:"ticks",vgProp:"strokeDash"},tickDashOffset:{part:"ticks",vgProp:"strokeDash"},tickOpacity:{part:"ticks",vgProp:"opacity"},tickSize:null,tickWidth:{part:"ticks",vgProp:"strokeWidth"},titleColor:{part:"title",vgProp:"fill"},title:null};function lj(t){return t&&t.condition;}var fj=["domain","grid","labels","ticks","title"],hj={grid:"grid",gridCap:"grid",gridColor:"grid",gridDash:"grid",gridDashOffset:"grid",gridOpacity:"grid",gridScale:"grid",gridWidth:"grid",orient:"main",bandPosition:"both",aria:"main",description:"main",domain:"main",domainCap:"main",domainColor:"main",domainDash:"main",domainDashOffset:"main",domainOpacity:"main",domainWidth:"main",format:"main",formatType:"main",labelAlign:"main",labelAngle:"main",labelBaseline:"main",labelBound:"main",labelColor:"main",labelFlush:"main",labelFlushOffset:"main",labelFont:"main",labelFontSize:"main",labelFontStyle:"main",labelFontWeight:"main",labelLimit:"main",labelLineHeight:"main",labelOffset:"main",labelOpacity:"main",labelOverlap:"main",labelPadding:"main",labels:"main",labelSeparation:"main",maxExtent:"main",minExtent:"main",offset:"both",position:"main",tickCap:"main",tickColor:"main",tickDash:"main",tickDashOffset:"main",tickMinStep:"main",tickOffset:"both",tickOpacity:"main",tickRound:"both",ticks:"main",tickSize:"main",tickWidth:"both",title:"main",titleAlign:"main",titleAnchor:"main",titleAngle:"main",titleBaseline:"main",titleColor:"main",titleFont:"main",titleFontSize:"main",titleFontStyle:"main",titleFontWeight:"main",titleLimit:"main",titleLineHeight:"main",titleOpacity:"main",titlePadding:"main",titleX:"main",titleY:"main",encode:"both",scale:"both",tickBand:"both",tickCount:"both",tickExtra:"both",translate:"both",values:"both",zindex:"both"},dj={orient:1,aria:1,bandPosition:1,description:1,domain:1,domainCap:1,domainColor:1,domainDash:1,domainDashOffset:1,domainOpacity:1,domainWidth:1,format:1,formatType:1,grid:1,gridCap:1,gridColor:1,gridDash:1,gridDashOffset:1,gridOpacity:1,gridWidth:1,labelAlign:1,labelAngle:1,labelBaseline:1,labelBound:1,labelColor:1,labelFlush:1,labelFlushOffset:1,labelFont:1,labelFontSize:1,labelFontStyle:1,labelFontWeight:1,labelLimit:1,labelLineHeight:1,labelOffset:1,labelOpacity:1,labelOverlap:1,labelPadding:1,labels:1,labelSeparation:1,maxExtent:1,minExtent:1,offset:1,position:1,tickBand:1,tickCap:1,tickColor:1,tickCount:1,tickDash:1,tickDashOffset:1,tickExtra:1,tickMinStep:1,tickOffset:1,tickOpacity:1,tickRound:1,ticks:1,tickSize:1,tickWidth:1,title:1,titleAlign:1,titleAnchor:1,titleAngle:1,titleBaseline:1,titleColor:1,titleFont:1,titleFontSize:1,titleFontStyle:1,titleFontWeight:1,titleLimit:1,titleLineHeight:1,titleOpacity:1,titlePadding:1,titleX:1,titleY:1,translate:1,values:1,zindex:1},pj=Object.assign(Object.assign({},dj),{style:1,labelExpr:1,encoding:1});function mj(t){return !!pj[t];}var gj={arc:"arc",area:"area",bar:"bar",image:"image",line:"line",point:"point",rect:"rect",rule:"rule",text:"text",tick:"tick",trail:"trail",circle:"circle",square:"square",geoshape:"geoshape"},vj=gj.arc,yj=gj.area,bj=gj.bar,xj=gj.image,wj=gj.line,kj=gj.point,Ej=gj.rect,Cj=gj.rule,Aj=gj.text,Oj=gj.tick,_j=gj.trail,Sj=gj.circle,Dj=gj.square,Fj=gj.geoshape;function Tj(t){return MM(["line","area","trail"],t);}function Nj(t){return MM(["rect","bar","image","arc"],t);}var Ij=qM(gj);function Rj(t){return t.type;}vM(Ij);var Mj=["stroke","strokeWidth","strokeDash","strokeDashOffset","strokeOpacity","strokeJoin","strokeMiterLimit"].concat(["fill","fillOpacity"]),jj=qM({color:1,filled:1,invalid:1,order:1,radius2:1,theta2:1,timeUnitBand:1,timeUnitBandPosition:1}),Bj={horizontal:["cornerRadiusTopRight","cornerRadiusBottomRight"],vertical:["cornerRadiusTopLeft","cornerRadiusTopRight"]},Pj={binSpacing:1,continuousBandSize:5,timeUnitBandPosition:.5},Lj={binSpacing:0,continuousBandSize:5,timeUnitBandPosition:.5};function zj(t){return "mark"in t;}var Uj=/*#__PURE__*/function(){function Uj(t,e){_classCallCheck(this,Uj);this.name=t,this.run=e;}_createClass(Uj,[{key:"hasMatchingType",value:function hasMatchingType(t){return !!zj(t)&&function(t){return Rj(t)?t.type:t;}(t.mark)===this.name;}}]);return Uj;}();var Wj={argmax:1,argmin:1,average:1,count:1,distinct:1,product:1,max:1,mean:1,median:1,min:1,missing:1,q1:1,q3:1,ci0:1,ci1:1,stderr:1,stdev:1,stdevp:1,sum:1,valid:1,values:1,variance:1,variancep:1},Vj={count:1,min:1,max:1};function qj(t){return !!t&&!!t.argmin;}function $j(t){return !!t&&!!t.argmax;}function Hj(t){return mM(t)&&!!Wj[t];}var Gj=["count","valid","missing","distinct"];function Kj(t){return mM(t)&&MM(Gj,t);}var Xj=["count","sum","distinct","valid","missing"],Yj=vM(["mean","average","median","q1","q3","min","max"]),Jj="row",Qj="column",Zj="facet",tB="x",eB="y",nB="x2",rB="y2",iB="radius",oB="radius2",aB="theta",sB="theta2",uB="latitude",cB="longitude",lB="latitude2",fB="longitude2",hB="color",dB="fill",pB="stroke",mB="shape",gB="size",vB="angle",yB="opacity",bB="fillOpacity",xB="strokeOpacity",wB="strokeWidth",kB="strokeDash",EB="text",CB="order",AB="detail",OB="key",_B="tooltip",SB="href",DB="url",FB="description",TB={theta:1,theta2:1,radius:1,radius2:1};function NB(t){return t in TB;}var IB={longitude:1,longitude2:1,latitude:1,latitude2:1};var RB=qM(IB),MB=Object.assign(Object.assign(Object.assign(Object.assign({},{x:1,y:1,x2:1,y2:1}),TB),IB),{color:1,fill:1,stroke:1,opacity:1,fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeDash:1,size:1,angle:1,shape:1,order:1,text:1,detail:1,key:1,tooltip:1,href:1,url:1,description:1});function jB(t){return t===hB||t===dB||t===pB;}var BB={row:1,column:1,facet:1},PB=qM(BB),LB=Object.assign(Object.assign({},MB),BB),zB=qM(LB);LB.order;LB.detail;LB.tooltip;var qB=yM(LB,["order","detail","tooltip"]),KB=yM(qB,["row","column","facet"]);function XB(t){return !!KB[t];}function YB(t){return !!LB[t];}var JB=[nB,rB,lB,fB,sB,oB];function QB(t){return ZB(t)!==t;}function ZB(t){switch(t){case nB:return tB;case rB:return eB;case lB:return uB;case fB:return cB;case sB:return aB;case oB:return iB;}return t;}function tP(t){if(NB(t))switch(t){case aB:return "startAngle";case sB:return "endAngle";case iB:return "outerRadius";case oB:return "innerRadius";}return t;}function eP(t){switch(t){case tB:return nB;case eB:return rB;case uB:return lB;case cB:return fB;case aB:return sB;case iB:return oB;}}function nP(t){switch(t){case tB:case nB:return "width";case eB:case rB:return "height";}}MB.x;MB.y;MB.x2;MB.y2;MB.latitude;MB.longitude;MB.latitude2;MB.longitude2;MB.theta;MB.theta2;MB.radius;MB.radius2;var mP=(yM(MB,["x","y","x2","y2","latitude","longitude","latitude2","longitude2","theta","theta2","radius","radius2"])),gP=qM(mP),vP={x:1,y:1},yP=qM(vP);function bP(t){return t in vP;}var xP={theta:1,radius:1},wP=qM(xP);function kP(t){return "width"===t?tB:eB;}var TP=yM(mP,["text","tooltip","href","url","description","detail","key","order"]),NP=qM(TP);var IP=Object.assign(Object.assign(Object.assign({},vP),xP),TP),RP=qM(IP);function MP(t){return !!IP[t];}function jP(t,e){return function(t){switch(t){case hB:case dB:case pB:case FB:case AB:case OB:case _B:case SB:case CB:case yB:case bB:case xB:case wB:case Zj:case Jj:case Qj:return BP;case tB:case eB:case uB:case cB:return LP;case nB:case rB:case lB:case fB:return {area:"always",bar:"always",image:"always",rect:"always",rule:"always",circle:"binned",point:"binned",square:"binned",tick:"binned",line:"binned",trail:"binned"};case gB:return {point:"always",tick:"always",rule:"always",circle:"always",square:"always",bar:"always",text:"always",line:"always",trail:"always"};case kB:return {line:"always",point:"always",tick:"always",rule:"always",circle:"always",square:"always",bar:"always",geoshape:"always"};case mB:return {point:"always",geoshape:"always"};case EB:return {text:"always"};case vB:return {point:"always",square:"always",text:"always"};case DB:return {image:"always"};case aB:case iB:return {text:"always",arc:"always"};case sB:case oB:return {arc:"always"};}}(t)[e];}var BP={arc:"always",area:"always",bar:"always",circle:"always",geoshape:"always",image:"always",line:"always",rule:"always",point:"always",rect:"always",square:"always",trail:"always",text:"always",tick:"always"},LP=yM(BP,["geoshape"]);function zP(t){switch(t){case tB:case eB:case aB:case iB:case gB:case vB:case wB:case yB:case bB:case xB:case nB:case rB:case sB:case oB:return;case Zj:case Jj:case Qj:case mB:case kB:case EB:case _B:case SB:case DB:case FB:return "discrete";case hB:case dB:case pB:return "flexible";case uB:case cB:case lB:case fB:case AB:case OB:case CB:return;}}function UP(t){return dM(t)&&(t=zW(t,void 0)),"bin"+qM(t).map(function(e){return $P(t[e])?KM("_".concat(e,"_").concat(Object.entries(t[e]))):KM("_".concat(e,"_").concat(t[e]));}).join("");}function WP(t){return !0===t||qP(t)&&!t.binned;}function VP(t){return "binned"===t||qP(t)&&!0===t.binned;}function qP(t){return iM(t);}function $P(t){return null===t||void 0===t?void 0:t.selection;}function HP(t){switch(t){case Jj:case Qj:case gB:case hB:case dB:case pB:case wB:case yB:case bB:case xB:case mB:return 6;case kB:return 4;default:return 10;}}function GP(t){return "Invalid specification ".concat(JSON.stringify(t),". Make sure the specification includes at least one of the following properties: \"mark\", \"layer\", \"facet\", \"hconcat\", \"vconcat\", \"concat\", or \"repeat\".");}var KP='Autosize "fit" only works for single views and layered views.';function XP(t){return "".concat("width"==t?"Width":"Height"," \"container\" only works for single views and layered views.");}function YP(t){return "".concat("width"==t?"Width":"Height"," \"container\" only works well with autosize \"fit\" or \"fit-").concat("width"==t?"x":"y","\".");}function JP(t){return t?"Dropping \"fit-".concat(t,"\" because spec has discrete ").concat(nP(t),"."):'Dropping "fit" because spec has discrete size.';}function QP(t){return "Cannot project a selection on encoding channel \"".concat(t,"\", which has no field.");}function ZP(t,e){return "Cannot project a selection on encoding channel \"".concat(t,"\" as it uses an aggregate function (\"").concat(e,"\").");}function tL(t){return "The \"nearest\" transform is not supported for ".concat(t," marks.");}function eL(t){return "Selection not supported for ".concat(t," yet.");}function nL(t){return "Cannot find a selection named \"".concat(t,"\".");}var rL="Scale bindings are currently only supported for scales with unbinned, continuous domains.",iL="Legend bindings are only supported for selections over an individual field or encoding channel.";function oL(t){return "Cannot define and lookup the \"".concat(t,"\" selection in the same view. ")+"Try moving the lookup into a second, layered view?";}function aL(t){return "Unknown repeated value \"".concat(t,"\".");}function sL(t){return "The \"columns\" property cannot be used when \"".concat(t,"\" has nested row/column.");}var uL="Axes cannot be shared in concatenated or repeated views yet (https://github.com/vega/vega-lite/issues/2415).";function cL(t){return "Unrecognized parse \"".concat(t,"\".");}function lL(t,e,n){return "An ancestor parsed field \"".concat(t,"\" as ").concat(n," but a child wants to parse the field as ").concat(e,".");}function fL(t){return "Ignoring an invalid transform: ".concat(NM(t),".");}var hL='If "from.fields" is not specified, "as" has to be a string that specifies the key to be used for the data from the secondary source.';function dL(t){return "Config.customFormatTypes is not true, thus custom format type and format for channel ".concat(t," are dropped.");}function pL(t){return "Layer's shared ".concat(t.join(",")," channel ").concat(1===t.length?"is":"are"," overriden.");}function mL(t){var e=t.parentProjection,n=t.projection;return "Layer's shared projection ".concat(NM(e)," is overridden by a child projection ").concat(NM(n),".");}var gL="Arc marks uses theta channel rather than angle, replacing angle with theta.";function vL(t,e,n){return "Channel ".concat(t," is a ").concat(e,". Converted to {value: ").concat(NM(n),"}.");}function yL(t){return "Invalid field type \"".concat(t,"\".");}function bL(t,e){return "Invalid field type \"".concat(t,"\" for aggregate: \"").concat(e,"\", using \"quantitative\" instead.");}function xL(t){return "Invalid aggregation operator \"".concat(t,"\".");}function wL(t,e){return "Missing type for channel \"".concat(t,"\", using \"").concat(e,"\" instead.");}function kL(t,e){var n=e.fill,r=e.stroke;return "Dropping color ".concat(t," as the plot also has ").concat(n&&r?"fill and stroke":n?"fill":"stroke",".");}function EL(t,e){return "Dropping ".concat(NM(t)," from channel \"").concat(e,"\" since it does not contain any data field, datum, value, or signal.");}function CL(t,e,n){return "".concat(t,"-encoding with type ").concat(e," is deprecated. Replacing with ").concat(n,"-encoding.");}var AL="Line marks cannot encode size with a non-groupby field. You may want to use trail marks instead.";function OL(t,e,n){return "".concat(t," dropped as it is incompatible with \"").concat(e,"\"").concat(n?" when ".concat(n):"",".");}function _L(t){return "".concat(t,"-encoding is dropped as ").concat(t," is not a valid encoding channel.");}function SL(t){return "".concat(t," encoding should be discrete (ordinal / nominal / binned).");}function DL(t){return "Facet encoding dropped as ".concat(t.join(" and ")," ").concat(t.length>1?"are":"is"," also specified.");}function FL(t,e){return "Using discrete channel \"".concat(t,"\" to encode \"").concat(e,"\" field can be misleading as it does not encode ").concat("ordinal"===e?"order":"magnitude",".");}function TL(t,e){return "Line mark is for continuous lines and thus cannot be used with ".concat(t&&e?"x2 and y2":t?"x2":"y2",". We will use the rule mark (line segments) instead.");}function NL(t,e){return "Specified orient \"".concat(t,"\" overridden with \"").concat(e,"\".");}var IL="Custom domain scale cannot be unioned with default field-based domain.",RL='Scale\'s "rangeStep" is deprecated and will be removed in Vega-Lite 5.0. Please use "width"/"height": {"step": ...} instead. See https://vega.github.io/vega-lite/docs/size.html.';function ML(t){return "Cannot use the scale property \"".concat(t,"\" with non-color channel.");}function jL(t){return "Using unaggregated domain with raw field has no effect (".concat(NM(t),").");}function BL(t){return "Unaggregated domain not applicable for \"".concat(t,"\" since it produces values outside the origin domain of the source data.");}function PL(t){return "Unaggregated domain is currently unsupported for log scale (".concat(NM(t),").");}function LL(t){return "Cannot apply size to non-oriented mark \"".concat(t,"\".");}function zL(t,e,n){return "Channel \"".concat(t,"\" does not work with \"").concat(e,"\" scale. We are using \"").concat(n,"\" scale instead.");}function UL(t,e){return "FieldDef does not work with \"".concat(t,"\" scale. We are using \"").concat(e,"\" scale instead.");}function WL(t,e,n){return "".concat(n,"-scale's \"").concat(e,"\" is dropped as it does not work with ").concat(t," scale.");}function VL(t,e){return "Scale type \"".concat(e,"\" does not work with mark \"").concat(t,"\".");}function qL(t){return "The step for \"".concat(t,"\" is dropped because the ").concat("width"===t?"x":"y"," is continuous.");}function $L(t,e,n,r){return "Conflicting ".concat(e.toString()," property \"").concat(t.toString(),"\" (").concat(NM(n)," and ").concat(NM(r),"). Using ").concat(NM(n),".");}function HL(t,e,n,r){return "Conflicting ".concat(e.toString()," property \"").concat(t.toString(),"\" (").concat(NM(n)," and ").concat(NM(r),"). Using the union of the two domains.");}function GL(t){return "Setting the scale to be independent for \"".concat(t,"\" means we also have to set the guide (axis or legend) to be independent.");}function KL(t){return "Dropping sort property ".concat(NM(t)," as unioned domains only support boolean or op \"count\", \"min\", and \"max\".");}var XL="Domains that should be unioned has conflicting sort properties. Sort will be set to true.",YL="Detected faceted independent scales that union domain of multiple fields from different data sources. We will use the first field. The result view size may be incorrect.",JL="Detected faceted independent scales that union domain of the same fields from different source. We will assume that this is the same field from a different fork of the same data source. However, if this is not the case, the result view size may be incorrect.",QL="Detected faceted independent scales that union domain of multiple fields from the same data source. We will use the first field. The result view size may be incorrect.",ZL="Invalid channel for axis.";function tz(t){return "Cannot stack \"".concat(t,"\" if there is already \"").concat(t,"2\".");}function ez(t){return "Cannot stack non-linear scale (".concat(t,").");}function nz(t){return "Stacking is applied even though the aggregate function is non-summative (\"".concat(t,"\").");}function rz(t,e){return "Invalid ".concat(t,": ").concat(NM(e),".");}function iz(t){return "Dropping day from datetime ".concat(NM(t)," as day cannot be combined with other units.");}function oz(t,e){return "".concat(e?"extent ":"").concat(e&&t?"and ":"").concat(t?"center ":"").concat(e&&t?"are ":"is ","not needed when data are aggregated.");}function az(t,e,n){return "".concat(t," is not usually used with ").concat(e," for ").concat(n,".");}function sz(t,e){return "Continuous axis should not have customized aggregation function ".concat(t,"; ").concat(e," already agregates the axis.");}function uz(t,e){return "Center is not needed to be specified in ".concat(e," when extent is ").concat(t,".");}function cz(t){return "1D error band does not support ".concat(t,".");}function lz(t){return "Channel ".concat(t," is required for \"binned\" bin.");}function fz(t){return "Domain for ".concat(t," is required for threshold scale.");}var hz=function(t,e){var n=t||0;return {level:function level(t){return arguments.length?(n=+t,this):n;},error:function error(){return n>=1&&nM(e||"error","ERROR",arguments),this;},warn:function warn(){return n>=2&&nM(e||"warn","WARN",arguments),this;},info:function info(){return n>=3&&nM(e||"log","INFO",arguments),this;},debug:function debug(){return n>=4&&nM(e||"log","DEBUG",arguments),this;}};}(2);var dz=hz;function pz(){return dz=hz;}function mz(){var _dz;(_dz=dz).warn.apply(_dz,arguments);}function gz(t){if(t&&iM(t)){var _iterator39=_createForOfIteratorHelper(Cz),_step39;try{for(_iterator39.s();!(_step39=_iterator39.n()).done;){var _e122=_step39.value;if(_e122 in t)return !0;}}catch(err){_iterator39.e(err);}finally{_iterator39.f();}}return !1;}var vz=["january","february","march","april","may","june","july","august","september","october","november","december"],yz=vz.map(function(t){return t.substr(0,3);}),bz=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],xz=bz.map(function(t){return t.substr(0,3);});function wz(t,e){var n=[];if(e&&void 0!==t.day&&qM(t).length>1&&(mz(y.droppedDay(t)),delete(t=DM(t)).day),void 0!==t.year?n.push(t.year):n.push(2012),void 0!==t.month){var _r102=e?function(t){if(uj(t)&&(t=+t),pM(t))return t-1;{var _e123=t.toLowerCase(),_n100=vz.indexOf(_e123);if(-1!==_n100)return _n100;var _r103=_e123.substr(0,3),_i74=yz.indexOf(_r103);if(-1!==_i74)return _i74;throw new Error(y.invalidTimeUnit("month",t));}}(t.month):t.month;n.push(_r102);}else if(void 0!==t.quarter){var _r104=e?function(t){if(uj(t)&&(t=+t),pM(t))return t>4&&mz(y.invalidTimeUnit("quarter",t)),t-1;throw new Error(y.invalidTimeUnit("quarter",t));}(t.quarter):t.quarter;n.push(pM(_r104)?3*_r104:_r104+"*3");}else n.push(0);if(void 0!==t.date)n.push(t.date);else if(void 0!==t.day){var _r105=e?function(t){if(uj(t)&&(t=+t),pM(t))return t%7;{var _e124=t.toLowerCase(),_n101=bz.indexOf(_e124);if(-1!==_n101)return _n101;var _r106=_e124.substr(0,3),_i75=xz.indexOf(_r106);if(-1!==_i75)return _i75;throw new Error(y.invalidTimeUnit("day",t));}}(t.day):t.day;n.push(pM(_r105)?_r105+1:_r105+"+1");}else n.push(1);for(var _i76=0,_arr=["hours","minutes","seconds","milliseconds"];_i76<_arr.length;_i76++){var _e125=_arr[_i76];var _r107=t[_e125];n.push(void 0===_r107?0:_r107);}return n;}function kz(t){var e=wz(t,!0).join(", ");return t.utc?"utc(".concat(e,")"):"datetime(".concat(e,")");}var Ez={year:1,quarter:1,month:1,week:1,day:1,dayofyear:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1},Cz=qM(Ez);function Az(t){return t.startsWith("utc");}var Oz={"year-month":"%b %Y ","year-month-date":"%b %d, %Y "};function _z(t){var e=[];var _iterator40=_createForOfIteratorHelper(Cz),_step40;try{for(_iterator40.s();!(_step40=_iterator40.n()).done;){var _n102=_step40.value;Sz(t,_n102)&&e.push(_n102);}}catch(err){_iterator40.e(err);}finally{_iterator40.f();}return e;}function Sz(t,e){var n=t.indexOf(e);return !(n<0)&&!(n>0&&"seconds"===e&&"i"===t.charAt(n-1))&&!(t.length>n+3&&"day"===e&&"o"===t.charAt(n+3))&&!(n>0&&"year"===e&&"f"===t.charAt(n-1));}function Dz(t,e){var _ref19=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{end:!1},n=_ref19.end;var r=QM(e),i=Az(t)?"utc":"";function o(t){return "quarter"===t?"(".concat(i,"quarter(").concat(r,")-1)"):"".concat(i).concat(t,"(").concat(r,")");}var a;var s={};var _iterator41=_createForOfIteratorHelper(Cz),_step41;try{for(_iterator41.s();!(_step41=_iterator41.n()).done;){var _e126=_step41.value;Sz(t,_e126)&&(s[_e126]=o(_e126),a=_e126);}}catch(err){_iterator41.e(err);}finally{_iterator41.f();}return n&&(s[a]+="+1"),function(t){var e=wz(t,!1).join(", ");return t.utc?"utc(".concat(e,")"):"datetime(".concat(e,")");}(s);}function Fz(t){if(!t)return;var e=_z(t);return "timeUnitSpecifier(".concat(CM()(e),", ").concat(CM()(Oz),")");}function Tz(t){if(!t)return;var e;return mM(t)?e={unit:t}:iM(t)&&(e=Object.assign(Object.assign({},t),t.unit?{unit:t.unit}:{})),Az(e.unit)&&(e.utc=!0,e.unit=function(t){return t.substr(3);}(e.unit)),e;}function Nz(t){return t&&!!t.signal;}function Iz(t){return !!t.step;}function Rz(t){return !rM(t)&&"field"in t&&"data"in t;}var Mz=qM({aria:1,description:1,ariaRole:1,ariaRoleDescription:1,blend:1,opacity:1,fill:1,fillOpacity:1,stroke:1,strokeCap:1,strokeWidth:1,strokeOpacity:1,strokeDash:1,strokeDashOffset:1,strokeJoin:1,strokeOffset:1,strokeMiterLimit:1,startAngle:1,endAngle:1,padAngle:1,innerRadius:1,outerRadius:1,size:1,shape:1,interpolate:1,tension:1,orient:1,align:1,baseline:1,text:1,dir:1,dx:1,dy:1,ellipsis:1,limit:1,radius:1,theta:1,angle:1,font:1,fontSize:1,fontWeight:1,fontStyle:1,lineBreak:1,lineHeight:1,cursor:1,href:1,tooltip:1,cornerRadius:1,cornerRadiusTopLeft:1,cornerRadiusTopRight:1,cornerRadiusBottomLeft:1,cornerRadiusBottomRight:1,aspect:1,width:1,height:1}),jz={arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1},Bz=["cornerRadius","cornerRadiusTopLeft","cornerRadiusTopRight","cornerRadiusBottomLeft","cornerRadiusBottomRight"];function Pz(t){return t&&!!t.field&&void 0!==t.equal;}function Lz(t){return t&&!!t.field&&void 0!==t.lt;}function zz(t){return t&&!!t.field&&void 0!==t.lte;}function Uz(t){return t&&!!t.field&&void 0!==t.gt;}function Wz(t){return t&&!!t.field&&void 0!==t.gte;}function Vz(t){if(t&&t.field){if(rM(t.range)&&2===t.range.length)return !0;if(Nz(t.range))return !0;}return !1;}function qz(t){return t&&!!t.field&&(rM(t.oneOf)||rM(t.in));}function $z(t){return qz(t)||Pz(t)||Vz(t)||Lz(t)||Uz(t)||zz(t)||Wz(t);}function Hz(t,e){return VW(t,{timeUnit:e,wrapTime:!0});}function Gz(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var n;var r=t.field,i=null===(n=Tz(t.timeUnit))||void 0===n?void 0:n.unit,o=i?"time("+Dz(i,r)+")":AW(t,{expr:"datum"});if(Pz(t))return o+"==="+Hz(t.equal,i);if(Lz(t)){return "".concat(o,"<").concat(Hz(t.lt,i));}if(Uz(t)){return "".concat(o,">").concat(Hz(t.gt,i));}if(zz(t)){return "".concat(o,"<=").concat(Hz(t.lte,i));}if(Wz(t)){return "".concat(o,">=").concat(Hz(t.gte,i));}if(qz(t))return "indexof([".concat(function(t,e){return t.map(function(t){return Hz(t,e);});}(t.oneOf,i).join(","),"], ").concat(o,") !== -1");if(function(t){return t&&!!t.field&&void 0!==t.valid;}(t))return Kz(o,t.valid);if(Vz(t)){var _n103=t.range,_r108=Nz(_n103)?{signal:"".concat(_n103.signal,"[0]")}:_n103[0],_a42=Nz(_n103)?{signal:"".concat(_n103.signal,"[1]")}:_n103[1];if(null!==_r108&&null!==_a42&&e)return "inrange("+o+", ["+Hz(_r108,i)+", "+Hz(_a42,i)+"])";var _s37=[];return null!==_r108&&_s37.push("".concat(o," >= ").concat(Hz(_r108,i))),null!==_a42&&_s37.push("".concat(o," <= ").concat(Hz(_a42,i))),_s37.length>0?_s37.join(" && "):"true";}throw new Error("Invalid field predicate: ".concat(JSON.stringify(t)));}function Kz(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;return e?"isValid(".concat(t,") && isFinite(+").concat(t,")"):"!isValid(".concat(t,") || !isFinite(+").concat(t,")");}function Xz(t){var e;return $z(t)&&t.timeUnit?Object.assign(Object.assign({},t),{timeUnit:null===(e=Tz(t.timeUnit))||void 0===e?void 0:e.unit}):t;}var Yz={quantitative:"quantitative",ordinal:"ordinal",temporal:"temporal",nominal:"nominal",geojson:"geojson"};var Jz=Yz.quantitative,Qz=Yz.ordinal,Zz=Yz.temporal,tU=Yz.nominal,eU=Yz.geojson,nU=qM(Yz);var rU={LINEAR:"linear",LOG:"log",POW:"pow",SQRT:"sqrt",SYMLOG:"symlog",IDENTITY:"identity",SEQUENTIAL:"sequential",TIME:"time",UTC:"utc",QUANTILE:"quantile",QUANTIZE:"quantize",THRESHOLD:"threshold",BIN_ORDINAL:"bin-ordinal",ORDINAL:"ordinal",POINT:"point",BAND:"band"},iU={linear:"numeric",log:"numeric",pow:"numeric",sqrt:"numeric",symlog:"numeric",identity:"numeric",sequential:"numeric",time:"time",utc:"time",ordinal:"ordinal","bin-ordinal":"bin-ordinal",point:"ordinal-position",band:"ordinal-position",quantile:"discretizing",quantize:"discretizing",threshold:"discretizing"},oU=qM(iU);function aU(t,e){var n=iU[t],r=iU[e];return n===r||"ordinal-position"===n&&"time"===r||"ordinal-position"===r&&"time"===n;}var sU={linear:0,log:1,pow:1,sqrt:1,symlog:1,identity:1,sequential:1,time:0,utc:0,point:10,band:11,ordinal:0,"bin-ordinal":0,quantile:0,quantize:0,threshold:0};function uU(t){return sU[t];}var cU=["linear","log","pow","sqrt","symlog","time","utc"],lU=vM(cU),fU=vM(["linear","log","pow","sqrt","symlog"]);var hU=vM(["quantile","quantize","threshold"]),dU=vM(cU.concat(["quantile","quantize","threshold","sequential","identity"])),pU=vM(["ordinal","bin-ordinal","point","band"]);function mU(t){return t in pU;}function gU(t){return t in dU;}function vU(t){return t in lU;}function yU(t){return t in hU;}function bU(t){return null===t||void 0===t?void 0:t.selection;}var xU={type:1,domain:1,domainMid:1,align:1,range:1,scheme:1,bins:1,reverse:1,round:1,clamp:1,nice:1,base:1,exponent:1,constant:1,interpolate:1,zero:1,padding:1,paddingInner:1,paddingOuter:1},AU=(yM(xU,["type","domain","range","scheme"])),OU=qM(AU);!function(){var t;var e={};var _iterator42=_createForOfIteratorHelper(zB),_step42;try{for(_iterator42.s();!(_step42=_iterator42.n()).done;){var _n104=_step42.value;var _iterator43=_createForOfIteratorHelper(nU),_step43;try{for(_iterator43.s();!(_step43=_iterator43.n()).done;){var _r109=_step43.value;var _iterator44=_createForOfIteratorHelper(oU),_step44;try{for(_iterator44.s();!(_step44=_iterator44.n()).done;){var _i77=_step44.value;var _o43=TU(_n104,_r109);FU(_n104,_i77)&&DU(_i77,_r109)&&(e[_o43]=null!==(t=e[_o43])&&void 0!==t?t:[],e[_o43].push(_i77));}}catch(err){_iterator44.e(err);}finally{_iterator44.f();}}}catch(err){_iterator43.e(err);}finally{_iterator43.f();}}}catch(err){_iterator42.e(err);}finally{_iterator42.f();}}();function _U(t,e){switch(e){case"type":case"domain":case"reverse":case"range":return !0;case"scheme":case"interpolate":return !MM(["point","band","identity"],t);case"bins":return !MM(["point","band","identity","ordinal"],t);case"round":return vU(t)||"band"===t||"point"===t;case"padding":return vU(t)||MM(["point","band"],t);case"paddingOuter":case"align":return MM(["point","band"],t);case"paddingInner":return "band"===t;case"domainMid":case"clamp":return vU(t);case"nice":return vU(t)||"quantize"===t||"threshold"===t;case"exponent":return "pow"===t;case"base":return "log"===t;case"constant":return "symlog"===t;case"zero":return gU(t)&&!MM(["log","time","utc","threshold","quantile"],t);}}function SU(t,e){switch(e){case"interpolate":case"scheme":case"domainMid":return jB(t)?void 0:y.cannotUseScalePropertyWithNonColor(t);case"align":case"type":case"bins":case"domain":case"range":case"base":case"exponent":case"constant":case"nice":case"padding":case"paddingInner":case"paddingOuter":case"reverse":case"round":case"clamp":case"zero":return;}}function DU(t,e){return MM([Qz,tU],e)?void 0===t||mU(t):e===Zz?MM([rU.TIME,rU.UTC,void 0],t):e!==Jz||MM([rU.LOG,rU.POW,rU.SQRT,rU.SYMLOG,rU.QUANTILE,rU.QUANTIZE,rU.THRESHOLD,rU.LINEAR,void 0],t);}function FU(t,e){if(!MP(t))return !1;switch(t){case tB:case eB:case aB:case iB:return vU(e)||MM(["band","point"],e);case gB:case wB:case yB:case bB:case xB:case vB:return vU(e)||yU(e)||MM(["band","point","ordinal"],e);case hB:case dB:case pB:return "band"!==e;case kB:return "ordinal"===e||yU(e);case mB:return "ordinal"===e;}}function TU(t,e){return t+"_"+e;}function NU(t){var e=t.channel,n=t.channelDef,r=t.markDef,i=t.scale,o=t.config,a=BU(t);return dW(n)&&!Kj(n.aggregate)&&i&&vU(i.get("type"))&&!1===i.get("zero")?IU({fieldDef:n,channel:e,markDef:r,ref:a,config:o}):a;}function IU(_ref20){var t=_ref20.fieldDef,e=_ref20.channel,n=_ref20.markDef,r=_ref20.ref,i=_ref20.config;if(Tj(n.type))return r;return null===QW("invalid",n,i)?r:[function(t,e){var n=RU(t,!0),r="y"===ZB(e)?{field:{group:"height"}}:{value:0};return Object.assign({test:n},r);}(t,e),r];}function RU(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;return Kz(mM(t)?t:AW(t,{expr:"datum"}),!e);}function MU(t,e,n,r){var i={};if(e&&(i.scale=e),mW(t)){var _e127=t.datum;gz(_e127)?i.signal=kz(_e127):Nz(_e127)?i.signal=_e127.signal:i.value=_e127;}else i.field=AW(t,n);if(r){var _t117=r.offset,_e128=r.band;_t117&&(i.offset=_t117),_e128&&(i.band=_e128);}return i;}function jU(_ref21){var t=_ref21.scaleName,e=_ref21.fieldOrDatumDef,n=_ref21.fieldOrDatumDef2,r=_ref21.offset,i=_ref21.startSuffix,_ref21$band=_ref21.band,o=_ref21$band===void 0?.5:_ref21$band;var a=0<o&&o<1?"datum":void 0,s=AW(e,{expr:a,suffix:i}),u=void 0!==n?AW(n,{expr:a}):AW(e,{suffix:"end",expr:a}),c={};if(0===o||1===o){c.scale=t;var _e129=0===o?s:u;c.field=_e129;}else {var _e130="".concat(o," * ").concat(s," + ").concat(1-o," * ").concat(u);c.signal="scale(\"".concat(t,"\", ").concat(_e130,")");}return r&&(c.offset=r),c;}function BU(_ref22){var t=_ref22.channel,e=_ref22.channelDef,n=_ref22.channel2Def,r=_ref22.markDef,i=_ref22.config,o=_ref22.scaleName,a=_ref22.scale,s=_ref22.stack,u=_ref22.offset,c=_ref22.defaultRef,l=_ref22.band;var f;if(e){if(yW(e)){if(bW(e)){l=null!==l&&void 0!==l?l:uW({channel:t,fieldDef:e,fieldDef2:n,markDef:r,stack:s,config:i,isMidPoint:!0});var _a43=e.bin,_c15=e.timeUnit,_f10=e.type;if(WP(_a43)||l&&_c15&&_f10===Zz)return s&&s.impute?MU(e,o,{binSuffix:"mid"},{offset:u}):l?jU({scaleName:o,fieldOrDatumDef:e,band:l,offset:u}):MU(e,o,$W(e,t)?{binSuffix:"range"}:{},{offset:u});if(VP(_a43)){if(dW(n))return jU({scaleName:o,fieldOrDatumDef:e,fieldOrDatumDef2:n,band:l,offset:u});{var _e131=t===tB?nB:rB;mz(y.channelRequiredForBinned(_e131));}}}var _c14=null===a||void 0===a?void 0:a.get("type");return MU(e,o,mU(_c14)?{binSuffix:"range"}:{},{offset:u,band:"band"===_c14?null!==(f=null!==l&&void 0!==l?l:e.band)&&void 0!==f?f:.5:void 0});}if(xW(e)){var _n105=e.value,_r110=u?{offset:u}:{};return Object.assign(Object.assign({},PU(t,_n105)),_r110);}}return lM(c)&&(c=c()),c?Object.assign(Object.assign({},c),u?{offset:u}:{}):c;}function PU(t,e){return MM(["x","x2"],t)&&"width"===e?{field:{group:"width"}}:MM(["y","y2"],t)&&"height"===e?{field:{group:"height"}}:KW(e);}function LU(t){return t&&"number"!==t&&"time"!==t;}function zU(t,e,n){return "".concat(t,"(").concat(e).concat(n?", ".concat(JSON.stringify(n)):"",")");}var UU=" – ";function WU(_ref23){var t=_ref23.fieldOrDatumDef,e=_ref23.format,n=_ref23.formatType,r=_ref23.expr,i=_ref23.normalizeStack,o=_ref23.config;var a,s;if(LU(n))return qU({fieldOrDatumDef:t,format:e,formatType:n,expr:r,config:o});var u=VU(t,r,i);if(WW(t)){var _n106=function(t,e,n,r,i){return !e||n?(n=mM(n)?n:r,"".concat(i?"utc":"time","Format(").concat(t,", '").concat(n,"')")):function(t,e,n){if(!t)return;var r=Fz(t);return "".concat(n||Az(t)?"utc":"time","Format(").concat(e,", ").concat(r,")");}(e,t,i);}(u,dW(t)?null===(a=Tz(t.timeUnit))||void 0===a?void 0:a.unit:void 0,e,o.timeFormat,wW(t)&&(null===(s=t.scale)||void 0===s?void 0:s.type)===rU.UTC);return _n106?{signal:_n106}:void 0;}if(e=GU(pW(t),e,o),dW(t)&&WP(t.bin)){return {signal:YU(u,AW(t,{expr:r,binSuffix:"end"}),e,n,o)};}return e||"quantitative"===pW(t)?{signal:"".concat(KU(u,e))}:{signal:"isValid(".concat(u,") ? ").concat(u," : \"\"+").concat(u)};}function VU(t,e,n){return dW(t)?n?"".concat(AW(t,{expr:e,suffix:"end"}),"-").concat(AW(t,{expr:e,suffix:"start"})):AW(t,{expr:e}):function(t){var e=t.datum;return gz(e)?kz(e):"".concat(JSON.stringify(e));}(t);}function qU(_ref24){var t=_ref24.fieldOrDatumDef,e=_ref24.format,n=_ref24.formatType,r=_ref24.expr,i=_ref24.normalizeStack,o=_ref24.config,a=_ref24.field;if(a=null!==a&&void 0!==a?a:VU(t,r,i),dW(t)&&WP(t.bin)){return {signal:YU(a,AW(t,{expr:r,binSuffix:"end"}),e,n,o)};}return {signal:zU(n,a,e)};}function $U(t,e,n,r,i,o){var a;if(!LU(r)){if(WW(t)){return function(t,e,n,r){if(t)return t;if(e)return {signal:Fz(e)};return r?void 0:n.timeFormat;}(n,dW(t)?null===(a=Tz(t.timeUnit))||void 0===a?void 0:a.unit:void 0,i,o);}return GU(e,n,i);}}function HU(t,e,n){return t&&(Nz(t)||"number"===t||"time"===t)?t:WW(e)&&"time"!==n&&"utc"!==n?"time":void 0;}function GU(t,e,n){return mM(e)?e:t===Jz?n.numberFormat:void 0;}function KU(t,e){return "format(".concat(t,", \"").concat(e||"","\")");}function XU(t,e,n,r){var i;return LU(n)?zU(n,t,e):KU(t,null!==(i=mM(e)?e:void 0)&&void 0!==i?i:r.numberFormat);}function YU(t,e,n,r,i){var o=XU(t,n,r,i),a=XU(e,n,r,i);return "".concat(Kz(t,!1)," ? \"null\" : ").concat(o," + \"").concat(UU,"\" + ").concat(a);}var JU="min",QU={x:1,y:1,color:1,fill:1,stroke:1,strokeWidth:1,size:1,shape:1,fillOpacity:1,strokeOpacity:1,opacity:1,text:1};function ZU(t){return t in QU;}function tW(t){return !!t&&!!t.encoding;}function eW(t){return !(!t||"count"!==t.op&&!t.field);}function nW(t){return !!t&&rM(t);}function rW(t){return "row"in t||"column"in t;}function iW(t){return !!t&&"header"in t;}function oW(t){return "facet"in t;}function aW(t){var e=t.field,n=t.timeUnit,r=t.bin,i=t.aggregate;return Object.assign(Object.assign(Object.assign(Object.assign({},n?{timeUnit:n}:{}),r?{bin:r}:{}),i?{aggregate:i}:{}),{field:e});}function sW(t){return bW(t)&&"sort"in t;}function uW(_ref25){var t=_ref25.channel,e=_ref25.fieldDef,n=_ref25.fieldDef2,r=_ref25.markDef,i=_ref25.stack,o=_ref25.config,a=_ref25.isMidPoint;if(yW(e)&&void 0!==e.band)return e.band;if(dW(e)){var _t118=e.timeUnit,_i78=e.bin;if(_t118&&!n)return a?ZW("timeUnitBandPosition",r,o):Nj(r.type)?ZW("timeUnitBand",r,o):0;if(WP(_i78))return Nj(r.type)&&!a?1:.5;}return (null===i||void 0===i?void 0:i.fieldChannel)===t&&a?.5:void 0;}function cW(t,e,n,r,i,o){return !!(WP(e.bin)||e.timeUnit&&bW(e)&&"temporal"===e.type)&&!!uW({channel:t,fieldDef:e,fieldDef2:n,stack:r,markDef:i,config:o});}function lW(t){return !!t&&"condition"in t;}function fW(t){var e=t&&t.condition;return !!e&&!rM(e)&&dW(e);}function hW(t){var e=t&&t.condition;return !!e&&!rM(e)&&yW(e);}function dW(t){return !(!t||!t.field&&"count"!==t.aggregate);}function pW(t){return t&&t.type;}function mW(t){return !!t&&"datum"in t;}function gW(t){return bW(t)&&_W(t)||vW(t);}function vW(t){return mW(t)&&pM(t.datum);}function yW(t){return dW(t)||mW(t);}function bW(t){return !!t&&("field"in t&&"type"in t||"count"===t.aggregate);}function xW(t){return t&&"value"in t&&"value"in t;}function wW(t){return !!t&&("scale"in t||"sort"in t);}function kW(t){return t&&("axis"in t||"stack"in t||"impute"in t);}function EW(t){return !!t&&"legend"in t;}function CW(t){return !!t&&("format"in t||"formatType"in t);}function AW(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var n,r,i;var o=t.field;var a=e.prefix;var s=e.suffix,u="";if(function(t){return "count"===t.aggregate;}(t))o=function(t){return function(t){return 0===t.indexOf("__");}(t)?t:"__".concat(t);}("count");else {var _a44;if(!e.nofn)if(function(t){return "op"in t;}(t))_a44=t.op;else {var _c16=t.bin,_l11=t.aggregate,_f11=t.timeUnit;WP(_c16)?(_a44=UP(_c16),s=(null!==(n=e.binSuffix)&&void 0!==n?n:"")+(null!==(r=e.suffix)&&void 0!==r?r:"")):_l11?$j(_l11)?(u="[\"".concat(o,"\"]"),o="argmax_".concat(_l11.argmax)):qj(_l11)?(u="[\"".concat(o,"\"]"),o="argmin_".concat(_l11.argmin)):_a44=String(_l11):_f11&&(_a44=function(t){var e=Tz(t),n=e.utc,r=yM(e,["utc"]);return r.unit?(n?"utc":"")+qM(r).map(function(t){return KM("".concat("unit"===t?"":"_".concat(t,"_")).concat(r[t]));}).join(""):(n?"utc":"")+"timeunit"+qM(r).map(function(t){return KM("_".concat(t,"_").concat(r[t]));}).join("");}(_f11),s=(!MM(["range","mid"],e.binSuffix)&&e.binSuffix||"")+(null!==(i=e.suffix)&&void 0!==i?i:""));}_a44&&(o=o?"".concat(_a44,"_").concat(o):_a44);}return s&&(o="".concat(o,"_").concat(s)),a&&(o="".concat(a,"_").concat(o)),e.forAs?nj(o):e.expr?function(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"datum";return "".concat(e,"[").concat(gM(QR(t).join(".")),"]");}(o,e.expr)+u:tj(o)+u;}function OW(t){switch(t.type){case"nominal":case"ordinal":case"geojson":return !0;case"quantitative":return dW(t)&&!!t.bin;case"temporal":return !1;}throw new Error(y.invalidFieldType(t.type));}function _W(t){return !OW(t);}var SW=function SW(t,e){switch(e.fieldTitle){case"plain":return t.field;case"functional":return function(t){var e=t.aggregate,n=t.bin,r=t.timeUnit,i=t.field;if($j(e))return "".concat(i," for argmax(").concat(e.argmax,")");if(qj(e))return "".concat(i," for argmin(").concat(e.argmin,")");var o=Tz(r),a=e||(null===o||void 0===o?void 0:o.unit)||(null===o||void 0===o?void 0:o.maxbins)&&"timeunit"||WP(n)&&"bin";return a?a.toUpperCase()+"("+i+")":i;}(t);default:return function(t,e){var n;var r=t.field,i=t.bin,o=t.timeUnit,a=t.aggregate;if("count"===a)return e.countTitle;if(WP(i))return "".concat(r," (binned)");if(o){var _t119=null===(n=Tz(o))||void 0===n?void 0:n.unit;if(_t119)return "".concat(r," (").concat(_z(_t119).join("-"),")");}else if(a)return $j(a)?"".concat(r," for max ").concat(a.argmax):qj(a)?"".concat(r," for min ").concat(a.argmin):"".concat(JM(a)," of ").concat(r);return r;}(t,e);}};var DW=SW;function FW(t){DW=t;}function TW(t,e,_ref26){var n=_ref26.allowDisabling,_ref26$includeDefault=_ref26.includeDefault,r=_ref26$includeDefault===void 0?!0:_ref26$includeDefault;var i,o;var a=(null!==(i=NW(t))&&void 0!==i?i:{}).title;if(!dW(t))return a;var s=t,u=r?IW(s,e):void 0;return n?ij(a,s.title,u):null!==(o=null!==a&&void 0!==a?a:s.title)&&void 0!==o?o:u;}function NW(t){return kW(t)&&t.axis?t.axis:EW(t)&&t.legend?t.legend:iW(t)&&t.header?t.header:void 0;}function IW(t,e){return DW(t,e);}function RW(t){var e;if(CW(t)){var _e132=t.format,_n107=t.formatType;return {format:_e132,formatType:_n107};}{var _n108=null!==(e=NW(t))&&void 0!==e?e:{},_r111=_n108.format,_i79=_n108.formatType;return {format:_r111,formatType:_i79};}}function MW(t){return dW(t)?t:fW(t)?t.condition:void 0;}function jW(t){return yW(t)?t:hW(t)?t.condition:void 0;}function BW(t,e,n){if(mM(t)||pM(t)||dM(t)){var _n109=mM(t)?"string":pM(t)?"number":"boolean";return mz(y.primitiveChannelDef(e,_n109,t)),{value:t};}return yW(t)?PW(t,e,n):hW(t)?Object.assign(Object.assign({},t),{condition:PW(t.condition,e,n)}):t;}function PW(t,e,n){if(CW(t)){t.format;var _i80=t.formatType,_o44=yM(t,["format","formatType"]);if(LU(_i80)&&!n.customFormatTypes)return mz(y.customFormatTypeNotAllowed(e)),PW(_o44,e,n);}else {var _r113=kW(t)?"axis":EW(t)?"legend":iW(t)?"header":null;if(_r113&&t[_r113]){var _i81=t[_r113];_i81.format;var _a45=_i81.formatType,_s38=yM(_i81,["format","formatType"]);if(LU(_a45)&&!n.customFormatTypes)return mz(y.customFormatTypeNotAllowed(e)),PW(Object.assign(Object.assign({},t),_defineProperty({},_r113,_s38)),e,n);}}return dW(t)?LW(t,e):function(t){var e=t.type;if(e)return t;var n=t.datum;return e=pM(n)?"quantitative":mM(n)?"nominal":gz(n)?"temporal":void 0,Object.assign(Object.assign({},t),{type:e});}(t);}function LW(t,e){var n=t.aggregate,r=t.timeUnit,i=t.bin,o=t.field,a=Object.assign({},t);if(!n||Hj(n)||$j(n)||qj(n)||(mz(y.invalidAggregate(n)),delete a.aggregate),r&&(a.timeUnit=Tz(r)),o&&(a.field="".concat(o)),WP(i)&&(a.bin=zW(i,e)),VP(i)&&!bP(e)&&mz("Channel ".concat(e," should not be used with \"binned\" bin.")),bW(a)){var _t120=a.type,_e133=function(t){if(t)switch(t=t.toLowerCase()){case"q":case Jz:return "quantitative";case"t":case Zz:return "temporal";case"o":case Qz:return "ordinal";case"n":case tU:return "nominal";case eU:return "geojson";}}(_t120);_t120!==_e133&&(a.type=_e133),"quantitative"!==_t120&&Kj(n)&&(mz(y.invalidFieldTypeForCountAggregate(_t120,n)),a.type="quantitative");}else if(!QB(e)){var _t121=function(t,e){if(t.timeUnit)return "temporal";if(WP(t.bin))return "quantitative";switch(zP(e)){case"continuous":return "quantitative";case"discrete":case"flexible":return "nominal";default:return "quantitative";}}(a,e);mz(y.missingFieldType(e,_t121)),a.type=_t121;}if(bW(a)){var _ref27=function(t,e){var n=t.type;if("geojson"===n&&"shape"!==e)return {compatible:!1,warning:"Channel ".concat(e," should not be used with a geojson data.")};switch(e){case Jj:case Qj:case Zj:return _W(t)?{compatible:!1,warning:y.facetChannelShouldBeDiscrete(e)}:UW;case tB:case eB:case hB:case dB:case pB:case EB:case AB:case OB:case _B:case SB:case DB:case vB:case aB:case iB:case FB:return UW;case cB:case fB:case uB:case lB:return n!==Jz?{compatible:!1,warning:"Channel ".concat(e," should be used with a quantitative field only, not ").concat(t.type," field.")}:UW;case yB:case bB:case xB:case wB:case gB:case sB:case oB:case nB:case rB:return "nominal"!==n||t.sort?UW:{compatible:!1,warning:"Channel ".concat(e," should not be used with an unsorted discrete field.")};case kB:return MM(["ordinal","nominal"],t.type)?UW:{compatible:!1,warning:"StrokeDash channel should be used with only discrete data."};case mB:return MM(["ordinal","nominal","geojson"],t.type)?UW:{compatible:!1,warning:"Shape channel should be used with only either discrete or geojson data."};case CB:return "nominal"!==t.type||"sort"in t?UW:{compatible:!1,warning:"Channel order is inappropriate for nominal field, which has no inherent order."};}}(a,e),_t122=_ref27.compatible,_n110=_ref27.warning;_t122||mz(_n110);}if(sW(a)&&mM(a.sort)){var _t123=a.sort;if(ZU(_t123))return Object.assign(Object.assign({},a),{sort:{encoding:_t123}});var _e134=_t123.substr(1);if("-"===_t123.charAt(0)&&ZU(_e134))return Object.assign(Object.assign({},a),{sort:{encoding:_e134,order:"descending"}});}if(iW(a)){var _t124=a.header,_e135=_t124.orient,_n111=yM(_t124,["orient"]);if(_e135)return Object.assign(Object.assign({},a),{header:Object.assign(Object.assign({},_n111),{labelOrient:_t124.labelOrient||_e135,titleOrient:_t124.titleOrient||_e135})});}return a;}function zW(t,e){return dM(t)?{maxbins:HP(e)}:"binned"===t?{binned:!0}:t.maxbins||t.step?t:Object.assign(Object.assign({},t),{maxbins:HP(e)});}var UW={compatible:!0};function WW(t){var _RW=RW(t),e=_RW.formatType;return "time"===e||!e&&function(t){return t&&("temporal"===t.type||dW(t)&&!!t.timeUnit);}(t);}function VW(t,_ref28){var e=_ref28.timeUnit,n=_ref28.type,r=_ref28.wrapTime,i=_ref28.undefinedIfExprNotRequired;var o;var a=e&&(null===(o=Tz(e))||void 0===o?void 0:o.unit);var s,u=a||"temporal"===n;return Nz(t)?s=t.signal:gz(t)?(u=!0,s=kz(t)):(mM(t)||pM(t))&&u&&(s="datetime(".concat(JSON.stringify(t),")"),function(t){return !!Ez[t];}(a)&&(pM(t)&&t<1e4||mM(t)&&isNaN(Date.parse(t)))&&(s=kz(_defineProperty({},a,t)))),s?r&&u?"time(".concat(s,")"):s:i?void 0:JSON.stringify(t);}function qW(t,e){var n=t.type;return e.map(function(e){var r=VW(e,{timeUnit:dW(t)?t.timeUnit:void 0,type:n,undefinedIfExprNotRequired:!0});return void 0!==r?{signal:r}:e;});}function $W(t,e){return WP(t.bin)?MP(e)&&MM(["ordinal","nominal"],t.type):(console.warn("Only call this method for binned field defs."),!1);}function HW(t){var e=t.anchor,n=t.frame,r=t.offset,i=t.orient,o=t.color,a=t.subtitleColor,s=t.subtitleFont,u=t.subtitleFontSize,c=t.subtitleFontStyle,l=t.subtitleFontWeight,f=t.subtitleLineHeight,h=t.subtitlePadding,d=yM(t,["anchor","frame","offset","orient","color","subtitleColor","subtitleFont","subtitleFontSize","subtitleFontStyle","subtitleFontWeight","subtitleLineHeight","subtitlePadding"]),p=Object.assign(Object.assign({},d),o?{fill:o}:{}),m=Object.assign(Object.assign(Object.assign(Object.assign({},e?{anchor:e}:{}),n?{frame:n}:{}),r?{offset:r}:{}),i?{orient:i}:{}),g=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},a?{subtitleColor:a}:{}),s?{subtitleFont:s}:{}),u?{subtitleFontSize:u}:{}),c?{subtitleFontStyle:c}:{}),l?{subtitleFontWeight:l}:{}),f?{subtitleLineHeight:f}:{}),h?{subtitlePadding:h}:{});return {titleMarkConfig:p,subtitleMarkConfig:FM(p,["align","baseline","dx","dy","limit"]),nonMark:m,subtitle:g};}function GW(t){return mM(t)||rM(t)&&mM(t[0]);}function KW(t){return Nz(t)?t:void 0!==t?{value:t}:void 0;}function XW(t){return Nz(t)?t.signal:gM(t.value);}function YW(t){return Nz(t)?t.signal:null==t?null:gM(t);}function JW(t){var e;return [].concat(t.type,null!==(e=t.style)&&void 0!==e?e:[]);}function QW(t,e,n){var r=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var i=r.vgChannel,o=r.ignoreVgConfig;return i&&void 0!==e[i]?e[i]:void 0!==e[t]?e[t]:!o||i&&i!==t?ZW(t,e,n,r):void 0;}function ZW(t,e,n){var _ref29=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},r=_ref29.vgChannel;return ij(r?tV(t,e,n.style):void 0,tV(t,e,n.style),r?n[e.type][r]:void 0,n[e.type][t],r?n.mark[r]:n.mark[t]);}function tV(t,e,n){return eV(t,JW(e),n);}function eV(t,e,n){var r;e=cM(e);var _iterator45=_createForOfIteratorHelper(e),_step45;try{for(_iterator45.s();!(_step45=_iterator45.n()).done;){var _i82=_step45.value;var _e136=n[_i82];_e136&&void 0!==_e136[t]&&(r=_e136[t]);}}catch(err){_iterator45.e(err);}finally{_iterator45.f();}return r;}function nV(t,e){return cM(t).reduce(function(t,n){var r;return t.field.push(AW(n,e)),t.order.push(null!==(r=n.sort)&&void 0!==r?r:"ascending"),t;},{field:[],order:[]});}function rV(t,e){var n=_toConsumableArray(t);return e.forEach(function(t){var _iterator46=_createForOfIteratorHelper(n),_step46;try{for(_iterator46.s();!(_step46=_iterator46.n()).done;){var _e137=_step46.value;if(SM(_e137,t))return;}}catch(err){_iterator46.e(err);}finally{_iterator46.f();}n.push(t);}),n;}function iV(t,e){return SM(t,e)||!e?t:t?[].concat(_toConsumableArray(cM(t)),_toConsumableArray(cM(e))).join(", "):e;}function oV(t,e){var n=t.value,r=e.value;if(null==n||null===r)return {explicit:t.explicit,value:null};if((GW(n)||Nz(n))&&(GW(r)||Nz(r)))return {explicit:t.explicit,value:iV(n,r)};if(GW(n)||Nz(n))return {explicit:t.explicit,value:n};if(GW(r)||Nz(r))return {explicit:t.explicit,value:r};if(!(GW(n)||Nz(n)||GW(r)||Nz(r)))return {explicit:t.explicit,value:rV(n,r)};throw new Error("It should never reach here");}function aV(t,e){var n=t&&t[e];return !!n&&(rM(n)?jM(n,function(t){return !!t.field;}):dW(n)||fW(n));}function sV(t){return jM(zB,function(e){if(aV(t,e)){var _n112=t[e];if(rM(_n112))return jM(_n112,function(t){return !!t.aggregate;});{var _t125=MW(_n112);return _t125&&!!_t125.aggregate;}}return !1;});}function uV(t,e){var n=[],r=[],i=[],o=[],a={};return lV(t,function(s,u){if(dW(s)){var _c17=s.field,_l12=s.aggregate,_f12=s.bin,_h9=s.timeUnit,_d6=yM(s,["field","aggregate","bin","timeUnit"]);if(_l12||_h9||_f12){var _t126=NW(s),_p6=_t126&&_t126.title;var _m5=AW(s,{forAs:!0});var _g5=Object.assign(Object.assign(Object.assign({},_p6?[]:{title:TW(s,e,{allowDisabling:!0})}),_d6),{field:_m5});if(_l12){var _t127;if($j(_l12)?(_t127="argmax",_m5=AW({op:"argmax",field:_l12.argmax},{forAs:!0}),_g5.field="".concat(_m5,".").concat(_c17)):qj(_l12)?(_t127="argmin",_m5=AW({op:"argmin",field:_l12.argmin},{forAs:!0}),_g5.field="".concat(_m5,".").concat(_c17)):"boxplot"!==_l12&&"errorbar"!==_l12&&"errorband"!==_l12&&(_t127=_l12),_t127){var _e138={op:_t127,as:_m5};_c17&&(_e138.field=_c17),o.push(_e138);}}else if(n.push(_m5),bW(s)&&WP(_f12)){if(r.push({bin:_f12,field:_c17,as:_m5}),n.push(AW(s,{binSuffix:"end"})),$W(s,u)&&n.push(AW(s,{binSuffix:"range"})),bP(u)){var _t128={field:_m5+"_end"};a[u+"2"]=_t128;}_g5.bin="binned",QB(u)||(_g5.type=Jz);}else if(_h9){i.push({timeUnit:_h9,field:_c17,as:_m5});var _t129=bW(s)&&s.type!==Zz&&"time";_t129&&(u===EB||u===_B?_g5.formatType=_t129:!function(t){return !!mP[t];}(u)?bP(u)&&(_g5.axis=Object.assign({formatType:_t129},_g5.axis)):_g5.legend=Object.assign({formatType:_t129},_g5.legend));}a[u]=_g5;}else n.push(_c17),a[u]=t[u];}else a[u]=t[u];}),{bins:r,timeUnits:i,aggregate:o,groupby:n,encoding:a};}function cV(t,e,n){var r=e.type;return qM(t).reduce(function(i,o){if(!YB(o))return mz(y.invalidEncodingChannel(o)),i;var a=t[o];if("angle"!==o||"arc"!==r||t.theta||(mz(y.REPLACE_ANGLE_WITH_THETA),o=aB),!function(t,e,n){var r=jP(e,n);if(!r)return !1;if("binned"===r){var _n113=t[e===nB?tB:eB];return !!(dW(_n113)&&dW(t[e])&&VP(_n113.bin));}return !0;}(t,o,r))return mz(y.incompatibleChannel(o,r)),i;if(o===gB&&"line"===r){var _e139=MW(t[o]);if(null===_e139||void 0===_e139?void 0:_e139.aggregate)return mz(y.LINE_WITH_VARYING_SIZE),i;}if(o===hB&&(e.filled?"fill"in t:"stroke"in t))return mz(y.droppingColor("encoding",{fill:"fill"in t,stroke:"stroke"in t})),i;if(o===AB||o===CB&&!rM(a)&&!xW(a)||o===_B&&rM(a))a&&(i[o]=cM(a).reduce(function(t,e){return dW(e)?t.push(LW(e,o)):mz(y.emptyFieldDef(e,o)),t;},[]));else {if(o===_B&&null===a)i[o]=null;else if(!(dW(a)||mW(a)||xW(a)||lW(a)||Nz(a)))return mz(y.emptyFieldDef(a,o)),i;i[o]=BW(a,o,n);}return i;},{});}function lV(t,e,n){if(t){var _iterator47=_createForOfIteratorHelper(qM(t)),_step47;try{for(_iterator47.s();!(_step47=_iterator47.n()).done;){var _r114=_step47.value;var _i83=t[_r114];if(rM(_i83)){var _iterator48=_createForOfIteratorHelper(_i83),_step48;try{for(_iterator48.s();!(_step48=_iterator48.n()).done;){var _t130=_step48.value;e.call(n,_t130,_r114);}}catch(err){_iterator48.e(err);}finally{_iterator48.f();}}else e.call(n,_i83,_r114);}}catch(err){_iterator47.e(err);}finally{_iterator47.f();}}}function fV(t,e,n,r){return t?qM(t).reduce(function(n,i){var o=t[i];return rM(o)?o.reduce(function(t,n){return e.call(r,t,n,i);},n):e.call(r,n,o,i);},n):n;}function hV(t,e){return qM(e).reduce(function(n,r){switch(r){case tB:case eB:case SB:case FB:case DB:case nB:case rB:case aB:case sB:case iB:case oB:case uB:case cB:case lB:case fB:case EB:case mB:case vB:case _B:return n;case CB:if("line"===t||"trail"===t)return n;case AB:case OB:{var _t131=e[r];if(rM(_t131)||dW(_t131)){var _iterator49=_createForOfIteratorHelper(cM(_t131)),_step49;try{for(_iterator49.s();!(_step49=_iterator49.n()).done;){var _e140=_step49.value;_e140.aggregate||n.push(AW(_e140,{}));}}catch(err){_iterator49.e(err);}finally{_iterator49.f();}}return n;}case gB:if("trail"===t)return n;case hB:case dB:case pB:case yB:case bB:case xB:case kB:case wB:{var _t132=MW(e[r]);return _t132&&!_t132.aggregate&&n.push(AW(_t132,{})),n;}}},[]);}function dV(t,e,n){var r=arguments.length>3&&arguments[3]!==undefined?arguments[3]:!0;if("tooltip"in n)return {tooltip:n.tooltip};return {tooltip:[].concat(_toConsumableArray(t.map(function(_ref30){var t=_ref30.fieldPrefix,n=_ref30.titlePrefix;var i=r?" of ".concat(e.field):"";return {field:t+e.field,type:e.type,title:Nz(n)?{signal:n+"\"".concat(escape(i),"\"")}:n+i};})),_toConsumableArray(function(t){var e=[];var _iterator50=_createForOfIteratorHelper(qM(t)),_step50;try{for(_iterator50.s();!(_step50=_iterator50.n()).done;){var _n114=_step50.value;if(aV(t,_n114)){var _r115=t[_n114],_i84=cM(_r115);var _iterator51=_createForOfIteratorHelper(_i84),_step51;try{for(_iterator51.s();!(_step51=_iterator51.n()).done;){var _t133=_step51.value;dW(_t133)?e.push(_t133):fW(_t133)&&e.push(_t133.condition);}}catch(err){_iterator51.e(err);}finally{_iterator51.f();}}}}catch(err){_iterator50.e(err);}finally{_iterator50.f();}return e;}(n)))};}function pV(t){var e=t.axis,n=t.title,r=t.field;return e&&void 0!==e.title?void 0:ij(n,r);}function mV(t,e,n,r,i){var o=n.scale,a=n.axis;return function(_ref31){var s=_ref31.partName,u=_ref31.mark,c=_ref31.positionPrefix,l=_ref31.endPositionPrefix,f=_ref31.aria,_ref31$extraEncoding=_ref31.extraEncoding,h=_ref31$extraEncoding===void 0?{}:_ref31$extraEncoding;var d=pV(n);return gV(t,s,i,f,{mark:u,encoding:Object.assign(Object.assign(Object.assign(_defineProperty({},e,Object.assign(Object.assign(Object.assign({field:c+"_"+n.field,type:n.type},void 0!==d?{title:d}:{}),void 0!==o?{scale:o}:{}),void 0!==a?{axis:a}:{})),mM(l)?_defineProperty({},e+"2",{field:l+"_"+n.field}):{}),r),h)});};}function gV(t,e,n,r,i){var o=t.clip,a=t.color,s=t.opacity,u=t.type;return t[e]||void 0===t[e]&&n[e]?[Object.assign(Object.assign({},i),{mark:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n[e]),o?{clip:o}:{}),a?{color:a}:{}),s?{opacity:s}:{}),Rj(i.mark)?i.mark:{type:i.mark}),{style:"".concat(u,"-").concat(e)}),dM(t[e])?{}:t[e]),!1===r?{aria:r}:{})})]:[];}function vV(t,e,n){var r=t.encoding,i="vertical"===e?"y":"x",o=r[i],a=r[i+"2"],s=r[i+"Error"],u=r[i+"Error2"];return {continuousAxisChannelDef:yV(o,n),continuousAxisChannelDef2:yV(a,n),continuousAxisChannelDefError:yV(s,n),continuousAxisChannelDefError2:yV(u,n),continuousAxis:i};}function yV(t,e){if(t&&t.aggregate){var _n115=t.aggregate,_r116=yM(t,["aggregate"]);return _n115!==e&&mz(y.errorBarContinuousAxisHasCustomizedAggregate(_n115,e)),_r116;}return t;}function bV(t,e){var n=t.mark,r=t.encoding,i=r.x,o=r.y;if(gW(i)){if(gW(o)){var _t134=dW(i)&&i.aggregate,_r117=dW(o)&&o.aggregate;if(_t134||_r117!==e){if(_r117||_t134!==e){if(_t134===e&&_r117===e)throw new Error("Both x and y cannot have aggregate");return Rj(n)&&n.orient?n.orient:"vertical";}return "horizontal";}return "vertical";}return "horizontal";}if(gW(o))return "vertical";throw new Error("Need a valid continuous axis for "+e+"s");}var xV="boxplot",wV=new Uj(xV,EV);function kV(t){return pM(t)?"tukey":t;}function EV(t,_ref33){var e=_ref33.config;var n,r;var i=t.mark;t.encoding;var a=t.selection;t.projection;var u=yM(t,["mark","encoding","selection","projection"]),c=Rj(i)?i:{type:i};a&&mz(y.selectionNotSupported("boxplot"));var l=null!==(n=c.extent)&&void 0!==n?n:e.boxplot.extent,f=QW("size",c,e),h=kV(l),_ref34=function(t,e,n){var r=bV(t,xV),_vV=vV(t,r,xV),i=_vV.continuousAxisChannelDef,o=_vV.continuousAxis,a=i.field,s=kV(e),u=[].concat(_toConsumableArray(CV(a)),[{op:"median",field:a,as:"mid_box_"+a},{op:"min",field:a,as:("min-max"===s?"lower_whisker_":"min_")+a},{op:"max",field:a,as:("min-max"===s?"upper_whisker_":"max_")+a}]),c="min-max"===s||"tukey"===s?[]:[{calculate:"datum[\"upper_box_".concat(a,"\"] - datum[\"lower_box_").concat(a,"\"]"),as:"iqr_"+a},{calculate:"min(datum[\"upper_box_".concat(a,"\"] + datum[\"iqr_").concat(a,"\"] * ").concat(e,", datum[\"max_").concat(a,"\"])"),as:"upper_whisker_"+a},{calculate:"max(datum[\"lower_box_".concat(a,"\"] - datum[\"iqr_").concat(a,"\"] * ").concat(e,", datum[\"min_").concat(a,"\"])"),as:"lower_whisker_"+a}],l=t.encoding,f=o,h=(l[f],yM(l,["symbol"==_typeof$1(f)?f:f+""])),_ref35=function(t){var e=t.tooltip,n=yM(t,["tooltip"]);if(!e)return {filteredEncoding:t};var r,i;if(rM(e)){var _iterator52=_createForOfIteratorHelper(e),_step52;try{for(_iterator52.s();!(_step52=_iterator52.n()).done;){var _t135=_step52.value;_t135.aggregate?(r||(r=[]),r.push(_t135)):(i||(i=[]),i.push(_t135));}}catch(err){_iterator52.e(err);}finally{_iterator52.f();}r&&(n.tooltip=r);}else e.aggregate?n.tooltip=e:i=e;return rM(i)&&1===i.length&&(i=i[0]),{customTooltipWithoutAggregatedField:i,filteredEncoding:n};}(h),d=_ref35.customTooltipWithoutAggregatedField,p=_ref35.filteredEncoding,_uV=uV(p,n),m=_uV.bins,g=_uV.timeUnits,v=_uV.aggregate,y=_uV.groupby,b=_uV.encoding;return {transform:[].concat(_toConsumableArray(m),_toConsumableArray(g),[{aggregate:[].concat(_toConsumableArray(v),u),groupby:y}],c),groupby:y,aggregate:v,continuousAxisChannelDef:i,continuousAxis:o,encodingWithoutContinuousAxis:b,ticksOrient:"vertical"===r?"horizontal":"vertical",boxOrient:r,customTooltipWithoutAggregatedField:d};}(t,l,e),d=_ref34.transform,p=_ref34.continuousAxisChannelDef,m=_ref34.continuousAxis,g=_ref34.groupby,v=_ref34.aggregate,b=_ref34.encodingWithoutContinuousAxis,x=_ref34.ticksOrient,w=_ref34.boxOrient,k=_ref34.customTooltipWithoutAggregatedField,C=b.size,A=yM(b,["color","size"]),O=function O(t){return mV(c,m,p,t,e.boxplot);},_=O(A),S=O(b),D=O(Object.assign(Object.assign({},A),C?{size:C}:{})),F=dV([{fieldPrefix:"min-max"===h?"upper_whisker_":"max_",titlePrefix:"Max"},{fieldPrefix:"upper_box_",titlePrefix:"Q3"},{fieldPrefix:"mid_box_",titlePrefix:"Median"},{fieldPrefix:"lower_box_",titlePrefix:"Q1"},{fieldPrefix:"min-max"===h?"lower_whisker_":"min_",titlePrefix:"Min"}],p,b),T={type:"tick",color:"black",opacity:1,orient:x,invalid:null},N="min-max"===h?F:dV([{fieldPrefix:"upper_whisker_",titlePrefix:"Upper Whisker"},{fieldPrefix:"lower_whisker_",titlePrefix:"Lower Whisker"}],p,b),I=[].concat(_toConsumableArray(_({partName:"rule",mark:{type:"rule",invalid:null},positionPrefix:"lower_whisker",endPositionPrefix:"lower_box",aria:!1,extraEncoding:N})),_toConsumableArray(_({partName:"rule",mark:{type:"rule",invalid:null},positionPrefix:"upper_box",endPositionPrefix:"upper_whisker",aria:!1,extraEncoding:N})),_toConsumableArray(_({partName:"ticks",mark:T,positionPrefix:"lower_whisker",aria:!1,extraEncoding:N})),_toConsumableArray(_({partName:"ticks",mark:T,positionPrefix:"upper_whisker",aria:!1,extraEncoding:N}))),R=[].concat(_toConsumableArray("tukey"!==h?I:[]),_toConsumableArray(S({partName:"box",mark:Object.assign(Object.assign({type:"bar"},f?{size:f}:{}),{orient:w,invalid:null}),positionPrefix:"lower_box",endPositionPrefix:"upper_box",aria:!1,extraEncoding:F})),_toConsumableArray(D({partName:"median",mark:Object.assign(Object.assign(Object.assign({type:"tick",invalid:null},iM(e.boxplot.median)&&e.boxplot.median.color?{color:e.boxplot.median.color}:{}),f?{size:f}:{}),{orient:x,ariaRoleDescription:"box"}),positionPrefix:"mid_box",extraEncoding:F})));var M;if("min-max"!==h){var _t136="datum[\"lower_box_".concat(p.field,"\"]"),_n116="datum[\"upper_box_".concat(p.field,"\"]"),_r118="(".concat(_n116," - ").concat(_t136,")"),_i85="".concat(_t136," - ").concat(l," * ").concat(_r118),_o46="".concat(_n116," + ").concat(l," * ").concat(_r118),_a46="datum[\"".concat(p.field,"\"]"),_s39={joinaggregate:CV(p.field),groupby:g};var _u20=void 0;"tukey"===h&&(_u20={transform:[{filter:"(".concat(_i85," <= ").concat(_a46,") && (").concat(_a46," <= ").concat(_o46,")")},{aggregate:[{op:"min",field:p.field,as:"lower_whisker_"+p.field},{op:"max",field:p.field,as:"upper_whisker_"+p.field},{op:"min",field:"lower_box_"+p.field,as:"lower_box_"+p.field},{op:"max",field:"upper_box_"+p.field,as:"upper_box_"+p.field}].concat(_toConsumableArray(v)),groupby:g}],layer:I});var _d7=yM(A,["tooltip"]),_y5=p.scale,_b3=p.axis,_x31=pV(p),_w3=gV(c,"outliers",e.boxplot,!0,{transform:[{filter:"(".concat(_a46," < ").concat(_i85,") || (").concat(_a46," > ").concat(_o46,")")}],mark:"point",encoding:Object.assign(Object.assign(_defineProperty({},m,Object.assign(Object.assign(Object.assign({field:p.field,type:p.type},void 0!==_x31?{title:_x31}:{}),void 0!==_y5?{scale:_y5}:{}),void 0!==_b3?{axis:_b3}:{})),_d7),k?{tooltip:k}:{})})[0];_w3&&_u20?M={transform:[_s39],layer:[_w3,_u20]}:_w3?(M=_w3).transform.unshift(_s39):_u20&&(M=_u20).transform.unshift(_s39);}return M?Object.assign(Object.assign({},u),{layer:[M,{transform:d,layer:R}]}):Object.assign(Object.assign({},u),{transform:(null!==(r=u.transform)&&void 0!==r?r:[]).concat(d),layer:R});}function CV(t){return [{op:"q1",field:t,as:"lower_box_"+t},{op:"q3",field:t,as:"upper_box_"+t}];}var AV="errorbar",OV=new Uj(AV,_V);function _V(t,_ref36){var e=_ref36.config;var _DV=DV(t,AV,e),n=_DV.transform,r=_DV.continuousAxisChannelDef,i=_DV.continuousAxis,o=_DV.encodingWithoutContinuousAxis,a=_DV.ticksOrient,s=_DV.markDef,u=_DV.outerSpec,c=_DV.tooltipEncoding,l=mV(s,i,r,o,e.errorbar),f={type:"tick",orient:a},h=[].concat(_toConsumableArray(l({partName:"ticks",mark:f,positionPrefix:"lower",aria:!1,extraEncoding:c})),_toConsumableArray(l({partName:"ticks",mark:f,positionPrefix:"upper",aria:!1,extraEncoding:c})),_toConsumableArray(l({partName:"rule",mark:{type:"rule",ariaRoleDescription:"errorbar"},positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:c})));return Object.assign(Object.assign(Object.assign({},u),{transform:n}),h.length>1?{layer:h}:Object.assign({},h[0]));}function SV(t,e){var n=t.encoding;if(function(t){return (yW(t.x)||yW(t.y))&&!yW(t.x2)&&!yW(t.y2)&&!yW(t.xError)&&!yW(t.xError2)&&!yW(t.yError)&&!yW(t.yError2);}(n))return {orient:bV(t,e),inputType:"raw"};var r=function(t){return yW(t.x2)||yW(t.y2);}(n),i=function(t){return yW(t.xError)||yW(t.xError2)||yW(t.yError)||yW(t.yError2);}(n),o=n.x,a=n.y;if(r){if(i)throw new Error("".concat(e," cannot be both type aggregated-upper-lower and aggregated-error"));var _t137=n.x2,_r119=n.y2;if(yW(_t137)&&yW(_r119))throw new Error("".concat(e," cannot have both x2 and y2"));if(yW(_t137)){if(gW(o))return {orient:"horizontal",inputType:"aggregated-upper-lower"};throw new Error("Both x and x2 have to be quantitative in ".concat(e));}if(yW(_r119)){if(gW(a))return {orient:"vertical",inputType:"aggregated-upper-lower"};throw new Error("Both y and y2 have to be quantitative in ".concat(e));}throw new Error("No ranged axis");}{var _t138=n.xError,_r120=n.xError2,_i86=n.yError,_s40=n.yError2;if(yW(_r120)&&!yW(_t138))throw new Error("".concat(e," cannot have xError2 without xError"));if(yW(_s40)&&!yW(_i86))throw new Error("".concat(e," cannot have yError2 without yError"));if(yW(_t138)&&yW(_i86))throw new Error("".concat(e," cannot have both xError and yError with both are quantiative"));if(yW(_t138)){if(gW(o))return {orient:"horizontal",inputType:"aggregated-error"};throw new Error("All x, xError, and xError2 (if exist) have to be quantitative");}if(yW(_i86)){if(gW(a))return {orient:"vertical",inputType:"aggregated-error"};throw new Error("All y, yError, and yError2 (if exist) have to be quantitative");}throw new Error("No ranged axis");}}function DV(t,e,n){var r;var i=t.mark,o=t.encoding,a=t.selection;t.projection;var u=yM(t,["mark","encoding","selection","projection"]),c=Rj(i)?i:{type:i};a&&mz(y.selectionNotSupported(e));var _SV=SV(t,e),l=_SV.orient,f=_SV.inputType,_vV2=vV(t,l,e),h=_vV2.continuousAxisChannelDef,d=_vV2.continuousAxisChannelDef2,p=_vV2.continuousAxisChannelDefError,m=_vV2.continuousAxisChannelDefError2,g=_vV2.continuousAxis,_ref37=function(t,e,n,r,i,o,a,s){var u=[],c=[];var l=e.field;var f,h=!1;if("raw"===o){var _e141=t.center?t.center:t.extent?"iqr"===t.extent?"median":"mean":s.errorbar.center,_n117=t.extent?t.extent:"mean"===_e141?"stderr":"iqr";if("median"===_e141!=("iqr"===_n117)&&mz(y.errorBarCenterIsUsedWithWrongExtent(_e141,_n117,a)),"stderr"===_n117||"stdev"===_n117)u=[{op:_n117,field:l,as:"extent_"+l},{op:_e141,field:l,as:"center_"+l}],c=[{calculate:"datum[\"center_".concat(l,"\"] + datum[\"extent_").concat(l,"\"]"),as:"upper_"+l},{calculate:"datum[\"center_".concat(l,"\"] - datum[\"extent_").concat(l,"\"]"),as:"lower_"+l}],f=[{fieldPrefix:"center_",titlePrefix:JM(_e141)},{fieldPrefix:"upper_",titlePrefix:FV(_e141,_n117,"+")},{fieldPrefix:"lower_",titlePrefix:FV(_e141,_n117,"-")}],h=!0;else {var _e142,_r121,_i87;t.center&&t.extent&&mz(y.errorBarCenterIsNotNeeded(t.extent,a)),"ci"===_n117?(_e142="mean",_r121="ci0",_i87="ci1"):(_e142="median",_r121="q1",_i87="q3"),u=[{op:_r121,field:l,as:"lower_"+l},{op:_i87,field:l,as:"upper_"+l},{op:_e142,field:l,as:"center_"+l}],f=[{fieldPrefix:"upper_",titlePrefix:TW({field:l,aggregate:_i87,type:"quantitative"},s,{allowDisabling:!1})},{fieldPrefix:"lower_",titlePrefix:TW({field:l,aggregate:_r121,type:"quantitative"},s,{allowDisabling:!1})},{fieldPrefix:"center_",titlePrefix:TW({field:l,aggregate:_e142,type:"quantitative"},s,{allowDisabling:!1})}];}}else {(t.center||t.extent)&&mz(y.errorBarCenterAndExtentAreNotNeeded(t.center,t.extent)),"aggregated-upper-lower"===o?(f=[],c=[{calculate:"datum[\"".concat(n.field,"\"]"),as:"upper_"+l},{calculate:"datum[\"".concat(l,"\"]"),as:"lower_"+l}]):"aggregated-error"===o&&(f=[{fieldPrefix:"",titlePrefix:l}],c=[{calculate:"datum[\"".concat(l,"\"] + datum[\"").concat(r.field,"\"]"),as:"upper_"+l}],i?c.push({calculate:"datum[\"".concat(l,"\"] + datum[\"").concat(i.field,"\"]"),as:"lower_"+l}):c.push({calculate:"datum[\"".concat(l,"\"] - datum[\"").concat(r.field,"\"]"),as:"lower_"+l}));var _iterator53=_createForOfIteratorHelper(c),_step53;try{for(_iterator53.s();!(_step53=_iterator53.n()).done;){var _t139=_step53.value;f.push({fieldPrefix:_t139.as.substring(0,6),titlePrefix:ej(ej(_t139.calculate,'datum["',""),'"]',"")});}}catch(err){_iterator53.e(err);}finally{_iterator53.f();}}return {postAggregateCalculates:c,errorBarSpecificAggregate:u,tooltipSummary:f,tooltipTitleWithFieldName:h};}(c,h,d,p,m,f,e,n),v=_ref37.errorBarSpecificAggregate,b=_ref37.postAggregateCalculates,x=_ref37.tooltipSummary,w=_ref37.tooltipTitleWithFieldName,k=o,E=g,C=(k[E],"x"===g?"x2":"y2"),A=(k[C],"x"===g?"xError":"yError"),O=(k[A],"x"===g?"xError2":"yError2"),_=(k[O],yM(k,["symbol"==_typeof$1(E)?E:E+"","symbol"==_typeof$1(C)?C:C+"","symbol"==_typeof$1(A)?A:A+"","symbol"==_typeof$1(O)?O:O+""])),_uV2=uV(_,n),S=_uV2.bins,D=_uV2.timeUnits,F=_uV2.aggregate,T=_uV2.groupby,N=_uV2.encoding,I=[].concat(_toConsumableArray(F),_toConsumableArray(v)),R="raw"!==f?[]:T,M=dV(x,h,N,w);return {transform:[].concat(_toConsumableArray(null!==(r=u.transform)&&void 0!==r?r:[]),_toConsumableArray(S),_toConsumableArray(D),_toConsumableArray(0===I.length?[]:[{aggregate:I,groupby:R}]),_toConsumableArray(b)),groupby:R,continuousAxisChannelDef:h,continuousAxis:g,encodingWithoutContinuousAxis:N,ticksOrient:"vertical"===l?"horizontal":"vertical",markDef:c,outerSpec:u,tooltipEncoding:M};}function FV(t,e,n){return JM(t)+" "+n+" "+e;}var TV="errorband",NV=new Uj(TV,IV);function IV(t,_ref38){var e=_ref38.config;var _DV2=DV(t,TV,e),n=_DV2.transform,r=_DV2.continuousAxisChannelDef,i=_DV2.continuousAxis,o=_DV2.encodingWithoutContinuousAxis,a=_DV2.markDef,s=_DV2.outerSpec,u=_DV2.tooltipEncoding,c=a,l=mV(c,i,r,o,e.errorband),f=void 0!==t.encoding.x&&void 0!==t.encoding.y;var h={type:f?"area":"rect"},d={type:f?"line":"rule"};var p=Object.assign(Object.assign({},c.interpolate?{interpolate:c.interpolate}:{}),c.tension&&c.interpolate?{tension:c.tension}:{});return f?(h=Object.assign(Object.assign(Object.assign({},h),p),{ariaRoleDescription:"errorband"}),d=Object.assign(Object.assign({},d),p)):c.interpolate?mz(y.errorBand1DNotSupport("interpolate")):c.tension&&mz(y.errorBand1DNotSupport("tension")),Object.assign(Object.assign({},s),{transform:n,layer:[].concat(_toConsumableArray(l({partName:"band",mark:h,positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:u})),_toConsumableArray(l({partName:"borders",mark:d,positionPrefix:"lower",aria:!1,extraEncoding:u})),_toConsumableArray(l({partName:"borders",mark:d,positionPrefix:"upper",aria:!1,extraEncoding:u})))});}var RV={};function MV(t,e,n){var r=new Uj(t,e);RV[t]={normalizer:r,parts:n};}MV(xV,EV,["box","median","outliers","rule","ticks"]),MV(AV,_V,["ticks","rule"]),MV(TV,IV,["band","borders"]);var jV=["gradientHorizontalMaxLength","gradientHorizontalMinLength","gradientVerticalMaxLength","gradientVerticalMinLength","unselectedOpacity"],BV=["size","shape","fill","stroke","strokeDash","strokeWidth","opacity"],PV={fillColor:{part:"legend",vgProp:"fill"},gradientStrokeColor:{part:"gradient",vgProp:"stroke"},labelColor:{part:"labels",vgProp:"fill"},strokeColor:{part:"legend",vgProp:"stroke"},symbolFillColor:{part:"symbols",vgProp:"fill"},symbolStrokeColor:{part:"symbols",vgProp:"stroke"},titleColor:{part:"title",vgProp:"fill"}},LV={aria:1,clipHeight:1,columnPadding:1,columns:1,cornerRadius:1,description:1,direction:1,fillColor:1,format:1,formatType:1,gradientLength:1,gradientOpacity:1,gradientStrokeColor:1,gradientStrokeWidth:1,gradientThickness:1,gridAlign:1,labelAlign:1,labelBaseline:1,labelColor:1,labelFont:1,labelFontSize:1,labelFontStyle:1,labelFontWeight:1,labelLimit:1,labelOffset:1,labelOpacity:1,labelOverlap:1,labelPadding:1,labelSeparation:1,legendX:1,legendY:1,offset:1,orient:1,padding:1,rowPadding:1,strokeColor:1,symbolDash:1,symbolDashOffset:1,symbolFillColor:1,symbolLimit:1,symbolOffset:1,symbolOpacity:1,symbolSize:1,symbolStrokeColor:1,symbolStrokeWidth:1,symbolType:1,tickCount:1,tickMinStep:1,title:1,titleAlign:1,titleAnchor:1,titleBaseline:1,titleColor:1,titleFont:1,titleFontSize:1,titleFontStyle:1,titleFontWeight:1,titleLimit:1,titleLineHeight:1,titleOpacity:1,titleOrient:1,titlePadding:1,type:1,values:1,zindex:1},zV=("_vgsid_"),UV={single:{on:"click",fields:[zV],resolve:"global",empty:"all",clear:"dblclick"},multi:{on:"click",fields:[zV],toggle:"event.shiftKey",resolve:"global",empty:"all",clear:"dblclick"},interval:{on:"[mousedown, window:mouseup] > window:mousemove!",encodings:["x","y"],translate:"[mousedown, window:mouseup] > window:mousemove!",zoom:"wheel!",mark:{fill:"#333",fillOpacity:.125,stroke:"white"},resolve:"global",clear:"dblclick"}};function WV(t){return !(!t||"legend"!==t&&!t.legend);}function VV(t){return WV(t)&&iM(t);}function qV(t){return "concat"in t;}function $V(t){return "vconcat"in t;}function HV(t){return "hconcat"in t;}function GV(t){return iM(t)&&void 0!==t.step;}function KV(t){return t.view||t.width||t.height;}var XV=qM({align:1,bounds:1,center:1,columns:1,spacing:1});function YV(t,e){var n;return null!==(n=t[e])&&void 0!==n?n:t["width"===e?"continuousWidth":"continuousHeight"];}function JV(t,e){var n=QV(t,e);return GV(n)?n.step:ZV;}function QV(t,e){var n;return ij(null!==(n=t[e])&&void 0!==n?n:t["width"===e?"discreteWidth":"discreteHeight"],{step:t.step});}var ZV=20;var tq={background:"white",padding:5,timeFormat:"%b %d, %Y",countTitle:"Count of Records",view:{continuousWidth:200,continuousHeight:200,step:ZV},mark:{color:"#4c78a8",invalid:"filter",timeUnitBand:1},arc:{},area:{},bar:Pj,circle:{},geoshape:{},image:{},line:{},point:{},rect:Lj,rule:{color:"black"},square:{},text:{color:"black"},tick:{thickness:1},trail:{},boxplot:{size:14,extent:1.5,box:{},median:{color:"white"},outliers:{},rule:{},ticks:null},errorbar:{center:"mean",rule:!0,ticks:!1},errorband:{band:{opacity:.3},borders:!1},scale:{pointPadding:.5,barBandPaddingInner:.1,rectBandPaddingInner:0,minBandSize:2,minFontSize:8,maxFontSize:40,minOpacity:.3,maxOpacity:.8,minSize:9,minStrokeWidth:1,maxStrokeWidth:4,quantileCount:4,quantizeCount:4},projection:{},legend:{gradientHorizontalMaxLength:200,gradientHorizontalMinLength:100,gradientVerticalMaxLength:200,gradientVerticalMinLength:64,unselectedOpacity:.35},header:{titlePadding:10,labelPadding:10},headerColumn:{},headerRow:{},headerFacet:{},selection:UV,style:{},title:{},facet:{spacing:20},concat:{spacing:20}},eq=["#4c78a8","#f58518","#e45756","#72b7b2","#54a24b","#eeca3b","#b279a2","#ff9da6","#9d755d","#bab0ac"],nq={text:11,guideLabel:10,guideTitle:11,groupTitle:13,groupSubtitle:12},rq={blue:eq[0],orange:eq[1],red:eq[2],teal:eq[3],green:eq[4],yellow:eq[5],purple:eq[6],pink:eq[7],brown:eq[8],gray0:"#000",gray1:"#111",gray2:"#222",gray3:"#333",gray4:"#444",gray5:"#555",gray6:"#666",gray7:"#777",gray8:"#888",gray9:"#999",gray10:"#aaa",gray11:"#bbb",gray12:"#ccc",gray13:"#ddd",gray14:"#eee",gray15:"#fff"};function iq(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var e=t.color,n=t.font,r=t.fontSize,i=yM(t,["color","font","fontSize"]);return aM({},tq,n?function(t){return {text:{font:t},style:{"guide-label":{font:t},"guide-title":{font:t},"group-title":{font:t},"group-subtitle":{font:t}}};}(n):{},e?function(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return {signals:[{name:"color",value:iM(t)?Object.assign(Object.assign({},rq),t):rq}],mark:{color:{signal:"color.blue"}},rule:{color:{signal:"color.gray0"}},text:{color:{signal:"color.gray0"}},style:{"guide-label":{fill:{signal:"color.gray0"}},"guide-title":{fill:{signal:"color.gray0"}},"group-title":{fill:{signal:"color.gray0"}},"group-subtitle":{fill:{signal:"color.gray0"}},cell:{stroke:{signal:"color.gray8"}}},axis:{domainColor:{signal:"color.gray13"},gridColor:{signal:"color.gray8"},tickColor:{signal:"color.gray13"}},range:{category:[{signal:"color.blue"},{signal:"color.orange"},{signal:"color.red"},{signal:"color.teal"},{signal:"color.green"},{signal:"color.yellow"},{signal:"color.purple"},{signal:"color.pink"},{signal:"color.brown"},{signal:"color.grey8"}]}};}(e):{},r?function(t){return {signals:[{name:"fontSize",value:iM(t)?Object.assign(Object.assign({},nq),t):nq}],text:{fontSize:{signal:"fontSize.text"}},style:{"guide-label":{fontSize:{signal:"fontSize.guideLabel"}},"guide-title":{fontSize:{signal:"fontSize.guideTitle"}},"group-title":{fontSize:{signal:"fontSize.groupTitle"}},"group-subtitle":{fontSize:{signal:"fontSize.groupSubtitle"}}}};}(r):{},i||{});}var oq=["view"].concat(_toConsumableArray(Ij)),aq=["color","fontSize","background","padding","facet","concat","numberFormat","timeFormat","countTitle","header","axisQuantitative","axisTemporal","axisDiscrete","axisPoint","axisXBand","axisXPoint","axisXDiscrete","axisXQuantitative","axisXTemporal","axisYBand","axisYPoint","axisYDiscrete","axisYQuantitative","axisYTemporal","scale","selection","overlay"],sq=Object.assign({view:["continuousWidth","continuousHeight","discreteWidth","discreteHeight","step"]},{area:["line","point"],bar:["binSpacing","continuousBandSize","discreteBandSize"],rect:["binSpacing","continuousBandSize","discreteBandSize"],line:["point"],tick:["bandSize","thickness"]});function uq(t){t=DM(t);var _iterator54=_createForOfIteratorHelper(aq),_step54;try{for(_iterator54.s();!(_step54=_iterator54.n()).done;){var _e147=_step54.value;delete t[_e147];}}catch(err){_iterator54.e(err);}finally{_iterator54.f();}if(t.axis)for(var _e143 in t.axis){lj(t.axis[_e143])&&delete t.axis[_e143];}if(t.legend){var _iterator55=_createForOfIteratorHelper(jV),_step55;try{for(_iterator55.s();!(_step55=_iterator55.n()).done;){var _e144=_step55.value;delete t.legend[_e144];}}catch(err){_iterator55.e(err);}finally{_iterator55.f();}}if(t.mark){var _iterator56=_createForOfIteratorHelper(jj),_step56;try{for(_iterator56.s();!(_step56=_iterator56.n()).done;){var _e145=_step56.value;delete t.mark[_e145];}}catch(err){_iterator56.e(err);}finally{_iterator56.f();}t.mark.tooltip&&iM(t.mark.tooltip)&&delete t.mark.tooltip;}var _iterator57=_createForOfIteratorHelper(oq),_step57;try{for(_iterator57.s();!(_step57=_iterator57.n()).done;){var _e148=_step57.value;var _iterator59=_createForOfIteratorHelper(jj),_step59;try{for(_iterator59.s();!(_step59=_iterator59.n()).done;){var _n119=_step59.value;delete t[_e148][_n119];}}catch(err){_iterator59.e(err);}finally{_iterator59.f();}var _n118=sq[_e148];if(_n118){var _iterator60=_createForOfIteratorHelper(_n118),_step60;try{for(_iterator60.s();!(_step60=_iterator60.n()).done;){var _r122=_step60.value;delete t[_e148][_r122];}}catch(err){_iterator60.e(err);}finally{_iterator60.f();}}cq(t,_e148);}}catch(err){_iterator57.e(err);}finally{_iterator57.f();}var _iterator58=_createForOfIteratorHelper(qM(RV)),_step58;try{for(_iterator58.s();!(_step58=_iterator58.n()).done;){var _e149=_step58.value;delete t[_e149];}}catch(err){_iterator58.e(err);}finally{_iterator58.f();}!function(t){var _HW=HW(t.title),e=_HW.titleMarkConfig,n=_HW.subtitleMarkConfig,r=_HW.subtitle;VM(e)||(t.style["group-title"]=Object.assign(Object.assign({},t.style["group-title"]),e));VM(n)||(t.style["group-subtitle"]=Object.assign(Object.assign({},t.style["group-subtitle"]),n));VM(r)?delete t.title:t.title=r;}(t);for(var _e146 in t){iM(t[_e146])&&VM(t[_e146])&&delete t[_e146];}return VM(t)?void 0:t;}function cq(t,e,n,r){var i=r?t[e][r]:t[e];"view"===e&&(n="cell");var o=Object.assign(Object.assign({},i),t.style[null!==n&&void 0!==n?n:e]);VM(o)||(t.style[null!==n&&void 0!==n?n:e]=o),r||delete t[e];}function lq(t){return "layer"in t;}var fq=/*#__PURE__*/function(){function fq(){_classCallCheck(this,fq);}_createClass(fq,[{key:"map",value:function map(t,e){return oW(t)?this.mapFacet(t,e):function(t){return "repeat"in t;}(t)?this.mapRepeat(t,e):HV(t)?this.mapHConcat(t,e):$V(t)?this.mapVConcat(t,e):qV(t)?this.mapConcat(t,e):this.mapLayerOrUnit(t,e);}},{key:"mapLayerOrUnit",value:function mapLayerOrUnit(t,e){if(lq(t))return this.mapLayer(t,e);if(zj(t))return this.mapUnit(t,e);throw new Error(y.invalidSpec(t));}},{key:"mapLayer",value:function mapLayer(t,e){var _this25=this;return Object.assign(Object.assign({},t),{layer:t.layer.map(function(t){return _this25.mapLayerOrUnit(t,e);})});}},{key:"mapHConcat",value:function mapHConcat(t,e){var _this26=this;return Object.assign(Object.assign({},t),{hconcat:t.hconcat.map(function(t){return _this26.map(t,e);})});}},{key:"mapVConcat",value:function mapVConcat(t,e){var _this27=this;return Object.assign(Object.assign({},t),{vconcat:t.vconcat.map(function(t){return _this27.map(t,e);})});}},{key:"mapConcat",value:function mapConcat(t,e){var _this28=this;var n=t.concat,r=yM(t,["concat"]);return Object.assign(Object.assign({},r),{concat:n.map(function(t){return _this28.map(t,e);})});}},{key:"mapFacet",value:function mapFacet(t,e){return Object.assign(Object.assign({},t),{spec:this.map(t.spec,e)});}},{key:"mapRepeat",value:function mapRepeat(t,e){return Object.assign(Object.assign({},t),{spec:this.map(t.spec,e)});}}]);return fq;}();var hq={zero:1,center:1,normalize:1};var dq=new Set([vj,bj,yj,Cj,kj,Sj,Dj,wj,Aj,Oj]),pq=new Set([bj,yj,vj]);function mq(t,e){var n,r;var i="x"===e?"y":"radius",o=t[e],a=t[i];if(dW(o)&&dW(a)){if("quantitative"===pW(o)&&"quantitative"===pW(a)){if(o.stack)return e;if(a.stack)return i;var _t140=dW(o)&&!!o.aggregate;if(_t140!==(dW(a)&&!!a.aggregate))return _t140?e:i;{var _t141=null===(n=o.scale)||void 0===n?void 0:n.type,_s41=null===(r=a.scale)||void 0===r?void 0:r.type;if(_t141&&"linear"!==_t141)return i;if(_s41&&"linear"!==_s41)return e;}}else {if("quantitative"===pW(o))return e;if("quantitative"===pW(a))return i;}}else {if("quantitative"===pW(o))return e;if("quantitative"===pW(a))return i;}}function gq(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var r=Rj(t)?t.type:t;if(!dq.has(r))return null;var i=mq(e,"x")||mq(e,"theta");if(!i)return null;var o=e[i],a=dW(o)?AW(o,{}):void 0;var s=function(t){switch(t){case"x":return "y";case"y":return "x";case"theta":return "radius";case"radius":return "theta";}}(i),u=e[s],c=dW(u)?AW(u,{}):void 0;c===a&&(c=void 0,u=void 0,s=void 0);var l=gP.reduce(function(t,n){if("tooltip"!==n&&aV(e,n)){var _r123=e[n];var _iterator61=_createForOfIteratorHelper(cM(_r123)),_step61;try{for(_iterator61.s();!(_step61=_iterator61.n()).done;){var _e150=_step61.value;var _r124=MW(_e150);if(_r124.aggregate)continue;var _i88=AW(_r124,{});_i88&&_i88===c||t.push({channel:n,fieldDef:_r124});}}catch(err){_iterator61.e(err);}finally{_iterator61.f();}}return t;},[]);var f;if(void 0!==o.stack?f=dM(o.stack)?o.stack?"zero":null:o.stack:l.length>0&&pq.has(r)&&(f="zero"),!f||!function(t){return t in hq;}(f))return null;if(sV(e)&&0===l.length)return null;if(o.scale&&o.scale.type&&o.scale.type!==rU.LINEAR){if(n.disallowNonLinearStack)return null;mz(y.cannotStackNonLinearScale(o.scale.type));}return yW(e[eP(i)])?(void 0!==o.stack&&mz(y.cannotStackRangedMark(i)),null):(dW(o)&&o.aggregate&&!MM(Xj,o.aggregate)&&mz(y.stackNonSummativeAggregate(o.aggregate)),{groupbyChannel:u?s:void 0,groupbyField:c,fieldChannel:i,impute:null!==o.impute&&Tj(r),stackBy:l,offset:f});}function vq(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var n=arguments.length>2?arguments[2]:undefined;return "transparent"===t.point?{opacity:0}:t.point?iM(t.point)?t.point:{}:void 0!==t.point?null:e.point||n.shape?iM(e.point)?e.point:{}:void 0;}function yq(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return t.line?!0===t.line?{}:t.line:void 0!==t.line?null:e.line?!0===e.line?{}:e.line:void 0;}var bq=/*#__PURE__*/function(){function bq(){_classCallCheck(this,bq);this.name="path-overlay";}_createClass(bq,[{key:"hasMatchingType",value:function hasMatchingType(t,e){if(zj(t)){var _n120=t.mark,_r125=t.encoding,_i89=Rj(_n120)?_n120:{type:_n120};switch(_i89.type){case"line":case"rule":case"trail":return !!vq(_i89,e[_i89.type],_r125);case"area":return !!vq(_i89,e[_i89.type],_r125)||!!yq(_i89,e[_i89.type]);}}return !1;}},{key:"run",value:function run(t,e,n){var r=e.config,i=t.selection,o=t.projection,a=t.encoding,s=t.mark,u=yM(t,["selection","projection","encoding","mark"]),c=Rj(s)?s:{type:s},l=vq(c,r[c.type],a),f="area"===c.type&&yq(c,r[c.type]),h=[Object.assign(Object.assign({},i?{selection:i}:{}),{mark:function(t){t.point;t.line;var r=yM(t,["point","line"]);return qM(r).length>1?r:r.type;}(Object.assign(Object.assign({},"area"===c.type&&void 0===c.opacity&&void 0===c.fillOpacity?{opacity:.7}:{}),c)),encoding:TM(a,["shape"])})],d=gq(c,a);var p=a;if(d){var _t142=d.fieldChannel,_e151=d.offset;p=Object.assign(Object.assign({},a),_defineProperty({},_t142,Object.assign(Object.assign({},a[_t142]),_e151?{stack:_e151}:{})));}return f&&h.push(Object.assign(Object.assign({},o?{projection:o}:{}),{mark:Object.assign(Object.assign({type:"line"},FM(c,["clip","interpolate","tension","tooltip"])),f),encoding:p})),l&&h.push(Object.assign(Object.assign({},o?{projection:o}:{}),{mark:Object.assign(Object.assign({type:"point",opacity:1,filled:!0},FM(c,["clip","tooltip"])),l),encoding:p})),n(Object.assign(Object.assign({},u),{layer:h}),Object.assign(Object.assign({},e),{config:function(t){for(var _i90=0,_arr2=["line","area","rule","trail"];_i90<_arr2.length;_i90++){var _e152=_arr2[_i90];t[_e152]&&(t=Object.assign(Object.assign({},t),_defineProperty({},_e152,TM(t[_e152],["point","line"]))));}return t;}(r)}));}}]);return bq;}();var xq=/*#__PURE__*/function(){function xq(){_classCallCheck(this,xq);this.name="RangeStep";}_createClass(xq,[{key:"hasMatchingType",value:function hasMatchingType(t){var e;if(zj(t)&&t.encoding){var _iterator62=_createForOfIteratorHelper(yP),_step62;try{for(_iterator62.s();!(_step62=_iterator62.n()).done;){var _n121=_step62.value;var _r126=t.encoding[_n121];if(_r126&&yW(_r126)&&(null===(e=null===_r126||void 0===_r126?void 0:_r126.scale)||void 0===e?void 0:e.rangeStep))return !0;}}catch(err){_iterator62.e(err);}finally{_iterator62.f();}}return !1;}},{key:"run",value:function run(t){var e;var n={};var r=Object.assign({},t.encoding);var _iterator63=_createForOfIteratorHelper(yP),_step63;try{for(_iterator63.s();!(_step63=_iterator63.n()).done;){var _t143=_step63.value;var _i91=nP(_t143),_o47=r[_t143];if(_o47&&yW(_o47)&&(null===(e=null===_o47||void 0===_o47?void 0:_o47.scale)||void 0===e?void 0:e.rangeStep)){var _e153=_o47.scale,_a47=yM(_o47,["scale"]),_s42=_e153,_u21=_s42.rangeStep,_c18=yM(_s42,["rangeStep"]);n[_i91]={step:_e153.rangeStep},mz(y.RANGE_STEP_DEPRECATED),r=Object.assign(Object.assign({},r),_defineProperty({},_t143,Object.assign(Object.assign({},_a47),VM(_c18)?{}:{scale:_c18})));}}}catch(err){_iterator63.e(err);}finally{_iterator63.f();}return Object.assign(Object.assign(Object.assign({},n),t),{encoding:r});}}]);return xq;}();function wq(t,e){return e?Oq(t,e):t;}function kq(t,e,n){var r=e[t];return function(t){return t&&!mM(t)&&"repeat"in t;}(r)?r.repeat in n?Object.assign(Object.assign({},e),_defineProperty({},t,n[r.repeat])):void mz(y.noSuchRepeatedValue(r.repeat)):e;}function Eq(t,e){if(void 0!==(t=kq("field",t,e))){if(null===t)return null;if(sW(t)&&eW(t.sort)){var _n122=kq("field",t.sort,e);t=Object.assign(Object.assign({},t),_n122?{sort:_n122}:{});}return t;}}function Cq(t,e){if(dW(t))return Eq(t,e);{var _n123=kq("datum",t,e);return _n123===t||_n123.type||(_n123.type="nominal"),_n123;}}function Aq(t,e){if(!yW(t)){if(hW(t)){var _n124=Cq(t.condition,e);if(_n124)return Object.assign(Object.assign({},t),{condition:_n124});{t.condition;return yM(t,["condition"]);}}return t;}{var _n125=Cq(t,e);if(_n125)return _n125;if(lW(t))return {condition:t.condition};}}function Oq(t,e){var n={};for(var _r127 in t){if(hM(t,_r127)){var _i92=t[_r127];if(rM(_i92))n[_r127]=_i92.map(function(t){return Aq(t,e);}).filter(function(t){return t;});else {var _t144=Aq(_i92,e);void 0!==_t144&&(n[_r127]=_t144);}}}return n;}var _q=/*#__PURE__*/function(){function _q(){_classCallCheck(this,_q);this.name="RuleForRangedLine";}_createClass(_q,[{key:"hasMatchingType",value:function hasMatchingType(t){if(zj(t)){var _e155=t.encoding,_n126=t.mark;if("line"===_n126){var _iterator64=_createForOfIteratorHelper(JB),_step64;try{for(_iterator64.s();!(_step64=_iterator64.n()).done;){var _t145=_step64.value;var _n127=_e155[ZB(_t145)];if(_e155[_t145]&&(dW(_n127)&&!VP(_n127.bin)||mW(_n127)))return !0;}}catch(err){_iterator64.e(err);}finally{_iterator64.f();}}}return !1;}},{key:"run",value:function run(t,e,n){var r=t.encoding;return mz(y.lineWithRange(!!r.x2,!!r.y2)),n(Object.assign(Object.assign({},t),{mark:"rule"}),e);}}]);return _q;}();function Sq(t){var e=t.parentEncoding,n=t.encoding;if(e&&n){var _t146=qM(e).reduce(function(t,e){return n[e]&&t.push(e),t;},[]);_t146.length>0&&mz(y.encodingOverridden(_t146));}var r=Object.assign(Object.assign({},null!==e&&void 0!==e?e:{}),null!==n&&void 0!==n?n:{});return VM(r)?void 0:r;}function Dq(t){var e=t.parentProjection,n=t.projection;return e&&n&&mz(y.projectionOverridden({parentProjection:e,projection:n})),null!==n&&void 0!==n?n:e;}function Fq(t,e){void 0===e&&(e=iq(t.config));var n=function(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return Tq.map(t,{config:e});}(t,e),r=t.width,i=t.height,o=function(t,e,n){var r=e.width,i=e.height;var o=zj(t)||lq(t),a={};o?"container"==r&&"container"==i?(a.type="fit",a.contains="padding"):"container"==r?(a.type="fit-x",a.contains="padding"):"container"==i&&(a.type="fit-y",a.contains="padding"):("container"==r&&(mz(y.containerSizeNonSingle("width")),r=void 0),"container"==i&&(mz(y.containerSizeNonSingle("height")),i=void 0));var s=Object.assign(Object.assign(Object.assign({type:"pad"},a),n?Nq(n.autosize):{}),Nq(t.autosize));"fit"!==s.type||o||(mz(y.FIT_NON_SINGLE),s.type="pad");"container"==r&&"fit"!=s.type&&"fit-x"!=s.type&&mz(y.containerSizeNotCompatibleWithAutosize("width"));"container"==i&&"fit"!=s.type&&"fit-y"!=s.type&&mz(y.containerSizeNotCompatibleWithAutosize("height"));if(SM(s,{type:"pad"}))return;return s;}(n,{width:r,height:i,autosize:t.autosize},e);return Object.assign(Object.assign({},n),o?{autosize:o}:{});}var Tq=new(/*#__PURE__*/function(_fq){_inherits(_class,_fq);var _super=_createSuper(_class);function _class(){var _this29;_classCallCheck(this,_class);_this29=_super.apply(this,arguments),_this29.nonFacetUnitNormalizers=[wV,OV,NV,new bq(),new _q(),new xq()];return _this29;}_createClass(_class,[{key:"map",value:function map(t,e){if(zj(t)){var _n128=aV(t.encoding,Jj),_r128=aV(t.encoding,Qj),_i93=aV(t.encoding,Zj);if(_n128||_r128||_i93)return this.mapFacetedUnit(t,e);}return _get(_getPrototypeOf(_class.prototype),"map",this).call(this,t,e);}},{key:"mapUnit",value:function mapUnit(t,e){var n=e.parentEncoding,r=e.parentProjection,i=Object.assign(Object.assign({},t),{encoding:wq(t.encoding,e.repeater)});if(n||r)return this.mapUnitWithParentEncodingOrProjection(i,e);var o=this.mapLayerOrUnit.bind(this);var _iterator65=_createForOfIteratorHelper(this.nonFacetUnitNormalizers),_step65;try{for(_iterator65.s();!(_step65=_iterator65.n()).done;){var _t147=_step65.value;if(_t147.hasMatchingType(i,e.config))return _t147.run(i,e,o);}}catch(err){_iterator65.e(err);}finally{_iterator65.f();}return i;}},{key:"mapRepeat",value:function mapRepeat(t,e){return function(t){return !rM(t.repeat)&&t.repeat.layer;}(t)?this.mapLayerRepeat(t,e):this.mapNonLayerRepeat(t,e);}},{key:"mapLayerRepeat",value:function mapLayerRepeat(t,e){var _this30=this;var n=t.repeat,r=t.spec,i=yM(t,["repeat","spec"]),o=n.row,a=n.column,s=n.layer,_e$repeater=e.repeater,u=_e$repeater===void 0?{}:_e$repeater,_e$repeaterPrefix=e.repeaterPrefix,c=_e$repeaterPrefix===void 0?"":_e$repeaterPrefix;return o||a?this.mapRepeat(Object.assign(Object.assign({},t),{repeat:Object.assign(Object.assign({},o?{row:o}:{}),a?{column:a}:{}),spec:{repeat:{layer:s},spec:r}}),e):Object.assign(Object.assign({},i),{layer:s.map(function(t){var n=Object.assign(Object.assign({},u),{layer:t}),i=(r.name||"")+c+"child__layer_".concat(KM(t)),o=_this30.mapLayerOrUnit(r,Object.assign(Object.assign({},e),{repeater:n,repeaterPrefix:i}));return o.name=i,o;})});}},{key:"mapNonLayerRepeat",value:function mapNonLayerRepeat(t,e){var n;var _t148=t,r=_t148.repeat,i=_t148.spec,o=_t148.data,a=yM(t,["repeat","spec","data"]);!rM(r)&&t.columns&&(t=TM(t,["columns"]),mz(y.columnsNotSupportByRowCol("repeat")));var s=[],_e$repeater2=e.repeater,u=_e$repeater2===void 0?{}:_e$repeater2,_e$repeaterPrefix2=e.repeaterPrefix,c=_e$repeaterPrefix2===void 0?"":_e$repeaterPrefix2,l=!rM(r)&&r.row||[u?u.row:null],f=!rM(r)&&r.column||[u?u.column:null],h=rM(r)&&r||[u?u.repeat:null];var _iterator66=_createForOfIteratorHelper(h),_step66;try{for(_iterator66.s();!(_step66=_iterator66.n()).done;){var _t149=_step66.value;var _iterator67=_createForOfIteratorHelper(l),_step67;try{for(_iterator67.s();!(_step67=_iterator67.n()).done;){var _n129=_step67.value;var _iterator68=_createForOfIteratorHelper(f),_step68;try{for(_iterator68.s();!(_step68=_iterator68.n()).done;){var _o48=_step68.value;var _a48={repeat:_t149,row:_n129,column:_o48,layer:u.layer},_l13=(i.name||"")+c+"child__"+(rM(r)?"".concat(KM(_t149)):(r.row?"row_".concat(KM(_n129)):"")+(r.column?"column_".concat(KM(_o48)):"")),_f14=this.map(i,Object.assign(Object.assign({},e),{repeater:_a48,repeaterPrefix:_l13}));_f14.name=_l13,s.push(TM(_f14,["data"]));}}catch(err){_iterator68.e(err);}finally{_iterator68.f();}}}catch(err){_iterator67.e(err);}finally{_iterator67.f();}}}catch(err){_iterator66.e(err);}finally{_iterator66.f();}var d=rM(r)?t.columns:r.column?r.column.length:1;return Object.assign(Object.assign({data:null!==(n=i.data)&&void 0!==n?n:o,align:"all"},a),{columns:d,concat:s});}},{key:"mapFacet",value:function mapFacet(t,e){var _t150=t,n=_t150.facet;return rW(n)&&t.columns&&(t=TM(t,["columns"]),mz(y.columnsNotSupportByRowCol("facet"))),_get(_getPrototypeOf(_class.prototype),"mapFacet",this).call(this,t,e);}},{key:"mapUnitWithParentEncodingOrProjection",value:function mapUnitWithParentEncodingOrProjection(t,e){var n=t.encoding,r=t.projection,i=e.parentEncoding,o=e.parentProjection,a=e.config,s=Dq({parentProjection:o,projection:r}),u=Sq({parentEncoding:i,encoding:wq(n,e.repeater)});return this.mapUnit(Object.assign(Object.assign(Object.assign({},t),s?{projection:s}:{}),u?{encoding:u}:{}),{config:a});}},{key:"mapFacetedUnit",value:function mapFacetedUnit(t,e){var n=t.encoding,r=n.row,i=n.column,o=n.facet,a=yM(n,["row","column","facet"]),s=t.mark,u=t.width,c=t.projection,l=t.height,f=t.view,h=t.selection;t.encoding;var p=yM(t,["mark","width","projection","height","view","selection","encoding"]),_this$getFacetMapping=this.getFacetMappingAndLayout({row:r,column:i,facet:o},e),m=_this$getFacetMapping.facetMapping,g=_this$getFacetMapping.layout,v=wq(a,e.repeater);return this.mapFacet(Object.assign(Object.assign(Object.assign({},p),g),{facet:m,spec:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},u?{width:u}:{}),l?{height:l}:{}),f?{view:f}:{}),c?{projection:c}:{}),{mark:s,encoding:v}),h?{selection:h}:{})}),e);}},{key:"getFacetMappingAndLayout",value:function getFacetMappingAndLayout(t,e){var n;var r=t.row,i=t.column,o=t.facet;if(r||i){o&&mz(y.facetChannelDropped([].concat(_toConsumableArray(r?[Jj]:[]),_toConsumableArray(i?[Qj]:[]))));var _e156={},_a49={};for(var _i94=0,_arr3=[Jj,Qj];_i94<_arr3.length;_i94++){var _r129=_arr3[_i94];var _i95=t[_r129];if(_i95){_i95.align;_i95.center;_i95.spacing;_i95.columns;var _c19=yM(_i95,["align","center","spacing","columns"]);_e156[_r129]=_c19;for(var _i96=0,_arr4=["align","center","spacing"];_i96<_arr4.length;_i96++){var _t152=_arr4[_i96];void 0!==_i95[_t152]&&(_a49[_t152]=null!==(n=_a49[_t152])&&void 0!==n?n:{},_a49[_t152][_r129]=_i95[_t152]);}}}return {facetMapping:_e156,layout:_a49};}{var _t153=o.align,_n130=o.center,_r130=o.spacing,_i97=o.columns;return {facetMapping:function(t,e){return e?rW(t)?Oq(t,e):Eq(t,e):t;}(yM(o,["align","center","spacing","columns"]),e.repeater),layout:Object.assign(Object.assign(Object.assign(Object.assign({},_t153?{align:_t153}:{}),_n130?{center:_n130}:{}),_r130?{spacing:_r130}:{}),_i97?{columns:_i97}:{})};}}},{key:"mapLayer",value:function mapLayer(t,e){var n=e.parentEncoding,r=e.parentProjection,i=yM(e,["parentEncoding","parentProjection"]);var o=t.encoding,a=t.projection,s=yM(t,["encoding","projection"]),u=Object.assign(Object.assign({},i),{parentEncoding:Sq({parentEncoding:n,encoding:o}),parentProjection:Dq({parentProjection:r,projection:a})});return _get(_getPrototypeOf(_class.prototype),"mapLayer",this).call(this,s,u);}}]);return _class;}(fq))();function Nq(t){return mM(t)?{type:t}:null!==t&&void 0!==t?t:{};}var Iq=["background","padding"];function Rq(t){return Iq.reduce(function(e,n){return t&&void 0!==t[n]&&(e[n]=t[n]),e;},{});}var Mq=/*#__PURE__*/function(){function Mq(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,Mq);this.explicit=t,this.implicit=e;}_createClass(Mq,[{key:"clone",value:function clone(){return new Mq(DM(this.explicit),DM(this.implicit));}},{key:"combine",value:function combine(){return Object.assign(Object.assign({},this.explicit),this.implicit);}},{key:"get",value:function get(t){return ij(this.explicit[t],this.implicit[t]);}},{key:"getWithExplicit",value:function getWithExplicit(t){return void 0!==this.explicit[t]?{explicit:!0,value:this.explicit[t]}:void 0!==this.implicit[t]?{explicit:!1,value:this.implicit[t]}:{explicit:!1,value:void 0};}},{key:"setWithExplicit",value:function setWithExplicit(t,e){void 0!==e.value&&this.set(t,e.value,e.explicit);}},{key:"set",value:function set(t,e,n){return delete this[n?"implicit":"explicit"][t],this[n?"explicit":"implicit"][t]=e,this;}},{key:"copyKeyFromSplit",value:function copyKeyFromSplit(t,e){void 0!==e.explicit[t]?this.set(t,e.explicit[t],!0):void 0!==e.implicit[t]&&this.set(t,e.implicit[t],!1);}},{key:"copyKeyFromObject",value:function copyKeyFromObject(t,e){void 0!==e[t]&&this.set(t,e[t],!0);}},{key:"copyAll",value:function copyAll(t){var _iterator69=_createForOfIteratorHelper(qM(t.combine())),_step69;try{for(_iterator69.s();!(_step69=_iterator69.n()).done;){var _e157=_step69.value;var _n131=t.getWithExplicit(_e157);this.setWithExplicit(_e157,_n131);}}catch(err){_iterator69.e(err);}finally{_iterator69.f();}}}]);return Mq;}();function jq(t){return {explicit:!0,value:t};}function Bq(t){return {explicit:!1,value:t};}function Pq(t){return function(e,n,r,i){var o=t(e.value,n.value);return o>0?e:o<0?n:Lq(e,n,r,i);};}function Lq(t,e,n,r){return t.explicit&&e.explicit&&mz(y.mergeConflictingProperty(n,r,t.value,e.value)),t;}function zq(t,e,n,r){var i=arguments.length>4&&arguments[4]!==undefined?arguments[4]:Lq;return void 0===t||void 0===t.value?e:t.explicit&&!e.explicit?t:e.explicit&&!t.explicit?e:SM(t.value,e.value)?t:i(t,e,n,r);}var Uq=/*#__PURE__*/function(_Mq){_inherits(Uq,_Mq);var _super2=_createSuper(Uq);function Uq(){var _this31;var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!1;_classCallCheck(this,Uq);_this31=_super2.call(this,t,e),_this31.explicit=t,_this31.implicit=e,_this31.parseNothing=n;return _this31;}_createClass(Uq,[{key:"clone",value:function clone(){var t=_get(_getPrototypeOf(Uq.prototype),"clone",this).call(this);return t.parseNothing=this.parseNothing,t;}}]);return Uq;}(Mq);function Wq(t){return "url"in t;}function Vq(t){return "values"in t;}function qq(t){return "name"in t&&!Wq(t)&&!Vq(t)&&!$q(t);}function $q(t){return t&&(Hq(t)||Gq(t)||Kq(t));}function Hq(t){return "sequence"in t;}function Gq(t){return "sphere"in t;}function Kq(t){return "graticule"in t;}var Xq="main",Yq="raw";function Jq(t){return "filter"in t;}function Qq(t){return "lookup"in t;}function Zq(t){return "pivot"in t;}function t$(t){return "density"in t;}function e$(t){return "quantile"in t;}function n$(t){return "regression"in t;}function r$(t){return "loess"in t;}function i$(t){return "sample"in t;}function o$(t){return "window"in t;}function a$(t){return "joinaggregate"in t;}function s$(t){return "flatten"in t;}function u$(t){return "calculate"in t;}function c$(t){return "bin"in t;}function l$(t){return "impute"in t;}function f$(t){return "timeUnit"in t;}function h$(t){return "aggregate"in t;}function d$(t){return "stack"in t;}function p$(t){return "fold"in t;}function m$(t){return t.map(function(t){return Jq(t)?{filter:function t(e,n){return _M(e)?{not:t(e.not,n)}:OM(e)?{and:e.and.map(function(e){return t(e,n);})}:AM(e)?{or:e.or.map(function(e){return t(e,n);})}:n(e);}(t.filter,Xz)}:t;});}function g$(t,e,n,r){var i=lW(e)&&e.condition,o=r(e);if(i){return _defineProperty({},n,[].concat(_toConsumableArray(cM(i).map(function(e){var n=r(e),i=function(t){return t.selection;}(e)?EK(t,e.selection):AK(t,e.test);return Object.assign({test:i},n);})),_toConsumableArray(void 0!==o?[o]:[])));}return void 0!==o?_defineProperty({},n,o):{};}function v$(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"text";var n=t.encoding[e];return g$(t,n,e,function(e){return y$(e,t.config);});}function y$(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"datum";if(t){if(xW(t))return KW(t.value);if(yW(t)){var _RW2=RW(t),_r131=_RW2.format,_i98=_RW2.formatType;return WU({fieldOrDatumDef:t,format:_r131,formatType:_i98,expr:n,config:e});}}}function b$(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var n=t.encoding,r=t.markDef,i=t.config,o=t.stack,a=n.tooltip;if(rM(a))return {tooltip:w$({tooltip:a},o,i,e)};{var _s44=e.reactiveGeom?"datum.datum":"datum";return g$(t,a,"tooltip",function(t){var a=y$(t,i,_s44);if(a)return a;if(null===t)return;var u=QW("tooltip",r,i);return !0===u&&(u={content:"encoding"}),mM(u)?{value:u}:iM(u)?"encoding"===u.content?w$(n,o,i,e):{signal:_s44}:void 0;});}}function x$(t,e,n){var _ref41=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},r=_ref41.reactiveGeom;var i={},o=r?"datum.datum":"datum",a=[];function s(r,s){var u=ZB(s),c=bW(r)?r:Object.assign(Object.assign({},r),{type:t[u].type}),l=cM(TW(c,n,{allowDisabling:!1})).join(", ");var f;if(bP(s)){var _r132="x"===s?"x2":"y2",_a50=MW(t[_r132]);if(VP(c.bin)&&_a50){var _t154=AW(c,{expr:o}),_e158=AW(_a50,{expr:o}),_RW3=RW(c),_s45=_RW3.format,_u23=_RW3.formatType;f=YU(_t154,_e158,_s45,_u23,n),i[_r132]=!0;}else if(e&&e.fieldChannel===s&&"normalize"===e.offset){var _RW4=RW(c),_t155=_RW4.format,_e159=_RW4.formatType;f=WU({fieldOrDatumDef:c,format:_t155,formatType:_e159,expr:o,config:n,normalizeStack:!0}).signal;}}f=null!==f&&void 0!==f?f:y$(c,n,o).signal,a.push({channel:s,key:l,value:f});}lV(t,function(t,e){dW(t)?s(t,e):fW(t)&&s(t.condition,e);});var u={};for(var _i99=0,_a51=a;_i99<_a51.length;_i99++){var _a51$_i=_a51[_i99],_t156=_a51$_i.channel,_e160=_a51$_i.key,_n132=_a51$_i.value;i[_t156]||u[_e160]||(u[gM(_e160)]=_n132);}return u;}function w$(t,e,n){var _ref42=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},r=_ref42.reactiveGeom;var i=HM(x$(t,e,n,{reactiveGeom:r})).map(function(_ref43){var t=_ref43.key,e=_ref43.value;return "".concat(t,": ").concat(e);});return i.length>0?{signal:"{".concat(i.join(", "),"}")}:void 0;}function k$(t){var e=t.markDef,n=t.config,r=QW("aria",e,n);return !1===r?{}:Object.assign(Object.assign(Object.assign({},r?{aria:r}:{}),function(t){var e=t.mark,n=t.markDef,r=t.config;if(!1===r.aria)return {};var i=QW("ariaRoleDescription",n,r);if(null!=i)return {ariaRoleDescription:{value:i}};return e in jz?{}:{ariaRoleDescription:{value:e}};}(t)),function(t){var e=t.encoding,n=t.markDef,r=t.config,i=t.stack,o=e.description;if(o)return g$(t,o,"description",function(e){return y$(e,t.config);});var a=QW("description",n,r);if(null!=a)return {description:KW(a)};if(!1===r.aria)return {};var s=x$(e,i,r);if(VM(s))return;return {description:{signal:HM(s).map(function(_ref44){var t=_ref44.key,e=_ref44.value;return "".concat(t," + \": \" + (").concat(e,")");}).join(' + "; " + ')}};}(t));}function E$(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var r=e.markDef,i=e.encoding,o=e.config,a=n.vgChannel;var s=n.defaultRef,u=n.defaultValue;void 0===s&&void 0!==(u=null!==u&&void 0!==u?u:QW(t,r,o,{vgChannel:a,ignoreVgConfig:!0}))&&(s=KW(u));var c=i[t];return g$(e,c,null!==a&&void 0!==a?a:t,function(n){return BU({channel:t,channelDef:n,markDef:r,config:o,scaleName:e.scaleName(t),scale:e.getScaleComponent(t),stack:null,defaultRef:s});});}function C$(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{filled:void 0};var n,r,i,o;var a=t.markDef,s=t.encoding,u=t.config,c=a.type,l=null!==(n=e.filled)&&void 0!==n?n:QW("filled",a,u),f=MM(["bar","point","circle","square","geoshape"],c)?"transparent":void 0,h=null!==(i=null!==(r=QW(!0===l?"color":void 0,a,u,{vgChannel:"fill"}))&&void 0!==r?r:u.mark[!0===l&&"color"])&&void 0!==i?i:f,d=null!==(o=QW(!1===l?"color":void 0,a,u,{vgChannel:"stroke"}))&&void 0!==o?o:u.mark[!1===l&&"color"],p=l?"fill":"stroke",m=Object.assign(Object.assign({},h?{fill:KW(h)}:{}),d?{stroke:KW(d)}:{});return a.color&&(l?a.fill:a.stroke)&&mz(y.droppingColor("property",{fill:"fill"in a,stroke:"stroke"in a})),Object.assign(Object.assign(Object.assign(Object.assign({},m),E$("color",t,{vgChannel:p,defaultValue:l?h:d})),E$("fill",t,{defaultValue:s.fill?h:void 0})),E$("stroke",t,{defaultValue:s.stroke?d:void 0}));}function A$(t,e){var n=e[function(t){switch(t){case tB:return "xOffset";case eB:return "yOffset";case nB:return "x2Offset";case rB:return "y2Offset";case aB:return "thetaOffset";case iB:return "radiusOffset";case sB:return "theta2Offset";case oB:return "radius2Offset";}}(t)];if(n)return n;}function O$(t,e,_ref45){var n=_ref45.defaultPos,r=_ref45.vgChannel,i=_ref45.isMidPoint;var o=e.encoding,a=e.markDef,s=e.config,u=e.stack,c=o[t],l=o[eP(t)],f=e.scaleName(t),h=e.getScaleComponent(t),d=A$(t,a),p=_$({model:e,defaultPos:n,channel:t,scaleName:f,scale:h}),m=!c&&bP(t)&&(o.latitude||o.longitude)?{field:e.getName(t)}:function(t){var e=t.channel,n=t.channelDef,r=t.isMidPoint,i=t.scaleName,o=t.stack,a=t.offset,s=t.markDef,u=t.config;if(yW(n)&&o&&e===o.fieldChannel){if(dW(n)){var _t157=uW({channel:e,fieldDef:n,isMidPoint:r,markDef:s,stack:o,config:u});if(void 0!==_t157)return jU({scaleName:i,fieldOrDatumDef:n,startSuffix:"start",band:_t157,offset:a});}return MU(n,i,{suffix:"end"},{offset:a});}return NU(t);}({channel:t,channelDef:c,channel2Def:l,markDef:a,config:s,isMidPoint:i,scaleName:f,scale:h,stack:u,offset:d,defaultRef:p});return m?_defineProperty({},r||t,m):void 0;}function _$(_ref47){var t=_ref47.model,e=_ref47.defaultPos,n=_ref47.channel,r=_ref47.scaleName,i=_ref47.scale;var o=t.markDef,a=t.config;return function(){var s=ZB(n),u=tP(n),c=QW(n,o,a,{vgChannel:u});if(void 0!==c)return PU(n,c);switch(e){case"zeroOrMin":case"zeroOrMax":if(r){var _t158=i.get("type");if(MM([rU.LOG,rU.TIME,rU.UTC],_t158));else if(i.domainDefinitelyIncludesZero())return {scale:r,value:0};}if("zeroOrMin"===e)return "y"===s?{field:{group:"height"}}:{value:0};switch(s){case"radius":return {signal:"min(".concat(t.width.signal,",").concat(t.height.signal,")/2")};case"theta":return {signal:"2*PI"};case"x":return {field:{group:"width"}};case"y":return {value:0};}break;case"mid":{var _e161=t[nP(n)];return Object.assign(Object.assign({},_e161),{mult:.5});}}};}var S$={left:"x",center:"xc",right:"x2"},D$={top:"y",middle:"yc",bottom:"y2"};function F$(t,e,n){var r=arguments.length>3&&arguments[3]!==undefined?arguments[3]:"middle";if("radius"===t||"theta"===t)return tP(t);var i=QW("x"===t?"align":"baseline",e,n);return "x"===t?S$[i||("top"===r?"left":"center")]:D$[i||r];}function T$(t,e,_ref48){var n=_ref48.defaultPos,r=_ref48.defaultPos2,i=_ref48.range;return i?N$(t,e,{defaultPos:n,defaultPos2:r}):O$(t,e,{defaultPos:n});}function N$(t,e,_ref49){var n=_ref49.defaultPos,r=_ref49.defaultPos2;var i=e.markDef,o=e.config,a=eP(t),s=nP(t),u=function(t,e,n){var _I$;var r=t.encoding,i=t.mark,o=t.markDef,a=t.stack,s=t.config,u=ZB(n),c=nP(n),l=tP(n),f=r[u],h=t.scaleName(u),d=t.getScaleComponent(u),p=A$(n in r||n in o?n:u,t.markDef);if(!f&&("x2"===n||"y2"===n)&&(r.latitude||r.longitude))return _defineProperty({},l,{field:t.getName(n)});var m=function(_ref51){var t=_ref51.channel,e=_ref51.channelDef,n=_ref51.channel2Def,r=_ref51.markDef,i=_ref51.config,o=_ref51.scaleName,a=_ref51.scale,s=_ref51.stack,u=_ref51.offset,c=_ref51.defaultRef;if(yW(e)&&s&&t.charAt(0)===s.fieldChannel.charAt(0))return MU(e,o,{suffix:"start"},{offset:u});return NU({channel:t,channelDef:n,scaleName:o,scale:a,stack:s,markDef:r,config:i,offset:u,defaultRef:c});}({channel:n,channelDef:f,channel2Def:r[n],markDef:o,config:s,scaleName:h,scale:d,stack:a,offset:p,defaultRef:void 0});if(void 0!==m)return _defineProperty({},l,m);return I$(n,o)||I$(n,(_I$={},_defineProperty(_I$,n,tV(n,o,s.style)),_defineProperty(_I$,c,tV(c,o,s.style)),_I$))||I$(n,s[i])||I$(n,s.mark)||_defineProperty({},l,_$({model:t,defaultPos:e,channel:n,scaleName:h,scale:d})());}(e,r,a),c=u[s]?F$(t,i,o):tP(t);return Object.assign(Object.assign({},O$(t,e,{defaultPos:n,vgChannel:c})),u);}function I$(t,e){var n=nP(t),r=tP(t);return void 0!==e[r]?_defineProperty({},r,PU(t,e[r])):void 0!==e[t]?_defineProperty({},r,PU(t,e[t])):e[n]?_defineProperty({},n,PU(t,e[n])):void 0;}function R$(t,e,n){var r,i,o,a;var s=t.config,u=t.encoding,c=t.markDef,l=t.stack,f=eP(e),h=nP(e),d=u[e],p=u[f],m=t.getScaleComponent(e),g=m?m.get("type"):void 0,v=t.scaleName(e),b=c.orient,x=null!==(i=null!==(r=u[h])&&void 0!==r?r:u.size)&&void 0!==i?i:QW("size",c,s,{vgChannel:h}),w="bar"===n&&("x"===e?"vertical"===b:"horizontal"===b);if(dW(d)&&(WP(d.bin)||VP(d.bin)||d.timeUnit&&!p)&&!x&&!mU(g)){var _n133=uW({channel:e,fieldDef:d,stack:l,markDef:c,config:s}),_r133=null===(o=t.component.axes[e])||void 0===o?void 0:o[0];return function(_ref57){var _ref58;var t=_ref57.fieldDef,e=_ref57.fieldDef2,n=_ref57.channel,r=_ref57.band,i=_ref57.scaleName,o=_ref57.markDef,_ref57$spacing=_ref57.spacing,a=_ref57$spacing===void 0?0:_ref57$spacing,s=_ref57.axisTranslate,u=_ref57.reverse,c=_ref57.config;var l=eP(n),f=tP(n),h=tP(l),d=A$(n,o);if(WP(t.bin)||t.timeUnit)return _ref58={},_defineProperty(_ref58,h,j$({channel:n,fieldDef:t,scaleName:i,markDef:o,band:(1-r)/2,offset:M$(l,a,u,s,d),config:c})),_defineProperty(_ref58,f,j$({channel:n,fieldDef:t,scaleName:i,markDef:o,band:1-(1-r)/2,offset:M$(n,a,u,s,d),config:c})),_ref58;if(VP(t.bin)){var _ref59,_ref60;var _r134=MU(t,i,{},{offset:M$(l,a,u,s,d)});if(dW(e))return _ref59={},_defineProperty(_ref59,h,_r134),_defineProperty(_ref59,f,MU(e,i,{},{offset:M$(n,a,u,s,d)})),_ref59;if(qP(t.bin)&&t.bin.step)return _ref60={},_defineProperty(_ref60,h,_r134),_defineProperty(_ref60,f,{signal:"scale(\"".concat(i,"\", ").concat(AW(t,{expr:"datum"})," + ").concat(t.bin.step,")"),offset:M$(n,a,u,s,d)}),_ref60;}return void mz(y.channelRequiredForBinned(l));}({fieldDef:d,fieldDef2:p,channel:e,markDef:c,scaleName:v,band:_n133,axisTranslate:null!==(a=null===_r133||void 0===_r133?void 0:_r133.get("translate"))&&void 0!==a?a:.5,spacing:bP(e)?QW("binSpacing",c,s):void 0,reverse:m.get("reverse"),config:s});}return (yW(d)&&mU(g)||w)&&!p?function(t,e,n,r){var i;var o=r.markDef,a=r.encoding,s=r.config,u=r.stack,c=o.orient,l=r.scaleName(n),f=r.getScaleComponent(n),h=nP(n),d=eP(n),p="horizontal"===c&&"y"===n||"vertical"===c&&"x"===n,m=QW(p?"size":h,o,s,{vgChannel:h});var g;(a.size||void 0!==m)&&(p?g=E$("size",r,{vgChannel:h,defaultValue:m}):mz(y.cannotApplySizeToNonOrientedMark(o.type)));var v=null!==(i=yW(e)?uW({channel:n,fieldDef:e,markDef:o,stack:u,config:s}):void 0)&&void 0!==i?i:1;g=g||_defineProperty({},h,function(t,e,n,r,i,o){if(r){var _e162=r.get("type");if("point"===_e162||"band"===_e162){if(void 0!==i[t].discreteBandSize)return {value:i[t].discreteBandSize};if(_e162===rU.POINT){var _t159=r.get("range");return Iz(_t159)&&pM(_t159.step)?{value:_t159.step-2}:{value:ZV-2};}return {scale:n,band:o};}return {value:i[t].continuousBandSize};}var a=JV(i.view,e),s=ij(i[t].discreteBandSize,a-2);return void 0!==s?{value:s}:void 0;}(t,h,l,f,s,v));var b="band"!==(null===f||void 0===f?void 0:f.get("type"))||!("band"in g[h]),x=F$(n,o,s,b?"middle":"top"),w=A$(n,o),k=NU({channel:n,channelDef:e,markDef:o,config:s,scaleName:l,scale:f,stack:u,offset:w,defaultRef:_$({model:r,defaultPos:"mid",channel:n,scaleName:l,scale:f}),band:b?.5:(1-v)/2});if(h)return Object.assign(_defineProperty({},x,k),g);{var _ref62;var _t160=tP(d),_e163=g[h],_n134=w?Object.assign(Object.assign({},_e163),{offset:w}):_e163;return _ref62={},_defineProperty(_ref62,x,k),_defineProperty(_ref62,_t160,rM(k)?[k[0],Object.assign(Object.assign({},k[1]),{offset:_n134})]:Object.assign(Object.assign({},k),{offset:_n134})),_ref62;}}(n,d,e,t):N$(e,t,{defaultPos:"zeroOrMax",defaultPos2:"zeroOrMin"});}function M$(t,e,n,r,i){if(NB(t))return 0;var o="x"===t||"y2"===t?-e/2:e/2;if(Nz(n)){var _t161=YW(i);return {signal:"".concat(n.signal," ? ").concat(r-o).concat(_t161?"-"+_t161:""," : ").concat(r+o).concat(_t161?"+"+_t161:"")};}if(Nz(i)){var _t162=r+(n?-o:o);return {signal:"".concat(_t162||"").concat(n?" - ":_t162?" + ":"").concat(i.signal)};}return i=i||0,r+(n?-i-o:+i+o);}function j$(_ref63){var t=_ref63.channel,e=_ref63.fieldDef,n=_ref63.scaleName,r=_ref63.markDef,i=_ref63.band,o=_ref63.offset,a=_ref63.config;return IU({fieldDef:e,channel:t,markDef:r,ref:jU({scaleName:n,fieldOrDatumDef:e,band:i,offset:o}),config:a});}var B$=new Set(["aria"]);function P$(t,e){var _ref64="include"===e.color?C$(t):{},n=_ref64.fill,r=_ref64.stroke;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},function(t,e){return Mz.reduce(function(n,r){return B$.has(r)||void 0===t[r]||"ignore"===e[r]||(n[r]=KW(t[r])),n;},{});}(t.markDef,e)),L$(t,"fill",n)),L$(t,"stroke",r)),E$("opacity",t)),E$("fillOpacity",t)),E$("strokeOpacity",t)),E$("strokeWidth",t)),E$("strokeDash",t)),b$(t)),v$(t,"href")),k$(t));}function L$(t,e,n){var r=t.config,i=t.mark,o=t.markDef;if("hide"===QW("invalid",o,r)&&n&&!Tj(i)){var _r135=function(t,_ref65){var _ref65$invalid=_ref65.invalid,e=_ref65$invalid===void 0?!1:_ref65$invalid,n=_ref65.channels;var r=n.reduce(function(e,n){var r=t.getScaleComponent(n);if(r){var _i100=r.get("type"),_o50=t.vgField(n,{expr:"datum"});_o50&&gU(_i100)&&(e[_o50]=!0);}return e;},{}),i=qM(r);if(i.length>0){var _t163=e?"||":"&&";return i.map(function(t){return RU(t,e);}).join(" ".concat(_t163," "));}return;}(t,{invalid:!0,channels:RP});if(_r135)return _defineProperty({},e,[{test:_r135,value:null}].concat(_toConsumableArray(cM(n))));}return n?_defineProperty({},e,n):{};}function z$(t){var e=t.config,n=t.markDef;if(QW("invalid",n,e)){var _e164=function(t,_ref68){var _ref68$invalid=_ref68.invalid,e=_ref68$invalid===void 0?!1:_ref68$invalid,n=_ref68.channels;var r=n.reduce(function(e,n){var r=t.getScaleComponent(n);if(r){var _i101=r.get("type"),_o51=t.vgField(n,{expr:"datum"});_o51&&gU(_i101)&&(e[_o51]=!0);}return e;},{}),i=qM(r);if(i.length>0){var _t164=e?"||":"&&";return i.map(function(t){return RU(t,e);}).join(" ".concat(_t164," "));}return;}(t,{channels:yP});if(_e164)return {defined:{signal:_e164}};}return {};}function U$(t,e){if(void 0!==e)return _defineProperty({},t,KW(e));}var W$={has:function has(t){return "interval"!==t.type&&t.nearest;},parse:function parse(t,e){if(e.events){var _iterator70=_createForOfIteratorHelper(e.events),_step70;try{for(_iterator70.s();!(_step70=_iterator70.n()).done;){var _n135=_step70.value;_n135.markname=t.getName("voronoi");}}catch(err){_iterator70.e(err);}finally{_iterator70.f();}}},marks:function marks(t,e,n){var _e$project$hasChannel=e.project.hasChannel,r=_e$project$hasChannel.x,i=_e$project$hasChannel.y,o=t.mark;if(Tj(o))return mz(y.nearestNotSupportForContinuous(o)),n;var a={name:t.getName("voronoi"),type:"path",interactive:!0,from:{data:t.getName("marks")},encode:{update:Object.assign({fill:{value:"transparent"},strokeWidth:{value:.35},stroke:{value:"transparent"},isVoronoi:{value:!0}},b$(t,{reactiveGeom:!0}))},transform:[{type:"voronoi",x:{expr:r||!i?"datum.datum.x || 0":"0"},y:{expr:i||!r?"datum.datum.y || 0":"0"},size:[t.getSizeSignalRef("width"),t.getSizeSignalRef("height")]}]};var s=0,u=!1;return n.forEach(function(e,n){var r;var i=null!==(r=e.name)&&void 0!==r?r:"";i===t.component.mark[0].name?s=n:i.indexOf("voronoi")>=0&&(u=!0);}),u||n.splice(s+1,0,a),n;}};var V$=/*#__PURE__*/function(){function V$(t,e){_classCallCheck(this,V$);this.debugName=e,this._children=[],this._parent=null,t&&(this.parent=t);}_createClass(V$,[{key:"clone",value:function clone(){throw new Error("Cannot clone node");}},{key:"parent",get:function get(){return this._parent;},set:function set(t){this._parent=t,t&&t.addChild(this);}},{key:"children",get:function get(){return this._children;}},{key:"numChildren",value:function numChildren(){return this._children.length;}},{key:"addChild",value:function addChild(t,e){this._children.indexOf(t)>-1?console.warn("Attempt to add the same child twice."):void 0!==e?this._children.splice(e,0,t):this._children.push(t);}},{key:"removeChild",value:function removeChild(t){var e=this._children.indexOf(t);return this._children.splice(e,1),e;}},{key:"remove",value:function remove(){var t=this._parent.removeChild(this);var _iterator71=_createForOfIteratorHelper(this._children),_step71;try{for(_iterator71.s();!(_step71=_iterator71.n()).done;){var _e165=_step71.value;_e165._parent=this._parent,this._parent.addChild(_e165,t++);}}catch(err){_iterator71.e(err);}finally{_iterator71.f();}}},{key:"insertAsParentOf",value:function insertAsParentOf(t){var e=t.parent;e.removeChild(this),this.parent=e,t.parent=this;}},{key:"swapWithParent",value:function swapWithParent(){var t=this._parent,e=t.parent;var _iterator72=_createForOfIteratorHelper(this._children),_step72;try{for(_iterator72.s();!(_step72=_iterator72.n()).done;){var _e166=_step72.value;_e166.parent=t;}}catch(err){_iterator72.e(err);}finally{_iterator72.f();}this._children=[],t.removeChild(this),t.parent.removeChild(t),this.parent=e,t.parent=this;}}]);return V$;}();var q$=/*#__PURE__*/function(_V$){_inherits(q$,_V$);var _super3=_createSuper(q$);function q$(t,e,n,r){var _this32;_classCallCheck(this,q$);_this32=_super3.call(this,t,e),_this32.type=n,_this32.refCounts=r,_this32._source=_this32._name=e,!_this32.refCounts||_this32._name in _this32.refCounts||(_this32.refCounts[_this32._name]=0);return _this32;}_createClass(q$,[{key:"clone",value:function clone(){var t=new this.constructor();return t.debugName="clone_"+this.debugName,t._source=this._source,t._name="clone_"+this._name,t.type=this.type,t.refCounts=this.refCounts,t.refCounts[t._name]=0,t;}},{key:"dependentFields",value:function dependentFields(){return new Set();}},{key:"producedFields",value:function producedFields(){return new Set();}},{key:"hash",value:function hash(){return void 0===this._hash&&(this._hash="Output ".concat(aj())),this._hash;}},{key:"getSource",value:function getSource(){return this.refCounts[this._name]++,this._source;}},{key:"isRequired",value:function isRequired(){return !!this.refCounts[this._name];}},{key:"setSource",value:function setSource(t){this._source=t;}}]);return q$;}(V$);var $$=/*#__PURE__*/function(_V$2){_inherits($$,_V$2);var _super4=_createSuper($$);function $$(t,e){var _this33;_classCallCheck(this,$$);_this33=_super4.call(this,t),_this33.formula=e;return _this33;}_createClass($$,[{key:"clone",value:function clone(){return new $$(null,DM(this.formula));}},{key:"merge",value:function merge(t){this.formula=Object.assign({},this.formula);for(var _e167 in t.formula){this.formula[_e167]&&!t.formula[_e167].band||(this.formula[_e167]=t.formula[_e167]);}var _iterator73=_createForOfIteratorHelper(t.children),_step73;try{for(_iterator73.s();!(_step73=_iterator73.n()).done;){var _e168=_step73.value;t.removeChild(_e168),_e168.parent=this;}}catch(err){_iterator73.e(err);}finally{_iterator73.f();}t.remove();}},{key:"producedFields",value:function producedFields(){return new Set($M(this.formula).map(function(t){return t.as;}));}},{key:"dependentFields",value:function dependentFields(){return new Set($M(this.formula).map(function(t){return t.field;}));}},{key:"hash",value:function hash(){return "TimeUnit ".concat(IM(this.formula));}},{key:"assemble",value:function assemble(){var t=[];var _iterator74=_createForOfIteratorHelper($M(this.formula)),_step74;try{for(_iterator74.s();!(_step74=_iterator74.n()).done;){var _e169=_step74.value;var _n136=_e169.field,_r136=_e169.as,_i102=_e169.timeUnit,_o52=Tz(_i102),_a52=_o52.unit,_s46=_o52.utc,_u24=yM(_o52,["unit","utc"]);t.push(Object.assign(Object.assign(Object.assign(Object.assign({field:tj(_n136),type:"timeunit"},_a52?{units:_z(_a52)}:{}),_s46?{timezone:"utc"}:{}),_u24),{as:[_r136,"".concat(_r136,"_end")]}));}}catch(err){_iterator74.e(err);}finally{_iterator74.f();}return t;}}],[{key:"makeFromEncoding",value:function makeFromEncoding(t,e){var n=e.reduceFieldDef(function(t,n,r){var i=n.field,o=n.timeUnit,a=YY(e)?e.encoding[eP(r)]:void 0,s=YY(e)&&cW(r,n,a,e.stack,e.markDef,e.config);if(o){var _e170=AW(n,{forAs:!0});t[IM({as:_e170,field:i,timeUnit:o})]=Object.assign({as:_e170,field:i,timeUnit:o},s?{band:!0}:{});}return t;},{});return VM(n)?null:new $$(t,n);}},{key:"makeFromTransform",value:function makeFromTransform(t,e){var n=Object.assign({},e),r=n.timeUnit,i=yM(n,["timeUnit"]),o=Tz(r),a=Object.assign(Object.assign({},i),{timeUnit:o});return new $$(t,_defineProperty({},IM(a),a));}}]);return $$;}(V$);var H$="_tuple_fields";var G$={has:function has(t){return "single"===t.type&&"global"===t.resolve&&t.bind&&"scales"!==t.bind&&!WV(t.bind);},parse:function parse(t,e,n,r){r.on||delete e.events,r.clear||delete e.clear;},topLevelSignals:function topLevelSignals(t,e,n){var r=e.name,i=e.project,o=e.bind,a=e.init&&e.init[0],s=W$.has(e)?"(item().isVoronoi ? datum.datum : datum)":"datum";return i.items.forEach(function(t,i){var u,c;var l=KM("".concat(r,"_").concat(t.field));n.filter(function(t){return t.name===l;}).length||n.unshift(Object.assign(Object.assign({name:l},a?{init:sH(a[i])}:{value:null}),{on:e.events?[{events:e.events,update:"datum && item().mark.marktype !== 'group' ? ".concat(s,"[").concat(gM(t.field),"] : null")}]:[],bind:null!==(c=null!==(u=o[t.field])&&void 0!==u?u:o[t.channel])&&void 0!==c?c:o}));}),n;},signals:function signals(t,e,n){var r=e.name,i=e.project,o=n.filter(function(t){return t.name===r+yH;})[0],a=r+H$,s=i.items.map(function(t){return KM("".concat(r,"_").concat(t.field));}),u=s.map(function(t){return "".concat(t," !== null");}).join(" && ");return s.length&&(o.update="".concat(u," ? {fields: ").concat(a,", values: [").concat(s.join(", "),"]} : null")),delete o.value,delete o.on,n;}};var K$={has:function has(t){return "multi"===t.type&&!!t.toggle;},signals:function signals(t,e,n){return n.concat({name:e.name+"_toggle",value:!1,on:[{events:e.events,update:e.toggle}]});},modifyExpr:function modifyExpr(t,e){var n=e.name+yH,r=e.name+"_toggle";return "".concat(r," ? null : ").concat(n,", ")+("global"===e.resolve?"".concat(r," ? null : true, "):"".concat(r," ? null : {unit: ").concat(EH(t),"}, "))+"".concat(r," ? ").concat(n," : null");}};var X$={has:function has(t){return "interval"===t.type&&"global"===t.resolve&&t.bind&&"scales"===t.bind;},parse:function parse(t,e){var n=e.scales=[];var _iterator75=_createForOfIteratorHelper(e.project.items),_step75;try{for(_iterator75.s();!(_step75=_iterator75.n()).done;){var _r137=_step75.value;var _i103=_r137.channel;if(!MP(_i103))continue;var _o53=t.getScaleComponent(_i103),_a53=_o53?_o53.get("type"):void 0;if(!_o53||!gU(_a53)){mz(y.SCALE_BINDINGS_CONTINUOUS);continue;}var _s47={selection:e.name,field:_r137.field};_o53.set("selectionExtent",_s47,!0),n.push(_r137);}}catch(err){_iterator75.e(err);}finally{_iterator75.f();}},topLevelSignals:function topLevelSignals(t,e,n){var r=e.scales.filter(function(t){return 0===n.filter(function(e){return e.name===t.signals.data;}).length;});if(!t.parent||J$(t)||0===r.length)return n;var i=n.filter(function(t){return t.name===e.name;})[0];var o=i.update;if(o.indexOf(xH)>=0)i.update="{".concat(r.map(function(t){return "".concat(gM(t.field),": ").concat(t.signals.data);}).join(", "),"}");else {var _iterator76=_createForOfIteratorHelper(r),_step76;try{for(_iterator76.s();!(_step76=_iterator76.n()).done;){var _t165=_step76.value;var _e171="".concat(gM(_t165.field),": ").concat(_t165.signals.data);o.indexOf(_e171)<0&&(o="".concat(o.substring(0,o.length-1),", ").concat(_e171,"}"));}}catch(err){_iterator76.e(err);}finally{_iterator76.f();}i.update=o;}return n.concat(r.map(function(t){return {name:t.signals.data};}));},signals:function signals(t,e,n){if(t.parent&&!J$(t)){var _iterator77=_createForOfIteratorHelper(e.scales),_step77;try{var _loop3=function _loop3(){var t=_step77.value;var e=n.filter(function(e){return e.name===t.signals.data;})[0];e.push="outer",delete e.value,delete e.update;};for(_iterator77.s();!(_step77=_iterator77.n()).done;){_loop3();}}catch(err){_iterator77.e(err);}finally{_iterator77.f();}}return n;}};function Y$(t,e){return "domain(".concat(gM(t.scaleName(e)),")");}function J$(t){var e;return t.parent&&ZY(t.parent)&&(null!==(e=!t.parent.parent)&&void 0!==e?e:J$(t.parent.parent));}var Q$={has:function has(t){var e="global"===t.resolve&&t.bind&&WV(t.bind),n=1===t.project.items.length&&t.project.items[0].field!==zV;return e&&!n&&mz(y.LEGEND_BINDINGS_PROJECT_LENGTH),e&&n;},parse:function parse(t,e,n,r){var i;if(r.on||delete e.events,r.clear||delete e.clear,r.on||r.clear){var _t166='event.item && indexof(event.item.mark.role, "legend") < 0';var _iterator78=_createForOfIteratorHelper(e.events),_step78;try{for(_iterator78.s();!(_step78=_iterator78.n()).done;){var _n137=_step78.value;_n137.filter=cM(null!==(i=_n137.filter)&&void 0!==i?i:[]),_n137.filter.indexOf(_t166)<0&&_n137.filter.push(_t166);}}catch(err){_iterator78.e(err);}finally{_iterator78.f();}}var o=VV(e.bind)?e.bind.legend:"click",a=mM(o)?zR(o,"view"):cM(o);e.bind={legend:{merge:a}};},topLevelSignals:function topLevelSignals(t,e,n){var r=e.name,i=VV(e.bind)&&e.bind.legend,o=function o(t){return function(e){var n=DM(e);return n.markname=t,n;};};var _iterator79=_createForOfIteratorHelper(e.project.items),_step79;try{var _loop4=function _loop4(){var t=_step79.value;if(!t.hasLegend)return "continue";var a="".concat(KM(t.field),"_legend"),s="".concat(r,"_").concat(a);if(0===n.filter(function(t){return t.name===s;}).length){var _t167=i.merge.map(o("".concat(a,"_symbols"))).concat(i.merge.map(o("".concat(a,"_labels")))).concat(i.merge.map(o("".concat(a,"_entries"))));n.unshift(Object.assign(Object.assign({name:s},e.init?{}:{value:null}),{on:[{events:_t167,update:"datum.value || item().items[0].items[0].datum.value",force:!0},{events:i.merge,update:"!event.item || !datum ? null : ".concat(s),force:!0}]}));}};for(_iterator79.s();!(_step79=_iterator79.n()).done;){var _ret=_loop4();if(_ret==="continue")continue;}}catch(err){_iterator79.e(err);}finally{_iterator79.f();}return n;},signals:function signals(t,e,n){var r=e.name,i=e.project,o=n.find(function(t){return t.name===r+yH;}),a=r+H$,s=i.items.filter(function(t){return t.hasLegend;}).map(function(t){return KM("".concat(r,"_").concat(KM(t.field),"_legend"));}),u="".concat(s.map(function(t){return "".concat(t," !== null");}).join(" && ")," ? {fields: ").concat(a,", values: [").concat(s.join(", "),"]} : null");e.events&&s.length>0?o.on.push({events:s.map(function(t){return {signal:t};}),update:u}):s.length>0&&(o.update=u,delete o.value,delete o.on);var c=n.find(function(t){return t.name===r+"_toggle";}),l=VV(e.bind)&&e.bind.legend;return c&&(e.events?c.on.push(Object.assign(Object.assign({},c.on[0]),{events:l})):c.on[0].events=l),n;}};var Z$="_translate_anchor",tH="_translate_delta";function eH(t,e,n,r,i){var o;var a=e.name,s=a+Z$,u=a+tH,c=n.channel,l=X$.has(e),f=i.filter(function(t){return t.name===n.signals[l?"data":"visual"];})[0],h=t.getSizeSignalRef(r).signal,d=t.getScaleComponent(c),p=d.get("type"),m="".concat(s,".extent_").concat(c),g="".concat(l?"log"===p?"panLog":"pow"===p?"panPow":"panLinear":"panLinear","(").concat(m,", ").concat("".concat(l&&c===tB?"-":"").concat(u,".").concat(c," / ")+(l?"".concat(h):"span(".concat(m,")")))+(l&&"pow"===p?", ".concat(null!==(o=d.get("exponent"))&&void 0!==o?o:1):"")+")";f.on.push({events:{signal:u},update:l?g:"clampRange(".concat(g,", 0, ").concat(h,")")});}var nH="_zoom_anchor",rH="_zoom_delta";function iH(t,e,n,r,i){var o;var a=e.name,s=n.channel,u=X$.has(e),c=i.filter(function(t){return t.name===n.signals[u?"data":"visual"];})[0],l=t.getSizeSignalRef(r).signal,f=t.getScaleComponent(s),h=f.get("type"),d=u?Y$(t,s):c.name,p=a+rH,m="".concat(u?"log"===h?"zoomLog":"pow"===h?"zoomPow":"zoomLinear":"zoomLinear","(").concat(d,", ","".concat(a).concat(nH,".").concat(s),", ").concat(p)+(u&&"pow"===h?", ".concat(null!==(o=f.get("exponent"))&&void 0!==o?o:1):"")+")";c.on.push({events:{signal:p},update:u?m:"clampRange(".concat(m,", 0, ").concat(l,")")});}var oH=[{has:function has(){return !0;},parse:function parse(t,e,n){var r,i,o;var a=e.name,s=null!==(r=e.project)&&void 0!==r?r:e.project=new(/*#__PURE__*/function(){function _class2(){_classCallCheck(this,_class2);for(var _len9=arguments.length,t=new Array(_len9),_key9=0;_key9<_len9;_key9++){t[_key9]=arguments[_key9];}this.items=t,this.hasChannel={},this.hasField={};}return _class2;}())(),u={},c={},l=new Set(),f=function f(t,e){var n="visual"===e?t.channel:t.field;var r=KM("".concat(a,"_").concat(n));for(var _t168=1;l.has(r);_t168++){r=KM("".concat(a,"_").concat(n,"_").concat(_t168));}return l.add(r),_defineProperty({},e,r);};if(!n.fields&&!n.encodings){var _e172=t.config.selection[n.type];if(n.init){var _iterator80=_createForOfIteratorHelper(cM(n.init)),_step80;try{for(_iterator80.s();!(_step80=_iterator80.n()).done;){var _t169=_step80.value;var _iterator81=_createForOfIteratorHelper(qM(_t169)),_step81;try{for(_iterator81.s();!(_step81=_iterator81.n()).done;){var _r138=_step81.value;XB(_r138)?(n.encodings||(n.encodings=[])).push(_r138):"interval"===n.type?(mz('Interval selections should be initialized using "x" and/or "y" keys.'),n.encodings=_e172.encodings):(n.fields||(n.fields=[])).push(_r138);}}catch(err){_iterator81.e(err);}finally{_iterator81.f();}}}catch(err){_iterator80.e(err);}finally{_iterator80.f();}}else n.encodings=_e172.encodings,n.fields=_e172.fields;}var _iterator82=_createForOfIteratorHelper(null!==(i=n.fields)&&void 0!==i?i:[]),_step82;try{for(_iterator82.s();!(_step82=_iterator82.n()).done;){var _t171=_step82.value;var _e173={type:"E",field:_t171};_e173.signals=Object.assign({},f(_e173,"data")),s.items.push(_e173),s.hasField[_t171]=_e173;}}catch(err){_iterator82.e(err);}finally{_iterator82.f();}var _iterator83=_createForOfIteratorHelper(null!==(o=n.encodings)&&void 0!==o?o:[]),_step83;try{for(_iterator83.s();!(_step83=_iterator83.n()).done;){var _r140=_step83.value;var _n138=t.fieldDef(_r140);if(_n138){var _i104=_n138.field;if(_n138.aggregate){mz(y.cannotProjectAggregate(_r140,_n138.aggregate));continue;}if(!_i104){mz(y.cannotProjectOnChannelWithoutField(_r140));continue;}if(_n138.timeUnit){_i104=t.vgField(_r140);var _e174={timeUnit:_n138.timeUnit,as:_i104,field:_n138.field};c[IM(_e174)]=_e174;}if(!u[_i104]){var _o54="E";if("interval"===e.type){gU(t.getScaleComponent(_r140).get("type"))&&(_o54="R");}else _n138.bin&&(_o54="R-RE");var _a54={field:_i104,channel:_r140,type:_o54};_a54.signals=Object.assign(Object.assign({},f(_a54,"data")),f(_a54,"visual")),s.items.push(u[_i104]=_a54),s.hasField[_i104]=s.hasChannel[_r140]=u[_i104];}}else mz(y.cannotProjectOnChannelWithoutField(_r140));}}catch(err){_iterator83.e(err);}finally{_iterator83.f();}if(n.init){var _t170=function _t170(t){return s.items.map(function(e){return void 0!==t[e.channel]?t[e.channel]:t[e.field];});};if("interval"===n.type)e.init=_t170(n.init);else {var _r139=cM(n.init);e.init=_r139.map(_t170);}}VM(c)||(s.timeUnit=new $$(null,c));},signals:function signals(t,e,n){var r=e.name+H$;return n.filter(function(t){return t.name===r;}).length>0?n:n.concat({name:r,value:e.project.items.map(function(t){t.signals;t.hasLegend;var r=yM(t,["signals","hasLegend"]);return r.field=tj(r.field),r;})});}},K$,X$,Q$,{has:function has(t){return "interval"===t.type&&t.translate;},signals:function signals(t,e,n){var r=e.name,i=X$.has(e),o=r+Z$,_e$project$hasChannel2=e.project.hasChannel,a=_e$project$hasChannel2.x,s=_e$project$hasChannel2.y;var u=zR(e.translate,"scope");return i||(u=u.map(function(t){return t.between[0].markname=r+lH,t;})),n.push({name:o,value:{},on:[{events:u.map(function(t){return t.between[0];}),update:"{x: x(unit), y: y(unit)"+(void 0!==a?", extent_x: "+(i?Y$(t,tB):"slice(".concat(a.signals.visual,")")):"")+(void 0!==s?", extent_y: "+(i?Y$(t,eB):"slice(".concat(s.signals.visual,")")):"")+"}"}]},{name:r+tH,value:{},on:[{events:u,update:"{x: ".concat(o,".x - x(unit), y: ").concat(o,".y - y(unit)}")}]}),void 0!==a&&eH(t,e,a,"width",n),void 0!==s&&eH(t,e,s,"height",n),n;}},{has:function has(t){return "interval"===t.type&&t.zoom;},signals:function signals(t,e,n){var r=e.name,i=X$.has(e),o=r+rH,_e$project$hasChannel3=e.project.hasChannel,a=_e$project$hasChannel3.x,s=_e$project$hasChannel3.y,u=gM(t.scaleName(tB)),c=gM(t.scaleName(eB));var l=zR(e.zoom,"scope");return i||(l=l.map(function(t){return t.markname=r+lH,t;})),n.push({name:r+nH,on:[{events:l,update:i?"{"+[u?"x: invert(".concat(u,", x(unit))"):"",c?"y: invert(".concat(c,", y(unit))"):""].filter(function(t){return !!t;}).join(", ")+"}":"{x: x(unit), y: y(unit)}"}]},{name:o,on:[{events:l,force:!0,update:"pow(1.001, event.deltaY * pow(16, event.deltaMode))"}]}),void 0!==a&&iH(t,e,a,"width",n),void 0!==s&&iH(t,e,s,"height",n),n;}},G$,W$,{has:function has(t){return void 0!==t.clear&&!1!==t.clear;},parse:function parse(t,e,n){n.clear&&(e.clear=mM(n.clear)?zR(n.clear,"scope"):n.clear);},topLevelSignals:function topLevelSignals(t,e,n){if(G$.has(e)){var _iterator84=_createForOfIteratorHelper(e.project.items),_step84;try{var _loop5=function _loop5(){var t=_step84.value;var r=n.findIndex(function(n){return n.name===KM("".concat(e.name,"_").concat(t.field));});-1!==r&&n[r].on.push({events:e.clear,update:"null"});};for(_iterator84.s();!(_step84=_iterator84.n()).done;){_loop5();}}catch(err){_iterator84.e(err);}finally{_iterator84.f();}}return n;},signals:function signals(t,e,n){function r(t,r){-1!==t&&n[t].on&&n[t].on.push({events:e.clear,update:r});}if("interval"===e.type){var _iterator85=_createForOfIteratorHelper(e.project.items),_step85;try{var _loop6=function _loop6(){var t=_step85.value;var e=n.findIndex(function(e){return e.name===t.signals.visual;});if(r(e,"[0, 0]"),-1===e){r(n.findIndex(function(e){return e.name===t.signals.data;}),"null");}};for(_iterator85.s();!(_step85=_iterator85.n()).done;){_loop6();}}catch(err){_iterator85.e(err);}finally{_iterator85.f();}}else {var _t172=n.findIndex(function(t){return t.name===e.name+yH;});r(_t172,"null"),K$.has(e)&&r(_t172=n.findIndex(function(t){return t.name===e.name+"_toggle";}),"false");}return n;}}];function aH(t,e){var _iterator86=_createForOfIteratorHelper(oH),_step86;try{for(_iterator86.s();!(_step86=_iterator86.n()).done;){var _n139=_step86.value;_n139.has(t)&&e(_n139);}}catch(err){_iterator86.e(err);}finally{_iterator86.f();}}function sH(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!0;var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:eM;if(rM(t)){var _r141=t.map(function(t){return sH(t,e,n);});return e?"[".concat(_r141.join(", "),"]"):_r141;}return gz(t)?n(e?kz(t):function(t){var e=wz(t,!0);return t.utc?+new Date(Date.UTC.apply(Date,_toConsumableArray(e))):+_construct(Date,_toConsumableArray(e));}(t)):e?n(JSON.stringify(t)):t;}function uH(t,e){return kH(t,function(n,r){e=r.marks?r.marks(t,n,e):e,aH(n,function(r){r.marks&&(e=r.marks(t,n,e));});}),e;}function cH(t){return t.map(function(t){return t.on&&!t.on.length&&delete t.on,t;});}var lH="_brush",fH="_scale_trigger",hH={signals:function signals(t,e){var n=e.name,r=n+H$,i=X$.has(e),o=[],a=[],s=[];if(e.translate&&!i){var _t173="!event.item || event.item.mark.name !== ".concat(gM(n+lH));dH(e,function(e,n){var r;var i=cM(null!==(r=n.between[0].filter)&&void 0!==r?r:n.between[0].filter=[]);return i.indexOf(_t173)<0&&i.push(_t173),e;});}e.project.items.forEach(function(n,r){var i=n.channel;if(i!==tB&&i!==eB)return void mz("Interval selections only support x and y encoding channels.");var u=e.init?e.init[r]:null,c=function(t,e,n,r){var i=n.channel,o=n.signals.visual,a=n.signals.data,s=X$.has(e),u=gM(t.scaleName(i)),c=t.getScaleComponent(i),l=c?c.get("type"):void 0,f=function f(t){return "scale(".concat(u,", ").concat(t,")");},h=t.getSizeSignalRef(i===tB?"width":"height").signal,d="".concat(i,"(unit)"),p=dH(e,function(t,e){return [].concat(_toConsumableArray(t),[{events:e.between[0],update:"[".concat(d,", ").concat(d,"]")},{events:e,update:"[".concat(o,"[0], clamp(").concat(d,", 0, ").concat(h,")]")}]);});return p.push({events:{signal:e.name+fH},update:gU(l)?"[".concat(f("".concat(a,"[0]")),", ").concat(f("".concat(a,"[1]")),"]"):"[0, 0]"}),s?[{name:a,on:[]}]:[Object.assign(Object.assign({name:o},r?{init:sH(r,!0,f)}:{value:[]}),{on:p}),Object.assign(Object.assign({name:a},r?{init:sH(r)}:{}),{on:[{events:{signal:o},update:"".concat(o,"[0] === ").concat(o,"[1] ? null : invert(").concat(u,", ").concat(o,")")}]})];}(t,e,n,u),l=n.signals.data,f=n.signals.visual,h=gM(t.scaleName(i)),d=gU(t.getScaleComponent(i).get("type"))?"+":"";o.push.apply(o,_toConsumableArray(c)),a.push(l),s.push({scaleName:t.scaleName(i),expr:"(!isArray(".concat(l,") || ")+"(".concat(d,"invert(").concat(h,", ").concat(f,")[0] === ").concat(d).concat(l,"[0] && ")+"".concat(d,"invert(").concat(h,", ").concat(f,")[1] === ").concat(d).concat(l,"[1]))")});}),i||o.push({name:n+fH,value:{},on:[{events:s.map(function(t){return {scale:t.scaleName};}),update:s.map(function(t){return t.expr;}).join(" && ")+" ? ".concat(n+fH," : {}")}]});var u=e.init,c="unit: ".concat(EH(t),", fields: ").concat(r,", values");return o.concat(Object.assign(Object.assign({name:n+yH},u?{init:"{".concat(c,": ").concat(sH(u),"}")}:{}),{on:[{events:[{signal:a.join(" || ")}],update:a.join(" && ")+" ? {".concat(c,": [").concat(a,"]} : null")}]}));},modifyExpr:function modifyExpr(t,e){return e.name+yH+", "+("global"===e.resolve?"true":"{unit: ".concat(EH(t),"}"));},marks:function marks(t,e,n){var r=e.name,_e$project$hasChannel4=e.project.hasChannel,i=_e$project$hasChannel4.x,o=_e$project$hasChannel4.y,a=i&&i.signals.visual,s=o&&o.signals.visual,u="data(".concat(gM(e.name+vH),")");if(X$.has(e))return n;var c={x:void 0!==i?{signal:"".concat(a,"[0]")}:{value:0},y:void 0!==o?{signal:"".concat(s,"[0]")}:{value:0},x2:void 0!==i?{signal:"".concat(a,"[1]")}:{field:{group:"width"}},y2:void 0!==o?{signal:"".concat(s,"[1]")}:{field:{group:"height"}}};if("global"===e.resolve){var _iterator87=_createForOfIteratorHelper(qM(c)),_step87;try{for(_iterator87.s();!(_step87=_iterator87.n()).done;){var _e175=_step87.value;c[_e175]=[Object.assign({test:"".concat(u,".length && ").concat(u,"[0].unit === ").concat(EH(t))},c[_e175]),{value:0}];}}catch(err){_iterator87.e(err);}finally{_iterator87.f();}}var l=e.mark,f=l.fill,h=l.fillOpacity,d=l.cursor,p=yM(l,["fill","fillOpacity","cursor"]),m=qM(p).reduce(function(t,e){return t[e]=[{test:[void 0!==i&&"".concat(a,"[0] !== ").concat(a,"[1]"),void 0!==o&&"".concat(s,"[0] !== ").concat(s,"[1]")].filter(function(t){return t;}).join(" && "),value:p[e]},{value:null}],t;},{});return [{name:r+lH+"_bg",type:"rect",clip:!0,encode:{enter:{fill:{value:f},fillOpacity:{value:h}},update:c}}].concat(_toConsumableArray(n),[{name:r+lH,type:"rect",clip:!0,encode:{enter:Object.assign(Object.assign({},d?{cursor:{value:d}}:{}),{fill:{value:"transparent"}}),update:Object.assign(Object.assign({},c),m)}}]);}};function dH(t,e){return t.events.reduce(function(t,n){return n.between?e(t,n):(mz("".concat(n," is not an ordered event stream for interval selections.")),t);},[]);}function pH(t,e){var n=e.name,r=n+H$,i="(item().isVoronoi ? datum.datum : datum)",o=e.project.items.map(function(e){var n=t.fieldDef(e.channel);return n&&n.bin?"[".concat(i,"[").concat(gM(t.vgField(e.channel,{})),"], ")+"".concat(i,"[").concat(gM(t.vgField(e.channel,{binSuffix:"end"})),"]]"):"".concat(i,"[").concat(gM(e.field),"]");}).join(", "),a="unit: ".concat(EH(t),", fields: ").concat(r,", values"),s=e.events;return [{name:n+yH,on:s?[{events:s,update:"datum && item().mark.marktype !== 'group' ? {".concat(a,": [").concat(o,"]} : null"),force:!0}]:[]}];}var mH={signals:pH,modifyExpr:function modifyExpr(t,e){return e.name+yH+", "+("global"===e.resolve?"null":"{unit: ".concat(EH(t),"}"));}};var gH={signals:pH,modifyExpr:function modifyExpr(t,e){return e.name+yH+", "+("global"===e.resolve?"true":"{unit: ".concat(EH(t),"}"));}};var vH="_store",yH="_tuple",bH="_modify",xH="vlSelectionResolve",wH={single:gH,multi:mH,interval:hH};function kH(t,e){var n=t.component.selection;if(n){var _iterator88=_createForOfIteratorHelper($M(n)),_step88;try{for(_iterator88.s();!(_step88=_iterator88.n()).done;){var _t174=_step88.value;if(!0===e(_t174,wH[_t174.type]))break;}}catch(err){_iterator88.e(err);}finally{_iterator88.f();}}}function EH(t){var _ref71=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{escape:!0},e=_ref71.escape;var n=e?gM(t.name):t.name;var r=function(t){var e=t.parent;for(;e&&!JY(e);){e=e.parent;}return e;}(t);if(r){var _t175=r.facet;var _iterator89=_createForOfIteratorHelper(PB),_step89;try{for(_iterator89.s();!(_step89=_iterator89.n()).done;){var _e176=_step89.value;_t175[_e176]&&(n+=" + '__facet_".concat(_e176,"_' + (facet[").concat(gM(r.vgField(_e176)),"])"));}}catch(err){_iterator89.e(err);}finally{_iterator89.f();}}return n;}function CH(t){var e=!1;return kH(t,function(t){e=e||t.project.items.some(function(t){return t.field===zV;});}),e;}var AH="RawCode",OH="Literal",_H="Property",SH="Identifier",DH="ArrayExpression",FH="BinaryExpression",TH="CallExpression",NH="ConditionalExpression",IH="LogicalExpression",RH="MemberExpression",MH="ObjectExpression",jH="UnaryExpression";function BH(t){this.type=t;}var PH,LH,zH,UH,WH;BH.prototype.visit=function(t){var e,n,r;if(t(this))return 1;for(n=0,r=(e=function(t){switch(t.type){case DH:return t.elements;case FH:case IH:return [t.left,t.right];case TH:return [t.callee].concat(t.arguments);case NH:return [t.test,t.consequent,t.alternate];case RH:return [t.object,t.property];case MH:return t.properties;case _H:return [t.key,t.value];case jH:return [t.argument];case SH:case OH:case AH:default:return [];}}(this)).length;n<r;++n){if(e[n].visit(t))return 1;}};var VH=1,qH=2,$H=3,HH=4,GH=5,KH=6,XH=7,YH=8;(PH={})[VH]="Boolean",PH[qH]="<end>",PH[$H]="Identifier",PH[HH]="Keyword",PH[GH]="Null",PH[KH]="Numeric",PH[XH]="Punctuator",PH[YH]="String",PH[9]="RegularExpression";var JH="ArrayExpression",QH="BinaryExpression",ZH="CallExpression",tG="ConditionalExpression",eG="Identifier",nG="Literal",rG="LogicalExpression",iG="MemberExpression",oG="ObjectExpression",aG="Property",sG="UnaryExpression",uG="Unexpected token %0",cG="Unexpected number",lG="Unexpected string",fG="Unexpected identifier",hG="Unexpected reserved word",dG="Unexpected end of input",pG="Invalid regular expression",mG="Invalid regular expression: missing /",gG="Octal literals are not allowed in strict mode.",vG="Duplicate data property in object literal not allowed in strict mode",yG="ILLEGAL",bG="Disabled.",xG=new RegExp("[\\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\\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-\\u08B2\\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\\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-\\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-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\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-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\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-\\uAB5F\\uAB64\\uAB65\\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\\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]"),wG=new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C81-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\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\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\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\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\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-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\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-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]");function kG(t,e){if(!t)throw new Error("ASSERT: "+e);}function EG(t){return t>=48&&t<=57;}function CG(t){return "0123456789abcdefABCDEF".indexOf(t)>=0;}function AG(t){return "01234567".indexOf(t)>=0;}function OG(t){return 32===t||9===t||11===t||12===t||160===t||t>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(t)>=0;}function _G(t){return 10===t||13===t||8232===t||8233===t;}function SG(t){return 36===t||95===t||t>=65&&t<=90||t>=97&&t<=122||92===t||t>=128&&xG.test(String.fromCharCode(t));}function DG(t){return 36===t||95===t||t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||92===t||t>=128&&wG.test(String.fromCharCode(t));}var FG={if:1,in:1,do:1,var:1,for:1,new:1,try:1,let:1,this:1,else:1,case:1,void:1,with:1,enum:1,while:1,break:1,catch:1,throw:1,const:1,yield:1,class:1,super:1,return:1,typeof:1,delete:1,switch:1,export:1,import:1,public:1,static:1,default:1,finally:1,extends:1,package:1,private:1,function:1,continue:1,debugger:1,interface:1,protected:1,instanceof:1,implements:1};function TG(){for(var t;zH<UH&&(OG(t=LH.charCodeAt(zH))||_G(t));){++zH;}}function NG(t){var e,n,r,i=0;for(n="u"===t?4:2,e=0;e<n;++e){zH<UH&&CG(LH[zH])?(r=LH[zH++],i=16*i+"0123456789abcdef".indexOf(r.toLowerCase())):KG({},uG,yG);}return String.fromCharCode(i);}function IG(){var t,e,n,r;for(e=0,"}"===(t=LH[zH])&&KG({},uG,yG);zH<UH&&CG(t=LH[zH++]);){e=16*e+"0123456789abcdef".indexOf(t.toLowerCase());}return (e>1114111||"}"!==t)&&KG({},uG,yG),e<=65535?String.fromCharCode(e):(n=55296+(e-65536>>10),r=56320+(e-65536&1023),String.fromCharCode(n,r));}function RG(){var t,e;for(t=LH.charCodeAt(zH++),e=String.fromCharCode(t),92===t&&(117!==LH.charCodeAt(zH)&&KG({},uG,yG),++zH,(t=NG("u"))&&"\\"!==t&&SG(t.charCodeAt(0))||KG({},uG,yG),e=t);zH<UH&&DG(t=LH.charCodeAt(zH));){++zH,e+=String.fromCharCode(t),92===t&&(e=e.substr(0,e.length-1),117!==LH.charCodeAt(zH)&&KG({},uG,yG),++zH,(t=NG("u"))&&"\\"!==t&&DG(t.charCodeAt(0))||KG({},uG,yG),e+=t);}return e;}function MG(){var t,e;return t=zH,{type:1===(e=92===LH.charCodeAt(zH)?RG():function(){var t,e;for(t=zH++;zH<UH;){if(92===(e=LH.charCodeAt(zH)))return zH=t,RG();if(!DG(e))break;++zH;}return LH.slice(t,zH);}()).length?$H:FG.hasOwnProperty(e)?HH:"null"===e?GH:"true"===e||"false"===e?VH:$H,value:e,start:t,end:zH};}function jG(){var t,e,n,r,i=zH,o=LH.charCodeAt(zH),a=LH[zH];switch(o){case 46:case 40:case 41:case 59:case 44:case 123:case 125:case 91:case 93:case 58:case 63:case 126:return ++zH,{type:XH,value:String.fromCharCode(o),start:i,end:zH};default:if(61===(t=LH.charCodeAt(zH+1)))switch(o){case 43:case 45:case 47:case 60:case 62:case 94:case 124:case 37:case 38:case 42:return zH+=2,{type:XH,value:String.fromCharCode(o)+String.fromCharCode(t),start:i,end:zH};case 33:case 61:return zH+=2,61===LH.charCodeAt(zH)&&++zH,{type:XH,value:LH.slice(i,zH),start:i,end:zH};}}return ">>>="===(r=LH.substr(zH,4))?{type:XH,value:r,start:i,end:zH+=4}:">>>"===(n=r.substr(0,3))||"<<="===n||">>="===n?{type:XH,value:n,start:i,end:zH+=3}:a===(e=n.substr(0,2))[1]&&"+-<>&|".indexOf(a)>=0||"=>"===e?{type:XH,value:e,start:i,end:zH+=2}:"<>=!+-*%&|^/".indexOf(a)>=0?{type:XH,value:a,start:i,end:++zH}:void KG({},uG,yG);}function BG(){var t,e,n;if(kG(EG((n=LH[zH]).charCodeAt(0))||"."===n,"Numeric literal must start with a decimal digit or a decimal point"),e=zH,t="","."!==n){if(t=LH[zH++],n=LH[zH],"0"===t){if("x"===n||"X"===n)return ++zH,function(t){for(var e="";zH<UH&&CG(LH[zH]);){e+=LH[zH++];}return 0===e.length&&KG({},uG,yG),SG(LH.charCodeAt(zH))&&KG({},uG,yG),{type:KH,value:parseInt("0x"+e,16),start:t,end:zH};}(e);if(AG(n))return function(t){for(var e="0"+LH[zH++];zH<UH&&AG(LH[zH]);){e+=LH[zH++];}return (SG(LH.charCodeAt(zH))||EG(LH.charCodeAt(zH)))&&KG({},uG,yG),{type:KH,value:parseInt(e,8),octal:!0,start:t,end:zH};}(e);n&&EG(n.charCodeAt(0))&&KG({},uG,yG);}for(;EG(LH.charCodeAt(zH));){t+=LH[zH++];}n=LH[zH];}if("."===n){for(t+=LH[zH++];EG(LH.charCodeAt(zH));){t+=LH[zH++];}n=LH[zH];}if("e"===n||"E"===n)if(t+=LH[zH++],"+"!==(n=LH[zH])&&"-"!==n||(t+=LH[zH++]),EG(LH.charCodeAt(zH)))for(;EG(LH.charCodeAt(zH));){t+=LH[zH++];}else KG({},uG,yG);return SG(LH.charCodeAt(zH))&&KG({},uG,yG),{type:KH,value:parseFloat(t),start:e,end:zH};}function PG(){var t,e,n,r;return WH=null,TG(),t=zH,e=function(){var t,e,n,r;for(kG("/"===(t=LH[zH]),"Regular expression literal must start with a slash"),e=LH[zH++],n=!1,r=!1;zH<UH;){if(e+=t=LH[zH++],"\\"===t)_G((t=LH[zH++]).charCodeAt(0))&&KG({},mG),e+=t;else if(_G(t.charCodeAt(0)))KG({},mG);else if(n)"]"===t&&(n=!1);else {if("/"===t){r=!0;break;}"["===t&&(n=!0);}}return r||KG({},mG),{value:e.substr(1,e.length-2),literal:e};}(),n=function(){var t,e,n;for(e="",n="";zH<UH&&DG((t=LH[zH]).charCodeAt(0));){++zH,"\\"===t&&zH<UH?KG({},uG,yG):(n+=t,e+=t);}return n.search(/[^gimuy]/g)>=0&&KG({},pG,n),{value:n,literal:e};}(),r=function(t,e){var n=t;e.indexOf("u")>=0&&(n=n.replace(/\\u\{([0-9a-fA-F]+)\}/g,function(t,e){if(parseInt(e,16)<=1114111)return "x";KG({},pG);}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"x"));try{new RegExp(n);}catch(t){KG({},pG);}try{return new RegExp(t,e);}catch(t){return null;}}(e.value,n.value),{literal:e.literal+n.literal,value:r,regex:{pattern:e.value,flags:n.value},start:t,end:zH};}function LG(){var t;return TG(),zH>=UH?{type:qH,start:zH,end:zH}:SG(t=LH.charCodeAt(zH))?MG():40===t||41===t||59===t?jG():39===t||34===t?function(){var t,e,n,r,i="",o=!1;for(kG("'"===(t=LH[zH])||'"'===t,"String literal must starts with a quote"),e=zH,++zH;zH<UH;){if((n=LH[zH++])===t){t="";break;}if("\\"===n){if((n=LH[zH++])&&_G(n.charCodeAt(0)))"\r"===n&&"\n"===LH[zH]&&++zH;else switch(n){case"u":case"x":"{"===LH[zH]?(++zH,i+=IG()):i+=NG(n);break;case"n":i+="\n";break;case"r":i+="\r";break;case"t":i+="\t";break;case"b":i+="\b";break;case"f":i+="\f";break;case"v":i+="\v";break;default:AG(n)?(0!==(r="01234567".indexOf(n))&&(o=!0),zH<UH&&AG(LH[zH])&&(o=!0,r=8*r+"01234567".indexOf(LH[zH++]),"0123".indexOf(n)>=0&&zH<UH&&AG(LH[zH])&&(r=8*r+"01234567".indexOf(LH[zH++]))),i+=String.fromCharCode(r)):i+=n;}}else {if(_G(n.charCodeAt(0)))break;i+=n;}}return ""!==t&&KG({},uG,yG),{type:YH,value:i,octal:o,start:e,end:zH};}():46===t?EG(LH.charCodeAt(zH+1))?BG():jG():EG(t)?BG():jG();}function zG(){var t;return zH=(t=WH).end,WH=LG(),zH=t.end,t;}function UG(){var t;t=zH,WH=LG(),zH=t;}function WG(t,e,n){var r=new BH("||"===t||"&&"===t?rG:QH);return r.operator=t,r.left=e,r.right=n,r;}function VG(t,e){var n=new BH(ZH);return n.callee=t,n.arguments=e,n;}function qG(t){var e=new BH(eG);return e.name=t,e;}function $G(t){var e=new BH(nG);return e.value=t.value,e.raw=LH.slice(t.start,t.end),t.regex&&("//"===e.raw&&(e.raw="/(?:)/"),e.regex=t.regex),e;}function HG(t,e,n){var r=new BH(iG);return r.computed="["===t,r.object=e,r.property=n,r.computed||(n.member=!0),r;}function GG(t,e,n){var r=new BH(aG);return r.key=e,r.value=n,r.kind=t,r;}function KG(t,e){var n,r=Array.prototype.slice.call(arguments,2),i=e.replace(/%(\d)/g,function(t,e){return kG(e<r.length,"Message reference must be in range"),r[e];});throw (n=new Error(i)).index=zH,n.description=i,n;}function XG(t){t.type===qH&&KG(t,dG),t.type===KH&&KG(t,cG),t.type===YH&&KG(t,lG),t.type===$H&&KG(t,fG),t.type===HH&&KG(t,hG),KG(t,uG,t.value);}function YG(t){var e=zG();e.type===XH&&e.value===t||XG(e);}function JG(t){return WH.type===XH&&WH.value===t;}function QG(t){return WH.type===HH&&WH.value===t;}function ZG(){var t=[];for(zH=WH.start,YG("[");!JG("]");){JG(",")?(zG(),t.push(null)):(t.push(fK()),JG("]")||YG(","));}return zG(),function(t){var e=new BH(JH);return e.elements=t,e;}(t);}function tK(){var t;return zH=WH.start,(t=zG()).type===YH||t.type===KH?(t.octal&&KG(t,gG),$G(t)):qG(t.value);}function eK(){var t,e,n;return zH=WH.start,(t=WH).type===$H?(n=tK(),YG(":"),GG("init",n,fK())):t.type!==qH&&t.type!==XH?(e=tK(),YG(":"),GG("init",e,fK())):void XG(t);}function nK(){var t,e,n=[],r={},i=String;for(zH=WH.start,YG("{");!JG("}");){e="$"+((t=eK()).key.type===eG?t.key.name:i(t.key.value)),Object.prototype.hasOwnProperty.call(r,e)?KG({},vG):r[e]=!0,n.push(t),JG("}")||YG(",");}return YG("}"),function(t){var e=new BH(oG);return e.properties=t,e;}(n);}var rK={if:1};function iK(){var t,e,n;if(JG("("))return function(){var t;return YG("("),t=hK(),YG(")"),t;}();if(JG("["))return ZG();if(JG("{"))return nK();if(t=WH.type,zH=WH.start,t===$H||rK[WH.value])n=qG(zG().value);else if(t===YH||t===KH)WH.octal&&KG(WH,gG),n=$G(zG());else {if(t===HH)throw new Error(bG);t===VH?((e=zG()).value="true"===e.value,n=$G(e)):t===GH?((e=zG()).value=null,n=$G(e)):JG("/")||JG("/=")?(n=$G(PG()),UG()):XG(zG());}return n;}function oK(){var t=[];if(YG("("),!JG(")"))for(;zH<UH&&(t.push(fK()),!JG(")"));){YG(",");}return YG(")"),t;}function aK(){var t;return zH=WH.start,function(t){return t.type===$H||t.type===HH||t.type===VH||t.type===GH;}(t=zG())||XG(t),qG(t.value);}function sK(){var t;return YG("["),t=hK(),YG("]"),t;}function uK(){var t=function(){var t;for(t=iK();;){if(JG("."))YG("."),t=HG(".",t,aK());else if(JG("("))t=VG(t,oK());else {if(!JG("["))break;t=HG("[",t,sK());}}return t;}();if(WH.type===XH&&(JG("++")||JG("--")))throw new Error(bG);return t;}function cK(){var t,e;if(WH.type!==XH&&WH.type!==HH)e=uK();else {if(JG("++")||JG("--"))throw new Error(bG);if(JG("+")||JG("-")||JG("~")||JG("!"))t=zG(),e=cK(),e=function(t,e){var n=new BH(sG);return n.operator=t,n.argument=e,n.prefix=!0,n;}(t.value,e);else {if(QG("delete")||QG("void")||QG("typeof"))throw new Error(bG);e=uK();}}return e;}function lK(t){var e=0;if(t.type!==XH&&t.type!==HH)return 0;switch(t.value){case"||":e=1;break;case"&&":e=2;break;case"|":e=3;break;case"^":e=4;break;case"&":e=5;break;case"==":case"!=":case"===":case"!==":e=6;break;case"<":case">":case"<=":case">=":case"instanceof":case"in":e=7;break;case"<<":case">>":case">>>":e=8;break;case"+":case"-":e=9;break;case"*":case"/":case"%":e=11;}return e;}function fK(){var t,e;return t=function(){var t,e,n,r,i,o,a,s,u,c;if(t=WH,u=cK(),0===(i=lK(r=WH)))return u;for(r.prec=i,zG(),e=[t,WH],o=[u,r,a=cK()];(i=lK(WH))>0;){for(;o.length>2&&i<=o[o.length-2].prec;){a=o.pop(),s=o.pop().value,u=o.pop(),e.pop(),n=WG(s,u,a),o.push(n);}(r=zG()).prec=i,o.push(r),e.push(WH),n=cK(),o.push(n);}for(n=o[c=o.length-1],e.pop();c>1;){e.pop(),n=WG(o[c-1].value,o[c-2],n),c-=2;}return n;}(),JG("?")&&(zG(),e=fK(),YG(":"),t=function(t,e,n){var r=new BH(tG);return r.test=t,r.consequent=e,r.alternate=n,r;}(t,e,fK())),t;}function hK(){var t=fK();if(JG(","))throw new Error(bG);return t;}var dK=function dK(t){zH=0,UH=(LH=t).length,WH=null,UG();var e=hK();if(WH.type!==qH)throw new Error("Unexpect token after expression.");return e;};function pK(t,e,n){return t.fields=e||[],t.fname=n,t;}function mK(t){return 1===t.length?gK(t[0]):vK(t);}var gK=function gK(t){return function(e){return e[t];};},vK=function vK(t){var e=t.length;return function(n){for(var _r142=0;_r142<e;++_r142){n=n[t[_r142]];}return n;};};function yK(t){throw Error(t);}function bK(t){var e=[],n=t.length;var r,i,o,a=null,s=0,u="";function c(){e.push(u+t.substring(r,i)),u="",r=i+1;}for(t+="",r=i=0;i<n;++i){if("\\"===(o=t[i]))u+=t.substring(r,i),u+=t.substring(++i,++i),r=i;else if(o===a)c(),a=null,s=-1;else {if(a)continue;r===s&&'"'===o?(r=i+1,a=o):r===s&&"'"===o?(r=i+1,a=o):"."!==o||s?"["===o?(i>r&&c(),s=r=i+1):"]"===o&&(s||yK("Access path missing open bracket: "+t),s>0&&c(),s=0,r=i+1):i>r?c():r=i+1;}}return s&&yK("Access path missing closing bracket: "+t),a&&yK("Access path missing closing quote: "+t),i>r&&(i++,c()),e;}function xK(t,e,n){var r=bK(t);return t=1===r.length?r[0]:t,pK((n&&n.get||mK)(r),[t],e||t);}xK("id"),pK(function(t){return t;},[],"identity"),pK(function(){return 0;},[],"zero"),pK(function(){return 1;},[],"one"),pK(function(){return !0;},[],"true"),pK(function(){return !1;},[],"false");function wK(t){var e=dK(t),n=new Set();return e.visit(function(t){"MemberExpression"===t.type&&function t(e){return "MemberExpression"===e.object.type?t(e.object):"datum"===e.object.name;}(t)&&n.add(function t(e){var n=[];return "Identifier"===e.type?[e.name]:"Literal"===e.type?[e.value]:("MemberExpression"===e.type&&(n.push.apply(n,_toConsumableArray(t(e.object))),n.push.apply(n,_toConsumableArray(t(e.property)))),n);}(t).slice(1).join("."));}),n;}var kK=/*#__PURE__*/function(_V$3){_inherits(kK,_V$3);var _super5=_createSuper(kK);function kK(t,e,n){var _this34;_classCallCheck(this,kK);_this34=_super5.call(this,t),_this34.model=e,_this34.filter=n,_this34.expr=AK(_this34.model,_this34.filter,_assertThisInitialized(_this34)),_this34._dependentFields=wK(_this34.expr);return _this34;}_createClass(kK,[{key:"clone",value:function clone(){return new kK(null,this.model,DM(this.filter));}},{key:"dependentFields",value:function dependentFields(){return this._dependentFields;}},{key:"producedFields",value:function producedFields(){return new Set();}},{key:"assemble",value:function assemble(){return {type:"filter",expr:this.expr};}},{key:"hash",value:function hash(){return "Filter ".concat(this.expr);}}]);return kK;}(V$);function EK(t,e,n){var r=arguments.length>3&&arguments[3]!==undefined?arguments[3]:"datum";var i=[];var o=XM(e,function(e){var o=KM(e),a=t.getSelectionComponent(o,e),s=gM(o+vH);if(a.project.timeUnit){var _e177=null!==n&&void 0!==n?n:t.component.data.raw,_r143=a.project.timeUnit.clone();_e177.parent?_r143.insertAsParentOf(_e177):_e177.parent=_r143;}return "none"!==a.empty&&i.push(s),"vlSelectionTest(".concat(s,", ").concat(r)+("global"===a.resolve?")":", ".concat(gM(a.resolve),")"));});return (i.length?"!("+i.map(function(t){return "length(data(".concat(t,"))");}).join(" || ")+") || ":"")+"(".concat(o,")");}function CK(t,e){var n=e.encoding;var r=e.field;if(n||r){if(n&&!r){var _i105=t.project.items.filter(function(t){return t.channel===n;});!_i105.length||_i105.length>1?(r=t.project.items[0].field,mz((_i105.length?"Multiple ":"No ")+"matching ".concat(gM(n)," encoding found for selection ").concat(gM(e.selection),". ")+"Using \"field\": ".concat(gM(r),"."))):r=_i105[0].field;}}else r=t.project.items[0].field,t.project.items.length>1&&mz('A "field" or "encoding" must be specified when using a selection as a scale domain. '+"Using \"field\": ".concat(gM(r),"."));return "".concat(t.name,"[").concat(gM(r),"]");}function AK(t,e,n){return XM(e,function(e){return mM(e)?e:function(t){return null===t||void 0===t?void 0:t.selection;}(e)?EK(t,e.selection,n):Gz(e);});}function OK(t,e,n,r){var i,o,a;t.encode=null!==(i=t.encode)&&void 0!==i?i:{},t.encode[e]=null!==(o=t.encode[e])&&void 0!==o?o:{},t.encode[e].update=null!==(a=t.encode[e].update)&&void 0!==a?a:{},t.encode[e].update[n]=r;}function _K(t,e,n){var r=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{header:!1};var i,o;var a=t.combine(),s=a.disable,u=a.orient,c=a.scale,l=a.labelExpr,f=a.title,h=a.zindex,d=yM(a,["disable","orient","scale","labelExpr","title","zindex"]);if(!s){for(var _t176 in d){var _n140=hj[_t176],_r144=d[_t176];if(_n140&&_n140!==e&&"both"!==_n140)delete d[_t176];else if(lj(_r144)){var _e178=_r144.condition,_n141=yM(_r144,["condition"]),_i106=cM(_e178),_o55=cj[_t176];if(_o55){var _e179=_o55.vgProp,_r145=_o55.part;OK(d,_r145,_e179,[].concat(_toConsumableArray(_i106.map(function(t){var e=t.test,n=yM(t,["test"]);return Object.assign({test:AK(null,e)},n);})),[_n141])),delete d[_t176];}else if(null===_o55){var _e180={signal:_i106.map(function(t){var e=t.test,n=yM(t,["test"]);return "".concat(AK(null,e)," ? ").concat(XW(n)," : ");}).join("")+XW(_n141)};d[_t176]=_e180;}}else if(Nz(_r144)){var _e181=cj[_t176];if(_e181){var _n142=_e181.vgProp,_i107=_e181.part;OK(d,_i107,_n142,_r144),delete d[_t176];}}}if("grid"===e){if(!d.grid)return;if(d.encode){var _t177=d.encode.grid;d.encode=Object.assign({},_t177?{grid:_t177}:{}),VM(d.encode)&&delete d.encode;}return Object.assign(Object.assign({scale:c,orient:u},d),{domain:!1,labels:!1,aria:!1,maxExtent:0,minExtent:0,ticks:!1,zindex:ij(h,0)});}{if(!r.header&&t.mainExtracted)return;if(void 0!==l){var _t178=l;(null===(o=null===(i=d.encode)||void 0===i?void 0:i.labels)||void 0===o?void 0:o.update)&&Nz(d.encode.labels.update.text)&&(_t178=ej(l,"datum.label",d.encode.labels.update.text.signal)),OK(d,"labels","text",{signal:_t178});}if(null===d.labelAlign&&delete d.labelAlign,d.encode){var _iterator90=_createForOfIteratorHelper(fj),_step90;try{for(_iterator90.s();!(_step90=_iterator90.n()).done;){var _e183=_step90.value;t.hasAxisPart(_e183)||delete d.encode[_e183];}}catch(err){_iterator90.e(err);}finally{_iterator90.f();}VM(d.encode)&&delete d.encode;}var _e182=function(t,e){if(t)return rM(t)&&!GW(t)?t.map(function(t){return IW(t,e);}).join(", "):t;}(f,n);return Object.assign(Object.assign(Object.assign(Object.assign({scale:c,orient:u,grid:!1},_e182?{title:_e182}:{}),d),!1===n.aria?{aria:!1}:{}),{zindex:ij(h,0)});}}}function SK(t){var e=t.component.axes,n=[];var _iterator91=_createForOfIteratorHelper(yP),_step91;try{for(_iterator91.s();!(_step91=_iterator91.n()).done;){var _r146=_step91.value;if(e[_r146]){var _iterator92=_createForOfIteratorHelper(e[_r146]),_step92;try{for(_iterator92.s();!(_step92=_iterator92.n()).done;){var _i108=_step92.value;if(!_i108.get("disable")&&!_i108.get("gridScale")){var _e184="x"===_r146?"height":"width",_i109=t.getSizeSignalRef(_e184).signal;_e184!==_i109&&n.push({name:_e184,update:_i109});}}}catch(err){_iterator92.e(err);}finally{_iterator92.f();}}}}catch(err){_iterator91.e(err);}finally{_iterator91.f();}return n;}var DK={titleAlign:"align",titleAnchor:"anchor",titleAngle:"angle",titleBaseline:"baseline",titleColor:"color",titleFont:"font",titleFontSize:"fontSize",titleFontStyle:"fontStyle",titleFontWeight:"fontWeight",titleLimit:"limit",titleLineHeight:"lineHeight",titleOrient:"orient",titlePadding:"offset"},FK={labelAlign:"align",labelAnchor:"anchor",labelAngle:"angle",labelBaseline:"baseline",labelColor:"color",labelFont:"font",labelFontSize:"fontSize",labelFontStyle:"fontStyle",labelFontWeight:"fontWeight",labelLimit:"limit",labelLineHeight:"lineHeight",labelOrient:"orient",labelPadding:"offset"},TK=qM(DK),NK=qM(FK);function IK(t,e,n,r){return Object.assign.apply(null,[{}].concat(_toConsumableArray(t.map(function(t){if("axisOrient"===t){var _t179="x"===n?"bottom":"left",_i110=e["x"===n?"axisBottom":"axisLeft"]||{},_o56=e["x"===n?"axisTop":"axisRight"]||{},_a55=new Set([].concat(_toConsumableArray(qM(_i110)),_toConsumableArray(qM(_o56)))),_s48={};var _iterator93=_createForOfIteratorHelper(_a55.values()),_step93;try{for(_iterator93.s();!(_step93=_iterator93.n()).done;){var _e185=_step93.value;_s48[_e185]={signal:"".concat(r.signal," === \"").concat(_t179,"\" ? ").concat(YW(_i110[_e185])," : ").concat(YW(_o56[_e185]))};}}catch(err){_iterator93.e(err);}finally{_iterator93.f();}return _s48;}return e[t];}))));}function RK(t,e,n,r){var i="band"===e?["axisDiscrete","axisBand"]:"point"===e?["axisDiscrete","axisPoint"]:function(t){return t in fU;}(e)?["axisQuantitative"]:"time"===e||"utc"===e?["axisTemporal"]:[],o="x"===t?"axisX":"axisY",a=Nz(n)?"axisOrient":"axis"+JM(n),s=[].concat(i,_toConsumableArray(i.map(function(t){return o+t.substr(4);}))),u=["axis",a,o];return {vlOnlyAxisConfig:IK(s,r,t,n),vgAxisConfig:IK(u,r,t,n),axisConfigStyle:function(t,e){var n;var r=[{}];var _iterator94=_createForOfIteratorHelper(t),_step94;try{for(_iterator94.s();!(_step94=_iterator94.n()).done;){var _i111=_step94.value;var _t180=null===(n=e[_i111])||void 0===n?void 0:n.style;if(_t180){_t180=cM(_t180);var _iterator95=_createForOfIteratorHelper(_t180),_step95;try{for(_iterator95.s();!(_step95=_iterator95.n()).done;){var _n143=_step95.value;r.push(e.style[_n143]);}}catch(err){_iterator95.e(err);}finally{_iterator95.f();}}}}catch(err){_iterator94.e(err);}finally{_iterator94.f();}return Object.assign.apply(null,r);}([].concat(u,_toConsumableArray(s)),r)};}function MK(t,e,n){var r=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var i;var o=eV(t,n,e.style);if(void 0!==o)return {configFrom:"style",configValue:o};for(var _i112=0,_arr5=["vlOnlyAxisConfig","vgAxisConfig","axisConfigStyle"];_i112<_arr5.length;_i112++){var _e186=_arr5[_i112];if(void 0!==(null===(i=r[_e186])||void 0===i?void 0:i[t]))return {configFrom:_e186,configValue:r[_e186][t]};}return {};}var jK={scale:function scale(_ref72){var t=_ref72.model,e=_ref72.channel;return t.scaleName(e);},format:function format(_ref73){var t=_ref73.fieldOrDatumDef,e=_ref73.config,n=_ref73.axis;var r=n.format,i=n.formatType;return $U(t,t.type,r,i,e,!0);},formatType:function formatType(_ref74){var t=_ref74.axis,e=_ref74.fieldOrDatumDef,n=_ref74.scaleType;var r=t.formatType;return HU(r,e,n);},grid:function grid(_ref75){var t=_ref75.fieldOrDatumDef,e=_ref75.axis,n=_ref75.scaleType;var r;return (!dW(t)||!VP(t.bin))&&(null!==(r=e.grid)&&void 0!==r?r:function(t,e){return !mU(t)&&dW(e)&&!WP(null===e||void 0===e?void 0:e.bin);}(n,t));},gridScale:function gridScale(_ref76){var t=_ref76.model,e=_ref76.channel;return function(t,e){var n="x"===e?"y":"x";if(t.getScaleComponent(n))return t.scaleName(n);return;}(t,e);},labelAlign:function labelAlign(_ref77){var t=_ref77.axis,e=_ref77.labelAngle,n=_ref77.orient,r=_ref77.channel;return t.labelAlign||LK(e,n,r);},labelAngle:function labelAngle(_ref78){var t=_ref78.labelAngle;return t;},labelBaseline:function labelBaseline(_ref79){var t=_ref79.axis,e=_ref79.labelAngle,n=_ref79.orient,r=_ref79.channel;return t.labelBaseline||PK(e,n,r);},labelFlush:function labelFlush(_ref80){var t=_ref80.axis,e=_ref80.fieldOrDatumDef,n=_ref80.channel;var r;return null!==(r=t.labelFlush)&&void 0!==r?r:function(t,e){if("x"===e&&MM(["quantitative","temporal"],t))return !0;return;}(e.type,n);},labelOverlap:function labelOverlap(_ref81){var t=_ref81.axis,e=_ref81.fieldOrDatumDef,n=_ref81.scaleType;var r;return null!==(r=t.labelOverlap)&&void 0!==r?r:function(t,e){if("nominal"!==t)return "log"!==e||"greedy";return;}(e.type,n);},orient:function orient(_ref82){var t=_ref82.orient;return t;},tickCount:function tickCount(_ref83){var t=_ref83.channel,e=_ref83.model,n=_ref83.axis,r=_ref83.fieldOrDatumDef,i=_ref83.scaleType;var o;var a="x"===t?"width":"y"===t?"height":void 0,s=a?e.getSizeSignalRef(a):void 0;return null!==(o=n.tickCount)&&void 0!==o?o:function(_ref84){var t=_ref84.fieldOrDatumDef,e=_ref84.scaleType,n=_ref84.size,r=_ref84.values;var i;if(!r&&!mU(e)&&"log"!==e){if(dW(t)){if(WP(t.bin))return {signal:"ceil(".concat(n.signal,"/10)")};if(t.timeUnit&&MM(["month","hours","day","quarter"],null===(i=Tz(t.timeUnit))||void 0===i?void 0:i.unit))return;}return {signal:"ceil(".concat(n.signal,"/40)")};}return;}({fieldOrDatumDef:r,scaleType:i,size:s,values:n.values});},title:function title(_ref85){var t=_ref85.axis,e=_ref85.model,n=_ref85.channel;if(void 0!==t.title)return t.title;var r=zK(e,n);if(void 0!==r)return r;var i=e.typedFieldDef(n),o="x"===n?"x2":"y2",a=e.fieldDef(o);return rV(i?[aW(i)]:[],dW(a)?[aW(a)]:[]);},values:function values(_ref86){var t=_ref86.axis,e=_ref86.fieldOrDatumDef;return function(t,e){var n=t.values;if(rM(n))return qW(e,n);if(Nz(n))return n;return;}(t,e);},zindex:function zindex(_ref87){var t=_ref87.axis,e=_ref87.fieldOrDatumDef,n=_ref87.mark;var r;return null!==(r=t.zindex)&&void 0!==r?r:function(t,e){if("rect"===t&&OW(e))return 1;return 0;}(n,e);}};function BK(t){return "(((".concat(t.signal," % 360) + 360) % 360)");}function PK(t,e,n,r){if(void 0!==t){if("x"===n){if(Nz(t)){var _n144=BK(t);return {signal:"(45 < ".concat(_n144," && ").concat(_n144," < 135) || (225 < ").concat(_n144," && ").concat(_n144," < 315) ? \"middle\" :")+"(".concat(_n144," <= 45 || 315 <= ").concat(_n144,") === ").concat(Nz(e)?"(".concat(e.signal," === \"top\")"):"top"===e," ? \"bottom\" : \"top\"")};}if(45<t&&t<135||225<t&&t<315)return "middle";if(Nz(e)){var _n145=t<=45||315<=t?"===":"!==";return {signal:"".concat(e.signal," ").concat(_n145," \"top\" ? \"bottom\" : \"top\"")};}return (t<=45||315<=t)==("top"===e)?"bottom":"top";}if(Nz(t)){var _n146=BK(t),_i113=Nz(e)?"(".concat(e.signal," === \"left\")"):"left"===e;return {signal:"".concat(_n146," <= 45 || 315 <= ").concat(_n146," || (135 <= ").concat(_n146," && ").concat(_n146," <= 225) ? ").concat(r?'"middle"':"null"," : (45 <= ").concat(_n146," && ").concat(_n146," <= 135) === ").concat(_i113," ? \"top\" : \"bottom\"")};}if(t<=45||315<=t||135<=t&&t<=225)return r?"middle":null;if(Nz(e)){var _n147=45<=t&&t<=135?"===":"!==";return {signal:"".concat(e.signal," ").concat(_n147," \"left\" ? \"top\" : \"bottom\"")};}return (45<=t&&t<=135)==("left"===e)?"top":"bottom";}}function LK(t,e,n){if(void 0===t)return;var r="x"===n,i=r?0:90,o=r?"bottom":"left";if(Nz(t)){var _n148=BK(t),_a56=Nz(e)?"(".concat(e.signal," === \"").concat(o,"\")"):e===o;return {signal:"(".concat(i?"("+_n148+" + 90)":_n148," % 180 === 0) ? ").concat(r?null:'"center"'," :")+"(".concat(i," < ").concat(_n148," && ").concat(_n148," < ").concat(180+i,") === ").concat(_a56," ? \"left\" : \"right\"")};}if((t+i)%180==0)return r?null:"center";if(Nz(e)){var _n149=i<t&&t<180+i?"===":"!==";return {signal:"".concat("".concat(e.signal," ").concat(_n149," \"").concat(o,"\"")," ? \"left\" : \"right\"")};}return (i<t&&t<180+i)==(e===o)?"left":"right";}function zK(t,e){var n="x"===e?"x2":"y2",r=t.fieldDef(e),i=t.fieldDef(n),o=r?r.title:void 0,a=i?i.title:void 0;return o&&a?iV(o,a):o||a||(void 0!==o?o:void 0!==a?a:void 0);}var UK=/*#__PURE__*/function(_V$4){_inherits(UK,_V$4);var _super6=_createSuper(UK);function UK(t,e){var _this35;_classCallCheck(this,UK);_this35=_super6.call(this,t),_this35.transform=e,_this35._dependentFields=wK(_this35.transform.calculate);return _this35;}_createClass(UK,[{key:"clone",value:function clone(){return new UK(null,DM(this.transform));}},{key:"producedFields",value:function producedFields(){return new Set([this.transform.as]);}},{key:"dependentFields",value:function dependentFields(){return this._dependentFields;}},{key:"assemble",value:function assemble(){return {type:"formula",expr:this.transform.calculate,as:this.transform.as};}},{key:"hash",value:function hash(){return "Calculate ".concat(IM(this.transform));}}],[{key:"parseAllForSortIndex",value:function parseAllForSortIndex(t,e){return e.forEachFieldDef(function(e,n){if(wW(e)&&nW(e.sort)){var _r147=e.field,_i114=e.timeUnit,_o57=e.sort,_a57=_o57.map(function(t,e){return "".concat(Gz({field:_r147,timeUnit:_i114,equal:t})," ? ").concat(e," : ");}).join("")+_o57.length;t=new UK(t,{calculate:_a57,as:WK(e,n,{forAs:!0})});}}),t;}}]);return UK;}(V$);function WK(t,e,n){return AW(t,Object.assign({prefix:e,suffix:"sort_index"},null!==n&&void 0!==n?n:{}));}function VK(t,e){return MM(["top","bottom"],e)?"column":MM(["left","right"],e)?"row":"row"===t?"row":"column";}function qK(t,e,n,r){var i="row"===r?n.headerRow:"column"===r?n.headerColumn:n.headerFacet;return ij(((null===e||void 0===e?void 0:e.header)||{})[t],i[t],n.header[t]);}function $K(t,e,n,r){var i={};var _iterator96=_createForOfIteratorHelper(t),_step96;try{for(_iterator96.s();!(_step96=_iterator96.n()).done;){var _o58=_step96.value;var _t181=qK(_o58,e,n,r);void 0!==_t181&&(i[_o58]=_t181);}}catch(err){_iterator96.e(err);}finally{_iterator96.f();}return i;}var HK=["row","column"],GK=["header","footer"];function KK(t,e){var n=t.component.layoutHeaders[e].title,r=t.config?t.config:void 0,i=t.component.layoutHeaders[e].facetFieldDef?t.component.layoutHeaders[e].facetFieldDef:void 0,_$K=$K(["titleAnchor","titleAngle","titleOrient"],i,r,e),o=_$K.titleAnchor,a=_$K.titleAngle,s=_$K.titleOrient,u=VK(e,s),c=sj(a);return {name:"".concat(e,"-title"),type:"group",role:"".concat(u,"-title"),title:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({text:n},"row"===e?{orient:"left"}:{}),{style:"guide-title"}),YK(c,u)),XK(u,c,o)),nX(r,i,e,TK,DK))};}function XK(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"middle";switch(n){case"start":return {align:"left"};case"end":return {align:"right"};}var r=LK(e,"row"===t?"left":"top","row"===t?"y":"x");return r?{align:r}:{};}function YK(t,e){var n=PK(t,"row"===e?"left":"top","row"===e?"y":"x",!0);return n?{baseline:n}:{};}function JK(t,e){var n=t.component.layoutHeaders[e],r=[];var _iterator97=_createForOfIteratorHelper(GK),_step97;try{for(_iterator97.s();!(_step97=_iterator97.n()).done;){var _i115=_step97.value;if(n[_i115]){var _iterator98=_createForOfIteratorHelper(n[_i115]),_step98;try{for(_iterator98.s();!(_step98=_iterator98.n()).done;){var _o59=_step98.value;var _a58=ZK(t,e,_i115,n,_o59);null!=_a58&&r.push(_a58);}}catch(err){_iterator98.e(err);}finally{_iterator98.f();}}}}catch(err){_iterator97.e(err);}finally{_iterator97.f();}return r;}function QK(t,e,n){var _$K2=$K(["format","formatType","labelAngle","labelAnchor","labelOrient","labelExpr"],t,n,e),r=_$K2.format,i=_$K2.formatType,o=_$K2.labelAngle,a=_$K2.labelAnchor,s=_$K2.labelOrient,u=_$K2.labelExpr,c=WU({fieldOrDatumDef:t,format:r,formatType:i,expr:"parent",config:n}).signal,l=VK(e,s);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({text:{signal:u?ej(ej(u,"datum.label",c),"datum.value",AW(t,{expr:"parent"})):c}},"row"===e?{orient:"left"}:{}),{style:"guide-label",frame:"group"}),YK(o,l)),XK(l,o,a)),nX(n,t,e,NK,FK));}function ZK(t,e,n,r,i){if(i){var _o60=null;var _a59=r.facetFieldDef,_s49=t.config?t.config:void 0;if(_a59&&i.labels){var _$K3=$K(["labelOrient"],_a59,_s49,e),_t182=_$K3.labelOrient;("row"===e&&!MM(["top","bottom"],_t182)||"column"===e&&!MM(["left","right"],_t182))&&(_o60=QK(_a59,e,_s49));}var _u25=JY(t)&&!rW(t.facet),_c20=i.axes,_l14=(null===_c20||void 0===_c20?void 0:_c20.length)>0;if(_o60||_l14){var _s50="row"===e?"height":"width";return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({name:t.getName("".concat(e,"_").concat(n)),type:"group",role:"".concat(e,"-").concat(n)},r.facetFieldDef?{from:{data:t.getName(e+"_domain")},sort:function(t,e){var n;var r=t.sort;return eW(r)?{field:AW(r,{expr:"datum"}),order:null!==(n=r.order)&&void 0!==n?n:"ascending"}:rM(r)?{field:WK(t,e,{expr:"datum"}),order:"ascending"}:{field:AW(t,{expr:"datum"}),order:null!==r&&void 0!==r?r:"ascending"};}(_a59,e)}:{}),_l14&&_u25?{from:{data:t.getName("facet_domain_".concat(e))}}:{}),_o60?{title:_o60}:{}),i.sizeSignal?{encode:{update:_defineProperty({},_s50,i.sizeSignal)}}:{}),_l14?{axes:_c20}:{});}}return null;}var tX={column:{start:0,end:1},row:{start:1,end:0}};function eX(t,e){return tX[e][t];}function nX(t,e,n,r,i){var o={};var _iterator99=_createForOfIteratorHelper(r),_step99;try{for(_iterator99.s();!(_step99=_iterator99.n()).done;){var _a60=_step99.value;if(!i[_a60])continue;var _r148=qK(_a60,e,t,n);void 0!==_r148&&(o[i[_a60]]=_r148);}}catch(err){_iterator99.e(err);}finally{_iterator99.f();}return o;}function rX(t){return [].concat(_toConsumableArray(iX(t,"width")),_toConsumableArray(iX(t,"height")),_toConsumableArray(iX(t,"childWidth")),_toConsumableArray(iX(t,"childHeight")));}function iX(t,e){var n="width"===e?"x":"y",r=t.component.layoutSize.get(e);if(!r||"merged"===r)return [];var i=t.getSizeSignalRef(e).signal;if("step"===r){var _e187=t.getScaleComponent(n);if(_e187){var _r149=_e187.get("type"),_o61=_e187.get("range");if(mU(_r149)&&Iz(_o61)){var _r150=t.scaleName(n);if(JY(t.parent)){if("independent"===t.parent.component.resolve.scale[n])return [oX(_r150,_o61)];}return [oX(_r150,_o61),{name:i,update:aX(_r150,_e187,"domain('".concat(_r150,"').length"))}];}}throw new Error("layout size is step although width/height is not step.");}if("container"==r){var _e188=i.endsWith("width"),_n150=_e188?"containerSize()[0]":"containerSize()[1]",_r151="isFinite(".concat(_n150,") ? ").concat(_n150," : ").concat(YV(t.config.view,_e188?"width":"height"));return [{name:i,init:_r151,on:[{update:_r151,events:"window:resize"}]}];}return [{name:i,value:r}];}function oX(t,e){return {name:t+"_step",value:e.step};}function aX(t,e,n){var r=e.get("type"),i=e.get("padding"),o=ij(e.get("paddingOuter"),i);var a=e.get("paddingInner");return "bandspace(".concat(n,", ").concat(a="band"===r?void 0!==a?a:i:1,", ").concat(o,") * ").concat(t,"_step");}function sX(t){return "childWidth"===t?"width":"childHeight"===t?"height":t;}function uX(t,e){return qM(t).reduce(function(n,r){var i=t[r];return Object.assign(Object.assign({},n),g$(e,i,r,function(t){return Nz(t)?t:{value:t.value};}));},{});}function cX(t,e){if(ZY(e)||JY(e))return "shared";if(QY(e))return bP(t)?"independent":"shared";throw new Error("invalid model type for resolve");}function lX(t,e){var n=t.scale[e],r=bP(e)?"axis":"legend";return "independent"===n?("shared"===t[r][e]&&mz(y.independentScaleMeansIndependentGuide(e)),"independent"):t[r][e]||"shared";}var fX=Object.assign(Object.assign({},LV),{disable:1,labelExpr:1,selections:1,opacity:1,shape:1,stroke:1,fill:1,size:1,strokeWidth:1,strokeDash:1,encode:1}),hX=qM(fX);var dX=/*#__PURE__*/function(_Mq2){_inherits(dX,_Mq2);var _super7=_createSuper(dX);function dX(){_classCallCheck(this,dX);return _super7.apply(this,arguments);}return dX;}(Mq);var pX={symbols:function symbols(t,_ref88){var e=_ref88.fieldOrDatumDef,n=_ref88.model,r=_ref88.channel,i=_ref88.legendCmpt,o=_ref88.legendType;var a,s,u,c,l;if("symbol"!==o)return;var f=n.markDef,h=n.encoding,d=n.config,p=n.mark,m=f.filled&&"trail"!==p;var g=Object.assign(Object.assign({},function(t,e,n){var _iterator100=_createForOfIteratorHelper(n),_step100;try{for(_iterator100.s();!(_step100=_iterator100.n()).done;){var _r152=_step100.value;var _n151=ZW(_r152,e.markDef,e.config);void 0!==_n151&&(t[_r152]=KW(_n151));}}catch(err){_iterator100.e(err);}finally{_iterator100.f();}return t;}({},n,Mj)),C$(n,{filled:m}));var v=null!==(a=mX(h.opacity))&&void 0!==a?a:f.opacity;if(g.fill)if("fill"===r||m&&r===hB)delete g.fill;else if(g.fill.field)i.get("symbolFillColor")?delete g.fill:(g.fill=KW(null!==(s=d.legend.symbolBaseFillColor)&&void 0!==s?s:"black"),g.fillOpacity=KW(null!==v&&void 0!==v?v:1));else if(rM(g.fill)){var _t183=null!==(l=null!==(c=gX(null!==(u=h.fill)&&void 0!==u?u:h.color))&&void 0!==c?c:f.fill)&&void 0!==l?l:m&&f.color;_t183&&(g.fill=KW(_t183));}if(g.stroke)if("stroke"===r||!m&&r===hB)delete g.stroke;else if(g.stroke.field)delete g.stroke;else if(rM(g.stroke)){var _t184=ij(gX(h.stroke||h.color),f.stroke,m?f.color:void 0);_t184&&(g.stroke={value:_t184});}if(r!==yB){var _t185=dW(e)&&yX(n,i,e);_t185?g.opacity=[Object.assign({test:_t185},KW(null!==v&&void 0!==v?v:1)),KW(d.legend.unselectedOpacity)]:v&&(g.opacity=KW(v));}return VM(g=Object.assign(Object.assign({},g),t))?void 0:g;},gradient:function gradient(t,_ref89){var e=_ref89.model,n=_ref89.legendType;if("gradient"!==n)return;var r={};var i=mX(e.encoding.opacity)||e.markDef.opacity;i&&(r.opacity=KW(i));return VM(r=Object.assign(Object.assign({},r),t))?void 0:r;},labels:function labels(t,_ref90){var e=_ref90.fieldOrDatumDef,n=_ref90.model,r=_ref90.channel,i=_ref90.legendCmpt;var o=n.legend(r)||{},a=n.config,s=dW(e)?yX(n,i,e):void 0,u=s?[{test:s,value:1},{value:a.legend.unselectedOpacity}]:void 0,c=o.format,l=o.formatType,f=LU(l)?qU({fieldOrDatumDef:e,field:"datum.value",format:c,formatType:l,config:a}):void 0,h=Object.assign(Object.assign(Object.assign({},u?{opacity:u}:{}),f?{text:f}:{}),t);return VM(h)?void 0:h;},entries:function entries(t,_ref91){var e=_ref91.legendCmpt;var n=e.get("selections");return (null===n||void 0===n?void 0:n.length)?Object.assign(Object.assign({},t),{fill:{value:"transparent"}}):t;}};function mX(t){return vX(t,function(t,e){return Math.max(t,e.value);});}function gX(t){return vX(t,function(t,e){return ij(t,e.value);});}function vX(t,e){return function(t){var e=t&&t.condition;return !!e&&(rM(e)||xW(e));}(t)?cM(t.condition).reduce(e,t.value):xW(t)?t.value:void 0;}function yX(t,e,n){var r=e.get("selections");if(!(null===r||void 0===r?void 0:r.length))return;var i=gM(n.field);return r.map(function(t){return "(!length(data(".concat(gM(KM(t)+vH),")) || (").concat(t,"[").concat(i,"] && indexof(").concat(t,"[").concat(i,"], datum.value) >= 0))");}).join(" || ");}var bX={direction:function direction(_ref92){var t=_ref92.direction;return t;},format:function format(_ref93){var t=_ref93.fieldOrDatumDef,e=_ref93.legend,n=_ref93.config;var r=e.format,i=e.formatType;return $U(t,t.type,r,i,n,!1);},formatType:function formatType(_ref94){var t=_ref94.legend,e=_ref94.fieldOrDatumDef,n=_ref94.scaleType;var r=t.formatType;return HU(r,e,n);},gradientLength:function gradientLength(t){var e,n;var r=t.legend,i=t.legendConfig;return null!==(n=null!==(e=r.gradientLength)&&void 0!==e?e:i.gradientLength)&&void 0!==n?n:function(_ref95){var t=_ref95.legendConfig,e=_ref95.model,n=_ref95.direction,r=_ref95.orient,i=_ref95.scaleType;var o=t.gradientHorizontalMaxLength,a=t.gradientHorizontalMinLength,s=t.gradientVerticalMaxLength,u=t.gradientVerticalMinLength;if(vU(i))return "horizontal"===n?"top"===r||"bottom"===r?kX(e,"width",a,o):a:kX(e,"height",u,s);return;}(t);},labelOverlap:function labelOverlap(_ref96){var t=_ref96.legend,e=_ref96.legendConfig,n=_ref96.scaleType;var r,i;return null!==(i=null!==(r=t.labelOverlap)&&void 0!==r?r:e.labelOverlap)&&void 0!==i?i:function(t){if(MM(["quantile","threshold","log"],t))return "greedy";return;}(n);},symbolType:function symbolType(_ref97){var t=_ref97.legend,e=_ref97.markDef,n=_ref97.channel,r=_ref97.encoding;var i;return null!==(i=t.symbolType)&&void 0!==i?i:function(t,e,n,r){var i;if("shape"!==e){var _t186=null!==(i=gX(n))&&void 0!==i?i:r;if(_t186)return _t186;}switch(t){case"bar":case"rect":case"image":case"square":return "square";case"line":case"trail":case"rule":return "stroke";case"arc":case"point":case"circle":case"tick":case"geoshape":case"area":case"text":return "circle";}}(e.type,n,r.shape,e.shape);},title:function title(_ref98){var t=_ref98.fieldOrDatumDef,e=_ref98.config;return TW(t,e,{allowDisabling:!0});},type:function type(_ref99){var t=_ref99.legendType,e=_ref99.scaleType,n=_ref99.channel;if(jB(n)&&vU(e)){if("gradient"===t)return;}else if("symbol"===t)return;return t;},values:function values(_ref100){var t=_ref100.fieldOrDatumDef,e=_ref100.legend;return function(t,e){var n=t.values;if(rM(n))return qW(e,n);if(Nz(n))return n;return;}(e,t);}};function xX(t){var e=t.legend;return ij(e.type,function(_ref101){var t=_ref101.channel,e=_ref101.timeUnit,n=_ref101.scaleType;if(jB(t)){if(MM(["quarter","month","day"],e))return "symbol";if(vU(n))return "gradient";}return "symbol";}(t));}function wX(_ref102){var t=_ref102.legendConfig,e=_ref102.legendType,n=_ref102.orient,r=_ref102.legend;var i,o;return null!==(o=null!==(i=r.direction)&&void 0!==i?i:t[e?"gradientDirection":"symbolDirection"])&&void 0!==o?o:function(t,e){switch(t){case"top":case"bottom":return "horizontal";case"left":case"right":case"none":case void 0:return;default:return "gradient"===e?"horizontal":void 0;}}(n,e);}function kX(t,e,n,r){return {signal:"clamp(".concat(t.getSizeSignalRef(e).signal,", ").concat(n,", ").concat(r,")")};}function EX(t){var e=YY(t)?function(t){var e=t.encoding,n={};for(var _i116=0,_arr6=[hB].concat(BV);_i116<_arr6.length;_i116++){var _r153=_arr6[_i116];var _i117=jW(e[_r153]);_i117&&t.getScaleComponent(_r153)&&(_r153===mB&&dW(_i117)&&_i117.type===eU||(n[_r153]=AX(t,_r153)));}return n;}(t):function(t){var _t$component=t.component,e=_t$component.legends,n=_t$component.resolve;var _iterator101=_createForOfIteratorHelper(t.children),_step101;try{for(_iterator101.s();!(_step101=_iterator101.n()).done;){var _r154=_step101.value;EX(_r154);var _iterator103=_createForOfIteratorHelper(qM(_r154.component.legends)),_step103;try{for(_iterator103.s();!(_step103=_iterator103.n()).done;){var _i118=_step103.value;n.legend[_i118]=lX(t.component.resolve,_i118),"shared"===n.legend[_i118]&&(e[_i118]=OX(e[_i118],_r154.component.legends[_i118]),e[_i118]||(n.legend[_i118]="independent",delete e[_i118]));}}catch(err){_iterator103.e(err);}finally{_iterator103.f();}}}catch(err){_iterator101.e(err);}finally{_iterator101.f();}var _iterator102=_createForOfIteratorHelper(qM(e)),_step102;try{for(_iterator102.s();!(_step102=_iterator102.n()).done;){var _r155=_step102.value;var _iterator104=_createForOfIteratorHelper(t.children),_step104;try{for(_iterator104.s();!(_step104=_iterator104.n()).done;){var _e189=_step104.value;_e189.component.legends[_r155]&&"shared"===n.legend[_r155]&&delete _e189.component.legends[_r155];}}catch(err){_iterator104.e(err);}finally{_iterator104.f();}}}catch(err){_iterator102.e(err);}finally{_iterator102.f();}return e;}(t);return t.component.legends=e,e;}function CX(t,e,n,r){switch(e){case"disable":return void 0!==n;case"values":return !!(null===n||void 0===n?void 0:n.values);case"title":if("title"===e&&t===(null===r||void 0===r?void 0:r.title))return !0;}return t===(n||{})[e];}function AX(t,e){var n,r,i;var o=t.legend(e);var a=t.markDef,s=t.encoding,u=t.config,c=u.legend,l=new dX({},function(t,e){var n=t.scaleName(e);if("trail"===t.mark){if("color"===e)return {stroke:n};if("size"===e)return {strokeWidth:n};}return "color"===e?t.markDef.filled?{fill:n}:{stroke:n}:_defineProperty({},e,n);}(t,e));!function(t,e,n){var r;var i=null===(r=t.fieldDef(e))||void 0===r?void 0:r.field;kH(t,function(t){var r,o;var a=null!==(r=t.project.hasField[i])&&void 0!==r?r:t.project.hasChannel[e];if(a&&Q$.has(t)){var _e190=null!==(o=n.get("selections"))&&void 0!==o?o:[];_e190.push(t.name),n.set("selections",_e190,!1),a.hasLegend=!0;}});}(t,e,l);var f=void 0!==o?!o:c.disable;if(l.set("disable",f,void 0!==o),f)return l;o=o||{};var h=t.getScaleComponent(e).get("type"),d=jW(s[e]),p=dW(d)?null===(n=Tz(d.timeUnit))||void 0===n?void 0:n.unit:void 0,m=o.orient||u.legend.orient||"right",g=xX({legend:o,channel:e,timeUnit:p,scaleType:h}),v={legend:o,channel:e,model:t,markDef:a,encoding:s,fieldOrDatumDef:d,legendConfig:c,config:u,scaleType:h,orient:m,legendType:g,direction:wX({legend:o,legendType:g,orient:m,legendConfig:c})};var _iterator105=_createForOfIteratorHelper(hX),_step105;try{for(_iterator105.s();!(_step105=_iterator105.n()).done;){var _n153=_step105.value;var _r157=_n153 in bX?bX[_n153](v):o[_n153];if(void 0!==_r157){var _i120=CX(_r157,_n153,o,t.fieldDef(e));(_i120||void 0===u.legend[_n153])&&l.set(_n153,_r157,_i120);}}}catch(err){_iterator105.e(err);}finally{_iterator105.f();}var y=null!==(r=null===o||void 0===o?void 0:o.encoding)&&void 0!==r?r:{},b=l.get("selections"),x={},w={fieldOrDatumDef:d,model:t,channel:e,legendCmpt:l,legendType:g};for(var _i119=0,_arr7=["labels","legend","title","symbols","gradient","entries"];_i119<_arr7.length;_i119++){var _e191=_arr7[_i119];var _n152=uX(null!==(i=y[_e191])&&void 0!==i?i:{},t),_r156=_e191 in pX?pX[_e191](_n152,w):_n152;void 0===_r156||VM(_r156)||(x[_e191]=Object.assign(Object.assign(Object.assign({},(null===b||void 0===b?void 0:b.length)&&dW(d)?{name:"".concat(KM(d.field),"_legend_").concat(_e191)}:{}),(null===b||void 0===b?void 0:b.length)?{interactive:!!b}:{}),{update:_r156}));}return VM(x)||l.set("encode",x,!!(null===o||void 0===o?void 0:o.encoding)),l;}function OX(t,e){var n,r,i,o;if(!t)return e.clone();var a=t.getWithExplicit("orient"),s=e.getWithExplicit("orient");if(a.explicit&&s.explicit&&a.value!==s.value)return;var u=!1;var _iterator106=_createForOfIteratorHelper(hX),_step106;try{var _loop7=function _loop7(){var n=_step106.value;var r=zq(t.getWithExplicit(n),e.getWithExplicit(n),n,"legend",function(t,e){switch(n){case"symbolType":return _X(t,e);case"title":return oV(t,e);case"type":return u=!0,Bq("symbol");}return Lq(t,e,n,"legend");});t.setWithExplicit(n,r);};for(_iterator106.s();!(_step106=_iterator106.n()).done;){_loop7();}}catch(err){_iterator106.e(err);}finally{_iterator106.f();}return u&&((null===(r=null===(n=t.implicit)||void 0===n?void 0:n.encode)||void 0===r?void 0:r.gradient)&&YM(t.implicit,["encode","gradient"]),(null===(o=null===(i=t.explicit)||void 0===i?void 0:i.encode)||void 0===o?void 0:o.gradient)&&YM(t.explicit,["encode","gradient"])),t;}function _X(t,e){return "circle"===e.value?e:t;}function SX(t,e,n,r){var i,o,a;t.encode=null!==(i=t.encode)&&void 0!==i?i:{},t.encode[e]=null!==(o=t.encode[e])&&void 0!==o?o:{},t.encode[e].update=null!==(a=t.encode[e].update)&&void 0!==a?a:{},t.encode[e].update[n]=r;}function DX(t){var e=t.component.legends,n={};var _iterator107=_createForOfIteratorHelper(qM(e)),_step107;try{for(_iterator107.s();!(_step107=_iterator107.n()).done;){var _r159=_step107.value;var _i122=t.getScaleComponent(_r159),_o62=NM(_i122.get("domains"));if(n[_o62]){var _iterator109=_createForOfIteratorHelper(n[_o62]),_step109;try{for(_iterator109.s();!(_step109=_iterator109.n()).done;){var _t190=_step109.value;OX(_t190,e[_r159])||n[_o62].push(e[_r159]);}}catch(err){_iterator109.e(err);}finally{_iterator109.f();}}else n[_o62]=[e[_r159].clone()];}}catch(err){_iterator107.e(err);}finally{_iterator107.f();}return $M(n).flat().map(function(e){return function(t,e){var n,r,i;var o=t.combine(),a=o.disable,s=o.labelExpr;o.selections;var c=yM(o,["disable","labelExpr","selections"]);if(a)return;!1===e.aria&&void 0==c.aria&&(c.aria=!1);if(null===(n=c.encode)||void 0===n?void 0:n.symbols){var _t187=c.encode.symbols.update;!_t187.fill||"transparent"===_t187.fill.value||_t187.stroke||c.stroke||(_t187.stroke={value:"transparent"});var _iterator108=_createForOfIteratorHelper(BV),_step108;try{for(_iterator108.s();!(_step108=_iterator108.n()).done;){var _e192=_step108.value;c[_e192]&&delete _t187[_e192];}}catch(err){_iterator108.e(err);}finally{_iterator108.f();}}c.title||delete c.title;if(void 0!==s){var _t188=s;(null===(i=null===(r=c.encode)||void 0===r?void 0:r.labels)||void 0===i?void 0:i.update)&&Nz(c.encode.labels.update.text)&&(_t188=ej(s,"datum.label",c.encode.labels.update.text.signal)),SX(c,"labels","text",{signal:_t188});}for(var _t189 in c){var _e193=c[_t189];if(Nz(_e193)){var _n154=PV[_t189];if(_n154){var _r158=_n154.vgProp,_i121=_n154.part;SX(c,_i121,_r158,_e193),delete c[_t189];}}}return c;}(e,t.config);}).filter(function(t){return void 0!==t;});}function FX(t){return ZY(t)||QY(t)?function(t){return t.children.reduce(function(t,e){return t.concat(e.assembleProjections());},TX(t));}(t):TX(t);}function TX(t){var e=t.component.projection;if(!e||e.merged)return [];var n=e.combine(),r=n.name;if(e.data){var _i123={signal:"[".concat(e.size.map(function(t){return t.signal;}).join(", "),"]")},_o63=e.data.reduce(function(e,n){var r=Nz(n)?n.signal:"data('".concat(t.lookupDataSource(n),"')");return MM(e,r)||e.push(r),e;},[]);if(_o63.length<=0)throw new Error("Projection's fit didn't find any data sources");return [Object.assign({name:r,size:_i123,fit:{signal:_o63.length>1?"[".concat(_o63.join(", "),"]"):_o63[0]}},n)];}return [Object.assign(Object.assign({name:r},{translate:{signal:"[width / 2, height / 2]"}}),n)];}var NX=["type","clipAngle","clipExtent","center","rotate","precision","reflectX","reflectY","coefficient","distance","fraction","lobes","parallel","radius","ratio","spacing","tilt"];var IX=/*#__PURE__*/function(_Mq3){_inherits(IX,_Mq3);var _super8=_createSuper(IX);function IX(t,e,n,r){var _this36;_classCallCheck(this,IX);_this36=_super8.call(this,Object.assign({},e),{name:t}),_this36.specifiedProjection=e,_this36.size=n,_this36.data=r,_this36.merged=!1;return _this36;}_createClass(IX,[{key:"isFit",get:function get(){return !!this.data;}}]);return IX;}(Mq);function RX(t){t.component.projection=YY(t)?function(t){var e;if(t.hasProjection){var _n155=t.specifiedProjection,_r160=!(_n155&&(null!=_n155.scale||null!=_n155.translate)),_i124=_r160?[t.getSizeSignalRef("width"),t.getSizeSignalRef("height")]:void 0,_o64=_r160?function(t){var e=[],n=t.encoding;for(var _i125=0,_arr8=[[cB,uB],[fB,lB]];_i125<_arr8.length;_i125++){var _r161=_arr8[_i125];(jW(n[_r161[0]])||jW(n[_r161[1]]))&&e.push({signal:t.getName("geojson_".concat(e.length))});}t.channelHasField(mB)&&t.typedFieldDef(mB).type===eU&&e.push({signal:t.getName("geojson_".concat(e.length))});0===e.length&&e.push(t.requestDataName(Xq));return e;}(t):void 0;return new IX(t.projectionName(!0),Object.assign(Object.assign({},null!==(e=t.config.projection)&&void 0!==e?e:{}),null!==_n155&&void 0!==_n155?_n155:{}),_i124,_o64);}return;}(t):function(t){if(0===t.children.length)return;var e;var _iterator110=_createForOfIteratorHelper(t.children),_step110;try{for(_iterator110.s();!(_step110=_iterator110.n()).done;){var _e195=_step110.value;RX(_e195);}}catch(err){_iterator110.e(err);}finally{_iterator110.f();}var n=BM(t.children,function(t){var n=t.component.projection;if(n){if(e){var _t191=function(t,e){var n=BM(NX,function(n){return !hM(t.explicit,n)&&!hM(e.explicit,n)||!(!hM(t.explicit,n)||!hM(e.explicit,n)||NM(t.get(n))!==NM(e.get(n)));});if(NM(t.size)===NM(e.size)){if(n)return t;if(NM(t.explicit)===NM({}))return e;if(NM(e.explicit)===NM({}))return t;}return null;}(e,n);return _t191&&(e=_t191),!!_t191;}return e=n,!0;}return !0;});if(e&&n){var _n156=t.projectionName(!0),_r162=new IX(_n156,e.specifiedProjection,e.size,DM(e.data));var _iterator111=_createForOfIteratorHelper(t.children),_step111;try{for(_iterator111.s();!(_step111=_iterator111.n()).done;){var _r162$data;var _e194=_step111.value;var _t192=_e194.component.projection;_t192&&(_t192.isFit&&(_r162$data=_r162.data).push.apply(_r162$data,_toConsumableArray(_e194.component.projection.data)),_e194.renameProjection(_t192.get("name"),_n156),_t192.merged=!0);}}catch(err){_iterator111.e(err);}finally{_iterator111.f();}return _r162;}return;}(t);}function MX(t,e){return "".concat(UP(t),"_").concat(e);}function jX(t,e,n){var r;var i=MX(null!==(r=zW(n,void 0))&&void 0!==r?r:{},e);return t.getName("".concat(i,"_bins"));}function BX(t,e,n){var r,i;r=function(t){return "as"in t;}(t)?mM(t.as)?[t.as,"".concat(t.as,"_end")]:[t.as[0],t.as[1]]:[AW(t,{forAs:!0}),AW(t,{binSuffix:"end",forAs:!0})];var o=Object.assign({},zW(e,void 0)),a=MX(o,t.field),_ref104=function(t,e){return {signal:t.getName("".concat(e,"_bins")),extentSignal:t.getName("".concat(e,"_extent"))};}(n,a),s=_ref104.signal,u=_ref104.extentSignal;if($P(o.extent)){var _t193=o.extent,_e196=_t193.selection;i=CK(n.getSelectionComponent(KM(_e196),_e196),_t193),delete o.extent;}return {key:a,binComponent:Object.assign(Object.assign(Object.assign({bin:o,field:t.field,as:[r]},s?{signal:s}:{}),u?{extentSignal:u}:{}),i?{span:i}:{})};}var PX=/*#__PURE__*/function(_V$5){_inherits(PX,_V$5);var _super9=_createSuper(PX);function PX(t,e){var _this37;_classCallCheck(this,PX);_this37=_super9.call(this,t),_this37.bins=e;return _this37;}_createClass(PX,[{key:"clone",value:function clone(){return new PX(null,DM(this.bins));}},{key:"merge",value:function merge(t,e){var _iterator112=_createForOfIteratorHelper(qM(t.bins)),_step112;try{for(_iterator112.s();!(_step112=_iterator112.n()).done;){var _n157=_step112.value;_n157 in this.bins?(e(t.bins[_n157].signal,this.bins[_n157].signal),this.bins[_n157].as=LM([].concat(_toConsumableArray(this.bins[_n157].as),_toConsumableArray(t.bins[_n157].as)),IM)):this.bins[_n157]=t.bins[_n157];}}catch(err){_iterator112.e(err);}finally{_iterator112.f();}var _iterator113=_createForOfIteratorHelper(t.children),_step113;try{for(_iterator113.s();!(_step113=_iterator113.n()).done;){var _e197=_step113.value;t.removeChild(_e197),_e197.parent=this;}}catch(err){_iterator113.e(err);}finally{_iterator113.f();}t.remove();}},{key:"producedFields",value:function producedFields(){return new Set($M(this.bins).map(function(t){return t.as;}).flat(2));}},{key:"dependentFields",value:function dependentFields(){return new Set($M(this.bins).map(function(t){return t.field;}));}},{key:"hash",value:function hash(){return "Bin ".concat(IM(this.bins));}},{key:"assemble",value:function assemble(){return $M(this.bins).flatMap(function(t){var e=[],_t$as=_toArray(t.as),n=_t$as[0],r=_t$as.slice(1),i=t.bin,o=i.extent,a=yM(i,["extent"]),s=Object.assign(Object.assign(Object.assign({type:"bin",field:tj(t.field),as:n,signal:t.signal},$P(o)?{extent:null}:{extent:o}),t.span?{span:{signal:"span(".concat(t.span,")")}}:{}),a);!o&&t.extentSignal&&(e.push({type:"extent",field:tj(t.field),signal:t.extentSignal}),s.extent={signal:t.extentSignal}),e.push(s);var _iterator114=_createForOfIteratorHelper(r),_step114;try{for(_iterator114.s();!(_step114=_iterator114.n()).done;){var _t194=_step114.value;for(var _r163=0;_r163<2;_r163++){e.push({type:"formula",expr:AW({field:n[_r163]},{expr:"datum"}),as:_t194[_r163]});}}}catch(err){_iterator114.e(err);}finally{_iterator114.f();}return t.formula&&e.push({type:"formula",expr:t.formula,as:t.formulaAs}),e;});}}],[{key:"makeFromEncoding",value:function makeFromEncoding(t,e){var n=e.reduceFieldDef(function(t,n,r){if(bW(n)&&WP(n.bin)){var _BX=BX(n,n.bin,e),_i126=_BX.key,_o65=_BX.binComponent;t[_i126]=Object.assign(Object.assign(Object.assign({},_o65),t[_i126]),function(t,e,n,r){var i,o;if($W(e,n)){var _a61=YY(t)&&null!==(o=null!==(i=t.axis(n))&&void 0!==i?i:t.legend(n))&&void 0!==o?o:{},_s51=AW(e,{expr:"datum"}),_u26=AW(e,{expr:"datum",binSuffix:"end"});return {formulaAs:AW(e,{binSuffix:"range",forAs:!0}),formula:YU(_s51,_u26,_a61.format,_a61.formatType,r)};}return {};}(e,n,r,e.config));}return t;},{});return VM(n)?null:new PX(t,n);}},{key:"makeFromTransform",value:function makeFromTransform(t,e,n){var _BX2=BX(e,e.bin,n),r=_BX2.key,i=_BX2.binComponent;return new PX(t,_defineProperty({},r,i));}}]);return PX;}(V$);var LX=/*#__PURE__*/function(_V$6){_inherits(LX,_V$6);var _super10=_createSuper(LX);function LX(t){var _this38;_classCallCheck(this,LX);var e;if(_this38=_super10.call(this,null),$q(t=null!==t&&void 0!==t?t:{name:"source"})||(e=t.format?Object.assign({},TM(t.format,["parse"])):{}),Vq(t))_this38._data={values:t.values};else if(Wq(t)){if(_this38._data={url:t.url},!e.type){var _n158=/(?:\.([^.]+))?$/.exec(t.url)[1];MM(["json","csv","tsv","dsv","topojson"],_n158)||(_n158="json"),e.type=_n158;}}else Gq(t)?_this38._data={values:[{type:"Sphere"}]}:(qq(t)||$q(t))&&(_this38._data={});_this38._generator=$q(t),t.name&&(_this38._name=t.name),e&&!VM(e)&&(_this38._data.format=e);return _possibleConstructorReturn(_this38);}_createClass(LX,[{key:"dependentFields",value:function dependentFields(){return new Set();}},{key:"producedFields",value:function producedFields(){}},{key:"data",get:function get(){return this._data;}},{key:"hasName",value:function hasName(){return !!this._name;}},{key:"isGenerator",get:function get(){return this._generator;}},{key:"dataName",get:function get(){return this._name;},set:function set(t){this._name=t;}},{key:"parent",set:function set(t){throw new Error("Source nodes have to be roots.");}},{key:"remove",value:function remove(){throw new Error("Source nodes are roots and cannot be removed.");}},{key:"hash",value:function hash(){throw new Error("Cannot hash sources");}},{key:"assemble",value:function assemble(){return Object.assign(Object.assign({name:this._name},this._data),{transform:[]});}}]);return LX;}(V$);function zX(t){var _iterator115=_createForOfIteratorHelper(t),_step115;try{for(_iterator115.s();!(_step115=_iterator115.n()).done;){var _e198=_step115.value;var _iterator116=_createForOfIteratorHelper(_e198.children),_step116;try{for(_iterator116.s();!(_step116=_iterator116.n()).done;){var _t195=_step116.value;if(_t195.parent!==_e198)return console.error("Dataflow graph is inconsistent.",_e198,_t195),!1;}}catch(err){_iterator116.e(err);}finally{_iterator116.f();}if(!zX(_e198.children))return !1;}}catch(err){_iterator115.e(err);}finally{_iterator115.f();}return !0;}var UX=/*#__PURE__*/function(_V$7){_inherits(UX,_V$7);var _super11=_createSuper(UX);function UX(t,e){var _this39;_classCallCheck(this,UX);_this39=_super11.call(this,t),_this39.params=e;return _this39;}_createClass(UX,[{key:"clone",value:function clone(){return new UX(null,this.params);}},{key:"dependentFields",value:function dependentFields(){return new Set();}},{key:"producedFields",value:function producedFields(){}},{key:"hash",value:function hash(){return "Graticule ".concat(IM(this.params));}},{key:"assemble",value:function assemble(){return Object.assign({type:"graticule"},!0===this.params?{}:this.params);}}]);return UX;}(V$);var WX=/*#__PURE__*/function(_V$8){_inherits(WX,_V$8);var _super12=_createSuper(WX);function WX(t,e){var _this40;_classCallCheck(this,WX);_this40=_super12.call(this,t),_this40.params=e;return _this40;}_createClass(WX,[{key:"clone",value:function clone(){return new WX(null,this.params);}},{key:"dependentFields",value:function dependentFields(){return new Set();}},{key:"producedFields",value:function producedFields(){var t;return new Set([null!==(t=this.params.as)&&void 0!==t?t:"data"]);}},{key:"hash",value:function hash(){return "Hash ".concat(IM(this.params));}},{key:"assemble",value:function assemble(){return Object.assign({type:"sequence"},this.params);}}]);return WX;}(V$);function VX(t){return t instanceof LX||t instanceof UX||t instanceof WX;}var qX=/*#__PURE__*/function(){function qX(){_classCallCheck(this,qX);this._mutated=!1;}_createClass(qX,[{key:"setMutated",value:function setMutated(){this._mutated=!0;}},{key:"mutatedFlag",get:function get(){return this._mutated;}}]);return qX;}();var $X=/*#__PURE__*/function(_qX){_inherits($X,_qX);var _super13=_createSuper($X);function $X(){var _this41;_classCallCheck(this,$X);_this41=_super13.call(this),_this41._continue=!1;return _this41;}_createClass($X,[{key:"setContinue",value:function setContinue(){this._continue=!0;}},{key:"continueFlag",get:function get(){return this._continue;}},{key:"flags",get:function get(){return {continueFlag:this.continueFlag,mutatedFlag:this.mutatedFlag};},set:function set(_ref105){var t=_ref105.continueFlag,e=_ref105.mutatedFlag;t&&this.setContinue(),e&&this.setMutated();}},{key:"reset",value:function reset(){}},{key:"optimizeNextFromLeaves",value:function optimizeNextFromLeaves(t){if(VX(t))return !1;var e=t.parent,_this$run=this.run(t),n=_this$run.continueFlag;return n&&this.optimizeNextFromLeaves(e),this.mutatedFlag;}}]);return $X;}(qX);var HX=/*#__PURE__*/function(_qX2){_inherits(HX,_qX2);var _super14=_createSuper(HX);function HX(){_classCallCheck(this,HX);return _super14.apply(this,arguments);}return HX;}(qX);function GX(t,e,n,r){var i=YY(r)?r.encoding[eP(e)]:void 0;if(bW(n)&&YY(r)&&cW(e,n,i,r.stack,r.markDef,r.config))t.add(AW(n,{})),t.add(AW(n,{suffix:"end"})),n.bin&&$W(n,e)&&t.add(AW(n,{binSuffix:"range"}));else if(function(t){return t in IB;}(e)){var _n159=function(t){switch(t){case uB:return "y";case lB:return "y2";case cB:return "x";case fB:return "x2";}}(e);t.add(r.getName(_n159));}else t.add(AW(n));return t;}var KX=/*#__PURE__*/function(_V$9){_inherits(KX,_V$9);var _super15=_createSuper(KX);function KX(t,e,n){var _this42;_classCallCheck(this,KX);_this42=_super15.call(this,t),_this42.dimensions=e,_this42.measures=n;return _this42;}_createClass(KX,[{key:"clone",value:function clone(){return new KX(null,new Set(this.dimensions),DM(this.measures));}},{key:"groupBy",get:function get(){return this.dimensions;}},{key:"merge",value:function merge(t){return function(t,e){if(t.size!==e.size)return !1;var _iterator117=_createForOfIteratorHelper(t),_step117;try{for(_iterator117.s();!(_step117=_iterator117.n()).done;){var _n160=_step117.value;if(!e.has(_n160))return !1;}}catch(err){_iterator117.e(err);}finally{_iterator117.f();}return !0;}(this.dimensions,t.dimensions)?(function(t,e){var n;var _iterator118=_createForOfIteratorHelper(qM(e)),_step118;try{for(_iterator118.s();!(_step118=_iterator118.n()).done;){var _r164=_step118.value;var _i127=e[_r164];var _iterator119=_createForOfIteratorHelper(qM(_i127)),_step119;try{for(_iterator119.s();!(_step119=_iterator119.n()).done;){var _e199=_step119.value;_r164 in t?t[_r164][_e199]=new Set([].concat(_toConsumableArray(null!==(n=t[_r164][_e199])&&void 0!==n?n:[]),_toConsumableArray(_i127[_e199]))):t[_r164]=_defineProperty({},_e199,_i127[_e199]);}}catch(err){_iterator119.e(err);}finally{_iterator119.f();}}}catch(err){_iterator118.e(err);}finally{_iterator118.f();}}(this.measures,t.measures),!0):(function(){var _dz2;(_dz2=dz).debug.apply(_dz2,arguments);}("different dimensions, cannot merge"),!1);}},{key:"addDimensions",value:function addDimensions(t){t.forEach(this.dimensions.add,this.dimensions);}},{key:"dependentFields",value:function dependentFields(){return new Set([].concat(_toConsumableArray(this.dimensions),_toConsumableArray(qM(this.measures))));}},{key:"producedFields",value:function producedFields(){var t=new Set();var _iterator120=_createForOfIteratorHelper(qM(this.measures)),_step120;try{for(_iterator120.s();!(_step120=_iterator120.n()).done;){var _e200=_step120.value;var _iterator121=_createForOfIteratorHelper(qM(this.measures[_e200])),_step121;try{for(_iterator121.s();!(_step121=_iterator121.n()).done;){var _n161=_step121.value;var _r165=this.measures[_e200][_n161];0===_r165.size?t.add("".concat(_n161,"_").concat(_e200)):_r165.forEach(t.add,t);}}catch(err){_iterator121.e(err);}finally{_iterator121.f();}}}catch(err){_iterator120.e(err);}finally{_iterator120.f();}return t;}},{key:"hash",value:function hash(){return "Aggregate ".concat(IM({dimensions:this.dimensions,measures:this.measures}));}},{key:"assemble",value:function assemble(){var t=[],e=[],n=[];var _iterator122=_createForOfIteratorHelper(qM(this.measures)),_step122;try{for(_iterator122.s();!(_step122=_iterator122.n()).done;){var _r166=_step122.value;var _iterator123=_createForOfIteratorHelper(qM(this.measures[_r166])),_step123;try{for(_iterator123.s();!(_step123=_iterator123.n()).done;){var _i128=_step123.value;var _iterator124=_createForOfIteratorHelper(this.measures[_r166][_i128]),_step124;try{for(_iterator124.s();!(_step124=_iterator124.n()).done;){var _o66=_step124.value;n.push(_o66),t.push(_i128),e.push("*"===_r166?null:tj(_r166));}}catch(err){_iterator124.e(err);}finally{_iterator124.f();}}}catch(err){_iterator123.e(err);}finally{_iterator123.f();}}}catch(err){_iterator122.e(err);}finally{_iterator122.f();}return {type:"aggregate",groupby:_toConsumableArray(this.dimensions).map(tj),ops:t,fields:e,as:n};}}],[{key:"makeFromEncoding",value:function makeFromEncoding(t,e){var n=!1;e.forEachFieldDef(function(t){t.aggregate&&(n=!0);});var r={},i=new Set();return n?(e.forEachFieldDef(function(t,n){var o,a,s,u;var c=t.aggregate,l=t.field;if(c){if("count"===c)r["*"]=null!==(o=r["*"])&&void 0!==o?o:{},r["*"].count=new Set([AW(t,{forAs:!0})]);else {if(qj(c)||$j(c)){var _t196=qj(c)?"argmin":"argmax",_e201=c[_t196];r[_e201]=null!==(a=r[_e201])&&void 0!==a?a:{},r[_e201][_t196]=new Set([AW({op:_t196,field:_e201},{forAs:!0})]);}else r[l]=null!==(s=r[l])&&void 0!==s?s:{},r[l][c]=new Set([AW(t,{forAs:!0})]);MP(n)&&"unaggregated"===e.scaleDomain(n)&&(r[l]=null!==(u=r[l])&&void 0!==u?u:{},r[l].min=new Set([AW({field:l,aggregate:"min"},{forAs:!0})]),r[l].max=new Set([AW({field:l,aggregate:"max"},{forAs:!0})]));}}else GX(i,n,t,e);}),i.size+qM(r).length===0?null:new KX(t,i,r)):null;}},{key:"makeFromTransform",value:function makeFromTransform(t,e){var n,r,i;var o=new Set(),a={};var _iterator125=_createForOfIteratorHelper(e.aggregate),_step125;try{for(_iterator125.s();!(_step125=_iterator125.n()).done;){var _t197=_step125.value;var _e202=_t197.op,_i129=_t197.field,_o67=_t197.as;_e202&&("count"===_e202?(a["*"]=null!==(n=a["*"])&&void 0!==n?n:{},a["*"].count=new Set([_o67||AW(_t197,{forAs:!0})])):(a[_i129]=null!==(r=a[_i129])&&void 0!==r?r:{},a[_i129][_e202]=new Set([_o67||AW(_t197,{forAs:!0})])));}}catch(err){_iterator125.e(err);}finally{_iterator125.f();}var _iterator126=_createForOfIteratorHelper(null!==(i=e.groupby)&&void 0!==i?i:[]),_step126;try{for(_iterator126.s();!(_step126=_iterator126.n()).done;){var _t198=_step126.value;o.add(_t198);}}catch(err){_iterator126.e(err);}finally{_iterator126.f();}return o.size+qM(a).length===0?null:new KX(t,o,a);}}]);return KX;}(V$);var XX=/*#__PURE__*/function(_V$10){_inherits(XX,_V$10);var _super16=_createSuper(XX);function XX(t,e,n,r){var _this43;_classCallCheck(this,XX);_this43=_super16.call(this,t),_this43.model=e,_this43.name=n,_this43.data=r;var _iterator127=_createForOfIteratorHelper(PB),_step127;try{for(_iterator127.s();!(_step127=_iterator127.n()).done;){var _t199=_step127.value;var _n162=e.facet[_t199];if(_n162){var _r167=_n162.bin,_i130=_n162.sort;_this43[_t199]=Object.assign({name:e.getName("".concat(_t199,"_domain")),fields:[AW(_n162)].concat(_toConsumableArray(WP(_r167)?[AW(_n162,{binSuffix:"end"})]:[]))},eW(_i130)?{sortField:_i130}:rM(_i130)?{sortIndexField:WK(_n162,_t199)}:{});}}}catch(err){_iterator127.e(err);}finally{_iterator127.f();}_this43.childModel=e.child;return _this43;}_createClass(XX,[{key:"hash",value:function hash(){var t="Facet";var _iterator128=_createForOfIteratorHelper(PB),_step128;try{for(_iterator128.s();!(_step128=_iterator128.n()).done;){var _e203=_step128.value;this[_e203]&&(t+=" ".concat(_e203.charAt(0),":").concat(IM(this[_e203])));}}catch(err){_iterator128.e(err);}finally{_iterator128.f();}return t;}},{key:"fields",get:function get(){var t;var e=[];var _iterator129=_createForOfIteratorHelper(PB),_step129;try{for(_iterator129.s();!(_step129=_iterator129.n()).done;){var _n163=_step129.value;(null===(t=this[_n163])||void 0===t?void 0:t.fields)&&e.push.apply(e,_toConsumableArray(this[_n163].fields));}}catch(err){_iterator129.e(err);}finally{_iterator129.f();}return e;}},{key:"dependentFields",value:function dependentFields(){var t=new Set(this.fields);var _iterator130=_createForOfIteratorHelper(PB),_step130;try{for(_iterator130.s();!(_step130=_iterator130.n()).done;){var _e204=_step130.value;this[_e204]&&(this[_e204].sortField&&t.add(this[_e204].sortField.field),this[_e204].sortIndexField&&t.add(this[_e204].sortIndexField));}}catch(err){_iterator130.e(err);}finally{_iterator130.f();}return t;}},{key:"producedFields",value:function producedFields(){return new Set();}},{key:"getSource",value:function getSource(){return this.name;}},{key:"getChildIndependentFieldsWithStep",value:function getChildIndependentFieldsWithStep(){var t={};var _iterator131=_createForOfIteratorHelper(yP),_step131;try{for(_iterator131.s();!(_step131=_iterator131.n()).done;){var _e205=_step131.value;var _n164=this.childModel.component.scales[_e205];if(_n164&&!_n164.merged){var _r168=_n164.get("type"),_i131=_n164.get("range");if(mU(_r168)&&Iz(_i131)){var _n165=TY(NY(this.childModel,_e205));_n165?t[_e205]=_n165:mz("Unknown field for ".concat(_e205,". Cannot calculate view size."));}}}}catch(err){_iterator131.e(err);}finally{_iterator131.f();}return t;}},{key:"assembleRowColumnHeaderData",value:function assembleRowColumnHeaderData(t,e,n){var r={row:"y",column:"x"}[t],i=[],o=[],a=[];n&&n[r]&&(e?(i.push("distinct_".concat(n[r])),o.push("max")):(i.push(n[r]),o.push("distinct")),a.push("distinct_".concat(n[r])));var _this$t=this[t],s=_this$t.sortField,u=_this$t.sortIndexField;if(s){var _s$op=s.op,_t200=_s$op===void 0?JU:_s$op,_e206=s.field;i.push(_e206),o.push(_t200),a.push(AW(s,{forAs:!0}));}else u&&(i.push(u),o.push("max"),a.push(u));return {name:this[t].name,source:null!==e&&void 0!==e?e:this.data,transform:[Object.assign({type:"aggregate",groupby:this[t].fields},i.length?{fields:i,ops:o,as:a}:{})]};}},{key:"assembleFacetHeaderData",value:function assembleFacetHeaderData(t){var e,n;var r=this.model.layout.columns,i=this.model.component.layoutHeaders,o=[],a={};var _iterator132=_createForOfIteratorHelper(HK),_step132;try{for(_iterator132.s();!(_step132=_iterator132.n()).done;){var _t201=_step132.value;var _iterator133=_createForOfIteratorHelper(GK),_step133;try{for(_iterator133.s();!(_step133=_iterator133.n()).done;){var _r169=_step133.value;var _o68=null!==(e=i[_t201]&&i[_t201][_r169])&&void 0!==e?e:[];var _iterator134=_createForOfIteratorHelper(_o68),_step134;try{for(_iterator134.s();!(_step134=_iterator134.n()).done;){var _e208=_step134.value;if((null===(n=_e208.axes)||void 0===n?void 0:n.length)>0){a[_t201]=!0;break;}}}catch(err){_iterator134.e(err);}finally{_iterator134.f();}}}catch(err){_iterator133.e(err);}finally{_iterator133.f();}if(a[_t201]){var _e207="length(data(\"".concat(this.facet.name,"\"))"),_n166="row"===_t201?r?{signal:"ceil(".concat(_e207," / ").concat(r,")")}:1:r?{signal:"min(".concat(_e207,", ").concat(r,")")}:{signal:_e207};o.push({name:"".concat(this.facet.name,"_").concat(_t201),transform:[{type:"sequence",start:0,stop:_n166}]});}}}catch(err){_iterator132.e(err);}finally{_iterator132.f();}var s=a.row,u=a.column;return (s||u)&&o.unshift(this.assembleRowColumnHeaderData("facet",null,t)),o;}},{key:"assemble",value:function assemble(){var t,e;var n=[];var r=null;var i=this.getChildIndependentFieldsWithStep(),o=this.column,a=this.row,s=this.facet;if(o&&a&&(i.x||i.y)){r="cross_".concat(this.column.name,"_").concat(this.row.name);var _o69=[].concat(null!==(t=i.x)&&void 0!==t?t:[],null!==(e=i.y)&&void 0!==e?e:[]),_a62=_o69.map(function(){return "distinct";});n.push({name:r,source:this.data,transform:[{type:"aggregate",groupby:this.fields,fields:_o69,ops:_a62}]});}for(var _i132=0,_arr9=[Qj,Jj];_i132<_arr9.length;_i132++){var _t202=_arr9[_i132];this[_t202]&&n.push(this.assembleRowColumnHeaderData(_t202,r,i));}if(s){var _t203=this.assembleFacetHeaderData(i);_t203&&n.push.apply(n,_toConsumableArray(_t203));}return n;}}]);return XX;}(V$);function YX(t){return "'"===t[0]&&"'"===t[t.length-1]||'"'===t[0]&&'"'===t[t.length-1]?t.slice(1,-1):t;}function JX(t){var e={};return function t(e,n){if(_M(e))t(e.not,n);else if(OM(e)){var _iterator135=_createForOfIteratorHelper(e.and),_step135;try{for(_iterator135.s();!(_step135=_iterator135.n()).done;){var _r170=_step135.value;t(_r170,n);}}catch(err){_iterator135.e(err);}finally{_iterator135.f();}}else if(AM(e)){var _iterator136=_createForOfIteratorHelper(e.or),_step136;try{for(_iterator136.s();!(_step136=_iterator136.n()).done;){var _r171=_step136.value;t(_r171,n);}}catch(err){_iterator136.e(err);}finally{_iterator136.f();}}else n(e);}(t.filter,function(t){var n;if($z(t)){var _r172=null;Pz(t)?_r172=t.equal:Vz(t)?_r172=t.range[0]:qz(t)&&(_r172=(null!==(n=t.oneOf)&&void 0!==n?n:t.in)[0]),_r172&&(gz(_r172)?e[t.field]="date":pM(_r172)?e[t.field]="number":mM(_r172)&&(e[t.field]="string")),t.timeUnit&&(e[t.field]="date");}}),e;}function QX(t){var e={};function n(t){WW(t)?e[t.field]="date":"quantitative"===t.type&&function(t){return mM(t)&&MM(["min","max"],t);}(t.aggregate)?e[t.field]="number":rj(t.field)>1?t.field in e||(e[t.field]="flatten"):wW(t)&&eW(t.sort)&&rj(t.sort.field)>1&&(t.sort.field in e||(e[t.sort.field]="flatten"));}if((YY(t)||JY(t))&&t.forEachFieldDef(function(e,r){if(bW(e))n(e);else {var _i133=ZB(r),_o70=t.fieldDef(_i133);n(Object.assign(Object.assign({},e),{type:_o70.type}));}}),YY(t)){var _n167=t.mark,_r173=t.markDef,_i134=t.encoding;if(Tj(_n167)&&!t.encoding.order){var _t204=_i134["horizontal"===_r173.orient?"y":"x"];!dW(_t204)||"quantitative"!==_t204.type||_t204.field in e||(e[_t204.field]="number");}}return e;}var ZX=/*#__PURE__*/function(_V$11){_inherits(ZX,_V$11);var _super17=_createSuper(ZX);function ZX(t,e){var _this44;_classCallCheck(this,ZX);_this44=_super17.call(this,t),_this44._parse=e;return _this44;}_createClass(ZX,[{key:"clone",value:function clone(){return new ZX(null,DM(this._parse));}},{key:"hash",value:function hash(){return "Parse ".concat(IM(this._parse));}},{key:"parse",get:function get(){return this._parse;}},{key:"merge",value:function merge(t){this._parse=Object.assign(Object.assign({},this._parse),t.parse),t.remove();}},{key:"assembleFormatParse",value:function assembleFormatParse(){var t={};var _iterator137=_createForOfIteratorHelper(qM(this._parse)),_step137;try{for(_iterator137.s();!(_step137=_iterator137.n()).done;){var _e209=_step137.value;var _n168=this._parse[_e209];1===rj(_e209)&&(t[_e209]=_n168);}}catch(err){_iterator137.e(err);}finally{_iterator137.f();}return t;}},{key:"producedFields",value:function producedFields(){return new Set(qM(this._parse));}},{key:"dependentFields",value:function dependentFields(){return new Set(qM(this._parse));}},{key:"assembleTransforms",value:function assembleTransforms(){var _this45=this;var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:!1;return qM(this._parse).filter(function(e){return !t||rj(e)>1;}).map(function(t){var e=function(t,e){var n=QM(t);if("number"===e)return "toNumber(".concat(n,")");if("boolean"===e)return "toBoolean(".concat(n,")");if("string"===e)return "toString(".concat(n,")");if("date"===e)return "toDate(".concat(n,")");if("flatten"===e)return n;if(0===e.indexOf("date:"))return "timeParse(".concat(n,",'").concat(YX(e.slice(5,e.length)),"')");if(0===e.indexOf("utc:"))return "utcParse(".concat(n,",'").concat(YX(e.slice(4,e.length)),"')");return mz(y.unrecognizedParse(e)),null;}(t,_this45._parse[t]);return e?{type:"formula",expr:e,as:nj(t)}:null;}).filter(function(t){return null!==t;});}}],[{key:"makeExplicit",value:function makeExplicit(t,e,n){var r={};var i=e.data;return !$q(i)&&i&&i.format&&i.format.parse&&(r=i.format.parse),this.makeWithAncestors(t,r,{},n);}},{key:"makeWithAncestors",value:function makeWithAncestors(t,e,n,r){var _iterator138=_createForOfIteratorHelper(qM(n)),_step138;try{for(_iterator138.s();!(_step138=_iterator138.n()).done;){var _t205=_step138.value;var _e210=r.getWithExplicit(_t205);void 0!==_e210.value&&(_e210.explicit||_e210.value===n[_t205]||"derived"===_e210.value||"flatten"===n[_t205]?delete n[_t205]:mz(y.differentParse(_t205,n[_t205],_e210.value)));}}catch(err){_iterator138.e(err);}finally{_iterator138.f();}var _iterator139=_createForOfIteratorHelper(qM(e)),_step139;try{for(_iterator139.s();!(_step139=_iterator139.n()).done;){var _t206=_step139.value;var _n169=r.get(_t206);void 0!==_n169&&(_n169===e[_t206]?delete e[_t206]:mz(y.differentParse(_t206,e[_t206],_n169)));}}catch(err){_iterator139.e(err);}finally{_iterator139.f();}var i=new Mq(e,n);r.copyAll(i);var o={};var _iterator140=_createForOfIteratorHelper(qM(i.combine())),_step140;try{for(_iterator140.s();!(_step140=_iterator140.n()).done;){var _t207=_step140.value;var _e211=i.get(_t207);null!==_e211&&(o[_t207]=_e211);}}catch(err){_iterator140.e(err);}finally{_iterator140.f();}return 0===qM(o).length||r.parseNothing?null:new ZX(t,o);}}]);return ZX;}(V$);var tY=/*#__PURE__*/function(_V$12){_inherits(tY,_V$12);var _super18=_createSuper(tY);function tY(t){_classCallCheck(this,tY);return _super18.call(this,t);}_createClass(tY,[{key:"clone",value:function clone(){return new tY(null);}},{key:"dependentFields",value:function dependentFields(){return new Set();}},{key:"producedFields",value:function producedFields(){return new Set([zV]);}},{key:"hash",value:function hash(){return "Identifier";}},{key:"assemble",value:function assemble(){return {type:"identifier",as:zV};}}]);return tY;}(V$);var eY=/*#__PURE__*/function(_V$13){_inherits(eY,_V$13);var _super19=_createSuper(eY);function eY(t,e){var _this46;_classCallCheck(this,eY);_this46=_super19.call(this,t),_this46.transform=e;return _this46;}_createClass(eY,[{key:"clone",value:function clone(){return new eY(null,DM(this.transform));}},{key:"addDimensions",value:function addDimensions(t){this.transform.groupby=LM(this.transform.groupby.concat(t),function(t){return t;});}},{key:"dependentFields",value:function dependentFields(){var t=new Set();return this.transform.groupby&&this.transform.groupby.forEach(t.add,t),this.transform.joinaggregate.map(function(t){return t.field;}).filter(function(t){return void 0!==t;}).forEach(t.add,t),t;}},{key:"producedFields",value:function producedFields(){return new Set(this.transform.joinaggregate.map(this.getDefaultName));}},{key:"getDefaultName",value:function getDefaultName(t){var e;return null!==(e=t.as)&&void 0!==e?e:AW(t);}},{key:"hash",value:function hash(){return "JoinAggregateTransform ".concat(IM(this.transform));}},{key:"assemble",value:function assemble(){var t=[],e=[],n=[];var _iterator141=_createForOfIteratorHelper(this.transform.joinaggregate),_step141;try{for(_iterator141.s();!(_step141=_iterator141.n()).done;){var _r174=_step141.value;e.push(_r174.op),n.push(this.getDefaultName(_r174)),t.push(void 0===_r174.field?null:_r174.field);}}catch(err){_iterator141.e(err);}finally{_iterator141.f();}var r=this.transform.groupby;return Object.assign({type:"joinaggregate",as:n,ops:e,fields:t},void 0!==r?{groupby:r}:{});}}]);return eY;}(V$);var nY=/*#__PURE__*/function(_V$14){_inherits(nY,_V$14);var _super20=_createSuper(nY);function nY(t,e){var _this47;_classCallCheck(this,nY);_this47=_super20.call(this,t),_this47._stack=e;return _this47;}_createClass(nY,[{key:"clone",value:function clone(){return new nY(null,DM(this._stack));}},{key:"stack",get:function get(){return this._stack;}},{key:"addDimensions",value:function addDimensions(t){var _this$_stack$facetby;(_this$_stack$facetby=this._stack.facetby).push.apply(_this$_stack$facetby,_toConsumableArray(t));}},{key:"dependentFields",value:function dependentFields(){var t=new Set();return t.add(this._stack.stackField),this.getGroupbyFields().forEach(t.add,t),this._stack.facetby.forEach(t.add,t),this._stack.sort.field.forEach(t.add,t),t;}},{key:"producedFields",value:function producedFields(){return new Set(this._stack.as);}},{key:"hash",value:function hash(){return "Stack ".concat(IM(this._stack));}},{key:"getGroupbyFields",value:function getGroupbyFields(){var _this$_stack=this._stack,t=_this$_stack.dimensionFieldDef,e=_this$_stack.impute,n=_this$_stack.groupby;return t?t.bin?e?[AW(t,{binSuffix:"mid"})]:[AW(t,{}),AW(t,{binSuffix:"end"})]:[AW(t)]:null!==n&&void 0!==n?n:[];}},{key:"assemble",value:function assemble(){var t=[],_this$_stack2=this._stack,e=_this$_stack2.facetby,n=_this$_stack2.dimensionFieldDef,r=_this$_stack2.stackField,i=_this$_stack2.stackby,o=_this$_stack2.sort,a=_this$_stack2.offset,s=_this$_stack2.impute,u=_this$_stack2.as;if(s&&n){var _n$band=n.band,_o71=_n$band===void 0?.5:_n$band,_a63=n.bin;_a63&&t.push({type:"formula",expr:"".concat(_o71,"*")+AW(n,{expr:"datum"})+"+".concat(1-_o71,"*")+AW(n,{expr:"datum",binSuffix:"end"}),as:AW(n,{binSuffix:"mid",forAs:!0})}),t.push({type:"impute",field:r,groupby:[].concat(_toConsumableArray(i),_toConsumableArray(e)),key:AW(n,{binSuffix:"mid"}),method:"value",value:0});}return t.push({type:"stack",groupby:[].concat(_toConsumableArray(this.getGroupbyFields()),_toConsumableArray(e)),field:r,sort:o,as:u,offset:a}),t;}}],[{key:"makeFromTransform",value:function makeFromTransform(t,e){var n=e.stack,r=e.groupby,i=e.as,_e$offset=e.offset,o=_e$offset===void 0?"zero":_e$offset,a=[],s=[];if(void 0!==e.sort){var _iterator142=_createForOfIteratorHelper(e.sort),_step142;try{for(_iterator142.s();!(_step142=_iterator142.n()).done;){var _t208=_step142.value;a.push(_t208.field),s.push(ij(_t208.order,"ascending"));}}catch(err){_iterator142.e(err);}finally{_iterator142.f();}}var u={field:a,order:s};var c;return c=function(t){return rM(t)&&t.every(function(t){return mM(t);})&&t.length>1;}(i)?i:mM(i)?[i,i+"_end"]:[e.stack+"_start",e.stack+"_end"],new nY(t,{stackField:n,groupby:r,offset:o,sort:u,facetby:[],as:c});}},{key:"makeFromEncoding",value:function makeFromEncoding(t,e){var n=e.stack,r=e.encoding;if(!n)return null;var i=n.groupbyChannel,o=n.fieldChannel,a=n.offset,s=n.impute;var u;if(i){u=MW(r[i]);}var c=function(t){return t.stack.stackBy.reduce(function(t,e){var n=AW(e.fieldDef);return n&&t.push(n),t;},[]);}(e),l=e.encoding.order;var f;return f=rM(l)||dW(l)?nV(l):c.reduce(function(t,e){return t.field.push(e),t.order.push("y"===o?"descending":"ascending"),t;},{field:[],order:[]}),new nY(t,{dimensionFieldDef:u,stackField:e.vgField(o),facetby:[],stackby:c,sort:f,offset:a,impute:s,as:[e.vgField(o,{suffix:"start",forAs:!0}),e.vgField(o,{suffix:"end",forAs:!0})]});}}]);return nY;}(V$);var rY=/*#__PURE__*/function(_V$15){_inherits(rY,_V$15);var _super21=_createSuper(rY);function rY(t,e){var _this48;_classCallCheck(this,rY);_this48=_super21.call(this,t),_this48.transform=e;return _this48;}_createClass(rY,[{key:"clone",value:function clone(){return new rY(null,DM(this.transform));}},{key:"addDimensions",value:function addDimensions(t){this.transform.groupby=LM(this.transform.groupby.concat(t),function(t){return t;});}},{key:"dependentFields",value:function dependentFields(){var t,e;var n=new Set();return (null!==(t=this.transform.groupby)&&void 0!==t?t:[]).forEach(n.add,n),(null!==(e=this.transform.sort)&&void 0!==e?e:[]).forEach(function(t){return n.add(t.field);}),this.transform.window.map(function(t){return t.field;}).filter(function(t){return void 0!==t;}).forEach(n.add,n),n;}},{key:"producedFields",value:function producedFields(){return new Set(this.transform.window.map(this.getDefaultName));}},{key:"getDefaultName",value:function getDefaultName(t){var e;return null!==(e=t.as)&&void 0!==e?e:AW(t);}},{key:"hash",value:function hash(){return "WindowTransform ".concat(IM(this.transform));}},{key:"assemble",value:function assemble(){var t;var e=[],n=[],r=[],i=[];var _iterator143=_createForOfIteratorHelper(this.transform.window),_step143;try{for(_iterator143.s();!(_step143=_iterator143.n()).done;){var _t209=_step143.value;n.push(_t209.op),r.push(this.getDefaultName(_t209)),i.push(void 0===_t209.param?null:_t209.param),e.push(void 0===_t209.field?null:_t209.field);}}catch(err){_iterator143.e(err);}finally{_iterator143.f();}var o=this.transform.frame,a=this.transform.groupby;if(o&&null===o[0]&&null===o[1]&&n.every(function(t){return Hj(t);}))return Object.assign({type:"joinaggregate",as:r,ops:n,fields:e},void 0!==a?{groupby:a}:{});var s=[],u=[];if(void 0!==this.transform.sort){var _iterator144=_createForOfIteratorHelper(this.transform.sort),_step144;try{for(_iterator144.s();!(_step144=_iterator144.n()).done;){var _e212=_step144.value;s.push(_e212.field),u.push(null!==(t=_e212.order)&&void 0!==t?t:"ascending");}}catch(err){_iterator144.e(err);}finally{_iterator144.f();}}var c={field:s,order:u},l=this.transform.ignorePeers;return Object.assign(Object.assign(Object.assign({type:"window",params:i,as:r,ops:n,fields:e,sort:c},void 0!==l?{ignorePeers:l}:{}),void 0!==a?{groupby:a}:{}),void 0!==o?{frame:o}:{});}}]);return rY;}(V$);var iY=/*#__PURE__*/function(_$X){_inherits(iY,_$X);var _super22=_createSuper(iY);function iY(){_classCallCheck(this,iY);return _super22.apply(this,arguments);}_createClass(iY,[{key:"run",value:function run(t){var e=t.parent;if(t instanceof ZX){if(VX(e))return this.flags;if(e.numChildren()>1)return this.setContinue(),this.flags;if(e instanceof ZX)this.setMutated(),e.merge(t);else {if(WM(e.producedFields(),t.dependentFields()))return this.setContinue(),this.flags;this.setMutated(),t.swapWithParent();}}return this.setContinue(),this.flags;}}]);return iY;}($X);var oY=/*#__PURE__*/function(_HX){_inherits(oY,_HX);var _super23=_createSuper(oY);function oY(){_classCallCheck(this,oY);return _super23.apply(this,arguments);}_createClass(oY,[{key:"mergeNodes",value:function mergeNodes(t,e){var n=e.shift();var _iterator145=_createForOfIteratorHelper(e),_step145;try{for(_iterator145.s();!(_step145=_iterator145.n()).done;){var _r175=_step145.value;t.removeChild(_r175),_r175.parent=n,_r175.remove();}}catch(err){_iterator145.e(err);}finally{_iterator145.f();}}},{key:"run",value:function run(t){var e=t.children.map(function(t){return t.hash();}),n={};for(var _r176=0;_r176<e.length;_r176++){void 0===n[e[_r176]]?n[e[_r176]]=[t.children[_r176]]:n[e[_r176]].push(t.children[_r176]);}var _iterator146=_createForOfIteratorHelper(qM(n)),_step146;try{for(_iterator146.s();!(_step146=_iterator146.n()).done;){var _e213=_step146.value;n[_e213].length>1&&(this.setMutated(),this.mergeNodes(t,n[_e213]));}}catch(err){_iterator146.e(err);}finally{_iterator146.f();}var _iterator147=_createForOfIteratorHelper(t.children),_step147;try{for(_iterator147.s();!(_step147=_iterator147.n()).done;){var _e214=_step147.value;this.run(_e214);}}catch(err){_iterator147.e(err);}finally{_iterator147.f();}return this.mutatedFlag;}}]);return oY;}(HX);var aY=/*#__PURE__*/function(_$X2){_inherits(aY,_$X2);var _super24=_createSuper(aY);function aY(){_classCallCheck(this,aY);return _super24.apply(this,arguments);}_createClass(aY,[{key:"run",value:function run(t){return t instanceof q$||t.numChildren()>0||t instanceof XX?this.flags:(this.setMutated(),t.remove(),this.flags);}}]);return aY;}($X);var sY=/*#__PURE__*/function(_$X3){_inherits(sY,_$X3);var _super25=_createSuper(sY);function sY(){var _this49;_classCallCheck(this,sY);_this49=_super25.apply(this,arguments),_this49.fields=new Set(),_this49.prev=null;return _this49;}_createClass(sY,[{key:"run",value:function run(t){if(this.setContinue(),t instanceof $$){var _e215=t.producedFields();zM(_e215,this.fields)?(this.setMutated(),this.prev.remove()):this.fields=new Set([].concat(_toConsumableArray(this.fields),_toConsumableArray(_e215))),this.prev=t;}return this.flags;}},{key:"reset",value:function reset(){this.fields.clear();}}]);return sY;}($X);var uY=/*#__PURE__*/function(_$X4){_inherits(uY,_$X4);var _super26=_createSuper(uY);function uY(){_classCallCheck(this,uY);return _super26.apply(this,arguments);}_createClass(uY,[{key:"run",value:function run(t){this.setContinue();var e=t.parent.children.filter(function(t){return t instanceof $$;}),n=e.pop();var _iterator148=_createForOfIteratorHelper(e),_step148;try{for(_iterator148.s();!(_step148=_iterator148.n()).done;){var _t210=_step148.value;this.setMutated(),n.merge(_t210);}}catch(err){_iterator148.e(err);}finally{_iterator148.f();}return this.flags;}}]);return uY;}($X);function cY(t){if(t instanceof XX){if(1!==t.numChildren()||t.children[0]instanceof q$){var _e216=t.model.component.data.main;!function t(e){if(e instanceof q$&&e.type===Xq&&1===e.numChildren()){var _n171=e.children[0];_n171 instanceof XX||(_n171.swapWithParent(),t(e));}}(_e216);var _n170=function(t){return function e(n){if(!(n instanceof XX)){var _r178=n.clone();if(_r178 instanceof q$){var _e217=gY+_r178.getSource();_r178.setSource(_e217),t.model.component.data.outputNodes[_e217]=_r178;}else (_r178 instanceof KX||_r178 instanceof nY||_r178 instanceof rY||_r178 instanceof eY)&&_r178.addDimensions(t.fields);var _iterator149=_createForOfIteratorHelper(n.children.flatMap(e)),_step149;try{for(_iterator149.s();!(_step149=_iterator149.n()).done;){var _t211=_step149.value;_t211.parent=_r178;}}catch(err){_iterator149.e(err);}finally{_iterator149.f();}return [_r178];}return n.children.flatMap(e);};}(t),_r177=t.children.map(_n170).flat();var _iterator150=_createForOfIteratorHelper(_r177),_step150;try{for(_iterator150.s();!(_step150=_iterator150.n()).done;){var _t212=_step150.value;_t212.parent=_e216;}}catch(err){_iterator150.e(err);}finally{_iterator150.f();}}else {var _e218=t.children[0];(_e218 instanceof KX||_e218 instanceof nY||_e218 instanceof rY||_e218 instanceof eY)&&_e218.addDimensions(t.fields),_e218.swapWithParent(),cY(t);}}else t.children.map(cY);}var lY=/*#__PURE__*/function(_HX2){_inherits(lY,_HX2);var _super27=_createSuper(lY);function lY(){_classCallCheck(this,lY);return _super27.call(this);}_createClass(lY,[{key:"run",value:function run(t){t instanceof q$&&!t.isRequired()&&(this.setMutated(),t.remove());var _iterator151=_createForOfIteratorHelper(t.children),_step151;try{for(_iterator151.s();!(_step151=_iterator151.n()).done;){var _e219=_step151.value;this.run(_e219);}}catch(err){_iterator151.e(err);}finally{_iterator151.f();}return this.mutatedFlag;}}]);return lY;}(HX);var fY=/*#__PURE__*/function(_HX3){_inherits(fY,_HX3);var _super28=_createSuper(fY);function fY(t){var _this50;_classCallCheck(this,fY);_this50=_super28.call(this),_this50.requiresSelectionId=t&&CH(t);return _this50;}_createClass(fY,[{key:"run",value:function run(t){t instanceof tY&&(this.requiresSelectionId&&(VX(t.parent)||t.parent instanceof KX||t.parent instanceof ZX)||(this.setMutated(),t.remove()));var _iterator152=_createForOfIteratorHelper(t.children),_step152;try{for(_iterator152.s();!(_step152=_iterator152.n()).done;){var _e220=_step152.value;this.run(_e220);}}catch(err){_iterator152.e(err);}finally{_iterator152.f();}return this.mutatedFlag;}}]);return fY;}(HX);var hY=/*#__PURE__*/function(_$X5){_inherits(hY,_$X5);var _super29=_createSuper(hY);function hY(){_classCallCheck(this,hY);return _super29.apply(this,arguments);}_createClass(hY,[{key:"run",value:function run(t){var e=t.parent,n=_toConsumableArray(e.children),r=e.children.filter(function(t){return t instanceof ZX;});if(e.numChildren()>1&&r.length>=1){var _t213={},_i135=new Set();var _iterator153=_createForOfIteratorHelper(r),_step153;try{for(_iterator153.s();!(_step153=_iterator153.n()).done;){var _e222=_step153.value;var _n172=_e222.parse;var _iterator157=_createForOfIteratorHelper(qM(_n172)),_step157;try{for(_iterator157.s();!(_step157=_iterator157.n()).done;){var _e223=_step157.value;_e223 in _t213?_t213[_e223]!==_n172[_e223]&&_i135.add(_e223):_t213[_e223]=_n172[_e223];}}catch(err){_iterator157.e(err);}finally{_iterator157.f();}}}catch(err){_iterator153.e(err);}finally{_iterator153.f();}var _iterator154=_createForOfIteratorHelper(_i135),_step154;try{for(_iterator154.s();!(_step154=_iterator154.n()).done;){var _e224=_step154.value;delete _t213[_e224];}}catch(err){_iterator154.e(err);}finally{_iterator154.f();}if(!VM(_t213)){this.setMutated();var _r179=new ZX(e,_t213);var _iterator155=_createForOfIteratorHelper(n),_step155;try{for(_iterator155.s();!(_step155=_iterator155.n()).done;){var _i136=_step155.value;if(_i136 instanceof ZX){var _iterator156=_createForOfIteratorHelper(qM(_t213)),_step156;try{for(_iterator156.s();!(_step156=_iterator156.n()).done;){var _e221=_step156.value;delete _i136.parse[_e221];}}catch(err){_iterator156.e(err);}finally{_iterator156.f();}}e.removeChild(_i136),_i136.parent=_r179,_i136 instanceof ZX&&0===qM(_i136.parse).length&&_i136.remove();}}catch(err){_iterator155.e(err);}finally{_iterator155.f();}}}return this.setContinue(),this.flags;}}]);return hY;}($X);var dY=/*#__PURE__*/function(_$X6){_inherits(dY,_$X6);var _super30=_createSuper(dY);function dY(){_classCallCheck(this,dY);return _super30.apply(this,arguments);}_createClass(dY,[{key:"run",value:function run(t){var e=t.parent,n=e.children.filter(function(t){return t instanceof KX;}),r={};var _iterator158=_createForOfIteratorHelper(n),_step158;try{for(_iterator158.s();!(_step158=_iterator158.n()).done;){var _t214=_step158.value;var _e225=IM(_t214.groupBy);_e225 in r||(r[_e225]=[]),r[_e225].push(_t214);}}catch(err){_iterator158.e(err);}finally{_iterator158.f();}var _iterator159=_createForOfIteratorHelper(qM(r)),_step159;try{for(_iterator159.s();!(_step159=_iterator159.n()).done;){var _t215=_step159.value;var _n173=r[_t215];if(_n173.length>1){var _t216=_n173.pop();var _iterator160=_createForOfIteratorHelper(_n173),_step160;try{for(_iterator160.s();!(_step160=_iterator160.n()).done;){var _r180=_step160.value;_t216.merge(_r180)&&(e.removeChild(_r180),_r180.parent=_t216,_r180.remove(),this.setMutated());}}catch(err){_iterator160.e(err);}finally{_iterator160.f();}}}}catch(err){_iterator159.e(err);}finally{_iterator159.f();}return this.setContinue(),this.flags;}}]);return dY;}($X);var pY=/*#__PURE__*/function(_$X7){_inherits(pY,_$X7);var _super31=_createSuper(pY);function pY(t){var _this51;_classCallCheck(this,pY);_this51=_super31.call(this),_this51.model=t;return _this51;}_createClass(pY,[{key:"run",value:function run(t){var e=t.parent,n=!(VX(e)||e instanceof kK||e instanceof ZX||e instanceof tY),r=[],i=[];var _iterator161=_createForOfIteratorHelper(e.children),_step161;try{for(_iterator161.s();!(_step161=_iterator161.n()).done;){var _t219=_step161.value;_t219 instanceof PX&&(n&&!WM(e.producedFields(),_t219.dependentFields())?r.push(_t219):i.push(_t219));}}catch(err){_iterator161.e(err);}finally{_iterator161.f();}if(r.length>0){var _t217=r.pop();var _iterator162=_createForOfIteratorHelper(r),_step162;try{for(_iterator162.s();!(_step162=_iterator162.n()).done;){var _e226=_step162.value;_t217.merge(_e226,this.model.renameSignal.bind(this.model));}}catch(err){_iterator162.e(err);}finally{_iterator162.f();}this.setMutated(),e instanceof PX?e.merge(_t217,this.model.renameSignal.bind(this.model)):_t217.swapWithParent();}if(i.length>1){var _t218=i.pop();var _iterator163=_createForOfIteratorHelper(i),_step163;try{for(_iterator163.s();!(_step163=_iterator163.n()).done;){var _e227=_step163.value;_t218.merge(_e227,this.model.renameSignal.bind(this.model));}}catch(err){_iterator163.e(err);}finally{_iterator163.f();}this.setMutated();}return this.setContinue(),this.flags;}}]);return pY;}($X);var mY=/*#__PURE__*/function(_$X8){_inherits(mY,_$X8);var _super32=_createSuper(mY);function mY(){_classCallCheck(this,mY);return _super32.apply(this,arguments);}_createClass(mY,[{key:"run",value:function run(t){var e=t.parent,n=_toConsumableArray(e.children);if(!jM(n,function(t){return t instanceof q$;})||e.numChildren()<=1)return this.setContinue(),this.flags;var r=[];var i;var _iterator164=_createForOfIteratorHelper(n),_step164;try{for(_iterator164.s();!(_step164=_iterator164.n()).done;){var _t221=_step164.value;if(_t221 instanceof q$){var _n174=_t221;for(;1===_n174.numChildren();){var _t222=_n174.children[0];if(!(_t222 instanceof q$))break;_n174=_t222;}r.push.apply(r,_toConsumableArray(_n174.children)),i?(e.removeChild(_t221),_t221.parent=i.parent,i.parent.removeChild(i),i.parent=_n174,this.setMutated()):i=_n174;}else r.push(_t221);}}catch(err){_iterator164.e(err);}finally{_iterator164.f();}if(r.length){this.setMutated();var _iterator165=_createForOfIteratorHelper(r),_step165;try{for(_iterator165.s();!(_step165=_iterator165.n()).done;){var _t220=_step165.value;_t220.parent.removeChild(_t220),_t220.parent=i;}}catch(err){_iterator165.e(err);}finally{_iterator165.f();}}return this.setContinue(),this.flags;}}]);return mY;}($X);var gY="scale_",vY=5;function yY(t){var e=[];function n(t){if(0===t.numChildren())e.push(t);else {var _iterator166=_createForOfIteratorHelper(t.children),_step166;try{for(_iterator166.s();!(_step166=_iterator166.n()).done;){var _e228=_step166.value;n(_e228);}}catch(err){_iterator166.e(err);}finally{_iterator166.f();}}}var _iterator167=_createForOfIteratorHelper(t),_step167;try{for(_iterator167.s();!(_step167=_iterator167.n()).done;){var _e229=_step167.value;n(_e229);}}catch(err){_iterator167.e(err);}finally{_iterator167.f();}return e;}function bY(t){return t;}function xY(t,e){return e.map(function(e){if(t instanceof $X){var _n175=t.optimizeNextFromLeaves(e);return t.reset(),_n175;}return t.run(e);}).some(bY);}function wY(t,e){var n=t.sources;var r=new Set();return r.add(xY(new lY(),n)),r.add(xY(new fY(e),n)),n=n.filter(function(t){return t.numChildren()>0;}),r.add(xY(new aY(),yY(n))),n=n.filter(function(t){return t.numChildren()>0;}),r.add(xY(new iY(),yY(n))),r.add(xY(new pY(e),yY(n))),r.add(xY(new sY(),yY(n))),r.add(xY(new hY(),yY(n))),r.add(xY(new dY(),yY(n))),r.add(xY(new uY(),yY(n))),r.add(xY(new oY(),n)),r.add(xY(new mY(),yY(n))),t.sources=n,r.has(!0);}var kY=/*#__PURE__*/function(){function kY(t){_classCallCheck(this,kY);Object.defineProperty(this,"signal",{enumerable:!0,get:t});}_createClass(kY,null,[{key:"fromName",value:function fromName(t,e){return new kY(function(){return t(e);});}}]);return kY;}();function EY(t){YY(t)?function(t){var e=t.component.scales;var _iterator168=_createForOfIteratorHelper(qM(e)),_step168;try{for(_iterator168.s();!(_step168=_iterator168.n()).done;){var _n176=_step168.value;var _r181=CY(t,_n176),_i137=e[_n176];if(_i137.setWithExplicit("domains",_r181),SY(t,_n176),t.component.data.isFaceted){var _e230=t;for(;!JY(_e230)&&_e230.parent;){_e230=_e230.parent;}var _i138=_e230.component.resolve.scale[_n176];if("shared"===_i138){var _iterator169=_createForOfIteratorHelper(_r181.value),_step169;try{for(_iterator169.s();!(_step169=_iterator169.n()).done;){var _t223=_step169.value;Rz(_t223)&&(_t223.data=gY+_t223.data.replace(gY,""));}}catch(err){_iterator169.e(err);}finally{_iterator169.f();}}}}}catch(err){_iterator168.e(err);}finally{_iterator168.f();}}(t):function(t){var _iterator170=_createForOfIteratorHelper(t.children),_step170;try{for(_iterator170.s();!(_step170=_iterator170.n()).done;){var _e231=_step170.value;EY(_e231);}}catch(err){_iterator170.e(err);}finally{_iterator170.f();}var e=t.component.scales;var _iterator171=_createForOfIteratorHelper(qM(e)),_step171;try{for(_iterator171.s();!(_step171=_iterator171.n()).done;){var _n177=_step171.value;var _r182=void 0,_i139=null;var _iterator172=_createForOfIteratorHelper(t.children),_step172;try{for(_iterator172.s();!(_step172=_iterator172.n()).done;){var _e232=_step172.value;var _t224=_e232.component.scales[_n177];if(_t224){_r182=void 0===_r182?_t224.getWithExplicit("domains"):zq(_r182,_t224.getWithExplicit("domains"),"domains","scale",FY);var _e233=_t224.get("selectionExtent");_i139&&_e233&&_i139.selection!==_e233.selection&&mz("The same selection must be used to override scale domains in a layered view."),_i139=_e233;}}}catch(err){_iterator172.e(err);}finally{_iterator172.f();}e[_n177].setWithExplicit("domains",_r182),_i139&&e[_n177].set("selectionExtent",_i139,!0);}}catch(err){_iterator171.e(err);}finally{_iterator171.f();}}(t);}function CY(t,e){var n=t.getScaleComponent(e).get("type"),r=t.encoding,i=function(t,e,n,r){if("unaggregated"===t){var _DY=DY(e,n),_t225=_DY.valid,_r183=_DY.reason;if(!_t225)return void mz(_r183);}else if(void 0===t&&r.useUnaggregatedDomain){var _DY2=DY(e,n),_t226=_DY2.valid;if(_t226)return "unaggregated";}return t;}(t.scaleDomain(e),t.typedFieldDef(e),n,t.config.scale);return i!==t.scaleDomain(e)&&(t.specifiedScales[e]=Object.assign(Object.assign({},t.specifiedScales[e]),{domain:i})),"x"===e&&jW(r.x2)?jW(r.x)?zq(OY(n,i,t,"x"),OY(n,i,t,"x2"),"domain","scale",FY):OY(n,i,t,"x2"):"y"===e&&jW(r.y2)?jW(r.y)?zq(OY(n,i,t,"y"),OY(n,i,t,"y2"),"domain","scale",FY):OY(n,i,t,"y2"):OY(n,i,t,e);}function AY(t,e,n){var r;var i=null===(r=Tz(n))||void 0===r?void 0:r.unit;return "temporal"===e||i?function(t,e,n){return t.map(function(t){return {signal:"{data: ".concat(VW(t,{timeUnit:n,type:e}),"}")};});}(t,e,i):[t];}function OY(t,e,n,r){var i=n.encoding,o=jW(i[r]),a=o.type,s=o.timeUnit;if(function(t){return t&&t.unionWith;}(e)){var _i140=OY(t,void 0,n,r),_o72=AY(e.unionWith,a,s);return jq([].concat(_toConsumableArray(_i140.value),_toConsumableArray(_o72)));}if(Nz(e))return jq([e]);if(e&&"unaggregated"!==e&&!bU(e))return jq(AY(e,a,s));var u=n.stack;if(u&&r===u.fieldChannel){if("normalize"===u.offset)return Bq([[0,1]]);var _t227=n.requestDataName(Xq);return Bq([{data:_t227,field:n.vgField(r,{suffix:"start"})},{data:_t227,field:n.vgField(r,{suffix:"end"})}]);}var c=MP(r)&&dW(o)?function(t,e,n){if(!mU(n))return;var r=t.fieldDef(e),i=r.sort;if(nW(i))return {op:"min",field:WK(r,e),order:"ascending"};var o=t.stack,a=o?[].concat(_toConsumableArray(o.groupbyField?[o.groupbyField]:[]),_toConsumableArray(o.stackBy.map(function(t){return t.fieldDef.field;}))):void 0;if(eW(i)){var _t228=o&&!MM(a,i.field);return _Y(i,_t228);}if(tW(i)){var _e234=i.encoding,_n178=i.order,_r184=t.fieldDef(_e234),_s52=_r184.aggregate,_u27=_r184.field,_c21=o&&!MM(a,_u27);if(qj(_s52)||$j(_s52))return _Y({field:AW(_r184),order:_n178},_c21);if(Hj(_s52)||!_s52)return _Y({op:_s52,field:_u27,order:_n178},_c21);}else {if("descending"===i)return {op:"min",field:t.vgField(e),order:"descending"};if(MM(["ascending",void 0],i))return !0;}return;}(n,r,t):void 0;if(mW(o)){return Bq(AY([o.datum],a,s));}var l=o;if("unaggregated"===e){var _t229=n.requestDataName(Xq),_e235=o.field;return Bq([{data:_t229,field:AW({field:_e235,aggregate:"min"})},{data:_t229,field:AW({field:_e235,aggregate:"max"})}]);}if(WP(l.bin)){if(mU(t))return Bq("bin-ordinal"===t?[]:[{data:GM(c)?n.requestDataName(Xq):n.requestDataName(Yq),field:n.vgField(r,$W(l,r)?{binSuffix:"range"}:{}),sort:!0!==c&&iM(c)?c:{field:n.vgField(r,{}),op:"min"}}]);{var _t230=l.bin;if(WP(_t230)){var _e236=jX(n,l.field,_t230);return Bq([new kY(function(){var t=n.getSignalName(_e236);return "[".concat(t,".start, ").concat(t,".stop]");})]);}return Bq([{data:n.requestDataName(Xq),field:n.vgField(r,{})}]);}}if(l.timeUnit&&MM(["time","utc"],t)&&cW(r,l,YY(n)?n.encoding[eP(r)]:void 0,n.stack,n.markDef,n.config)){var _t231=n.requestDataName(Xq);return Bq([{data:_t231,field:n.vgField(r)},{data:_t231,field:n.vgField(r,{suffix:"end"})}]);}return Bq(c?[{data:GM(c)?n.requestDataName(Xq):n.requestDataName(Yq),field:n.vgField(r),sort:c}]:[{data:n.requestDataName(Xq),field:n.vgField(r)}]);}function _Y(t,e){var n=t.op,r=t.field,i=t.order;return Object.assign(Object.assign({op:null!==n&&void 0!==n?n:e?"sum":JU},r?{field:tj(r)}:{}),i?{order:i}:{});}function SY(t,e){var n;var r=t.component.scales[e],i=t.specifiedScales[e].domain,o=null===(n=t.fieldDef(e))||void 0===n?void 0:n.bin,a=bU(i)&&i,s=qP(o)&&$P(o.extent)&&o.extent;(a||s)&&r.set("selectionExtent",null!==a&&void 0!==a?a:s,!0);}function DY(t,e){var n=t.aggregate,r=t.type;return n?mM(n)&&!Yj[n]?{valid:!1,reason:y.unaggregateDomainWithNonSharedDomainOp(n)}:"quantitative"===r&&"log"===e?{valid:!1,reason:y.unaggregatedDomainWithLogScale(t)}:{valid:!0}:{valid:!1,reason:y.unaggregateDomainHasNoEffectForRawField(t)};}function FY(t,e,n,r){return t.explicit&&e.explicit&&mz(y.mergeConflictingDomainProperty(n,r,t.value,e.value)),{explicit:t.explicit,value:[].concat(_toConsumableArray(t.value),_toConsumableArray(e.value))};}function TY(t){if(Rz(t)&&mM(t.field))return t.field;if(function(t){return !rM(t)&&"fields"in t&&!("data"in t);}(t)){var _e237;var _iterator173=_createForOfIteratorHelper(t.fields),_step173;try{for(_iterator173.s();!(_step173=_iterator173.n()).done;){var _n179=_step173.value;if(Rz(_n179)&&mM(_n179.field))if(_e237){if(_e237!==_n179.field)return mz(y.FACETED_INDEPENDENT_DIFFERENT_SOURCES),_e237;}else _e237=_n179.field;}}catch(err){_iterator173.e(err);}finally{_iterator173.f();}return mz(y.FACETED_INDEPENDENT_SAME_FIELDS_DIFFERENT_SOURCES),_e237;}if(function(t){return !rM(t)&&"fields"in t&&"data"in t;}(t)){mz(y.FACETED_INDEPENDENT_SAME_SOURCE);var _e238=t.fields[0];return mM(_e238)?_e238:void 0;}}function NY(t,e){return function(t){var e=LM(t.map(function(t){if(Rz(t)){t.sort;return yM(t,["sort"]);}return t;}),IM),n=LM(t.map(function(t){if(Rz(t)){var _e240=t.sort;return void 0===_e240||GM(_e240)||("op"in _e240&&"count"===_e240.op&&delete _e240.field,"ascending"===_e240.order&&delete _e240.order),_e240;}}).filter(function(t){return void 0!==t;}),IM);if(0===e.length)return;if(1===e.length){var _e241=t[0];if(Rz(_e241)&&n.length>0){var _t232=n[0];if(n.length>1)mz(y.MORE_THAN_ONE_SORT),_t232=!0;else if(iM(_t232)&&"field"in _t232){var _n180=_t232.field;_e241.field===_n180&&(_t232=!_t232.order||{order:_t232.order});}return Object.assign(Object.assign({},_e241),{sort:_t232});}return _e241;}var r=LM(n.map(function(t){return GM(t)||!("op"in t)||t.op in Vj?t:(mz(y.domainSortDropped(t)),!0);}),IM);var i;1===r.length?i=r[0]:r.length>1&&(mz(y.MORE_THAN_ONE_SORT),i=!0);var o=LM(t.map(function(t){return Rz(t)?t.data:null;}),function(t){return t;});if(1===o.length&&null!==o[0])return Object.assign({data:o[0],fields:e.map(function(t){return t.field;})},i?{sort:i}:{});return Object.assign({fields:e},i?{sort:i}:{});}(t.component.scales[e].get("domains").map(function(e){return Rz(e)&&(e.data=t.lookupDataSource(e.data)),e;}));}function IY(t){return qM(t.component.scales).reduce(function(e,n){var r=t.component.scales[n];if(r.merged)return e;var i=r.combine(),o=i.name,a=i.type,s=i.selectionExtent;i.domains;i.range;var l=i.reverse,f=yM(i,["name","type","selectionExtent","domains","range","reverse"]),h=function(t,e,n){if(bP(n)&&Iz(t))return {step:{signal:e+"_step"}};return t;}(i.range,o,n);var d;s&&(d=function(t,e){var n=e.selection;return {signal:CK(t.getSelectionComponent(n,KM(n)),e)};}(t,s));var p=NY(t,n);return e.push(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({name:o,type:a},p?{domain:p}:{}),d?{domainRaw:d}:{}),{range:h}),void 0!==l?{reverse:l}:{}),f)),e;},[]);}var RY=/*#__PURE__*/function(_Mq4){_inherits(RY,_Mq4);var _super33=_createSuper(RY);function RY(t,e){var _this52;_classCallCheck(this,RY);_this52=_super33.call(this,{},{name:t}),_this52.merged=!1,_this52.setWithExplicit("type",e);return _this52;}_createClass(RY,[{key:"domainDefinitelyIncludesZero",value:function domainDefinitelyIncludesZero(){return !1!==this.get("zero")||jM(this.get("domains"),function(t){return rM(t)&&2===t.length&&t[0]<=0&&t[1]>=0;});}}]);return RY;}(Mq);var MY=["range","scheme"];function jY(t){return "x"===t?"width":"y"===t?"height":void 0;}function BY(t,e){var n=t.fieldDef(e);if(n&&n.bin&&WP(n.bin)){var _r185=jX(t,n.field,n.bin),_i141=jY(e),_o73=t.getName(_i141);return new kY(function(){var e=t.getSignalName(_r185),n="(".concat(e,".stop - ").concat(e,".start) / ").concat(e,".step");return "".concat(t.getSignalName(_o73)," / (").concat(n,")");});}}function PY(t,e){var n=e.specifiedScales[t],r=e.size,i=e.getScaleComponent(t).get("type");var _iterator174=_createForOfIteratorHelper(MY),_step174;try{for(_iterator174.s();!(_step174=_iterator174.n()).done;){var _r186=_step174.value;if(void 0!==n[_r186]){var _o76=_U(i,_r186),_a65=SU(t,_r186);if(_o76){if(_a65)mz(_a65);else switch(_r186){case"range":return rM(n.range)&&bP(t)?jq(n.range.map(function(t){if("width"===t||"height"===t){var _n182=e.getName(t),_r187=e.getSignalName.bind(e);return kY.fromName(_r187,_n182);}return t;})):jq(n.range);case"scheme":return jq(LY(n[_r186]));}}else mz(y.scalePropertyNotWorkWithScaleType(i,_r186,t));}}}catch(err){_iterator174.e(err);}finally{_iterator174.f();}if(t===tB||t===eB){var _e242=t===tB?"width":"height",_n181=r[_e242];if(GV(_n181)){if(mU(i))return jq({step:_n181.step});mz(y.stepDropped(_e242));}}return Bq(function(t,e){var n=e.size,r=e.config,i=e.mark,o=e.encoding,a=e.getSignalName.bind(e),_jW=jW(o[t]),s=_jW.type,u=e.getScaleComponent(t).get("type"),_e$specifiedScales$t=e.specifiedScales[t],c=_e$specifiedScales$t.domain,l=_e$specifiedScales$t.domainMid;switch(t){case tB:case eB:{if(MM(["point","band"],u))if(t!==tB||n.width){if(t===eB&&!n.height){var _t233=QV(r.view,"height");if(GV(_t233))return _t233;}}else {var _t234=QV(r.view,"width");if(GV(_t234))return _t234;}var _i142=jY(t),_o74=e.getName(_i142);return t===eB&&gU(u)?[kY.fromName(a,_o74),0]:[0,kY.fromName(a,_o74)];}case gB:{var _o75=e.component.scales[t].get("zero"),_a64=function t(e,n,r){if(n)return Nz(n)?{signal:"".concat(n.signal," ? 0 : ").concat(t(e,!1,r))}:0;switch(e){case"bar":case"tick":return r.scale.minBandSize;case"line":case"trail":case"rule":return r.scale.minStrokeWidth;case"text":return r.scale.minFontSize;case"point":case"square":case"circle":return r.scale.minSize;}throw new Error(y.incompatibleChannel("size",e));}(i,_o75,r),_s53=function(t,e,n,r){var i={x:BY(n,"x"),y:BY(n,"y")};switch(t){case"bar":case"tick":{if(void 0!==r.scale.maxBandSize)return r.scale.maxBandSize;var _t235=UY(e,i,r.view);return pM(_t235)?_t235-1:new kY(function(){return "".concat(_t235.signal," - 1");});}case"line":case"trail":case"rule":return r.scale.maxStrokeWidth;case"text":return r.scale.maxFontSize;case"point":case"square":case"circle":{if(r.scale.maxSize)return r.scale.maxSize;var _t236=UY(e,i,r.view);return pM(_t236)?Math.pow(zY*_t236,2):new kY(function(){return "pow(".concat(zY," * ").concat(_t236.signal,", 2)");});}}throw new Error(y.incompatibleChannel("size",t));}(i,n,e,r);return yU(u)?function(t,e,n){var r=function r(){var r=YW(e),i=YW(t),o="(".concat(r," - ").concat(i,") / (").concat(n," - 1)");return "sequence(".concat(i,", ").concat(r," + ").concat(o,", ").concat(o,")");};return Nz(e)?new kY(r):{signal:r()};}(_a64,_s53,function(t,e,n,r){switch(t){case"quantile":return e.scale.quantileCount;case"quantize":return e.scale.quantizeCount;case"threshold":return void 0!==n&&rM(n)?n.length+1:(mz(y.domainRequiredForThresholdScale(r)),3);}}(u,r,c,t)):[_a64,_s53];}case aB:return [0,2*Math.PI];case vB:return [0,360];case iB:return [0,new kY(function(){var t=e.getSignalName("width"),n=e.getSignalName("height");return "min(".concat(t,",").concat(n,")/2");})];case wB:return [r.scale.minStrokeWidth,r.scale.maxStrokeWidth];case kB:return [[1,0],[4,2],[2,1],[1,1],[1,2,4,2]];case mB:return "symbol";case hB:case dB:case pB:return "ordinal"===u?"nominal"===s?"category":"ordinal":void 0!==l?"diverging":"rect"===i||"geoshape"===i?"heatmap":"ramp";case yB:case bB:case xB:return [r.scale.minOpacity,r.scale.maxOpacity];}throw new Error("Scale range undefined for channel ".concat(t));}(t,e));}function LY(t){return function(t){return !mM(t)&&!!t.name;}(t)?Object.assign({scheme:t.name},TM(t,["name"])):{scheme:t};}var zY=.95;function UY(t,e,n){var r=GV(t.width)?t.width.step:JV(n,"width"),i=GV(t.height)?t.height.step:JV(n,"height");return e.x||e.y?new kY(function(){return "min(".concat([e.x?e.x.signal:r,e.y?e.y.signal:i].join(", "),")");}):Math.min(r,i);}function WY(t,e){YY(t)?function(t,e){var n=t.component.scales,r=t.config,i=t.encoding,o=t.markDef,a=t.specifiedScales;var _iterator175=_createForOfIteratorHelper(qM(n)),_step175;try{for(_iterator175.s();!(_step175=_iterator175.n()).done;){var _s54=_step175.value;var _u28=a[_s54],_c22=n[_s54],_l15=t.getScaleComponent(_s54),_f15=jW(i[_s54]),_h10=_u28[e],_d8=_l15.get("type"),_p7=_l15.get("padding"),_m6=_l15.get("paddingInner"),_g6=_U(_d8,e),_v5=SU(_s54,e);if(void 0!==_h10&&(_g6?_v5&&mz(_v5):mz(y.scalePropertyNotWorkWithScaleType(_d8,e,_s54))),_g6&&void 0===_v5)if(void 0!==_h10)_c22.copyKeyFromObject(e,_u28);else {var _n183=e in VY?VY[e]({model:t,channel:_s54,fieldOrDatumDef:_f15,scaleType:_d8,scalePadding:_p7,scalePaddingInner:_m6,domain:_u28.domain,markDef:o,config:r}):r.scale[e];void 0!==_n183&&_c22.set(e,_n183,!1);}}}catch(err){_iterator175.e(err);}finally{_iterator175.f();}}(t,e):$Y(t,e);}var VY={bins:function bins(_ref106){var t=_ref106.model,e=_ref106.fieldOrDatumDef;return dW(e)?function(t,e){var n=e.bin;if(WP(n)){var _r188=jX(t,e.field,n);return new kY(function(){return t.getSignalName(_r188);});}if(VP(n)&&qP(n)&&void 0!==n.step)return {step:n.step};return;}(t,e):void 0;},interpolate:function interpolate(_ref107){var t=_ref107.channel,e=_ref107.fieldOrDatumDef;return function(t,e){if(MM([hB,dB,pB],t)&&"nominal"!==e)return "hcl";return;}(t,e.type);},nice:function nice(_ref108){var t=_ref108.scaleType,e=_ref108.channel,n=_ref108.fieldOrDatumDef;return function(t,e,n){var r;if((null===(r=MW(n))||void 0===r?void 0:r.bin)||MM([rU.TIME,rU.UTC],t))return;return e in vP||void 0;}(t,e,n);},padding:function padding(_ref109){var t=_ref109.channel,e=_ref109.scaleType,n=_ref109.fieldOrDatumDef,r=_ref109.markDef,i=_ref109.config;return function(t,e,n,r,i,o){if(t in vP){if(vU(e)){if(void 0!==n.continuousPadding)return n.continuousPadding;var _e243=i.type,_a66=i.orient;if("bar"===_e243&&(!dW(r)||!r.bin&&!r.timeUnit)&&("vertical"===_a66&&"x"===t||"horizontal"===_a66&&"y"===t))return o.continuousBandSize;}if(e===rU.POINT)return n.pointPadding;}return;}(t,e,i.scale,n,r,i.bar);},paddingInner:function paddingInner(_ref110){var t=_ref110.scalePadding,e=_ref110.channel,n=_ref110.markDef,r=_ref110.config;return function(t,e,n,r){if(void 0!==t)return;if(e in vP){var _t237=r.bandPaddingInner,_e244=r.barBandPaddingInner,_i143=r.rectBandPaddingInner;return ij(_t237,"bar"===n?_e244:_i143);}return;}(t,e,n.type,r.scale);},paddingOuter:function paddingOuter(_ref111){var t=_ref111.scalePadding,e=_ref111.channel,n=_ref111.scaleType,r=_ref111.markDef,i=_ref111.scalePaddingInner,o=_ref111.config;return function(t,e,n,r,i,o){if(void 0!==t)return;if(e in vP&&n===rU.BAND){var _t238=o.bandPaddingOuter;return ij(_t238,Nz(i)?{signal:"".concat(i.signal,"/2")}:i/2);}return;}(t,e,n,r.type,i,o.scale);},reverse:function reverse(_ref112){var t=_ref112.fieldOrDatumDef,e=_ref112.scaleType,n=_ref112.channel,r=_ref112.config;return function(t,e,n,r){if("x"===n&&void 0!==r.xReverse)return gU(t)&&"descending"===e?Nz(r.xReverse)?{signal:"!".concat(r.xReverse.signal)}:!r.xReverse:r.xReverse;if(gU(t)&&"descending"===e)return !0;return;}(e,dW(t)?t.sort:void 0,n,r.scale);},zero:function zero(_ref113){var t=_ref113.channel,e=_ref113.fieldOrDatumDef,n=_ref113.domain,r=_ref113.markDef,i=_ref113.scaleType;return function(t,e,n,r,i){if(n&&"unaggregated"!==n&&gU(i)){if(rM(n)){var _t239=n[0],_e245=n[n.length-1];if(_t239<=0&&_e245>=0)return !0;}return !1;}if("size"===t&&"quantitative"===e.type&&!yU(i))return !0;if((!dW(e)||!e.bin)&&MM([].concat(_toConsumableArray(yP),_toConsumableArray(wP)),t)){var _e246=r.orient,_n184=r.type;return !MM(["bar","area","line","trail"],_n184)||!("horizontal"===_e246&&"y"===t||"vertical"===_e246&&"x"===t);}return !1;}(t,e,n,r,i);}};function qY(t){YY(t)?function(t){var e=t.component.scales;var _iterator176=_createForOfIteratorHelper(RP),_step176;try{for(_iterator176.s();!(_step176=_iterator176.n()).done;){var _n185=_step176.value;var _r189=e[_n185];if(!_r189)continue;var _i144=PY(_n185,t);_r189.setWithExplicit("range",_i144);}}catch(err){_iterator176.e(err);}finally{_iterator176.f();}}(t):$Y(t,"range");}function $Y(t,e){var n=t.component.scales;var _iterator177=_createForOfIteratorHelper(t.children),_step177;try{for(_iterator177.s();!(_step177=_iterator177.n()).done;){var _n186=_step177.value;"range"===e?qY(_n186):WY(_n186,e);}}catch(err){_iterator177.e(err);}finally{_iterator177.f();}var _iterator178=_createForOfIteratorHelper(qM(n)),_step178;try{for(_iterator178.s();!(_step178=_iterator178.n()).done;){var _r190=_step178.value;var _i145=void 0;var _iterator179=_createForOfIteratorHelper(t.children),_step179;try{for(_iterator179.s();!(_step179=_iterator179.n()).done;){var _n187=_step179.value;var _t240=_n187.component.scales[_r190];if(_t240){_i145=zq(_i145,_t240.getWithExplicit(e),e,"scale",Pq(function(t,n){switch(e){case"range":return t.step&&n.step?t.step-n.step:0;}return 0;}));}}}catch(err){_iterator179.e(err);}finally{_iterator179.f();}n[_r190].setWithExplicit(e,_i145);}}catch(err){_iterator178.e(err);}finally{_iterator178.f();}}function HY(t,e,n,r){var i=function(t,e,n){var r;switch(e.type){case"nominal":case"ordinal":if(jB(t)||"discrete"===zP(t))return "shape"===t&&"ordinal"===e.type&&mz(y.discreteChannelCannotEncode(t,"ordinal")),"ordinal";if(t in vP){if(MM(["rect","bar","image","rule"],n))return "band";}else if("arc"===n&&t in xP)return "band";return void 0!==e.band||kW(e)&&(null===(r=e.axis)||void 0===r?void 0:r.tickBand)?"band":"point";case"temporal":return jB(t)?"time":"discrete"===zP(t)?(mz(y.discreteChannelCannotEncode(t,"temporal")),"ordinal"):dW(e)&&e.timeUnit&&Tz(e.timeUnit).utc?"utc":"time";case"quantitative":return jB(t)?dW(e)&&WP(e.bin)?"bin-ordinal":"linear":"discrete"===zP(t)?(mz(y.discreteChannelCannotEncode(t,"quantitative")),"ordinal"):"linear";case"geojson":return;}throw new Error(y.invalidFieldType(e.type));}(e,n,r),o=t.type;return MP(e)?void 0!==o?FU(e,o)?dW(n)&&!DU(o,n.type)?(mz(y.scaleTypeNotWorkWithFieldDef(o,i)),i):o:(mz(y.scaleTypeNotWorkWithChannel(e,o,i)),i):i:null;}function GY(t){YY(t)?t.component.scales=function(t){var e=t.encoding,n=t.mark;return RP.reduce(function(r,i){var o=jW(e[i]);if(o&&n===Fj&&i===mB&&o.type===eU)return r;var a=o&&o.scale;if(o&&null!==a&&!1!==a){var _e247=HY(a=null!==a&&void 0!==a?a:{},i,o,n);r[i]=new RY(t.scaleName(i+"",!0),{value:_e247,explicit:a.type===_e247});}return r;},{});}(t):t.component.scales=function(t){var e;var n=t.component.scales={},r={},i=t.component.resolve;var _iterator180=_createForOfIteratorHelper(t.children),_step180;try{for(_iterator180.s();!(_step180=_iterator180.n()).done;){var _n188=_step180.value;GY(_n188);var _iterator182=_createForOfIteratorHelper(qM(_n188.component.scales)),_step182;try{for(_iterator182.s();!(_step182=_iterator182.n()).done;){var _o77=_step182.value;if(i.scale[_o77]=null!==(e=i.scale[_o77])&&void 0!==e?e:cX(_o77,t),"shared"===i.scale[_o77]){var _t241=r[_o77],_e248=_n188.component.scales[_o77].getWithExplicit("type");_t241?aU(_t241.value,_e248.value)?r[_o77]=zq(_t241,_e248,"type","scale",KY):(i.scale[_o77]="independent",delete r[_o77]):r[_o77]=_e248;}}}catch(err){_iterator182.e(err);}finally{_iterator182.f();}}}catch(err){_iterator180.e(err);}finally{_iterator180.f();}var _iterator181=_createForOfIteratorHelper(qM(r)),_step181;try{for(_iterator181.s();!(_step181=_iterator181.n()).done;){var _e249=_step181.value;var _i146=t.scaleName(_e249,!0),_o78=r[_e249];n[_e249]=new RY(_i146,_o78);var _iterator183=_createForOfIteratorHelper(t.children),_step183;try{for(_iterator183.s();!(_step183=_iterator183.n()).done;){var _n189=_step183.value;var _t242=_n189.component.scales[_e249];_t242&&(_n189.renameScale(_t242.get("name"),_i146),_t242.merged=!0);}}catch(err){_iterator183.e(err);}finally{_iterator183.f();}}}catch(err){_iterator181.e(err);}finally{_iterator181.f();}return n;}(t);}var KY=Pq(function(t,e){return uU(t)-uU(e);});var XY=/*#__PURE__*/function(){function XY(){_classCallCheck(this,XY);this.nameMap={};}_createClass(XY,[{key:"rename",value:function rename(t,e){this.nameMap[t]=e;}},{key:"has",value:function has(t){return void 0!==this.nameMap[t];}},{key:"get",value:function get(t){for(;this.nameMap[t]&&t!==this.nameMap[t];){t=this.nameMap[t];}return t;}}]);return XY;}();function YY(t){return "unit"===(null===t||void 0===t?void 0:t.type);}function JY(t){return "facet"===(null===t||void 0===t?void 0:t.type);}function QY(t){return "concat"===(null===t||void 0===t?void 0:t.type);}function ZY(t){return "layer"===(null===t||void 0===t?void 0:t.type);}var tJ=/*#__PURE__*/function(){function tJ(t,e,n,r,i,o,a){var _this53=this;_classCallCheck(this,tJ);var s,u;this.type=e,this.parent=n,this.config=i,this.view=a,this.children=[],this.correctDataNames=function(t){return t.from&&t.from.data&&(t.from.data=_this53.lookupDataSource(t.from.data)),t.from&&t.from.facet&&t.from.facet.data&&(t.from.facet.data=_this53.lookupDataSource(t.from.facet.data)),t;},this.parent=n,this.config=i,this.name=null!==(s=t.name)&&void 0!==s?s:r,this.title=GW(t.title)?{text:t.title}:t.title,this.scaleNameMap=n?n.scaleNameMap:new XY(),this.projectionNameMap=n?n.projectionNameMap:new XY(),this.signalNameMap=n?n.signalNameMap:new XY(),this.data=t.data,this.description=t.description,this.transforms=m$(null!==(u=t.transform)&&void 0!==u?u:[]),this.layout="layer"===e||"unit"===e?{}:function(t,e,n){var r,i;var o=n[e],a={},s=o.spacing,u=o.columns;void 0!==s&&(a.spacing=s),void 0!==u&&(oW(t)&&!rW(t.facet)||qV(t))&&(a.columns=u),$V(t)&&(a.columns=1);var _iterator184=_createForOfIteratorHelper(XV),_step184;try{for(_iterator184.s();!(_step184=_iterator184.n()).done;){var _e250=_step184.value;if(void 0!==t[_e250])if("spacing"===_e250){var _n190=t[_e250];a[_e250]=pM(_n190)?_n190:{row:null!==(r=_n190.row)&&void 0!==r?r:s,column:null!==(i=_n190.column)&&void 0!==i?i:s};}else a[_e250]=t[_e250];}}catch(err){_iterator184.e(err);}finally{_iterator184.f();}return a;}(t,e,i),this.component={data:{sources:n?n.component.data.sources:[],outputNodes:n?n.component.data.outputNodes:{},outputNodeRefCounts:n?n.component.data.outputNodeRefCounts:{},isFaceted:oW(t)||n&&n.component.data.isFaceted&&void 0===t.data},layoutSize:new Mq(),layoutHeaders:{row:{},column:{},facet:{}},mark:null,resolve:Object.assign({scale:{},axis:{},legend:{}},o?DM(o):{}),selection:null,scales:null,projection:null,axes:{},legends:{}};}_createClass(tJ,[{key:"width",get:function get(){return this.getSizeSignalRef("width");}},{key:"height",get:function get(){return this.getSizeSignalRef("height");}},{key:"parse",value:function parse(){this.parseScale(),this.parseLayoutSize(),this.renameTopLevelLayoutSizeSignal(),this.parseSelections(),this.parseProjection(),this.parseData(),this.parseAxesAndHeaders(),this.parseLegends(),this.parseMarkGroup();}},{key:"parseScale",value:function parseScale(){!function(t){var _ref114=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},e=_ref114.ignoreRange;GY(t),EY(t);var _iterator185=_createForOfIteratorHelper(OU),_step185;try{for(_iterator185.s();!(_step185=_iterator185.n()).done;){var _e251=_step185.value;WY(t,_e251);}}catch(err){_iterator185.e(err);}finally{_iterator185.f();}e||qY(t);}(this);}},{key:"parseProjection",value:function parseProjection(){RX(this);}},{key:"renameTopLevelLayoutSizeSignal",value:function renameTopLevelLayoutSizeSignal(){"width"!==this.getName("width")&&this.renameSignal(this.getName("width"),"width"),"height"!==this.getName("height")&&this.renameSignal(this.getName("height"),"height");}},{key:"parseLegends",value:function parseLegends(){EX(this);}},{key:"assembleGroupStyle",value:function assembleGroupStyle(){var t,e;if("unit"===this.type||"layer"===this.type)return null!==(e=null===(t=this.view)||void 0===t?void 0:t.style)&&void 0!==e?e:"cell";}},{key:"assembleEncodeFromView",value:function assembleEncodeFromView(t){t.style;var n=yM(t,["style"]),r={};var _iterator186=_createForOfIteratorHelper(qM(n)),_step186;try{for(_iterator186.s();!(_step186=_iterator186.n()).done;){var _t243=_step186.value;var _e252=n[_t243];void 0!==_e252&&(r[_t243]=KW(_e252));}}catch(err){_iterator186.e(err);}finally{_iterator186.f();}return r;}},{key:"assembleGroupEncodeEntry",value:function assembleGroupEncodeEntry(t){var e={};return this.view&&(e=this.assembleEncodeFromView(this.view)),t||(this.description&&(e.description=KW(this.description)),"unit"!==this.type&&"layer"!==this.type)?VM(e)?void 0:e:Object.assign({width:this.getSizeSignalRef("width"),height:this.getSizeSignalRef("height")},null!==e&&void 0!==e?e:{});}},{key:"assembleLayout",value:function assembleLayout(){if(!this.layout)return;var t=this.layout,e=t.spacing,n=yM(t,["spacing"]),r=this.component,i=this.config,o=function(t,e){var n={};var _iterator187=_createForOfIteratorHelper(PB),_step187;try{for(_iterator187.s();!(_step187=_iterator187.n()).done;){var _r191=_step187.value;var _i147=t[_r191];if(null===_i147||void 0===_i147?void 0:_i147.facetFieldDef){var _$K4=$K(["titleAnchor","titleOrient"],_i147.facetFieldDef,e,_r191),_t244=_$K4.titleAnchor,_o79=_$K4.titleOrient,_a67=VK(_r191,_o79),_s55=eX(_t244,_a67);void 0!==_s55&&(n[_a67]=_s55);}}}catch(err){_iterator187.e(err);}finally{_iterator187.f();}return VM(n)?void 0:n;}(r.layoutHeaders,i);return Object.assign(Object.assign(Object.assign({padding:e},this.assembleDefaultLayout()),n),o?{titleBand:o}:{});}},{key:"assembleDefaultLayout",value:function assembleDefaultLayout(){return {};}},{key:"assembleHeaderMarks",value:function assembleHeaderMarks(){var t=this.component.layoutHeaders;var e=[];var _iterator188=_createForOfIteratorHelper(PB),_step188;try{for(_iterator188.s();!(_step188=_iterator188.n()).done;){var _n191=_step188.value;t[_n191].title&&e.push(KK(this,_n191));}}catch(err){_iterator188.e(err);}finally{_iterator188.f();}var _iterator189=_createForOfIteratorHelper(HK),_step189;try{for(_iterator189.s();!(_step189=_iterator189.n()).done;){var _t245=_step189.value;e=e.concat(JK(this,_t245));}}catch(err){_iterator189.e(err);}finally{_iterator189.f();}return e;}},{key:"assembleAxes",value:function assembleAxes(){return function(t,e){var _t$x=t.x,n=_t$x===void 0?[]:_t$x,_t$y=t.y,r=_t$y===void 0?[]:_t$y;return [].concat(_toConsumableArray(n.map(function(t){return _K(t,"grid",e);})),_toConsumableArray(r.map(function(t){return _K(t,"grid",e);})),_toConsumableArray(n.map(function(t){return _K(t,"main",e);})),_toConsumableArray(r.map(function(t){return _K(t,"main",e);}))).filter(function(t){return t;});}(this.component.axes,this.config);}},{key:"assembleLegends",value:function assembleLegends(){return DX(this);}},{key:"assembleProjections",value:function assembleProjections(){return FX(this);}},{key:"assembleTitle",value:function assembleTitle(){var t,e,n;var r=null!==(t=this.title)&&void 0!==t?t:{},i=r.encoding,o=yM(r,["encoding"]),a=Object.assign(Object.assign(Object.assign({},HW(this.config.title).nonMark),o),i?{encode:{update:i}}:{});if(a.text)return MM(["unit","layer"],this.type)?MM(["middle",void 0],a.anchor)&&(a.frame=null!==(e=a.frame)&&void 0!==e?e:"group"):a.anchor=null!==(n=a.anchor)&&void 0!==n?n:"start",VM(a)?void 0:a;}},{key:"assembleGroup",value:function assembleGroup(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var e={};(t=t.concat(this.assembleSignals())).length>0&&(e.signals=t);var n=this.assembleLayout();n&&(e.layout=n),e.marks=[].concat(this.assembleHeaderMarks(),this.assembleMarks());var r=!this.parent||JY(this.parent)?function t(e){return ZY(e)||QY(e)?e.children.reduce(function(e,n){return e.concat(t(n));},IY(e)):IY(e);}(this):[];r.length>0&&(e.scales=r);var i=this.assembleAxes();i.length>0&&(e.axes=i);var o=this.assembleLegends();return o.length>0&&(e.legends=o),e;}},{key:"getName",value:function getName(t){return KM((this.name?this.name+"_":"")+t);}},{key:"requestDataName",value:function requestDataName(t){var e;var n=this.getName(t),r=this.component.data.outputNodeRefCounts;return r[n]=(null!==(e=r[n])&&void 0!==e?e:0)+1,n;}},{key:"getSizeSignalRef",value:function getSizeSignalRef(t){if(JY(this.parent)){var _e253=kP(sX(t)),_n192=this.component.scales[_e253];if(_n192&&!_n192.merged){var _t246=_n192.get("type"),_r192=_n192.get("range");if(mU(_t246)&&Iz(_r192)){var _t247=_n192.get("name"),_r193=TY(NY(this,_e253));if(_r193){return {signal:aX(_t247,_n192,AW({aggregate:"distinct",field:_r193},{expr:"datum"}))};}return mz("Unknown field for ".concat(_e253,". Cannot calculate view size.")),null;}}}return {signal:this.signalNameMap.get(this.getName(t))};}},{key:"lookupDataSource",value:function lookupDataSource(t){var e=this.component.data.outputNodes[t];return e?e.getSource():t;}},{key:"getSignalName",value:function getSignalName(t){return this.signalNameMap.get(t);}},{key:"renameSignal",value:function renameSignal(t,e){this.signalNameMap.rename(t,e);}},{key:"renameScale",value:function renameScale(t,e){this.scaleNameMap.rename(t,e);}},{key:"renameProjection",value:function renameProjection(t,e){this.projectionNameMap.rename(t,e);}},{key:"scaleName",value:function scaleName(t,e){return e?this.getName(t):YB(t)&&MP(t)&&this.component.scales[t]||this.scaleNameMap.has(this.getName(t))?this.scaleNameMap.get(this.getName(t)):void 0;}},{key:"projectionName",value:function projectionName(t){return t?this.getName("projection"):this.component.projection&&!this.component.projection.merged||this.projectionNameMap.has(this.getName("projection"))?this.projectionNameMap.get(this.getName("projection")):void 0;}},{key:"getScaleComponent",value:function getScaleComponent(t){if(!this.component.scales)throw new Error("getScaleComponent cannot be called before parseScale(). Make sure you have called parseScale or use parseUnitModelWithScale().");var e=this.component.scales[t];return e&&!e.merged?e:this.parent?this.parent.getScaleComponent(t):void 0;}},{key:"getSelectionComponent",value:function getSelectionComponent(t,e){var n=this.component.selection[t];if(!n&&this.parent&&(n=this.parent.getSelectionComponent(t,e)),!n)throw new Error(y.selectionNotFound(e));return n;}},{key:"hasAxisOrientSignalRef",value:function hasAxisOrientSignalRef(){var t,e;return (null===(t=this.component.axes.x)||void 0===t?void 0:t.some(function(t){return t.hasOrientSignalRef();}))||(null===(e=this.component.axes.y)||void 0===e?void 0:e.some(function(t){return t.hasOrientSignalRef();}));}}]);return tJ;}();var eJ=/*#__PURE__*/function(_tJ){_inherits(eJ,_tJ);var _super34=_createSuper(eJ);function eJ(){_classCallCheck(this,eJ);return _super34.apply(this,arguments);}_createClass(eJ,[{key:"vgField",value:function vgField(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var n=this.fieldDef(t);if(n)return AW(n,e);}},{key:"reduceFieldDef",value:function reduceFieldDef(t,e){return fV(this.getMapping(),function(e,n,r){var i=MW(n);return i?t(e,i,r):e;},e);}},{key:"forEachFieldDef",value:function forEachFieldDef(t,e){lV(this.getMapping(),function(e,n){var r=MW(e);r&&t(r,n);},e);}}]);return eJ;}(tJ);var nJ=/*#__PURE__*/function(_V$16){_inherits(nJ,_V$16);var _super35=_createSuper(nJ);function nJ(t,e){var _this54;_classCallCheck(this,nJ);var n,r,i;_this54=_super35.call(this,t),_this54.transform=e,_this54.transform=DM(e);var o=null!==(n=_this54.transform.as)&&void 0!==n?n:[void 0,void 0];_this54.transform.as=[null!==(r=o[0])&&void 0!==r?r:"value",null!==(i=o[1])&&void 0!==i?i:"density"];return _this54;}_createClass(nJ,[{key:"clone",value:function clone(){return new nJ(null,DM(this.transform));}},{key:"dependentFields",value:function dependentFields(){var t;return new Set([this.transform.density].concat(_toConsumableArray(null!==(t=this.transform.groupby)&&void 0!==t?t:[])));}},{key:"producedFields",value:function producedFields(){return new Set(this.transform.as);}},{key:"hash",value:function hash(){return "DensityTransform ".concat(IM(this.transform));}},{key:"assemble",value:function assemble(){var t=this.transform,e=t.density,n=yM(t,["density"]);return Object.assign({type:"kde",field:e},n);}}]);return nJ;}(V$);var rJ=/*#__PURE__*/function(_V$17){_inherits(rJ,_V$17);var _super36=_createSuper(rJ);function rJ(t,e){var _this55;_classCallCheck(this,rJ);_this55=_super36.call(this,t),_this55.filter=e;return _this55;}_createClass(rJ,[{key:"clone",value:function clone(){return new rJ(null,Object.assign({},this.filter));}},{key:"dependentFields",value:function dependentFields(){return new Set(qM(this.filter));}},{key:"producedFields",value:function producedFields(){return new Set();}},{key:"hash",value:function hash(){return "FilterInvalid ".concat(IM(this.filter));}},{key:"assemble",value:function assemble(){var _this56=this;var t=qM(this.filter).reduce(function(t,e){var n=_this56.filter[e],r=AW(n,{expr:"datum"});return null!==n&&("temporal"===n.type?t.push("(isDate(".concat(r,") || (isValid(").concat(r,") && isFinite(+").concat(r,")))")):"quantitative"===n.type&&(t.push("isValid(".concat(r,")")),t.push("isFinite(+".concat(r,")")))),t;},[]);return t.length>0?{type:"filter",expr:t.join(" && ")}:null;}}],[{key:"make",value:function make(t,e){var n=e.config,r=e.mark,i=e.markDef;if("filter"!==QW("invalid",i,n))return null;var o=e.reduceFieldDef(function(t,n,i){var o=MP(i)&&e.getScaleComponent(i);if(o){gU(o.get("type"))&&"count"!==n.aggregate&&!Tj(r)&&(t[n.field]=n);}return t;},{});return qM(o).length?new rJ(t,o):null;}}]);return rJ;}(V$);var iJ=/*#__PURE__*/function(_V$18){_inherits(iJ,_V$18);var _super37=_createSuper(iJ);function iJ(t,e){var _this57;_classCallCheck(this,iJ);_this57=_super37.call(this,t),_this57.transform=e,_this57.transform=DM(e);var _this57$transform=_this57.transform,n=_this57$transform.flatten,_this57$transform$as=_this57$transform.as,r=_this57$transform$as===void 0?[]:_this57$transform$as;_this57.transform.as=n.map(function(t,e){var n;return null!==(n=r[e])&&void 0!==n?n:t;});return _this57;}_createClass(iJ,[{key:"clone",value:function clone(){return new iJ(this.parent,DM(this.transform));}},{key:"dependentFields",value:function dependentFields(){return new Set(this.transform.flatten);}},{key:"producedFields",value:function producedFields(){return new Set(this.transform.as);}},{key:"hash",value:function hash(){return "FlattenTransform ".concat(IM(this.transform));}},{key:"assemble",value:function assemble(){var _this$transform=this.transform,t=_this$transform.flatten,e=_this$transform.as;return {type:"flatten",fields:t,as:e};}}]);return iJ;}(V$);var oJ=/*#__PURE__*/function(_V$19){_inherits(oJ,_V$19);var _super38=_createSuper(oJ);function oJ(t,e){var _this58;_classCallCheck(this,oJ);var n,r,i;_this58=_super38.call(this,t),_this58.transform=e,_this58.transform=DM(e);var o=null!==(n=_this58.transform.as)&&void 0!==n?n:[void 0,void 0];_this58.transform.as=[null!==(r=o[0])&&void 0!==r?r:"key",null!==(i=o[1])&&void 0!==i?i:"value"];return _this58;}_createClass(oJ,[{key:"clone",value:function clone(){return new oJ(null,DM(this.transform));}},{key:"dependentFields",value:function dependentFields(){return new Set(this.transform.fold);}},{key:"producedFields",value:function producedFields(){return new Set(this.transform.as);}},{key:"hash",value:function hash(){return "FoldTransform ".concat(IM(this.transform));}},{key:"assemble",value:function assemble(){var _this$transform2=this.transform,t=_this$transform2.fold,e=_this$transform2.as;return {type:"fold",fields:t,as:e};}}]);return oJ;}(V$);var aJ=/*#__PURE__*/function(_V$20){_inherits(aJ,_V$20);var _super39=_createSuper(aJ);function aJ(t,e,n,r){var _this59;_classCallCheck(this,aJ);_this59=_super39.call(this,t),_this59.fields=e,_this59.geojson=n,_this59.signal=r;return _this59;}_createClass(aJ,[{key:"clone",value:function clone(){return new aJ(null,DM(this.fields),this.geojson,this.signal);}},{key:"dependentFields",value:function dependentFields(){var t;var e=(null!==(t=this.fields)&&void 0!==t?t:[]).filter(mM);return new Set([].concat(_toConsumableArray(this.geojson?[this.geojson]:[]),_toConsumableArray(e)));}},{key:"producedFields",value:function producedFields(){return new Set();}},{key:"hash",value:function hash(){return "GeoJSON ".concat(this.geojson," ").concat(this.signal," ").concat(IM(this.fields));}},{key:"assemble",value:function assemble(){return Object.assign(Object.assign(Object.assign({type:"geojson"},this.fields?{fields:this.fields}:{}),this.geojson?{geojson:this.geojson}:{}),{signal:this.signal});}}],[{key:"parseAll",value:function parseAll(t,e){if(e.component.projection&&!e.component.projection.isFit)return t;var n=0;for(var _i148=0,_arr10=[[cB,uB],[fB,lB]];_i148<_arr10.length;_i148++){var _r194=_arr10[_i148];var _i149=_r194.map(function(t){var n=jW(e.encoding[t]);return dW(n)?n.field:mW(n)?{expr:"".concat(n.datum)}:xW(n)?{expr:"".concat(n.value)}:void 0;});(_i149[0]||_i149[1])&&(t=new aJ(t,_i149,null,e.getName("geojson_".concat(n++))));}if(e.channelHasField(mB)){var _r195=e.typedFieldDef(mB);_r195.type===eU&&(t=new aJ(t,null,_r195.field,e.getName("geojson_".concat(n++))));}return t;}}]);return aJ;}(V$);var sJ=/*#__PURE__*/function(_V$21){_inherits(sJ,_V$21);var _super40=_createSuper(sJ);function sJ(t,e,n,r){var _this60;_classCallCheck(this,sJ);_this60=_super40.call(this,t),_this60.projection=e,_this60.fields=n,_this60.as=r;return _this60;}_createClass(sJ,[{key:"clone",value:function clone(){return new sJ(null,this.projection,DM(this.fields),DM(this.as));}},{key:"dependentFields",value:function dependentFields(){return new Set(this.fields.filter(mM));}},{key:"producedFields",value:function producedFields(){return new Set(this.as);}},{key:"hash",value:function hash(){return "Geopoint ".concat(this.projection," ").concat(IM(this.fields)," ").concat(IM(this.as));}},{key:"assemble",value:function assemble(){return {type:"geopoint",projection:this.projection,fields:this.fields,as:this.as};}}],[{key:"parseAll",value:function parseAll(t,e){if(!e.projectionName())return t;for(var _i150=0,_arr11=[[cB,uB],[fB,lB]];_i150<_arr11.length;_i150++){var _n193=_arr11[_i150];var _r196=_n193.map(function(t){var n=jW(e.encoding[t]);return dW(n)?n.field:mW(n)?{expr:"".concat(n.datum)}:xW(n)?{expr:"".concat(n.value)}:void 0;}),_i151=_n193[0]===fB?"2":"";(_r196[0]||_r196[1])&&(t=new sJ(t,e.projectionName(),_r196,[e.getName("x"+_i151),e.getName("y"+_i151)]));}return t;}}]);return sJ;}(V$);var uJ=/*#__PURE__*/function(_V$22){_inherits(uJ,_V$22);var _super41=_createSuper(uJ);function uJ(t,e){var _this61;_classCallCheck(this,uJ);_this61=_super41.call(this,t),_this61.transform=e;return _this61;}_createClass(uJ,[{key:"clone",value:function clone(){return new uJ(null,DM(this.transform));}},{key:"dependentFields",value:function dependentFields(){var t;return new Set([this.transform.impute,this.transform.key].concat(_toConsumableArray(null!==(t=this.transform.groupby)&&void 0!==t?t:[])));}},{key:"producedFields",value:function producedFields(){return new Set([this.transform.impute]);}},{key:"processSequence",value:function processSequence(t){var _t$start=t.start,e=_t$start===void 0?0:_t$start,n=t.stop,r=t.step;return {signal:"sequence(".concat([e,n].concat(_toConsumableArray(r?[r]:[])).join(","),")")};}},{key:"hash",value:function hash(){return "Impute ".concat(IM(this.transform));}},{key:"assemble",value:function assemble(){var _this$transform3=this.transform,t=_this$transform3.impute,e=_this$transform3.key,n=_this$transform3.keyvals,r=_this$transform3.method,i=_this$transform3.groupby,o=_this$transform3.value,_this$transform3$fram=_this$transform3.frame,a=_this$transform3$fram===void 0?[null,null]:_this$transform3$fram,s=Object.assign(Object.assign(Object.assign(Object.assign({type:"impute",field:t,key:e},n?{keyvals:function(t){return void 0!==(null===t||void 0===t?void 0:t.stop);}(n)?this.processSequence(n):n}:{}),{method:"value"}),i?{groupby:i}:{}),{value:r&&"value"!==r?null:o});if(r&&"value"!==r){return [s,Object.assign({type:"window",as:["imputed_".concat(t,"_value")],ops:[r],fields:[t],frame:a,ignorePeers:!1},i?{groupby:i}:{}),{type:"formula",expr:"datum.".concat(t," === null ? datum.imputed_").concat(t,"_value : datum.").concat(t),as:t}];}return [s];}}],[{key:"makeFromTransform",value:function makeFromTransform(t,e){return new uJ(t,e);}},{key:"makeFromEncoding",value:function makeFromEncoding(t,e){var n=e.encoding,r=n.x,i=n.y;if(dW(r)&&dW(i)){var _o80=r.impute?r:i.impute?i:void 0;if(void 0===_o80)return;var _a68=r.impute?i:i.impute?r:void 0,_o80$impute=_o80.impute,_s56=_o80$impute.method,_u29=_o80$impute.value,_c23=_o80$impute.frame,_l16=_o80$impute.keyvals,_f16=hV(e.mark,n);return new uJ(t,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({impute:_o80.field,key:_a68.field},_s56?{method:_s56}:{}),void 0!==_u29?{value:_u29}:{}),_c23?{frame:_c23}:{}),void 0!==_l16?{keyvals:_l16}:{}),_f16.length?{groupby:_f16}:{}));}return null;}}]);return uJ;}(V$);var cJ=/*#__PURE__*/function(_V$23){_inherits(cJ,_V$23);var _super42=_createSuper(cJ);function cJ(t,e){var _this62;_classCallCheck(this,cJ);var n,r,i;_this62=_super42.call(this,t),_this62.transform=e,_this62.transform=DM(e);var o=null!==(n=_this62.transform.as)&&void 0!==n?n:[void 0,void 0];_this62.transform.as=[null!==(r=o[0])&&void 0!==r?r:e.on,null!==(i=o[1])&&void 0!==i?i:e.loess];return _this62;}_createClass(cJ,[{key:"clone",value:function clone(){return new cJ(null,DM(this.transform));}},{key:"dependentFields",value:function dependentFields(){var t;return new Set([this.transform.loess,this.transform.on].concat(_toConsumableArray(null!==(t=this.transform.groupby)&&void 0!==t?t:[])));}},{key:"producedFields",value:function producedFields(){return new Set(this.transform.as);}},{key:"hash",value:function hash(){return "LoessTransform ".concat(IM(this.transform));}},{key:"assemble",value:function assemble(){var t=this.transform,e=t.loess,n=t.on,r=yM(t,["loess","on"]);return Object.assign({type:"loess",x:n,y:e},r);}}]);return cJ;}(V$);var lJ=/*#__PURE__*/function(_V$24){_inherits(lJ,_V$24);var _super43=_createSuper(lJ);function lJ(t,e,n){var _this63;_classCallCheck(this,lJ);_this63=_super43.call(this,t),_this63.transform=e,_this63.secondary=n;return _this63;}_createClass(lJ,[{key:"clone",value:function clone(){return new lJ(null,DM(this.transform),this.secondary);}},{key:"dependentFields",value:function dependentFields(){return new Set([this.transform.lookup]);}},{key:"producedFields",value:function producedFields(){return new Set(this.transform.as?cM(this.transform.as):this.transform.from.fields);}},{key:"hash",value:function hash(){return "Lookup ".concat(IM({transform:this.transform,secondary:this.secondary}));}},{key:"assemble",value:function assemble(){var t;if(this.transform.from.fields)t=Object.assign({values:this.transform.from.fields},this.transform.as?{as:cM(this.transform.as)}:{});else {var _e254=this.transform.as;mM(_e254)||(mz(y.NO_FIELDS_NEEDS_AS),_e254="_lookup"),t={as:[_e254]};}return Object.assign(Object.assign({type:"lookup",from:this.secondary,key:this.transform.from.key,fields:[this.transform.lookup]},t),this.transform.default?{default:this.transform.default}:{});}}],[{key:"make",value:function make(t,e,n,r){var i=e.component.data.sources,_n194=n,o=_n194.from;var a=null;if(function(t){return "data"in t;}(o)){var _t248=OJ(o.data,i);_t248||(_t248=new LX(o.data),i.push(_t248));var _n195=e.getName("lookup_".concat(r));a=new q$(_t248,_n195,"lookup",e.component.data.outputNodeRefCounts),e.component.data.outputNodes[_n195]=a;}else if(function(t){return "selection"in t;}(o)){var _t249=o.selection;if(n=Object.assign({as:_t249},n),!(a=e.getSelectionComponent(KM(_t249),_t249).materialized))throw new Error(y.noSameUnitLookup(_t249));}return new lJ(t,n,a.getSource());}}]);return lJ;}(V$);var fJ=/*#__PURE__*/function(_V$25){_inherits(fJ,_V$25);var _super44=_createSuper(fJ);function fJ(t,e){var _this64;_classCallCheck(this,fJ);var n,r,i;_this64=_super44.call(this,t),_this64.transform=e,_this64.transform=DM(e);var o=null!==(n=_this64.transform.as)&&void 0!==n?n:[void 0,void 0];_this64.transform.as=[null!==(r=o[0])&&void 0!==r?r:"prob",null!==(i=o[1])&&void 0!==i?i:"value"];return _this64;}_createClass(fJ,[{key:"clone",value:function clone(){return new fJ(null,DM(this.transform));}},{key:"dependentFields",value:function dependentFields(){var t;return new Set([this.transform.quantile].concat(_toConsumableArray(null!==(t=this.transform.groupby)&&void 0!==t?t:[])));}},{key:"producedFields",value:function producedFields(){return new Set(this.transform.as);}},{key:"hash",value:function hash(){return "QuantileTransform ".concat(IM(this.transform));}},{key:"assemble",value:function assemble(){var t=this.transform,e=t.quantile,n=yM(t,["quantile"]);return Object.assign({type:"quantile",field:e},n);}}]);return fJ;}(V$);var hJ=/*#__PURE__*/function(_V$26){_inherits(hJ,_V$26);var _super45=_createSuper(hJ);function hJ(t,e){var _this65;_classCallCheck(this,hJ);var n,r,i;_this65=_super45.call(this,t),_this65.transform=e,_this65.transform=DM(e);var o=null!==(n=_this65.transform.as)&&void 0!==n?n:[void 0,void 0];_this65.transform.as=[null!==(r=o[0])&&void 0!==r?r:e.on,null!==(i=o[1])&&void 0!==i?i:e.regression];return _this65;}_createClass(hJ,[{key:"clone",value:function clone(){return new hJ(null,DM(this.transform));}},{key:"dependentFields",value:function dependentFields(){var t;return new Set([this.transform.regression,this.transform.on].concat(_toConsumableArray(null!==(t=this.transform.groupby)&&void 0!==t?t:[])));}},{key:"producedFields",value:function producedFields(){return new Set(this.transform.as);}},{key:"hash",value:function hash(){return "RegressionTransform ".concat(IM(this.transform));}},{key:"assemble",value:function assemble(){var t=this.transform,e=t.regression,n=t.on,r=yM(t,["regression","on"]);return Object.assign({type:"regression",x:n,y:e},r);}}]);return hJ;}(V$);var dJ=/*#__PURE__*/function(_V$27){_inherits(dJ,_V$27);var _super46=_createSuper(dJ);function dJ(t,e){var _this66;_classCallCheck(this,dJ);_this66=_super46.call(this,t),_this66.transform=e;return _this66;}_createClass(dJ,[{key:"clone",value:function clone(){return new dJ(null,DM(this.transform));}},{key:"addDimensions",value:function addDimensions(t){var e;this.transform.groupby=LM((null!==(e=this.transform.groupby)&&void 0!==e?e:[]).concat(t),function(t){return t;});}},{key:"producedFields",value:function producedFields(){}},{key:"dependentFields",value:function dependentFields(){var t;return new Set([this.transform.pivot,this.transform.value].concat(_toConsumableArray(null!==(t=this.transform.groupby)&&void 0!==t?t:[])));}},{key:"hash",value:function hash(){return "PivotTransform ".concat(IM(this.transform));}},{key:"assemble",value:function assemble(){var _this$transform4=this.transform,t=_this$transform4.pivot,e=_this$transform4.value,n=_this$transform4.groupby,r=_this$transform4.limit,i=_this$transform4.op;return Object.assign(Object.assign(Object.assign({type:"pivot",field:t,value:e},void 0!==r?{limit:r}:{}),void 0!==i?{op:i}:{}),void 0!==n?{groupby:n}:{});}}]);return dJ;}(V$);var pJ=/*#__PURE__*/function(_V$28){_inherits(pJ,_V$28);var _super47=_createSuper(pJ);function pJ(t,e){var _this67;_classCallCheck(this,pJ);_this67=_super47.call(this,t),_this67.transform=e;return _this67;}_createClass(pJ,[{key:"clone",value:function clone(){return new pJ(null,DM(this.transform));}},{key:"dependentFields",value:function dependentFields(){return new Set();}},{key:"producedFields",value:function producedFields(){return new Set();}},{key:"hash",value:function hash(){return "SampleTransform ".concat(IM(this.transform));}},{key:"assemble",value:function assemble(){return {type:"sample",size:this.transform.sample};}}]);return pJ;}(V$);function mJ(t){var e=0;return function n(r,i){var _i$transform,_i$transform2,_i$transform3;var o;r instanceof LX&&!r.isGenerator&&!Wq(r.data)&&(t.push(i),i={name:null,source:i.name,transform:[]});if(r instanceof ZX&&(r.parent instanceof LX&&!i.source?(i.format=Object.assign(Object.assign({},null!==(o=i.format)&&void 0!==o?o:{}),{parse:r.assembleFormatParse()}),(_i$transform=i.transform).push.apply(_i$transform,_toConsumableArray(r.assembleTransforms(!0)))):(_i$transform2=i.transform).push.apply(_i$transform2,_toConsumableArray(r.assembleTransforms()))),r instanceof XX){i.name||(i.name="data_".concat(e++)),!i.source||i.transform.length>0?(t.push(i),r.data=i.name):r.data=i.source;var _iterator190=_createForOfIteratorHelper(r.assemble()),_step190;try{for(_iterator190.s();!(_step190=_iterator190.n()).done;){var _e255=_step190.value;t.push(_e255);}}catch(err){_iterator190.e(err);}finally{_iterator190.f();}}else switch((r instanceof UX||r instanceof WX||r instanceof rJ||r instanceof kK||r instanceof UK||r instanceof sJ||r instanceof aJ||r instanceof KX||r instanceof lJ||r instanceof rY||r instanceof eY||r instanceof oJ||r instanceof iJ||r instanceof nJ||r instanceof cJ||r instanceof fJ||r instanceof hJ||r instanceof tY||r instanceof pJ||r instanceof dJ)&&i.transform.push(r.assemble()),(r instanceof PX||r instanceof $$||r instanceof uJ||r instanceof nY)&&(_i$transform3=i.transform).push.apply(_i$transform3,_toConsumableArray(r.assemble())),r instanceof q$&&(i.source&&0===i.transform.length?r.setSource(i.source):r.parent instanceof q$?r.setSource(i.name):(i.name||(i.name="data_".concat(e++)),r.setSource(i.name),1===r.numChildren()&&(t.push(i),i={name:null,source:i.name,transform:[]}))),r.numChildren()){case 0:r instanceof q$&&(!i.source||i.transform.length>0)&&t.push(i);break;case 1:n(r.children[0],i);break;default:{i.name||(i.name="data_".concat(e++));var _o81=i.name;!i.source||i.transform.length>0?t.push(i):_o81=i.source;var _iterator191=_createForOfIteratorHelper(r.children),_step191;try{for(_iterator191.s();!(_step191=_iterator191.n()).done;){var _t250=_step191.value;n(_t250,{name:null,source:_o81,transform:[]});}}catch(err){_iterator191.e(err);}finally{_iterator191.f();}break;}}};}function gJ(t){return "top"===t||"left"===t||Nz(t)?"header":"footer";}function vJ(t,e){var n;var r=t.facet,i=t.config,o=t.child,a=t.component;if(t.channelHasField(e)){var _s57=r[e],_u30=qK("title",null,i,e);var _c24=TW(_s57,i,{allowDisabling:!0,includeDefault:void 0===_u30||!!_u30});o.component.layoutHeaders[e].title&&(_c24=rM(_c24)?_c24.join(", "):_c24,_c24+=" / "+o.component.layoutHeaders[e].title,o.component.layoutHeaders[e].title=null);var _l17=qK("labelOrient",_s57,i,e),_f17=ij((null!==(n=_s57.header)&&void 0!==n?n:{}).labels,i.header.labels,!0),_h11=MM(["bottom","right"],_l17)?"footer":"header";a.layoutHeaders[e]=_defineProperty({title:_c24,facetFieldDef:_s57},_h11,"facet"===e?[]:[yJ(t,e,_f17)]);}}function yJ(t,e,n){var r="row"===e?"height":"width";return {labels:n,sizeSignal:t.child.component.layoutSize.get(r)?t.child.getSizeSignalRef(r):void 0,axes:[]};}function bJ(t,e){var n;var r=t.child;if(r.component.axes[e]){var _t$component2=t.component,_i152=_t$component2.layoutHeaders,_o82=_t$component2.resolve;if(_o82.axis[e]=lX(_o82,e),"shared"===_o82.axis[e]){var _o83="x"===e?"column":"row",_a69=_i152[_o83];var _iterator192=_createForOfIteratorHelper(r.component.axes[e]),_step192;try{for(_iterator192.s();!(_step192=_iterator192.n()).done;){var _i153=_step192.value;var _e256=gJ(_i153.get("orient"));_a69[_e256]=null!==(n=_a69[_e256])&&void 0!==n?n:[yJ(t,_o83,!1)];var _r197=_K(_i153,"main",t.config,{header:!0});_r197&&_a69[_e256][0].axes.push(_r197),_i153.mainExtracted=!0;}}catch(err){_iterator192.e(err);}finally{_iterator192.f();}}}}function xJ(t){wJ(t);var e=1===t.layout.columns?"width":"childWidth",n=void 0===t.layout.columns?"height":"childHeight";kJ(t,e),kJ(t,n);}function wJ(t){var _iterator193=_createForOfIteratorHelper(t.children),_step193;try{for(_iterator193.s();!(_step193=_iterator193.n()).done;){var _e257=_step193.value;_e257.parseLayoutSize();}}catch(err){_iterator193.e(err);}finally{_iterator193.f();}}function kJ(t,e){var n=sX(e),r=kP(n),i=t.component.resolve,o=t.component.layoutSize;var a;var _iterator194=_createForOfIteratorHelper(t.children),_step194;try{for(_iterator194.s();!(_step194=_iterator194.n()).done;){var _e258=_step194.value;var _t251=_e258.component.layoutSize.getWithExplicit(n),_o84=i.scale[r];if("independent"===_o84&&"step"===_t251.value){a=void 0;break;}if(a){if("independent"===_o84&&a.value!==_t251.value){a=void 0;break;}a=zq(a,_t251,n,"");}else a=_t251;}}catch(err){_iterator194.e(err);}finally{_iterator194.f();}if(a){var _iterator195=_createForOfIteratorHelper(t.children),_step195;try{for(_iterator195.s();!(_step195=_iterator195.n()).done;){var _r198=_step195.value;t.renameSignal(_r198.getName(n),t.getName(e)),_r198.component.layoutSize.set(n,"merged",!1);}}catch(err){_iterator195.e(err);}finally{_iterator195.f();}o.setWithExplicit(e,a);}else o.setWithExplicit(e,{explicit:!1,value:void 0});}function EJ(t,e){var n="width"===e?"x":"y",r=t.config,i=t.getScaleComponent(n);if(i){var _t252=i.get("type"),_n196=i.get("range");if(mU(_t252)){var _t253=QV(r.view,e);return Iz(_n196)||GV(_t253)?"step":_t253;}return YV(r.view,e);}if(t.hasProjection||"arc"===t.mark)return YV(r.view,e);{var _t254=QV(r.view,e);return GV(_t254)?_t254.step:_t254;}}function CJ(t,e,n){return AW(e,Object.assign({suffix:"by_".concat(AW(t))},null!==n&&void 0!==n?n:{}));}var AJ=/*#__PURE__*/function(_eJ){_inherits(AJ,_eJ);var _super48=_createSuper(AJ);function AJ(t,e,n,r){var _this68;_classCallCheck(this,AJ);_this68=_super48.call(this,t,"facet",e,n,r,t.resolve),_this68.child=KJ(t.spec,_assertThisInitialized(_this68),_this68.getName("child"),void 0,r),_this68.children=[_this68.child],_this68.facet=_this68.initFacet(t.facet,r);return _this68;}_createClass(AJ,[{key:"initFacet",value:function initFacet(t,e){return rW(t)?fV(t,function(t,n,r){return MM([Jj,Qj],r)?void 0===n.field?(mz(y.emptyFieldDef(n,r)),t):(t[r]=BW(n,r,e),t):(mz(y.incompatibleChannel(r,"facet")),t);},{}):{facet:BW(t,"facet",e)};}},{key:"channelHasField",value:function channelHasField(t){return !!this.facet[t];}},{key:"fieldDef",value:function fieldDef(t){return this.facet[t];}},{key:"parseData",value:function parseData(){this.component.data=SJ(this),this.child.parseData();}},{key:"parseLayoutSize",value:function parseLayoutSize(){wJ(this);}},{key:"parseSelections",value:function parseSelections(){this.child.parseSelections(),this.component.selection=this.child.component.selection;}},{key:"parseMarkGroup",value:function parseMarkGroup(){this.child.parseMarkGroup();}},{key:"parseAxesAndHeaders",value:function parseAxesAndHeaders(){this.child.parseAxesAndHeaders(),function(t){var _iterator196=_createForOfIteratorHelper(PB),_step196;try{for(_iterator196.s();!(_step196=_iterator196.n()).done;){var _e259=_step196.value;vJ(t,_e259);}}catch(err){_iterator196.e(err);}finally{_iterator196.f();}bJ(t,"x"),bJ(t,"y");}(this);}},{key:"assembleSelectionTopLevelSignals",value:function assembleSelectionTopLevelSignals(t){return this.child.assembleSelectionTopLevelSignals(t);}},{key:"assembleSignals",value:function assembleSignals(){return this.child.assembleSignals(),[];}},{key:"assembleSelectionData",value:function assembleSelectionData(t){return this.child.assembleSelectionData(t);}},{key:"getHeaderLayoutMixins",value:function getHeaderLayoutMixins(){var t,e,n;var r={};var _iterator197=_createForOfIteratorHelper(PB),_step197;try{for(_iterator197.s();!(_step197=_iterator197.n()).done;){var _i154=_step197.value;var _iterator198=_createForOfIteratorHelper(GK),_step198;try{for(_iterator198.s();!(_step198=_iterator198.n()).done;){var _o85=_step198.value;var _a70=this.component.layoutHeaders[_i154],_s58=_a70[_o85],_u31=_a70.facetFieldDef;if(_u31){var _e260=qK("titleOrient",_u31,this.config,_i154);if(MM(["right","bottom"],_e260)){var _n197=VK(_i154,_e260);r.titleAnchor=null!==(t=r.titleAnchor)&&void 0!==t?t:{},r.titleAnchor[_n197]="end";}}if(null===_s58||void 0===_s58?void 0:_s58[0]){var _t255="row"===_i154?"height":"width",_s59="header"===_o85?"headerBand":"footerBand";"facet"===_i154||this.child.component.layoutSize.get(_t255)||(r[_s59]=null!==(e=r[_s59])&&void 0!==e?e:{},r[_s59][_i154]=.5),_a70.title&&(r.offset=null!==(n=r.offset)&&void 0!==n?n:{},r.offset["row"===_i154?"rowTitle":"columnTitle"]=10);}}}catch(err){_iterator198.e(err);}finally{_iterator198.f();}}}catch(err){_iterator197.e(err);}finally{_iterator197.f();}return r;}},{key:"assembleDefaultLayout",value:function assembleDefaultLayout(){var _this$facet=this.facet,t=_this$facet.column,e=_this$facet.row,n=t?this.columnDistinctSignal():e?1:void 0;var r="all";return (e||"independent"!==this.component.resolve.scale.x)&&(t||"independent"!==this.component.resolve.scale.y)||(r="none"),Object.assign(Object.assign(Object.assign({},this.getHeaderLayoutMixins()),n?{columns:n}:{}),{bounds:"full",align:r});}},{key:"assembleLayoutSignals",value:function assembleLayoutSignals(){return this.child.assembleLayoutSignals();}},{key:"columnDistinctSignal",value:function columnDistinctSignal(){if(!(this.parent&&this.parent instanceof AJ)){return {signal:"length(data('".concat(this.getName("column_domain"),"'))")};}}},{key:"assembleGroup",value:function assembleGroup(t){return this.parent&&this.parent instanceof AJ?Object.assign(Object.assign({},this.channelHasField("column")?{encode:{update:{columns:{field:AW(this.facet.column,{prefix:"distinct"})}}}}:{}),_get(_getPrototypeOf(AJ.prototype),"assembleGroup",this).call(this,t)):_get(_getPrototypeOf(AJ.prototype),"assembleGroup",this).call(this,t);}},{key:"getCardinalityAggregateForChild",value:function getCardinalityAggregateForChild(){var t=[],e=[],n=[];if(this.child instanceof AJ){if(this.child.channelHasField("column")){var _r199=AW(this.child.facet.column);t.push(_r199),e.push("distinct"),n.push("distinct_".concat(_r199));}}else {var _iterator199=_createForOfIteratorHelper(yP),_step199;try{for(_iterator199.s();!(_step199=_iterator199.n()).done;){var _r200=_step199.value;var _i155=this.child.component.scales[_r200];if(_i155&&!_i155.merged){var _o86=_i155.get("type"),_a71=_i155.get("range");if(mU(_o86)&&Iz(_a71)){var _i156=TY(NY(this.child,_r200));_i156?(t.push(_i156),e.push("distinct"),n.push("distinct_".concat(_i156))):mz("Unknown field for ".concat(_r200,". Cannot calculate view size."));}}}}catch(err){_iterator199.e(err);}finally{_iterator199.f();}}return {fields:t,ops:e,as:n};}},{key:"assembleFacet",value:function assembleFacet(){var _this$component$data$=this.component.data.facetRoot,t=_this$component$data$.name,e=_this$component$data$.data,_this$facet2=this.facet,n=_this$facet2.row,r=_this$facet2.column,_this$getCardinalityA=this.getCardinalityAggregateForChild(),i=_this$getCardinalityA.fields,o=_this$getCardinalityA.ops,a=_this$getCardinalityA.as,s=[];var _iterator200=_createForOfIteratorHelper(PB),_step200;try{for(_iterator200.s();!(_step200=_iterator200.n()).done;){var _t256=_step200.value;var _e261=this.facet[_t256];if(_e261){s.push(AW(_e261));var _u32=_e261.bin,_c25=_e261.sort;if(WP(_u32)&&s.push(AW(_e261,{binSuffix:"end"})),eW(_c25)){var _t257=_c25.field,_c25$op=_c25.op,_s60=_c25$op===void 0?JU:_c25$op,_u33=CJ(_e261,_c25);n&&r?(i.push(_u33),o.push("max"),a.push(_u33)):(i.push(_t257),o.push(_s60),a.push(_u33));}else if(rM(_c25)){var _n198=WK(_e261,_t256);i.push(_n198),o.push("max"),a.push(_n198);}}}}catch(err){_iterator200.e(err);}finally{_iterator200.f();}var u=!!n&&!!r;return Object.assign({name:t,data:e,groupby:s},u||i.length>0?{aggregate:Object.assign(Object.assign({},u?{cross:u}:{}),i.length?{fields:i,ops:o,as:a}:{})}:{});}},{key:"facetSortFields",value:function facetSortFields(t){var e=this.facet,n=e[t];return n?eW(n.sort)?[CJ(n,n.sort,{expr:"datum"})]:rM(n.sort)?[WK(n,t,{expr:"datum"})]:[AW(n,{expr:"datum"})]:[];}},{key:"facetSortOrder",value:function facetSortOrder(t){var e=this.facet,n=e[t];if(n){var _t258=n.sort;return [(eW(_t258)?_t258.order:!rM(_t258)&&_t258)||"ascending"];}return [];}},{key:"assembleLabelTitle",value:function assembleLabelTitle(){var t=this.facet,e=this.config;if(t.facet)return QK(t.facet,"facet",e);var n={row:["top","bottom"],column:["left","right"]};var _iterator201=_createForOfIteratorHelper(HK),_step201;try{for(_iterator201.s();!(_step201=_iterator201.n()).done;){var _r201=_step201.value;if(t[_r201]){var _i157=qK("labelOrient",t[_r201],e,_r201);if(MM(n[_r201],_i157))return QK(t[_r201],_r201,e);}}}catch(err){_iterator201.e(err);}finally{_iterator201.f();}}},{key:"assembleMarks",value:function assembleMarks(){var _this69=this;var t=this.child,e=function(t){var e=[],n=mJ(e);var _iterator202=_createForOfIteratorHelper(t.children),_step202;try{for(_iterator202.s();!(_step202=_iterator202.n()).done;){var _e262=_step202.value;n(_e262,{source:t.name,name:null,transform:[]});}}catch(err){_iterator202.e(err);}finally{_iterator202.f();}return e;}(this.component.data.facetRoot),n=t.assembleGroupEncodeEntry(!1),r=this.assembleLabelTitle()||t.assembleTitle(),i=t.assembleGroupStyle();return [Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({name:this.getName("cell"),type:"group"},r?{title:r}:{}),i?{style:i}:{}),{from:{facet:this.assembleFacet()},sort:{field:PB.map(function(t){return _this69.facetSortFields(t);}).flat(),order:PB.map(function(t){return _this69.facetSortOrder(t);}).flat()}}),e.length>0?{data:e}:{}),n?{encode:{update:n}}:{}),t.assembleGroup(function(t,e){if(t.component.selection&&qM(t.component.selection).length){var _n199=gM(t.getName("cell"));e.unshift({name:"facet",value:{},on:[{events:zR("mousemove","scope"),update:"isTuple(facet) ? facet : group(".concat(_n199,").datum")}]});}return cH(e);}(this,[])))];}},{key:"getMapping",value:function getMapping(){return this.facet;}}]);return AJ;}(eJ);function OJ(t,e){var n,r,i,o,a,s,u,c,l,f;var _iterator203=_createForOfIteratorHelper(e),_step203;try{for(_iterator203.s();!(_step203=_iterator203.n()).done;){var _h12=_step203.value;var _e263=_h12.data;if((!t.name||!_h12.hasName()||t.name===_h12.dataName)&&!((null===(n=t.format)||void 0===n?void 0:n.mesh)&&(null===(r=_e263.format)||void 0===r?void 0:r.feature)||((null===(i=t.format)||void 0===i?void 0:i.feature)||(null===(o=_e263.format)||void 0===o?void 0:o.feature))&&(null===(a=t.format)||void 0===a?void 0:a.feature)!==(null===(s=_e263.format)||void 0===s?void 0:s.feature)||((null===(u=t.format)||void 0===u?void 0:u.mesh)||(null===(c=_e263.format)||void 0===c?void 0:c.mesh))&&(null===(l=t.format)||void 0===l?void 0:l.mesh)!==(null===(f=_e263.format)||void 0===f?void 0:f.mesh)))if(Vq(t)&&Vq(_e263)){if(SM(t.values,_e263.values))return _h12;}else if(Wq(t)&&Wq(_e263)){if(t.url===_e263.url)return _h12;}else if(qq(t)&&t.name===_h12.dataName)return _h12;}}catch(err){_iterator203.e(err);}finally{_iterator203.f();}return null;}function _J(t,e){if(t.data||!t.parent){if(null===t.data){var _t259=new LX({values:[]});return e.push(_t259),_t259;}var _n200=OJ(t.data,e);if(_n200)return $q(t.data)||(_n200.data.format=function(t){for(var _len10=arguments.length,e=new Array(_len10>1?_len10-1:0),_key10=1;_key10<_len10;_key10++){e[_key10-1]=arguments[_key10];}for(var _i158=0,_e264=e;_i158<_e264.length;_i158++){var _n201=_e264[_i158];PM(t,null!==_n201&&void 0!==_n201?_n201:{});}return t;}({},t.data.format,_n200.data.format)),!_n200.hasName()&&t.data.name&&(_n200.dataName=t.data.name),_n200;{var _n202=new LX(t.data);return e.push(_n202),_n202;}}return t.parent.component.data.facetRoot?t.parent.component.data.facetRoot:t.parent.component.data.main;}function SJ(t){var e,n,r,i,o,a,s,u,c,l;var f=_J(t,t.component.data.sources);var _t$component$data=t.component.data,h=_t$component$data.outputNodes,d=_t$component$data.outputNodeRefCounts,p=t.parent?t.parent.component.data.ancestorParse.clone():new Uq(),m=t.data;$q(m)?(Hq(m)?f=new WX(f,m.sequence):Kq(m)&&(f=new UX(f,m.graticule)),p.parseNothing=!0):null===(null===(e=null===m||void 0===m?void 0:m.format)||void 0===e?void 0:e.parse)&&(p.parseNothing=!0),f=null!==(n=ZX.makeExplicit(f,t,p))&&void 0!==n?n:f,f=new tY(f);var g=t.parent&&ZY(t.parent);(YY(t)||JY(t))&&g&&(f=null!==(r=PX.makeFromEncoding(f,t))&&void 0!==r?r:f),t.transforms.length>0&&(f=function(t,e,n){var r,i;var o=0;var _iterator204=_createForOfIteratorHelper(e.transforms),_step204;try{for(_iterator204.s();!(_step204=_iterator204.n()).done;){var _a72=_step204.value;var _s61=void 0,_u34=void 0;if(u$(_a72))_s61=t=new UK(t,_a72),_u34="derived";else if(Jq(_a72)){var _i159=JX(_a72);_s61=t=null!==(r=ZX.makeWithAncestors(t,{},_i159,n))&&void 0!==r?r:t,t=new kK(t,e,_a72.filter);}else if(c$(_a72))_s61=t=PX.makeFromTransform(t,_a72,e),_u34="number";else if(f$(_a72))_u34="date",void 0===n.getWithExplicit(_a72.field).value&&(t=new ZX(t,_defineProperty({},_a72.field,_u34)),n.set(_a72.field,_u34,!1)),_s61=t=$$.makeFromTransform(t,_a72);else if(h$(_a72))_s61=t=KX.makeFromTransform(t,_a72),_u34="number",CH(e)&&(t=new tY(t));else if(Qq(_a72))_s61=t=lJ.make(t,e,_a72,o++),_u34="derived";else if(o$(_a72))_s61=t=new rY(t,_a72),_u34="number";else if(a$(_a72))_s61=t=new eY(t,_a72),_u34="number";else if(d$(_a72))_s61=t=nY.makeFromTransform(t,_a72),_u34="derived";else if(p$(_a72))_s61=t=new oJ(t,_a72),_u34="derived";else if(s$(_a72))_s61=t=new iJ(t,_a72),_u34="derived";else if(Zq(_a72))_s61=t=new dJ(t,_a72),_u34="derived";else if(i$(_a72))t=new pJ(t,_a72);else if(l$(_a72))_s61=t=uJ.makeFromTransform(t,_a72),_u34="derived";else if(t$(_a72))_s61=t=new nJ(t,_a72),_u34="derived";else if(e$(_a72))_s61=t=new fJ(t,_a72),_u34="derived";else if(n$(_a72))_s61=t=new hJ(t,_a72),_u34="derived";else {if(!r$(_a72)){mz(y.invalidTransformIgnored(_a72));continue;}_s61=t=new cJ(t,_a72),_u34="derived";}if(_s61&&void 0!==_u34){var _iterator205=_createForOfIteratorHelper(null!==(i=_s61.producedFields())&&void 0!==i?i:[]),_step205;try{for(_iterator205.s();!(_step205=_iterator205.n()).done;){var _t260=_step205.value;n.set(_t260,_u34,!1);}}catch(err){_iterator205.e(err);}finally{_iterator205.f();}}}}catch(err){_iterator204.e(err);}finally{_iterator204.f();}return t;}(f,t,p));var v=function(t){var e={};if(YY(t)&&t.component.selection){var _iterator206=_createForOfIteratorHelper(qM(t.component.selection)),_step206;try{for(_iterator206.s();!(_step206=_iterator206.n()).done;){var _n203=_step206.value;var _r202=t.component.selection[_n203];var _iterator207=_createForOfIteratorHelper(_r202.project.items),_step207;try{for(_iterator207.s();!(_step207=_iterator207.n()).done;){var _t261=_step207.value;!_t261.channel&&rj(_t261.field)>1&&(e[_t261.field]="flatten");}}catch(err){_iterator207.e(err);}finally{_iterator207.f();}}}catch(err){_iterator206.e(err);}finally{_iterator206.f();}}return e;}(t),b=QX(t);f=null!==(i=ZX.makeWithAncestors(f,{},Object.assign(Object.assign({},v),b),p))&&void 0!==i?i:f,YY(t)&&(f=aJ.parseAll(f,t),f=sJ.parseAll(f,t)),(YY(t)||JY(t))&&(g||(f=null!==(o=PX.makeFromEncoding(f,t))&&void 0!==o?o:f),f=null!==(a=$$.makeFromEncoding(f,t))&&void 0!==a?a:f,f=UK.parseAllForSortIndex(f,t));var x=t.getName(Yq),w=new q$(f,x,Yq,d);if(h[x]=w,f=w,YY(t)){var _e265=KX.makeFromEncoding(f,t);_e265&&(f=_e265,CH(t)&&(f=new tY(f))),f=null!==(s=uJ.makeFromEncoding(f,t))&&void 0!==s?s:f,f=null!==(u=nY.makeFromEncoding(f,t))&&void 0!==u?u:f;}YY(t)&&(f=null!==(c=rJ.make(f,t))&&void 0!==c?c:f);var k=t.getName(Xq),E=new q$(f,k,Xq,d);h[k]=E,f=E,YY(t)&&function(t,e){kH(t,function(n){var r=n.name,i=t.getName("lookup_".concat(r));t.component.data.outputNodes[i]=n.materialized=new q$(new kK(e,t,{selection:r}),i,"lookup",t.component.data.outputNodeRefCounts);});}(t,E);var C=null;if(JY(t)){var _e266=t.getName("facet");f=null!==(l=function(t,e){var n=e.row,r=e.column;if(n&&r){var _e267=null;for(var _i160=0,_arr12=[n,r];_i160<_arr12.length;_i160++){var _i161=_arr12[_i160];if(eW(_i161.sort)){var _i161$sort=_i161.sort,_n204=_i161$sort.field,_i161$sort$op=_i161$sort.op,_r203=_i161$sort$op===void 0?JU:_i161$sort$op;t=_e267=new eY(t,{joinaggregate:[{op:_r203,field:_n204,as:CJ(_i161,_i161.sort,{forAs:!0})}],groupby:[AW(_i161)]});}}return _e267;}return null;}(f,t.facet))&&void 0!==l?l:f,C=new XX(f,t,_e266,E.getSource()),h[_e266]=C;}return Object.assign(Object.assign({},t.component.data),{outputNodes:h,outputNodeRefCounts:d,raw:w,main:E,facetRoot:C,ancestorParse:p});}var DJ=/*#__PURE__*/function(_tJ2){_inherits(DJ,_tJ2);var _super49=_createSuper(DJ);function DJ(t,e,n,r){var _this70;_classCallCheck(this,DJ);var i,o,a,s;_this70=_super49.call(this,t,"concat",e,n,r,t.resolve),"shared"!==(null===(o=null===(i=t.resolve)||void 0===i?void 0:i.axis)||void 0===o?void 0:o.x)&&"shared"!==(null===(s=null===(a=t.resolve)||void 0===a?void 0:a.axis)||void 0===s?void 0:s.y)||mz(y.CONCAT_CANNOT_SHARE_AXIS),_this70.children=_this70.getChildren(t).map(function(t,e){return KJ(t,_assertThisInitialized(_this70),_this70.getName("concat_"+e),void 0,r);});return _this70;}_createClass(DJ,[{key:"parseData",value:function parseData(){this.component.data=SJ(this);var _iterator208=_createForOfIteratorHelper(this.children),_step208;try{for(_iterator208.s();!(_step208=_iterator208.n()).done;){var _t262=_step208.value;_t262.parseData();}}catch(err){_iterator208.e(err);}finally{_iterator208.f();}}},{key:"parseSelections",value:function parseSelections(){this.component.selection={};var _iterator209=_createForOfIteratorHelper(this.children),_step209;try{for(_iterator209.s();!(_step209=_iterator209.n()).done;){var _t263=_step209.value;_t263.parseSelections();var _iterator210=_createForOfIteratorHelper(qM(_t263.component.selection)),_step210;try{for(_iterator210.s();!(_step210=_iterator210.n()).done;){var _e268=_step210.value;this.component.selection[_e268]=_t263.component.selection[_e268];}}catch(err){_iterator210.e(err);}finally{_iterator210.f();}}}catch(err){_iterator209.e(err);}finally{_iterator209.f();}}},{key:"parseMarkGroup",value:function parseMarkGroup(){var _iterator211=_createForOfIteratorHelper(this.children),_step211;try{for(_iterator211.s();!(_step211=_iterator211.n()).done;){var _t264=_step211.value;_t264.parseMarkGroup();}}catch(err){_iterator211.e(err);}finally{_iterator211.f();}}},{key:"parseAxesAndHeaders",value:function parseAxesAndHeaders(){var _iterator212=_createForOfIteratorHelper(this.children),_step212;try{for(_iterator212.s();!(_step212=_iterator212.n()).done;){var _t265=_step212.value;_t265.parseAxesAndHeaders();}}catch(err){_iterator212.e(err);}finally{_iterator212.f();}}},{key:"getChildren",value:function getChildren(t){return $V(t)?t.vconcat:HV(t)?t.hconcat:t.concat;}},{key:"parseLayoutSize",value:function parseLayoutSize(){xJ(this);}},{key:"parseAxisGroup",value:function parseAxisGroup(){return null;}},{key:"assembleSelectionTopLevelSignals",value:function assembleSelectionTopLevelSignals(t){return this.children.reduce(function(t,e){return e.assembleSelectionTopLevelSignals(t);},t);}},{key:"assembleSignals",value:function assembleSignals(){return this.children.forEach(function(t){return t.assembleSignals();}),[];}},{key:"assembleLayoutSignals",value:function assembleLayoutSignals(){var t=rX(this);var _iterator213=_createForOfIteratorHelper(this.children),_step213;try{for(_iterator213.s();!(_step213=_iterator213.n()).done;){var _e269=_step213.value;t.push.apply(t,_toConsumableArray(_e269.assembleLayoutSignals()));}}catch(err){_iterator213.e(err);}finally{_iterator213.f();}return t;}},{key:"assembleSelectionData",value:function assembleSelectionData(t){return this.children.reduce(function(t,e){return e.assembleSelectionData(t);},t);}},{key:"assembleMarks",value:function assembleMarks(){return this.children.map(function(t){var e=t.assembleTitle(),n=t.assembleGroupStyle(),r=t.assembleGroupEncodeEntry(!1);return Object.assign(Object.assign(Object.assign(Object.assign({type:"group",name:t.getName("group")},e?{title:e}:{}),n?{style:n}:{}),r?{encode:{update:r}}:{}),t.assembleGroup());});}},{key:"assembleDefaultLayout",value:function assembleDefaultLayout(){var t=this.layout.columns;return Object.assign(Object.assign({},null!=t?{columns:t}:{}),{bounds:"full",align:"each"});}}]);return DJ;}(tJ);var FJ=Object.assign(Object.assign({disable:1,gridScale:1,scale:1},dj),{labelExpr:1,encode:1}),TJ=qM(FJ);var NJ=/*#__PURE__*/function(_Mq5){_inherits(NJ,_Mq5);var _super50=_createSuper(NJ);function NJ(){var _this71;var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!1;_classCallCheck(this,NJ);_this71=_super50.call(this),_this71.explicit=t,_this71.implicit=e,_this71.mainExtracted=n;return _this71;}_createClass(NJ,[{key:"clone",value:function clone(){return new NJ(DM(this.explicit),DM(this.implicit),this.mainExtracted);}},{key:"hasAxisPart",value:function hasAxisPart(t){return "axis"===t||("grid"===t||"title"===t?!!this.get(t):!function(t){return !1===t||null===t;}(this.get(t)));}},{key:"hasOrientSignalRef",value:function hasOrientSignalRef(){return Nz(this.explicit.orient);}}]);return NJ;}(Mq);function IJ(t){return yP.reduce(function(e,n){return t.component.scales[n]&&(e[n]=[function(t,e){var n,r,i;var o=e.axis(t);var a=new NJ(),s=jW(e.encoding[t]),u=e.mark,c=e.config,l=(null===o||void 0===o?void 0:o.orient)||(null===(n=c["x"===t?"axisX":"axisY"])||void 0===n?void 0:n.orient)||(null===(r=c.axis)||void 0===r?void 0:r.orient)||function(t){return "x"===t?"bottom":"left";}(t),f=e.getScaleComponent(t).get("type"),h=RK(t,f,l,e.config),d=void 0!==o?!o:MK("disable",c,null===o||void 0===o?void 0:o.style,h).configValue;if(a.set("disable",d,void 0!==o),d)return a;var p=function(t,e,n,r,i){var o=null===e||void 0===e?void 0:e.labelAngle;if(void 0!==o)return Nz(o)?o:sj(o);{var _MK=MK("labelAngle",t.config,null===e||void 0===e?void 0:e.style,i),_o87=_MK.configValue;return void 0!==_o87?sj(_o87):n===tB&&MM([tU,Qz],r.type)?270:void 0;}}(e,o=o||{},t,s,h),m={fieldOrDatumDef:s,axis:o,channel:t,model:e,scaleType:f,orient:l,labelAngle:p,mark:u,config:c};var _iterator214=_createForOfIteratorHelper(TJ),_step214;try{for(_iterator214.s();!(_step214=_iterator214.n()).done;){var _n205=_step214.value;var _r204=_n205 in jK?jK[_n205](m):mj(_n205)?o[_n205]:void 0,_i162=void 0!==_r204,_s62=BJ(_r204,_n205,o,e,t);if(_i162&&_s62)a.set(_n205,_r204,_s62);else {var _ref115=mj(_n205)&&"values"!==_n205?MK(_n205,e.config,o.style,h):{},_t266=_ref115.configValue,_u35=_ref115.configFrom,_c26=void 0!==_t266;_i162&&!_c26?a.set(_n205,_r204,_s62):("vgAxisConfig"!==_u35||PJ.has(_n205)&&_c26||lj(_t266)||Nz(_t266))&&a.set(_n205,_t266,!1);}}}catch(err){_iterator214.e(err);}finally{_iterator214.f();}var g=null!==(i=o.encoding)&&void 0!==i?i:{},v=fj.reduce(function(n,r){var i;if(!a.hasAxisPart(r))return n;var o=uX(null!==(i=g[r])&&void 0!==i?i:{},e),s="labels"===r?function(t,e,n){var r;var i=t.encoding,o=t.config,a=null!==(r=jW(i[e]))&&void 0!==r?r:jW(i[eP(e)]),s=t.axis(e)||{},u=s.format,c=s.formatType;return LU(c)?Object.assign({text:qU({fieldOrDatumDef:a,field:"datum.value",format:u,formatType:c,config:o})},n):n;}(e,t,o):o;return void 0===s||VM(s)||(n[r]={update:s}),n;},{});VM(v)||a.set("encode",v,!!o.encoding||void 0!==o.labelAngle);return a;}(n,t)]),e;},{});}var RJ={bottom:"top",top:"bottom",left:"right",right:"left"};function MJ(t,e){if(!t)return e.map(function(t){return t.clone();});{if(t.length!==e.length)return;var _n206=t.length;for(var _r205=0;_r205<_n206;_r205++){var _n207=t[_r205],_i163=e[_r205];if(!!_n207!=!!_i163)return;if(_n207&&_i163){var _e270=_n207.getWithExplicit("orient"),_o88=_i163.getWithExplicit("orient");if(_e270.explicit&&_o88.explicit&&_e270.value!==_o88.value)return;t[_r205]=jJ(_n207,_i163);}}}return t;}function jJ(t,e){var _iterator215=_createForOfIteratorHelper(TJ),_step215;try{var _loop8=function _loop8(){var n=_step215.value;var r=zq(t.getWithExplicit(n),e.getWithExplicit(n),n,"axis",function(t,e){switch(n){case"title":return oV(t,e);case"gridScale":return {explicit:t.explicit,value:ij(t.value,e.value)};}return Lq(t,e,n,"axis");});t.setWithExplicit(n,r);};for(_iterator215.s();!(_step215=_iterator215.n()).done;){_loop8();}}catch(err){_iterator215.e(err);}finally{_iterator215.f();}return t;}function BJ(t,e,n,r,i){if("disable"===e)return void 0!==n;switch(n=n||{},e){case"titleAngle":case"labelAngle":return t===(Nz(n.labelAngle)?n.labelAngle:sj(n.labelAngle));case"values":return !!n.values;case"encode":return !!n.encoding||!!n.labelAngle;case"title":if(t===zK(r,i))return !0;}return t===n[e];}var PJ=new Set(["grid","translate","format","formatType","orient","labelExpr","tickCount","position","tickMinStep"]);function LJ(t,e,n,_ref116){var r=_ref116.graticule;var i=Rj(t)?Object.assign({},t):{type:t},o=QW("orient",i,n);if(i.orient=function(t,e,n){switch(t){case kj:case Sj:case Dj:case Aj:case Ej:case xj:return;}var r=e.x,i=e.y,o=e.x2,a=e.y2;switch(t){case bj:if(dW(r)&&(VP(r.bin)||dW(i)&&i.aggregate&&!r.aggregate))return "vertical";if(dW(i)&&(VP(i.bin)||dW(r)&&r.aggregate&&!i.aggregate))return "horizontal";if(a||o){if(n)return n;if(!o&&(dW(r)&&r.type===Jz&&!WP(r.bin)||vW(r)))return "horizontal";if(!a&&(dW(i)&&i.type===Jz&&!WP(i.bin)||vW(i)))return "vertical";}case Cj:if(o&&(!dW(r)||!VP(r.bin))&&a&&(!dW(i)||!VP(i.bin)))return;case yj:if(a)return dW(i)&&VP(i.bin)?"horizontal":"vertical";if(o)return dW(r)&&VP(r.bin)?"vertical":"horizontal";if(t===Cj){if(r&&!i)return "vertical";if(i&&!r)return "horizontal";}case wj:case Oj:{var _e271=gW(r),_o89=gW(i);if(_e271&&!_o89)return "tick"!==t?"horizontal":"vertical";if(!_e271&&_o89)return "tick"!==t?"vertical":"horizontal";if(_e271&&_o89){var _e272=r,_o90=i,_a73=_e272.type===Zz,_s63=_o90.type===Zz;return _a73&&!_s63?"tick"!==t?"vertical":"horizontal":!_a73&&_s63?"tick"!==t?"horizontal":"vertical":!_e272.aggregate&&_o90.aggregate?"tick"!==t?"vertical":"horizontal":_e272.aggregate&&!_o90.aggregate?"tick"!==t?"horizontal":"vertical":n||"vertical";}return n||void 0;}}return "vertical";}(i.type,e,o),void 0!==o&&o!==i.orient&&mz(y.orientOverridden(i.orient,o)),"bar"===i.type&&i.orient){var _t267=QW("cornerRadiusEnd",i,n);if(void 0!==_t267){var _n208="horizontal"===i.orient&&e.x2||"vertical"===i.orient&&e.y2?["cornerRadius"]:Bj[i.orient];var _iterator216=_createForOfIteratorHelper(_n208),_step216;try{for(_iterator216.s();!(_step216=_iterator216.n()).done;){var _e273=_step216.value;i[_e273]=_t267;}}catch(err){_iterator216.e(err);}finally{_iterator216.f();}void 0!==i.cornerRadiusEnd&&delete i.cornerRadiusEnd;}}return void 0===QW("opacity",i,n)&&(i.opacity=function(t,e){if(MM([kj,Oj,Sj,Dj],t)&&!sV(e))return .7;return;}(i.type,e)),void 0===i.filled&&(i.filled=!r&&function(t,e){var n=ZW("filled",t,e),r=t.type;return ij(n,r!==kj&&r!==wj&&r!==Cj);}(i,n)),void 0===QW("cursor",i,n)&&(i.cursor=function(t,e,n){if(e.href||t.href||QW("href",t,n))return "pointer";return t.cursor;}(i,e,n)),i;}function zJ(t,e){t.config;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},P$(t,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore",theta:"ignore"})),O$("x",t,{defaultPos:"mid"})),O$("y",t,{defaultPos:"mid"})),E$("size",t)),E$("angle",t)),function(t,e,n){if(n)return {shape:{value:n}};return E$("shape",t);}(t,0,e));}var UJ={arc:{vgMark:"arc",encodeEntry:function encodeEntry(t){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},P$(t,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"})),O$("x",t,{defaultPos:"mid"})),O$("y",t,{defaultPos:"mid"})),R$(t,"radius","arc")),R$(t,"theta","arc"));}},area:{vgMark:"area",encodeEntry:function encodeEntry(t){return Object.assign(Object.assign(Object.assign(Object.assign({},P$(t,{align:"ignore",baseline:"ignore",color:"include",orient:"include",size:"ignore",theta:"ignore"})),T$("x",t,{defaultPos:"zeroOrMin",defaultPos2:"zeroOrMin",range:"horizontal"===t.markDef.orient})),T$("y",t,{defaultPos:"zeroOrMin",defaultPos2:"zeroOrMin",range:"vertical"===t.markDef.orient})),z$(t));}},bar:{vgMark:"rect",encodeEntry:function encodeEntry(t){return Object.assign(Object.assign(Object.assign({},P$(t,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"})),R$(t,"x","bar")),R$(t,"y","bar"));}},circle:{vgMark:"symbol",encodeEntry:function encodeEntry(t){return zJ(t,"circle");}},geoshape:{vgMark:"shape",encodeEntry:function encodeEntry(t){return Object.assign({},P$(t,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"}));},postEncodingTransform:function postEncodingTransform(t){var e=t.encoding,n=e.shape;return [Object.assign({type:"geoshape",projection:t.projectionName()},n&&dW(n)&&n.type===eU?{field:AW(n,{expr:"datum"})}:{})];}},image:{vgMark:"image",encodeEntry:function encodeEntry(t){return Object.assign(Object.assign(Object.assign(Object.assign({},P$(t,{align:"ignore",baseline:"ignore",color:"ignore",orient:"ignore",size:"ignore",theta:"ignore"})),R$(t,"x","image")),R$(t,"y","image")),v$(t,"url"));}},line:{vgMark:"line",encodeEntry:function encodeEntry(t){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},P$(t,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"})),O$("x",t,{defaultPos:"mid"})),O$("y",t,{defaultPos:"mid"})),E$("size",t,{vgChannel:"strokeWidth"})),z$(t));}},point:{vgMark:"symbol",encodeEntry:function encodeEntry(t){return zJ(t);}},rect:{vgMark:"rect",encodeEntry:function encodeEntry(t){return Object.assign(Object.assign(Object.assign({},P$(t,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"})),R$(t,"x","rect")),R$(t,"y","rect"));}},rule:{vgMark:"rule",encodeEntry:function encodeEntry(t){var e=t.markDef,n=e.orient;return t.encoding.x||t.encoding.y||t.encoding.latitude||t.encoding.longitude?Object.assign(Object.assign(Object.assign(Object.assign({},P$(t,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"})),T$("x",t,{defaultPos:"horizontal"===n?"zeroOrMax":"mid",defaultPos2:"zeroOrMin",range:"vertical"!==n})),T$("y",t,{defaultPos:"vertical"===n?"zeroOrMax":"mid",defaultPos2:"zeroOrMin",range:"horizontal"!==n})),E$("size",t,{vgChannel:"strokeWidth"})):{};}},square:{vgMark:"symbol",encodeEntry:function encodeEntry(t){return zJ(t,"square");}},text:{vgMark:"text",encodeEntry:function encodeEntry(t){var e=t.config;t.encoding;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},P$(t,{align:"include",baseline:"include",color:"include",size:"ignore",orient:"ignore",theta:"include"})),O$("x",t,{defaultPos:"mid"})),O$("y",t,{defaultPos:"mid"})),v$(t)),E$("size",t,{vgChannel:"fontSize"})),E$("angle",t)),U$("align",function(t,e,n){if(void 0===QW("align",t,n))return "center";return;}(t.markDef,0,e))),U$("baseline",function(t,e,n){if(void 0===QW("baseline",t,n))return "middle";return;}(t.markDef,0,e))),O$("radius",t,{defaultPos:null,isMidPoint:!0})),O$("theta",t,{defaultPos:null,isMidPoint:!0}));}},tick:{vgMark:"rect",encodeEntry:function encodeEntry(t){var e=t.config,n=t.markDef,r=n.orient,i="horizontal"===r?"width":"height",o="horizontal"===r?"height":"width";return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},P$(t,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"})),O$("x",t,{defaultPos:"mid",vgChannel:"xc"})),O$("y",t,{defaultPos:"mid",vgChannel:"yc"})),E$("size",t,{defaultValue:function(t){var e;var n=t.config,r=t.markDef,i=r.orient,o="horizontal"===i?"width":"height",a=t.getScaleComponent("horizontal"===i?"x":"y"),s=null!==(e=QW("size",r,n,{vgChannel:o}))&&void 0!==e?e:n.tick.bandSize;if(void 0!==s)return s;{var _t268=a?a.get("range"):void 0;if(_t268&&Iz(_t268)&&pM(_t268.step))return 3*_t268.step/4;var _e274=JV(n.view,o);return 3*_e274/4;}}(t),vgChannel:i})),_defineProperty({},o,KW(QW("thickness",n,e))));}},trail:{vgMark:"trail",encodeEntry:function encodeEntry(t){return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},P$(t,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore",theta:"ignore"})),O$("x",t,{defaultPos:"mid"})),O$("y",t,{defaultPos:"mid"})),E$("size",t)),z$(t));}}};function WJ(t){return MM([wj,yj,_j],t.mark)?function(t){var e=hV(t.mark,t.encoding),n=$J(t,{fromPrefix:e.length>0?VJ:""});return e.length>0?[{name:t.getName("pathgroup"),type:"group",from:{facet:{name:VJ+t.requestDataName(Xq),data:t.requestDataName(Xq),groupby:e}},encode:{update:{width:{field:{group:"width"}},height:{field:{group:"height"}}}},marks:n}]:n;}(t):MM([bj],t.mark)?function(t){var e=Bz.some(function(e){return QW(e,t.markDef,t.config);});if(t.stack&&!t.fieldDef("size")&&e){var _$J=$J(t,{fromPrefix:qJ}),_$J2=_slicedToArray(_$J,1),_e275=_$J2[0],_n209=t.scaleName(t.stack.fieldChannel),_r206=function _r206(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return t.vgField(t.stack.fieldChannel,e);},_i164=function _i164(t,e){var i=[_r206({prefix:"min",suffix:"start",expr:e}),_r206({prefix:"max",suffix:"start",expr:e}),_r206({prefix:"min",suffix:"end",expr:e}),_r206({prefix:"max",suffix:"end",expr:e})];return "".concat(t,"(").concat(i.map(function(t){return "scale('".concat(_n209,"',").concat(t,")");}).join(","),")");};var _o91,_a74;"x"===t.stack.fieldChannel?(_o91=Object.assign(Object.assign({},FM(_e275.encode.update,["y","yc","y2","height"].concat(Bz))),{x:{signal:_i164("min","datum")},x2:{signal:_i164("max","datum")},clip:{value:!0}}),_a74={x:{field:{group:"x"},mult:-1},height:{field:{group:"height"}}},_e275.encode.update=Object.assign(Object.assign({},TM(_e275.encode.update,["y","yc","y2"])),{height:{field:{group:"height"}}})):(_o91=Object.assign(Object.assign({},FM(_e275.encode.update,["x","xc","x2","width"])),{y:{signal:_i164("min","datum")},y2:{signal:_i164("max","datum")},clip:{value:!0}}),_a74={y:{field:{group:"y"},mult:-1},width:{field:{group:"width"}}},_e275.encode.update=Object.assign(Object.assign({},TM(_e275.encode.update,["x","xc","x2"])),{width:{field:{group:"width"}}}));var _iterator217=_createForOfIteratorHelper(Bz),_step217;try{for(_iterator217.s();!(_step217=_iterator217.n()).done;){var _n210=_step217.value;var _r207=ZW(_n210,t.markDef,t.config);_e275.encode.update[_n210]?(_o91[_n210]=_e275.encode.update[_n210],delete _e275.encode.update[_n210]):_r207&&(_o91[_n210]=KW(_r207)),_r207&&(_e275.encode.update[_n210]={value:0});}}catch(err){_iterator217.e(err);}finally{_iterator217.f();}var _s64=t.fieldDef(t.stack.groupbyChannel),_u36=AW(_s64)?[AW(_s64)]:[];((null===_s64||void 0===_s64?void 0:_s64.bin)||(null===_s64||void 0===_s64?void 0:_s64.timeUnit))&&_u36.push(AW(_s64,{binSuffix:"end"}));var _c27=["stroke","strokeWidth","strokeJoin","strokeCap","strokeDash","strokeDashOffset","strokeMiterLimit","strokeOpacity"];return (_o91=_c27.reduce(function(n,r){if(_e275.encode.update[r])return Object.assign(Object.assign({},n),_defineProperty({},r,_e275.encode.update[r]));{var _e276=ZW(r,t.markDef,t.config);return void 0!==_e276?Object.assign(Object.assign({},n),_defineProperty({},r,KW(_e276))):n;}},_o91)).stroke&&(_o91.strokeForeground={value:!0},_o91.strokeOffset={value:0}),[{type:"group",from:{facet:{data:t.requestDataName(Xq),name:qJ+t.requestDataName(Xq),groupby:_u36,aggregate:{fields:[_r206({suffix:"start"}),_r206({suffix:"start"}),_r206({suffix:"end"}),_r206({suffix:"end"})],ops:["min","max","min","max"]}}},encode:{update:_o91},marks:[{type:"group",encode:{update:_a74},marks:[_e275]}]}];}return $J(t);}(t):$J(t);}var VJ="faceted_path_";var qJ="stack_group_";function $J(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{fromPrefix:""};var n=t.mark,r=t.markDef,i=t.config,o=ij(r.clip,function(t){var e=t.getScaleComponent("x"),n=t.getScaleComponent("y");return !!(e&&e.get("selectionExtent")||n&&n.get("selectionExtent"))||void 0;}(t),function(t){var e=t.component.projection;return !(!e||e.isFit)||void 0;}(t)),a=JW(r),s=t.encoding.key,u=function(t){var e=t.encoding,n=t.stack,r=t.mark,i=t.markDef,o=t.config,a=e.order;if(!(!rM(a)&&xW(a)&&RM(a.value)||!a&&RM(QW("order",i,o)))){if((rM(a)||dW(a))&&!n)return nV(a,{expr:"datum"});if(Tj(r)){var _n211="horizontal"===i.orient?"y":"x",_r208=e[_n211];if(dW(_r208)){var _e277=_r208.sort;return rM(_e277)?{field:AW(_r208,{prefix:_n211,suffix:"sort_index",expr:"datum"})}:eW(_e277)?{field:AW({aggregate:sV(t.encoding)?_e277.op:void 0,field:_e277.field},{expr:"datum"})}:tW(_e277)?{field:AW(t.fieldDef(_e277.encoding),{expr:"datum"}),order:_e277.order}:null===_e277?void 0:{field:AW(_r208,{binSuffix:t.stack&&t.stack.impute?"mid":void 0,expr:"datum"})};}}}}(t),c=function(t){if(!t.component.selection)return null;var e=qM(t.component.selection).length;var n=e,r=t.parent;for(;r&&0===n;){n=qM(r.component.selection).length,r=r.parent;}return n?{interactive:e>0}:null;}(t),l=QW("aria",r,i),f=UJ[n].postEncodingTransform?UJ[n].postEncodingTransform(t):null;return [Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({name:t.getName("marks"),type:UJ[n].vgMark},o?{clip:!0}:{}),a?{style:a}:{}),s?{key:s.field}:{}),u?{sort:u}:{}),c||{}),!1===l?{aria:l}:{}),{from:{data:e.fromPrefix+t.requestDataName(Xq)},encode:{update:UJ[n].encodeEntry(t)}}),f?{transform:f}:{})];}var HJ=/*#__PURE__*/function(_eJ2){_inherits(HJ,_eJ2);var _super51=_createSuper(HJ);function HJ(t,e,n){var _this72;var r=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var i=arguments.length>4?arguments[4]:undefined;_classCallCheck(this,HJ);var o,a;_this72=_super51.call(this,t,"unit",e,n,i,void 0,KV(t)?t.view:void 0),_this72.specifiedScales={},_this72.specifiedAxes={},_this72.specifiedLegends={},_this72.specifiedProjection={},_this72.selection={},_this72.children=[];var s=Rj(t.mark)?t.mark.type:t.mark;_this72.markDef=LJ(t.mark,null!==(o=t.encoding)&&void 0!==o?o:{},i,{graticule:t.data&&Kq(t.data)});var u=_this72.encoding=cV(null!==(a=t.encoding)&&void 0!==a?a:{},_this72.markDef,i);_this72.size=function(_ref117){var t=_ref117.encoding,e=_ref117.size;var _iterator218=_createForOfIteratorHelper(yP),_step218;try{for(_iterator218.s();!(_step218=_iterator218.n()).done;){var _n212=_step218.value;var _r209=nP(_n212);GV(e[_r209])&&gW(t[_n212])&&(delete e[_r209],mz(y.stepDropped(_r209)));}}catch(err){_iterator218.e(err);}finally{_iterator218.f();}return e;}({encoding:u,size:KV(t)?Object.assign(Object.assign(Object.assign({},r),t.width?{width:t.width}:{}),t.height?{height:t.height}:{}):r}),_this72.stack=gq(s,u),_this72.specifiedScales=_this72.initScales(s,u),_this72.specifiedAxes=_this72.initAxes(u),_this72.specifiedLegends=_this72.initLegend(u),_this72.specifiedProjection=t.projection,_this72.selection=t.selection;return _this72;}_createClass(HJ,[{key:"hasProjection",get:function get(){var t=this.encoding,e=this.mark===Fj,n=t&&RB.some(function(e){return yW(t[e]);});return e||n;}},{key:"scaleDomain",value:function scaleDomain(t){var e=this.specifiedScales[t];return e?e.domain:void 0;}},{key:"axis",value:function axis(t){return this.specifiedAxes[t];}},{key:"legend",value:function legend(t){return this.specifiedLegends[t];}},{key:"initScales",value:function initScales(t,e){return RP.reduce(function(t,n){var r;var i=jW(e[n]);return i&&(t[n]=null!==(r=i.scale)&&void 0!==r?r:{}),t;},{});}},{key:"initAxes",value:function initAxes(t){return yP.reduce(function(e,n){var r=t[n];if(yW(r)||n===tB&&yW(t.x2)||n===eB&&yW(t.y2)){var _t269=yW(r)?r.axis:void 0;e[n]=_t269?Object.assign({},_t269):_t269;}return e;},{});}},{key:"initLegend",value:function initLegend(t){return NP.reduce(function(e,n){var r=jW(t[n]);if(r&&function(t){switch(t){case hB:case dB:case pB:case gB:case mB:case yB:case wB:case kB:return !0;case bB:case xB:case vB:return !1;}}(n)){var _t270=r.legend;e[n]=_t270?Object.assign({},_t270):_t270;}return e;},{});}},{key:"parseData",value:function parseData(){this.component.data=SJ(this);}},{key:"parseLayoutSize",value:function parseLayoutSize(){!function(t){var e=t.size,n=t.component;var _iterator219=_createForOfIteratorHelper(yP),_step219;try{for(_iterator219.s();!(_step219=_iterator219.n()).done;){var _r210=_step219.value;var _i165=nP(_r210);if(e[_i165]){var _t271=e[_i165];n.layoutSize.set(_i165,GV(_t271)?"step":_t271,!0);}else {var _e278=EJ(t,_i165);n.layoutSize.set(_i165,_e278,!1);}}}catch(err){_iterator219.e(err);}finally{_iterator219.f();}}(this);}},{key:"parseSelections",value:function parseSelections(){this.component.selection=function(t,e){var n;var r={},i=t.config.selection;var _iterator220=_createForOfIteratorHelper(qM(null!==e&&void 0!==e?e:{})),_step220;try{var _loop9=function _loop9(){var o=_step220.value;var a=DM(e[o]),s=i[a.type],u=s.fields,c=s.encodings,l=yM(s,["fields","encodings"]);for(var _t272 in l){"encodings"===_t272&&a.fields||"fields"===_t272&&a.encodings||("mark"===_t272&&(a[_t272]=Object.assign(Object.assign({},l[_t272]),a[_t272])),void 0!==a[_t272]&&!0!==a[_t272]||(a[_t272]=null!==(n=l[_t272])&&void 0!==n?n:a[_t272]));}var f=KM(o),h=r[f]=Object.assign(Object.assign({},a),{name:f,events:mM(a.on)?zR(a.on,"scope"):DM(a.on)});aH(h,function(n){n.has(h)&&n.parse&&n.parse(t,h,a,e[o]);});};for(_iterator220.s();!(_step220=_iterator220.n()).done;){_loop9();}}catch(err){_iterator220.e(err);}finally{_iterator220.f();}return r;}(this,this.selection);}},{key:"parseMarkGroup",value:function parseMarkGroup(){this.component.mark=WJ(this);}},{key:"parseAxesAndHeaders",value:function parseAxesAndHeaders(){this.component.axes=IJ(this);}},{key:"assembleSelectionTopLevelSignals",value:function assembleSelectionTopLevelSignals(t){return function(t,e){var n=!1;kH(t,function(r,i){var o=r.name,a=gM(o+vH);if(0===e.filter(function(t){return t.name===o;}).length){var _t273="global"===r.resolve?"union":r.resolve,_n213="multi"===r.type?", true)":")";e.push({name:r.name,update:"".concat(xH,"(").concat(a,", ").concat(gM(_t273)).concat(_n213)});}n=!0,i.topLevelSignals&&(e=i.topLevelSignals(t,r,e)),aH(r,function(n){n.topLevelSignals&&(e=n.topLevelSignals(t,r,e));});}),n&&0===e.filter(function(t){return "unit"===t.name;}).length&&e.unshift({name:"unit",value:{},on:[{events:"mousemove",update:"isTuple(group()) ? group() : unit"}]});return cH(e);}(this,t);}},{key:"assembleSignals",value:function assembleSignals(){return [].concat(_toConsumableArray(SK(this)),_toConsumableArray(function(t,e){return kH(t,function(n,r){var _e279;var i=n.name;var o=r.modifyExpr(t,n);(_e279=e).push.apply(_e279,_toConsumableArray(r.signals(t,n))),aH(n,function(r){r.signals&&(e=r.signals(t,n,e)),r.modifyExpr&&(o=r.modifyExpr(t,n,o));}),e.push({name:i+bH,on:[{events:{signal:n.name+yH},update:"modify(".concat(gM(n.name+vH),", ").concat(o,")")}]});}),cH(e);}(this,[])));}},{key:"assembleSelectionData",value:function assembleSelectionData(t){return function(t,e){var n=_toConsumableArray(e);return kH(t,function(e){var r={name:e.name+vH};if(e.init){var _n214=e.project.items.map(function(t){var e=t.signals;return yM(t,["signals"]);}),_i166=e.init.map(function(t){return sH(t,!1);});r.values="interval"===e.type?[{unit:EH(t,{escape:!1}),fields:_n214,values:_i166}]:_i166.map(function(e){return {unit:EH(t,{escape:!1}),fields:_n214,values:e};});}n.filter(function(t){return t.name===e.name+vH;}).length||n.push(r);}),n;}(this,t);}},{key:"assembleLayout",value:function assembleLayout(){return null;}},{key:"assembleLayoutSignals",value:function assembleLayoutSignals(){return rX(this);}},{key:"assembleMarks",value:function assembleMarks(){var t;var e=null!==(t=this.component.mark)&&void 0!==t?t:[];return this.parent&&ZY(this.parent)||(e=uH(this,e)),e.map(this.correctDataNames);}},{key:"getMapping",value:function getMapping(){return this.encoding;}},{key:"mark",get:function get(){return this.markDef.type;}},{key:"channelHasField",value:function channelHasField(t){return aV(this.encoding,t);}},{key:"fieldDef",value:function fieldDef(t){return MW(this.encoding[t]);}},{key:"typedFieldDef",value:function typedFieldDef(t){var e=this.fieldDef(t);return bW(e)?e:null;}}]);return HJ;}(eJ);var GJ=/*#__PURE__*/function(_tJ3){_inherits(GJ,_tJ3);var _super52=_createSuper(GJ);function GJ(t,e,n,r,i){var _this73;_classCallCheck(this,GJ);_this73=_super52.call(this,t,"layer",e,n,i,t.resolve,t.view);var o=Object.assign(Object.assign(Object.assign({},r),t.width?{width:t.width}:{}),t.height?{height:t.height}:{});_this73.children=t.layer.map(function(t,e){if(lq(t))return new GJ(t,_assertThisInitialized(_this73),_this73.getName("layer_"+e),o,i);if(zj(t))return new HJ(t,_assertThisInitialized(_this73),_this73.getName("layer_"+e),o,i);throw new Error(y.invalidSpec(t));});return _this73;}_createClass(GJ,[{key:"parseData",value:function parseData(){this.component.data=SJ(this);var _iterator221=_createForOfIteratorHelper(this.children),_step221;try{for(_iterator221.s();!(_step221=_iterator221.n()).done;){var _t274=_step221.value;_t274.parseData();}}catch(err){_iterator221.e(err);}finally{_iterator221.f();}}},{key:"parseLayoutSize",value:function parseLayoutSize(){!function(t){wJ(t),kJ(t,"width"),kJ(t,"height");}(this);}},{key:"parseSelections",value:function parseSelections(){this.component.selection={};var _iterator222=_createForOfIteratorHelper(this.children),_step222;try{for(_iterator222.s();!(_step222=_iterator222.n()).done;){var _t275=_step222.value;_t275.parseSelections();var _iterator223=_createForOfIteratorHelper(qM(_t275.component.selection)),_step223;try{for(_iterator223.s();!(_step223=_iterator223.n()).done;){var _e280=_step223.value;this.component.selection[_e280]=_t275.component.selection[_e280];}}catch(err){_iterator223.e(err);}finally{_iterator223.f();}}}catch(err){_iterator222.e(err);}finally{_iterator222.f();}}},{key:"parseMarkGroup",value:function parseMarkGroup(){var _iterator224=_createForOfIteratorHelper(this.children),_step224;try{for(_iterator224.s();!(_step224=_iterator224.n()).done;){var _t276=_step224.value;_t276.parseMarkGroup();}}catch(err){_iterator224.e(err);}finally{_iterator224.f();}}},{key:"parseAxesAndHeaders",value:function parseAxesAndHeaders(){!function(t){var e;var _t$component3=t.component,n=_t$component3.axes,r=_t$component3.resolve,i={top:0,bottom:0,right:0,left:0};var _iterator225=_createForOfIteratorHelper(t.children),_step225;try{for(_iterator225.s();!(_step225=_iterator225.n()).done;){var _e281=_step225.value;_e281.parseAxesAndHeaders();var _iterator227=_createForOfIteratorHelper(qM(_e281.component.axes)),_step227;try{for(_iterator227.s();!(_step227=_iterator227.n()).done;){var _i167=_step227.value;r.axis[_i167]=lX(t.component.resolve,_i167),"shared"===r.axis[_i167]&&(n[_i167]=MJ(n[_i167],_e281.component.axes[_i167]),n[_i167]||(r.axis[_i167]="independent",delete n[_i167]));}}catch(err){_iterator227.e(err);}finally{_iterator227.f();}}}catch(err){_iterator225.e(err);}finally{_iterator225.f();}var _iterator226=_createForOfIteratorHelper(yP),_step226;try{for(_iterator226.s();!(_step226=_iterator226.n()).done;){var _o92=_step226.value;var _iterator228=_createForOfIteratorHelper(t.children),_step228;try{for(_iterator228.s();!(_step228=_iterator228.n()).done;){var _a75=_step228.value;if(_a75.component.axes[_o92]){if("independent"===r.axis[_o92]){n[_o92]=(null!==(e=n[_o92])&&void 0!==e?e:[]).concat(_a75.component.axes[_o92]);var _iterator230=_createForOfIteratorHelper(_a75.component.axes[_o92]),_step230;try{for(_iterator230.s();!(_step230=_iterator230.n()).done;){var _t278=_step230.value;var _t278$getWithExplicit=_t278.getWithExplicit("orient"),_e282=_t278$getWithExplicit.value,_n215=_t278$getWithExplicit.explicit;if(!Nz(_e282)){if(i[_e282]>0&&!_n215){var _n216=RJ[_e282];i[_e282]>i[_n216]&&_t278.set("orient",_n216,!1);}i[_e282]++;}}}catch(err){_iterator230.e(err);}finally{_iterator230.f();}}delete _a75.component.axes[_o92];}}}catch(err){_iterator228.e(err);}finally{_iterator228.f();}if("independent"===r.axis[_o92]&&n[_o92]&&n[_o92].length>1){var _iterator229=_createForOfIteratorHelper(n[_o92]),_step229;try{for(_iterator229.s();!(_step229=_iterator229.n()).done;){var _t277=_step229.value;_t277.get("grid")&&!_t277.explicit.grid&&(_t277.implicit.grid=!1);}}catch(err){_iterator229.e(err);}finally{_iterator229.f();}}}}catch(err){_iterator226.e(err);}finally{_iterator226.f();}}(this);}},{key:"assembleSelectionTopLevelSignals",value:function assembleSelectionTopLevelSignals(t){return this.children.reduce(function(t,e){return e.assembleSelectionTopLevelSignals(t);},t);}},{key:"assembleSignals",value:function assembleSignals(){return this.children.reduce(function(t,e){return t.concat(e.assembleSignals());},SK(this));}},{key:"assembleLayoutSignals",value:function assembleLayoutSignals(){return this.children.reduce(function(t,e){return t.concat(e.assembleLayoutSignals());},rX(this));}},{key:"assembleSelectionData",value:function assembleSelectionData(t){return this.children.reduce(function(t,e){return e.assembleSelectionData(t);},t);}},{key:"assembleTitle",value:function assembleTitle(){var t=_get(_getPrototypeOf(GJ.prototype),"assembleTitle",this).call(this);if(t)return t;var _iterator231=_createForOfIteratorHelper(this.children),_step231;try{for(_iterator231.s();!(_step231=_iterator231.n()).done;){var _e283=_step231.value;if(t=_e283.assembleTitle())return t;}}catch(err){_iterator231.e(err);}finally{_iterator231.f();}}},{key:"assembleLayout",value:function assembleLayout(){return null;}},{key:"assembleMarks",value:function assembleMarks(){return function(t,e){var _iterator232=_createForOfIteratorHelper(t.children),_step232;try{for(_iterator232.s();!(_step232=_iterator232.n()).done;){var _n217=_step232.value;YY(_n217)&&(e=uH(_n217,e));}}catch(err){_iterator232.e(err);}finally{_iterator232.f();}return e;}(this,this.children.flatMap(function(t){return t.assembleMarks();}));}},{key:"assembleLegends",value:function assembleLegends(){return this.children.reduce(function(t,e){return t.concat(e.assembleLegends());},DX(this));}}]);return GJ;}(tJ);function KJ(t,e,n,r,i){if(oW(t))return new AJ(t,e,n,i);if(lq(t))return new GJ(t,e,n,r,i);if(zj(t))return new HJ(t,e,n,r,i);if(function(t){return $V(t)||HV(t)||qV(t);}(t))return new DJ(t,e,n,i);throw new Error(y.invalidSpec(t));}function XJ(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};e.logger&&function(t){dz=t;}(e.logger),e.fieldTitle&&FW(e.fieldTitle);try{var _n218=iq(aM(e.config,t.config)),_r211=Fq(t,_n218),_i168=KJ(_r211,null,"",void 0,_n218);return _i168.parse(),function(t,e){zX(t.sources);var n=0,r=0;for(var _r212=0;_r212<vY&&wY(t,e);_r212++){n++;}t.sources.map(cY);for(var _n219=0;_n219<vY&&wY(t,e);_n219++){r++;}zX(t.sources),Math.max(n,r)===vY&&mz("Maximum optimization runs(".concat(vY,") reached."));}(_i168.component.data,_i168),{spec:function(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var r=arguments.length>3?arguments[3]:undefined;var i=t.config?uq(t.config):void 0,o=[].concat(t.assembleSelectionData([]),function(t,e){var n,r;var i=[],o=mJ(i);var a=0;var _iterator233=_createForOfIteratorHelper(t.sources),_step233;try{for(_iterator233.s();!(_step233=_iterator233.n()).done;){var _e285=_step233.value;_e285.hasName()||(_e285.dataName="source_".concat(a++)),o(_e285,_e285.assemble());}}catch(err){_iterator233.e(err);}finally{_iterator233.f();}for(var _i170=0,_i169=i;_i170<_i169.length;_i170++){var _t279=_i169[_i170];0===_t279.transform.length&&delete _t279.transform;}var s=0;var _iterator234=_createForOfIteratorHelper(i.entries()),_step234;try{for(_iterator234.s();!(_step234=_iterator234.n()).done;){var _step234$value=_slicedToArray(_step234.value,2),_t281=_step234$value[0],_e286=_step234$value[1];0!==(null!==(n=_e286.transform)&&void 0!==n?n:[]).length||_e286.source||i.splice(s++,0,i.splice(_t281,1)[0]);}}catch(err){_iterator234.e(err);}finally{_iterator234.f();}for(var _i172=0,_i171=i;_i172<_i171.length;_i172++){var _e284=_i171[_i172];var _iterator235=_createForOfIteratorHelper(null!==(r=_e284.transform)&&void 0!==r?r:[]),_step235;try{for(_iterator235.s();!(_step235=_iterator235.n()).done;){var _n220=_step235.value;"lookup"===_n220.type&&(_n220.from=t.outputNodes[_n220.from].getSource());}}catch(err){_iterator235.e(err);}finally{_iterator235.f();}}for(var _i174=0,_i173=i;_i174<_i173.length;_i174++){var _t280=_i173[_i174];_t280.name in e&&(_t280.values=e[_t280.name]);}return i;}(t.component.data,n)),a=t.assembleProjections(),s=t.assembleTitle(),u=t.assembleGroupStyle(),c=t.assembleGroupEncodeEntry(!0);var l=t.assembleLayoutSignals();return l=l.filter(function(t){return "width"!==t.name&&"height"!==t.name||void 0===t.value||(e[t.name]=+t.value,!1);}),Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({$schema:"https://vega.github.io/schema/vega/v5.json"},t.description?{description:t.description}:{}),e),s?{title:s}:{}),u?{style:u}:{}),c?{encode:{update:c}}:{}),{data:o}),a.length>0?{projections:a}:{}),t.assembleGroup([].concat(_toConsumableArray(l),_toConsumableArray(t.assembleSelectionTopLevelSignals([]))))),i?{config:i}:{}),r?{usermeta:r}:{});}(_i168,function(t,e,n,r){var i=r.component.layoutSize.get("width"),o=r.component.layoutSize.get("height");void 0===e?(e={type:"pad"},r.hasAxisOrientSignalRef()&&(e.resize=!0)):mM(e)&&(e={type:e});if(i&&o&&function(t){return "fit"===t||"fit-x"===t||"fit-y"===t;}(e.type))if("step"===i&&"step"===o)mz(y.droppingFit()),e.type="pad";else if("step"===i||"step"===o){var _t282="step"===i?"width":"height";mz(y.droppingFit(kP(_t282)));var _n221="width"===_t282?"height":"width";e.type=function(t){return t?"fit-".concat(kP(t)):"fit";}(_n221);}return Object.assign(Object.assign(Object.assign({},1===qM(e).length&&e.type?"pad"===e.type?{}:{autosize:e.type}:{autosize:e}),Rq(n)),Rq(t));}(t,_r211.autosize,_n218,_i168),t.datasets,t.usermeta),normalized:_r211};}finally{e.logger&&pz(),e.fieldTitle&&FW(SW);}}var YJ=new(/*#__PURE__*/function(_fq2){_inherits(_class3,_fq2);var _super53=_createSuper(_class3);function _class3(){_classCallCheck(this,_class3);return _super53.apply(this,arguments);}_createClass(_class3,[{key:"mapUnit",value:function mapUnit(t,_ref118){var e=_ref118.config;if(t.encoding){var _n222=t.encoding,_r213=t.transform,_uV3=uV(_n222,e),_i175=_uV3.bins,_o93=_uV3.timeUnits,_a76=_uV3.aggregate,_s65=_uV3.groupby,_u37=_uV3.encoding,_c28=[].concat(_toConsumableArray(_r213||[]),_toConsumableArray(_i175),_toConsumableArray(_o93),_toConsumableArray(0===_a76.length?[]:[{aggregate:_a76,groupby:_s65}]));return Object.assign(Object.assign(Object.assign({},t),_c28.length>0?{transform:_c28}:{}),{encoding:_u37});}return t;}}]);return _class3;}(fq))();function JJ(t,e){return YJ.map(t,{config:e});}var QJ=HR.version;var ZJ=function ZJ(t){var _$exec$slice=/schema\/([\w-]+)\/([\w\.\-]+)\.json$/g.exec(t).slice(1,3),_$exec$slice2=_slicedToArray(_$exec$slice,2),e=_$exec$slice2[0],n=_$exec$slice2[1];return {library:e,version:n};};var tQ={background:"#333",title:{color:"#fff",subtitleColor:"#fff"},style:{"guide-label":{fill:"#fff"},"guide-title":{fill:"#fff"}},axis:{domainColor:"#fff",gridColor:"#888",tickColor:"#fff"}},eQ={background:"#fff",arc:{fill:"#4572a7"},area:{fill:"#4572a7"},line:{stroke:"#4572a7",strokeWidth:2},path:{stroke:"#4572a7"},rect:{fill:"#4572a7"},shape:{stroke:"#4572a7"},symbol:{fill:"#4572a7",strokeWidth:1.5,size:50},axis:{bandPosition:.5,grid:!0,gridColor:"#000000",gridOpacity:1,gridWidth:.5,labelPadding:10,tickSize:5,tickWidth:.5},axisBand:{grid:!1,tickExtra:!0},legend:{labelBaseline:"middle",labelFontSize:11,symbolSize:50,symbolType:"square"},range:{category:["#4572a7","#aa4643","#8aa453","#71598e","#4598ae","#d98445","#94aace","#d09393","#b9cc98","#a99cbc"]}},nQ={arc:{fill:"#30a2da"},area:{fill:"#30a2da"},axis:{domainColor:"#cbcbcb",grid:!0,gridColor:"#cbcbcb",gridWidth:1,labelColor:"#999",labelFontSize:10,titleColor:"#333",tickColor:"#cbcbcb",tickSize:10,titleFontSize:14,titlePadding:10,labelPadding:4},axisBand:{grid:!1},background:"#f0f0f0",group:{fill:"#f0f0f0"},legend:{labelColor:"#333",labelFontSize:11,padding:1,symbolSize:30,symbolType:"square",titleColor:"#333",titleFontSize:14,titlePadding:10},line:{stroke:"#30a2da",strokeWidth:2},path:{stroke:"#30a2da",strokeWidth:.5},rect:{fill:"#30a2da"},range:{category:["#30a2da","#fc4f30","#e5ae38","#6d904f","#8b8b8b","#b96db8","#ff9e27","#56cc60","#52d2ca","#52689e","#545454","#9fe4f8"],diverging:["#cc0020","#e77866","#f6e7e1","#d6e8ed","#91bfd9","#1d78b5"],heatmap:["#d6e8ed","#cee0e5","#91bfd9","#549cc6","#1d78b5"]},point:{filled:!0,shape:"circle"},shape:{stroke:"#30a2da"},bar:{binSpacing:2,fill:"#30a2da",stroke:null},title:{anchor:"start",fontSize:24,fontWeight:600,offset:20}},rQ={group:{fill:"#e5e5e5"},arc:{fill:"#000"},area:{fill:"#000"},line:{stroke:"#000"},path:{stroke:"#000"},rect:{fill:"#000"},shape:{stroke:"#000"},symbol:{fill:"#000",size:40},axis:{domain:!1,grid:!0,gridColor:"#FFFFFF",gridOpacity:1,labelColor:"#7F7F7F",labelPadding:4,tickColor:"#7F7F7F",tickSize:5.67,titleFontSize:16,titleFontWeight:"normal"},legend:{labelBaseline:"middle",labelFontSize:11,symbolSize:40},range:{category:["#000000","#7F7F7F","#1A1A1A","#999999","#333333","#B0B0B0","#4D4D4D","#C9C9C9","#666666","#DCDCDC"]}},iQ="Benton Gothic Bold, sans-serif",oQ={"category-6":["#ec8431","#829eb1","#c89d29","#3580b1","#adc839","#ab7fb4"],"fire-7":["#fbf2c7","#f9e39c","#f8d36e","#f4bb6a","#e68a4f","#d15a40","#ab4232"],"fireandice-6":["#e68a4f","#f4bb6a","#f9e39c","#dadfe2","#a6b7c6","#849eae"],"ice-7":["#edefee","#dadfe2","#c4ccd2","#a6b7c6","#849eae","#607785","#47525d"]},aQ={background:"#ffffff",title:{anchor:"start",color:"#000000",font:iQ,fontSize:22,fontWeight:"normal"},arc:{fill:"#82c6df"},area:{fill:"#82c6df"},line:{stroke:"#82c6df",strokeWidth:2},path:{stroke:"#82c6df"},rect:{fill:"#82c6df"},shape:{stroke:"#82c6df"},symbol:{fill:"#82c6df",size:30},axis:{labelFont:"Benton Gothic, sans-serif",labelFontSize:11.5,labelFontWeight:"normal",titleFont:iQ,titleFontSize:13,titleFontWeight:"normal"},axisX:{labelAngle:0,labelPadding:4,tickSize:3},axisY:{labelBaseline:"middle",maxExtent:45,minExtent:45,tickSize:2,titleAlign:"left",titleAngle:0,titleX:-45,titleY:-11},legend:{labelFont:"Benton Gothic, sans-serif",labelFontSize:11.5,symbolType:"square",titleFont:iQ,titleFontSize:13,titleFontWeight:"normal"},range:{category:oQ["category-6"],diverging:oQ["fireandice-6"],heatmap:oQ["fire-7"],ordinal:oQ["fire-7"],ramp:oQ["fire-7"]}},sQ={background:"#f9f9f9",arc:{fill:"#ab5787"},area:{fill:"#ab5787"},line:{stroke:"#ab5787"},path:{stroke:"#ab5787"},rect:{fill:"#ab5787"},shape:{stroke:"#ab5787"},symbol:{fill:"#ab5787",size:30},axis:{domainColor:"#979797",domainWidth:.5,gridWidth:.2,labelColor:"#979797",tickColor:"#979797",tickWidth:.2,titleColor:"#979797"},axisBand:{grid:!1},axisX:{grid:!0,tickSize:10},axisY:{domain:!1,grid:!0,tickSize:0},legend:{labelFontSize:11,padding:1,symbolSize:30,symbolType:"square"},range:{category:["#ab5787","#51b2e5","#703c5c","#168dd9","#d190b6","#00609f","#d365ba","#154866","#666666","#c4c4c4"]}},uQ={background:"#fff",arc:{fill:"#3e5c69"},area:{fill:"#3e5c69"},line:{stroke:"#3e5c69"},path:{stroke:"#3e5c69"},rect:{fill:"#3e5c69"},shape:{stroke:"#3e5c69"},symbol:{fill:"#3e5c69"},axis:{domainWidth:.5,grid:!0,labelPadding:2,tickSize:5,tickWidth:.5,titleFontWeight:"normal"},axisBand:{grid:!1},axisX:{gridWidth:.2},axisY:{gridDash:[3],gridWidth:.4},legend:{labelFontSize:11,padding:1,symbolType:"square"},range:{category:["#3e5c69","#6793a6","#182429","#0570b0","#3690c0","#74a9cf","#a6bddb","#e2ddf2"]}},cQ={"main-colors":["#1696d2","#d2d2d2","#000000","#fdbf11","#ec008b","#55b748","#5c5859","#db2b27"],"shades-blue":["#CFE8F3","#A2D4EC","#73BFE2","#46ABDB","#1696D2","#12719E","#0A4C6A","#062635"],"shades-gray":["#F5F5F5","#ECECEC","#E3E3E3","#DCDBDB","#D2D2D2","#9D9D9D","#696969","#353535"],"shades-yellow":["#FFF2CF","#FCE39E","#FDD870","#FCCB41","#FDBF11","#E88E2D","#CA5800","#843215"],"shades-magenta":["#F5CBDF","#EB99C2","#E46AA7","#E54096","#EC008B","#AF1F6B","#761548","#351123"],"shades-green":["#DCEDD9","#BCDEB4","#98CF90","#78C26D","#55B748","#408941","#2C5C2D","#1A2E19"],"shades-black":["#D5D5D4","#ADABAC","#848081","#5C5859","#332D2F","#262223","#1A1717","#0E0C0D"],"shades-red":["#F8D5D4","#F1AAA9","#E9807D","#E25552","#DB2B27","#A4201D","#6E1614","#370B0A"],"one-group":["#1696d2","#000000"],"two-groups-cat-1":["#1696d2","#000000"],"two-groups-cat-2":["#1696d2","#fdbf11"],"two-groups-cat-3":["#1696d2","#db2b27"],"two-groups-seq":["#a2d4ec","#1696d2"],"three-groups-cat":["#1696d2","#fdbf11","#000000"],"three-groups-seq":["#a2d4ec","#1696d2","#0a4c6a"],"four-groups-cat-1":["#000000","#d2d2d2","#fdbf11","#1696d2"],"four-groups-cat-2":["#1696d2","#ec0008b","#fdbf11","#5c5859"],"four-groups-seq":["#cfe8f3","#73bf42","#1696d2","#0a4c6a"],"five-groups-cat-1":["#1696d2","#fdbf11","#d2d2d2","#ec008b","#000000"],"five-groups-cat-2":["#1696d2","#0a4c6a","#d2d2d2","#fdbf11","#332d2f"],"five-groups-seq":["#cfe8f3","#73bf42","#1696d2","#0a4c6a","#000000"],"six-groups-cat-1":["#1696d2","#ec008b","#fdbf11","#000000","#d2d2d2","#55b748"],"six-groups-cat-2":["#1696d2","#d2d2d2","#ec008b","#fdbf11","#332d2f","#0a4c6a"],"six-groups-seq":["#cfe8f3","#a2d4ec","#73bfe2","#46abdb","#1696d2","#12719e"],"diverging-colors":["#ca5800","#fdbf11","#fdd870","#fff2cf","#cfe8f3","#73bfe2","#1696d2","#0a4c6a"]},lQ={background:"#FFFFFF",title:{anchor:"start",fontSize:18,font:"Lato"},axisX:{domain:!0,domainColor:"#000000",domainWidth:1,grid:!1,labelFontSize:12,labelFont:"Lato",labelAngle:0,tickColor:"#000000",tickSize:5,titleFontSize:12,titlePadding:10,titleFont:"Lato"},axisY:{domain:!1,domainWidth:1,grid:!0,gridColor:"#DEDDDD",gridWidth:1,labelFontSize:12,labelFont:"Lato",labelPadding:8,ticks:!1,titleFontSize:12,titlePadding:10,titleFont:"Lato",titleAngle:0,titleY:-10,titleX:18},legend:{labelFontSize:12,labelFont:"Lato",symbolSize:100,titleFontSize:12,titlePadding:10,titleFont:"Lato",orient:"right",offset:10},view:{stroke:"transparent"},range:{category:cQ["six-groups-cat-1"],diverging:cQ["diverging-colors"],heatmap:cQ["diverging-colors"],ordinal:cQ["six-groups-seq"],ramp:cQ["shades-blue"]},area:{fill:"#1696d2"},rect:{fill:"#1696d2"},line:{color:"#1696d2",stroke:"#1696d2",strokeWidth:5},trail:{color:"#1696d2",stroke:"#1696d2",strokeWidth:0,size:1},path:{stroke:"#1696d2",strokeWidth:.5},point:{filled:!0},text:{font:"Lato",color:"#1696d2",fontSize:11,align:"center",fontWeight:400,size:11},style:{bar:{fill:"#1696d2",stroke:null}},arc:{fill:"#1696d2"},shape:{stroke:"#1696d2"},symbol:{fill:"#1696d2",size:30}},fQ={arc:{fill:"#3366CC"},area:{fill:"#3366CC"},path:{stroke:"#3366CC"},rect:{fill:"#3366CC"},shape:{stroke:"#3366CC"},symbol:{stroke:"#3366CC"},circle:{fill:"#3366CC"},background:"#fff",padding:{top:10,right:10,bottom:10,left:10},style:{"guide-label":{font:"Arial, sans-serif",fontSize:12},"guide-title":{font:"Arial, sans-serif",fontSize:12},"group-title":{font:"Arial, sans-serif",fontSize:12}},title:{font:"Arial, sans-serif",fontSize:14,fontWeight:"bold",dy:-3,anchor:"start"},axis:{gridColor:"#ccc",tickColor:"#ccc",domain:!1,grid:!0},range:{category:["#4285F4","#DB4437","#F4B400","#0F9D58","#AB47BC","#00ACC1","#FF7043","#9E9D24","#5C6BC0","#F06292","#00796B","#C2185B"],heatmap:["#c6dafc","#5e97f6","#2a56c6"]}},hQ="2.10.0";var dQ="#vg-tooltip-element {\n  visibility: hidden;\n  padding: 8px;\n  position: fixed;\n  z-index: 1000;\n  font-family: sans-serif;\n  font-size: 11px;\n  border-radius: 3px;\n  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);\n  /* The default theme is the light theme. */\n  background-color: rgba(255, 255, 255, 0.95);\n  border: 1px solid #d9d9d9;\n  color: black; }\n  #vg-tooltip-element.visible {\n    visibility: visible; }\n  #vg-tooltip-element h2 {\n    margin-top: 0;\n    margin-bottom: 10px;\n    font-size: 13px; }\n  #vg-tooltip-element img {\n    max-width: 200px;\n    max-height: 200px; }\n  #vg-tooltip-element table {\n    border-spacing: 0; }\n    #vg-tooltip-element table tr {\n      border: none; }\n      #vg-tooltip-element table tr td {\n        overflow: hidden;\n        text-overflow: ellipsis;\n        padding-top: 2px;\n        padding-bottom: 2px; }\n        #vg-tooltip-element table tr td.key {\n          color: #808080;\n          max-width: 150px;\n          text-align: right;\n          padding-right: 4px; }\n        #vg-tooltip-element table tr td.value {\n          display: block;\n          max-width: 300px;\n          max-height: 7em;\n          text-align: left; }\n  #vg-tooltip-element.dark-theme {\n    background-color: rgba(32, 32, 32, 0.9);\n    border: 1px solid #f5f5f5;\n    color: white; }\n    #vg-tooltip-element.dark-theme td.key {\n      color: #bfbfbf; }\n";var pQ="vg-tooltip-element",mQ={offsetX:10,offsetY:10,id:pQ,styleId:"vega-tooltip-style",theme:"light",disableDefaultStyle:!1,sanitize:function sanitize(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;");},maxDepth:2};function gQ(t,e,n){if(Object(Z.B)(t))return "[".concat(t.map(function(t){return e(Object(Z.J)(t)?t:vQ(t,n));}).join(", "),"]");if(Object(Z.H)(t)){var _r214="";var _i176=t,_o94=_i176.title,_a77=_i176.image,_s66=/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function(t,e){var n={};for(var r in t){Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);}if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++){e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);}}return n;}(_i176,["title","image"]);_o94&&(_r214+="<h2>".concat(e(_o94),"</h2>")),_a77&&(_r214+="<img src=\"".concat(e(_a77),"\">"));var _u38=Object.keys(_s66);if(_u38.length>0){_r214+="<table>";var _iterator236=_createForOfIteratorHelper(_u38),_step236;try{for(_iterator236.s();!(_step236=_iterator236.n()).done;){var _t283=_step236.value;var _i177=_s66[_t283];void 0!==_i177&&(Object(Z.H)(_i177)&&(_i177=vQ(_i177,n)),_r214+="<tr><td class=\"key\">".concat(e(_t283),":</td><td class=\"value\">").concat(e(_i177),"</td></tr>"));}}catch(err){_iterator236.e(err);}finally{_iterator236.f();}_r214+="</table>";}return _r214||"{}";}return e(t);}function vQ(t,e){return JSON.stringify(t,function(t){var e=[];return function(n,r){if("object"!=_typeof$1(r)||null===r)return r;var i=e.indexOf(this)+1;return e.length=i,e.length>t?"[Object]":e.indexOf(r)>=0?"[Circular]":(e.push(r),r);};}(e));}var yQ=/*#__PURE__*/function(){function yQ(t){_classCallCheck(this,yQ);this.options=Object.assign(Object.assign({},mQ),t);var e=this.options.id;if(this.el=null,this.call=this.tooltipHandler.bind(this),!this.options.disableDefaultStyle&&!document.getElementById(this.options.styleId)){var _t284=document.createElement("style");_t284.setAttribute("id",this.options.styleId),_t284.innerHTML=function(t){if(!/^[A-Za-z]+[-:.\w]*$/.test(t))throw new Error("Invalid HTML ID");return dQ.toString().replace(pQ,t);}(e);var _n223=document.head;_n223.childNodes.length>0?_n223.insertBefore(_t284,_n223.childNodes[0]):_n223.appendChild(_t284);}}_createClass(yQ,[{key:"tooltipHandler",value:function tooltipHandler(t,e,n,r){if(this.el=document.getElementById(this.options.id),this.el||(this.el=document.createElement("div"),this.el.setAttribute("id",this.options.id),this.el.classList.add("vg-tooltip"),document.body.appendChild(this.el)),(null!=document.fullscreenElement?document.fullscreenElement:document.body).appendChild(this.el),null==r||""===r)return void this.el.classList.remove("visible","".concat(this.options.theme,"-theme"));this.el.innerHTML=gQ(r,this.options.sanitize,this.options.maxDepth),this.el.classList.add("visible","".concat(this.options.theme,"-theme"));var _ref119=function(t,e,n,r){var i=t.clientX+n;i+e.width>window.innerWidth&&(i=+t.clientX-n-e.width);var o=t.clientY+r;return o+e.height>window.innerHeight&&(o=+t.clientY-r-e.height),{x:i,y:o};}(e,this.el.getBoundingClientRect(),this.options.offsetX,this.options.offsetY),i=_ref119.x,o=_ref119.y;this.el.setAttribute("style","top: ".concat(o,"px; left: ").concat(i,"px"));}}]);return yQ;}();/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function bQ(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):function(t){return t instanceof n?t:new n(function(e){e(t);});}(t.value).then(a,s);}u((r=r.apply(t,e||[])).next());});}n.d(e,"DEFAULT_ACTIONS",function(){return _Q;}),n.d(e,"guessMode",function(){return MQ;}),n.d(e,"vega",function(){return CQ;}),n.d(e,"vegaLite",function(){return AQ;});var xQ,wQ='.vega-embed {\n  position: relative;\n  display: inline-block;\n  box-sizing: border-box; }\n  .vega-embed.has-actions {\n    padding-right: 38px; }\n  .vega-embed details:not([open]) > :not(summary) {\n    display: none !important; }\n  .vega-embed summary {\n    list-style: none;\n    position: absolute;\n    top: 0;\n    right: 0;\n    padding: 6px;\n    z-index: 1000;\n    background: white;\n    box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);\n    color: #1b1e23;\n    border: 1px solid #aaa;\n    border-radius: 999px;\n    opacity: 0.2;\n    transition: opacity 0.4s ease-in;\n    outline: none;\n    cursor: pointer;\n    line-height: 0px; }\n    .vega-embed summary::-webkit-details-marker {\n      display: none; }\n    .vega-embed summary:active {\n      box-shadow: #aaa 0px 0px 0px 1px inset; }\n    .vega-embed summary svg {\n      width: 14px;\n      height: 14px; }\n  .vega-embed details[open] summary {\n    opacity: 0.7; }\n  .vega-embed:hover summary,\n  .vega-embed:focus summary {\n    opacity: 1 !important;\n    transition: opacity 0.2s ease; }\n  .vega-embed .vega-actions {\n    position: absolute;\n    z-index: 1001;\n    top: 35px;\n    right: -9px;\n    display: flex;\n    flex-direction: column;\n    padding-bottom: 8px;\n    padding-top: 8px;\n    border-radius: 4px;\n    box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.2);\n    border: 1px solid #d9d9d9;\n    background: white;\n    animation-duration: 0.15s;\n    animation-name: scale-in;\n    animation-timing-function: cubic-bezier(0.2, 0, 0.13, 1.5);\n    text-align: left; }\n    .vega-embed .vega-actions a {\n      padding: 8px 16px;\n      font-family: sans-serif;\n      font-size: 14px;\n      font-weight: 600;\n      white-space: nowrap;\n      color: #434a56;\n      text-decoration: none; }\n      .vega-embed .vega-actions a:hover {\n        background-color: #f7f7f9;\n        color: black; }\n    .vega-embed .vega-actions::before, .vega-embed .vega-actions::after {\n      content: "";\n      display: inline-block;\n      position: absolute; }\n    .vega-embed .vega-actions::before {\n      left: auto;\n      right: 14px;\n      top: -16px;\n      border: 8px solid #0000;\n      border-bottom-color: #d9d9d9; }\n    .vega-embed .vega-actions::after {\n      left: auto;\n      right: 15px;\n      top: -14px;\n      border: 7px solid #0000;\n      border-bottom-color: #fff; }\n  .vega-embed .chart-wrapper {\n    width: 100%;\n    height: 100%; }\n\n.vega-embed-wrapper {\n  max-width: 100%;\n  overflow: auto;\n  padding-right: 14px; }\n\n@keyframes scale-in {\n  from {\n    opacity: 0;\n    transform: scale(0.6); }\n  to {\n    opacity: 1;\n    transform: scale(1); } }\n';function kQ(t){for(var _len11=arguments.length,e=new Array(_len11>1?_len11-1:0),_key11=1;_key11<_len11;_key11++){e[_key11-1]=arguments[_key11];}for(var _i178=0,_e287=e;_i178<_e287.length;_i178++){var _n224=_e287[_i178];EQ(t,_n224);}return t;}function EQ(t,e){for(var _i179=0,_Object$keys=Object.keys(e);_i179<_Object$keys.length;_i179++){var _n225=_Object$keys[_i179];Object(Z.La)(t,_n225,e[_n225],!0);}}String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return this.substr(!e||e<0?0:+e,t.length)===t;});var CQ=v;var AQ=b;var OQ="undefined"!=typeof window?window:void 0;void 0===AQ&&(null===(xQ=null===OQ||void 0===OQ?void 0:OQ.vl)||void 0===xQ?void 0:xQ.compile)&&(AQ=OQ.vl);var _Q={export:{svg:!0,png:!0},source:!0,compiled:!0,editor:!0},SQ={CLICK_TO_VIEW_ACTIONS:"Click to view actions",COMPILED_ACTION:"View Compiled Vega",EDITOR_ACTION:"Open in Vega Editor",PNG_ACTION:"Save as PNG",SOURCE_ACTION:"View Source",SVG_ACTION:"Save as SVG"},DQ={vega:"Vega","vega-lite":"Vega-Lite"},FQ={vega:CQ.version,"vega-lite":AQ?AQ.version:"not available"},TQ={vega:function vega(t){return t;},"vega-lite":function vegaLite(t,e){return AQ.compile(t,{config:e}).spec;}},NQ='\n<svg viewBox="0 0 16 16" fill="currentColor" stroke="none" stroke-width="1" stroke-linecap="round" stroke-linejoin="round">\n  <circle r="2" cy="8" cx="2"></circle>\n  <circle r="2" cy="8" cx="8"></circle>\n  <circle r="2" cy="8" cx="14"></circle>\n</svg>',IQ="chart-wrapper";function RQ(t,e,n,r){var i="<html><head>".concat(e,"</head><body><pre><code class=\"json\">"),o="</code></pre>".concat(n,"</body></html>"),a=window.open("");a.document.write(i+t+o),a.document.title="".concat(DQ[r]," JSON Source");}function MQ(t,e){var n;if(t.$schema){var _r215=ZJ(t.$schema);e&&e!==_r215.library&&console.warn("The given visualization spec is written in ".concat(DQ[_r215.library],", but mode argument sets ").concat(null!==(n=DQ[e])&&void 0!==n?n:e,"."));var _i180=_r215.library;return Object(Q.satisfies)(FQ[_i180],"^".concat(_r215.version.slice(1)))||console.warn("The input spec uses ".concat(DQ[_i180]," ").concat(_r215.version,", but the current version of ").concat(DQ[_i180]," is v").concat(FQ[_i180],".")),_i180;}return "mark"in t||"encoding"in t||"layer"in t||"hconcat"in t||"vconcat"in t||"facet"in t||"repeat"in t?"vega-lite":"marks"in t||"signals"in t||"scales"in t||"axes"in t?"vega":null!==e&&void 0!==e?e:"vega";}function jQ(t){return function(t){return !!(t&&"load"in t);}(t)?t:CQ.loader(t);}function BQ(t){var e;return null!==(e=t.usermeta&&t.usermeta.embedOptions)&&void 0!==e?e:{};}function PQ(t,e){var n;return bQ(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee19(){var r,i;return regeneratorRuntime.wrap(function _callee19$(_context24){while(1){switch(_context24.prev=_context24.next){case 0:if(!Object(Z.J)(t.config)){_context24.next=8;break;}_context24.t1=JSON;_context24.next=4;return e.load(t.config);case 4:_context24.t2=_context24.sent;_context24.t0=_context24.t1.parse.call(_context24.t1,_context24.t2);_context24.next=9;break;case 8:_context24.t0=null!==(n=t.config)&&void 0!==n?n:{};case 9:r=_context24.t0;if(!Object(Z.J)(t.patch)){_context24.next=18;break;}_context24.t4=JSON;_context24.next=14;return e.load(t.patch);case 14:_context24.t5=_context24.sent;_context24.t3=_context24.t4.parse.call(_context24.t4,_context24.t5);_context24.next=19;break;case 18:_context24.t3=t.patch;case 19:i=_context24.t3;return _context24.abrupt("return",Object.assign(Object.assign(Object.assign({},t),i?{patch:i}:{}),r?{config:r}:{}));case 21:case"end":return _context24.stop();}}},_callee19);}));}e.default=function(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var r,i,o;return bQ(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee22(){var a,s,u,c,l,f;return regeneratorRuntime.wrap(function _callee22$(_context27){while(1){switch(_context27.prev=_context27.next){case 0:if(!Object(Z.J)(e)){_context27.next=9;break;}s=jQ(n.loader);_context27.t0=JSON;_context27.next=5;return s.load(e);case 5:_context27.t1=_context27.sent;a=_context27.t0.parse.call(_context27.t0,_context27.t1);_context27.next=10;break;case 9:a=e;case 10:u=BQ(a).loader;s&&!u||(s=jQ(null!==(r=n.loader)&&void 0!==r?r:u));_context27.next=14;return PQ(BQ(a),s);case 14:c=_context27.sent;_context27.next=17;return PQ(n,s);case 17:l=_context27.sent;f=Object.assign(Object.assign({},kQ(l,c)),{config:Object(Z.P)(null!==(i=l.config)&&void 0!==i?i:{},null!==(o=c.config)&&void 0!==o?o:{})});_context27.next=21;return function(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var r=arguments.length>3?arguments[3]:undefined;var i,o,a,s,u,c;return bQ(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee21(){var l,f,h,d,p,m,g,_t285,_ref120,_e288,_r216,_e289,v,y,_t286,b,_t287,w,k,E,C,_t288,A,O,_ref121,_t289,_e290,_t290,_e291,_n226,_r217,_loop10,_i181,_arr13,_t291,_t292,_t293,_i183;return regeneratorRuntime.wrap(function _callee21$(_context26){while(1){switch(_context26.prev=_context26.next){case 0:l=n.theme?Object(Z.P)(x[n.theme],null!==(i=n.config)&&void 0!==i?i:{}):n.config,f=Object(Z.C)(n.actions)?n.actions:kQ({},_Q,null!==(o=n.actions)&&void 0!==o?o:{}),h=Object.assign(Object.assign({},SQ),n.i18n),d=null!==(a=n.renderer)&&void 0!==a?a:"canvas",p=null!==(s=n.logLevel)&&void 0!==s?s:CQ.Warn,m=null!==(u=n.downloadFileName)&&void 0!==u?u:"visualization",g="string"==typeof t?document.querySelector(t):t;if(g){_context26.next=3;break;}throw new Error("".concat(t," does not exist"));case 3:if(!1!==n.defaultStyle){_t285="vega-embed-style",_ref120=function(t){var e;var n=t.getRootNode?t.getRootNode():document;return n instanceof ShadowRoot?{root:n,rootContainer:n}:{root:document,rootContainer:null!==(e=document.head)&&void 0!==e?e:document.body};}(g),_e288=_ref120.root,_r216=_ref120.rootContainer;if(!_e288.getElementById(_t285)){_e289=document.createElement("style");_e289.id=_t285,_e289.innerText=void 0===n.defaultStyle||!0===n.defaultStyle?wQ.toString():n.defaultStyle,_r216.appendChild(_e289);}}v=MQ(e,n.mode);y=TQ[v](e,l);if("vega-lite"===v&&y.$schema){_t286=ZJ(y.$schema);Object(Q.satisfies)(FQ.vega,"^".concat(_t286.version.slice(1)))||console.warn("The compiled spec uses Vega ".concat(_t286.version,", but current version is v").concat(FQ.vega,"."));}g.classList.add("vega-embed"),f&&g.classList.add("has-actions"),g.innerHTML="";b=g;if(f){_t287=document.createElement("div");_t287.classList.add(IQ),g.appendChild(_t287),b=_t287;}w=n.patch;w&&(y=w instanceof Function?w(y):B(y,w,!0,!1).newDocument),n.formatLocale&&CQ.formatLocale(n.formatLocale),n.timeFormatLocale&&CQ.timeFormatLocale(n.timeFormatLocale);k=n.ast,E=CQ.parse(y,"vega-lite"===v?{}:l,{ast:k}),C=new(n.viewClass||CQ.View)(E,Object.assign({loader:r,logLevel:p,renderer:d},k?{expr:CQ.expressionInterpreter}:{}));if(!1!==n.tooltip){_t288=function(t){return "function"==typeof t;}(n.tooltip)?n.tooltip:new yQ(!0===n.tooltip?{}:n.tooltip).call,C.tooltip(_t288);}O=n.hover;if(void 0===O&&(O="vega"===v),O){_ref121="boolean"==typeof O?{}:O,_t289=_ref121.hoverSet,_e290=_ref121.updateSet;C.hover(_t289,_e290);}n&&(null!=n.width&&C.width(n.width),null!=n.height&&C.height(n.height),null!=n.padding&&C.padding(n.padding));_context26.next=19;return C.initialize(b,n.bind).runAsync();case 19:if(!(!1!==f)){_context26.next=27;break;}_t290=g;if(!1!==n.defaultStyle){_e291=document.createElement("details");_e291.title=h.CLICK_TO_VIEW_ACTIONS,g.append(_e291),_t290=_e291;_n226=document.createElement("summary");_n226.innerHTML=NQ,_e291.append(_n226),A=function A(t){_e291.contains(t.target)||_e291.removeAttribute("open");},document.addEventListener("click",A);}_r217=document.createElement("div");if(_t290.append(_r217),_r217.classList.add("vega-actions"),!0===f||!1!==f.export){_loop10=function _loop10(){var t=_arr13[_i181];if(!0===f||!0===f.export||f.export[t]){var _e292=h["".concat(t.toUpperCase(),"_ACTION")],_i182=document.createElement("a");_i182.text=_e292,_i182.href="#",_i182.target="_blank",_i182.download="".concat(m,".").concat(t),_i182.addEventListener("mousedown",function(e){return bQ(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee20(){var r;return regeneratorRuntime.wrap(function _callee20$(_context25){while(1){switch(_context25.prev=_context25.next){case 0:e.preventDefault();_context25.next=3;return C.toImageURL(t,n.scaleFactor);case 3:r=_context25.sent;this.href=r;case 5:case"end":return _context25.stop();}}},_callee20,this);}));}),_r217.append(_i182);}};for(_i181=0,_arr13=["svg","png"];_i181<_arr13.length;_i181++){_loop10();}}if(!0===f||!1!==f.source){_t291=document.createElement("a");_t291.text=h.SOURCE_ACTION,_t291.href="#",_t291.addEventListener("click",function(t){var r,i;RQ(J()(e),null!==(r=n.sourceHeader)&&void 0!==r?r:"",null!==(i=n.sourceFooter)&&void 0!==i?i:"",v),t.preventDefault();}),_r217.append(_t291);}if("vega-lite"===v&&(!0===f||!1!==f.compiled)){_t292=document.createElement("a");_t292.text=h.COMPILED_ACTION,_t292.href="#",_t292.addEventListener("click",function(t){var e,r;RQ(J()(y),null!==(e=n.sourceHeader)&&void 0!==e?e:"",null!==(r=n.sourceFooter)&&void 0!==r?r:"","vega"),t.preventDefault();}),_r217.append(_t292);}if(!0===f||!1!==f.editor){_t293=null!==(c=n.editorUrl)&&void 0!==c?c:"https://vega.github.io/editor/",_i183=document.createElement("a");_i183.text=h.EDITOR_ACTION,_i183.href="#",_i183.addEventListener("click",function(n){!function(t,e,n){var r=t.open(e),i=250,_URL=new URL(e),o=_URL.origin;var a=~~(1e4/i);t.addEventListener("message",function e(n){n.source===r&&(a=0,t.removeEventListener("message",e,!1));},!1),setTimeout(function t(){a<=0||(r.postMessage(n,o),setTimeout(t,i),a-=1);},i);}(window,_t293,{config:l,mode:v,renderer:d,spec:J()(e)}),n.preventDefault();}),_r217.append(_i183);}case 27:return _context26.abrupt("return",{view:C,spec:e,vgSpec:y,finalize:function finalize(){A&&document.removeEventListener("click",A),C.finalize();}});case 28:case"end":return _context26.stop();}}},_callee21);}));}(t,a,f,s);case 21:return _context27.abrupt("return",_context27.sent);case 22:case"end":return _context27.stop();}}},_callee22);}));};},function(t,e,n){var _n227=n(117),r=_n227.MAX_LENGTH,_n228=n(90),i=_n228.re,o=_n228.t,a=n(32),s=n(115);t.exports=function(t,e){if(e=s(e),t instanceof a)return t;if("string"!=typeof t)return null;if(t.length>r)return null;if(!(e.loose?i[o.LOOSE]:i[o.FULL]).test(t))return null;try{return new a(t,e);}catch(t){return null;}};},function(t,e,n){var _n229=n(117),r=_n229.MAX_SAFE_COMPONENT_LENGTH,i=n(116),o=(e=t.exports={}).re=[],a=e.src=[],s=e.t={};var u=0;var c=function c(t,e,n){var r=u++;i(r,e),s[t]=r,a[r]=e,o[r]=new RegExp(e,n?"g":void 0);};c("NUMERICIDENTIFIER","0|[1-9]\\d*"),c("NUMERICIDENTIFIERLOOSE","[0-9]+"),c("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-][a-zA-Z0-9-]*"),c("MAINVERSION","(".concat(a[s.NUMERICIDENTIFIER],")\\.")+"(".concat(a[s.NUMERICIDENTIFIER],")\\.")+"(".concat(a[s.NUMERICIDENTIFIER],")")),c("MAINVERSIONLOOSE","(".concat(a[s.NUMERICIDENTIFIERLOOSE],")\\.")+"(".concat(a[s.NUMERICIDENTIFIERLOOSE],")\\.")+"(".concat(a[s.NUMERICIDENTIFIERLOOSE],")")),c("PRERELEASEIDENTIFIER","(?:".concat(a[s.NUMERICIDENTIFIER],"|").concat(a[s.NONNUMERICIDENTIFIER],")")),c("PRERELEASEIDENTIFIERLOOSE","(?:".concat(a[s.NUMERICIDENTIFIERLOOSE],"|").concat(a[s.NONNUMERICIDENTIFIER],")")),c("PRERELEASE","(?:-(".concat(a[s.PRERELEASEIDENTIFIER],"(?:\\.").concat(a[s.PRERELEASEIDENTIFIER],")*))")),c("PRERELEASELOOSE","(?:-?(".concat(a[s.PRERELEASEIDENTIFIERLOOSE],"(?:\\.").concat(a[s.PRERELEASEIDENTIFIERLOOSE],")*))")),c("BUILDIDENTIFIER","[0-9A-Za-z-]+"),c("BUILD","(?:\\+(".concat(a[s.BUILDIDENTIFIER],"(?:\\.").concat(a[s.BUILDIDENTIFIER],")*))")),c("FULLPLAIN","v?".concat(a[s.MAINVERSION]).concat(a[s.PRERELEASE],"?").concat(a[s.BUILD],"?")),c("FULL","^".concat(a[s.FULLPLAIN],"$")),c("LOOSEPLAIN","[v=\\s]*".concat(a[s.MAINVERSIONLOOSE]).concat(a[s.PRERELEASELOOSE],"?").concat(a[s.BUILD],"?")),c("LOOSE","^".concat(a[s.LOOSEPLAIN],"$")),c("GTLT","((?:<|>)?=?)"),c("XRANGEIDENTIFIERLOOSE","".concat(a[s.NUMERICIDENTIFIERLOOSE],"|x|X|\\*")),c("XRANGEIDENTIFIER","".concat(a[s.NUMERICIDENTIFIER],"|x|X|\\*")),c("XRANGEPLAIN","[v=\\s]*(".concat(a[s.XRANGEIDENTIFIER],")")+"(?:\\.(".concat(a[s.XRANGEIDENTIFIER],")")+"(?:\\.(".concat(a[s.XRANGEIDENTIFIER],")")+"(?:".concat(a[s.PRERELEASE],")?").concat(a[s.BUILD],"?")+")?)?"),c("XRANGEPLAINLOOSE","[v=\\s]*(".concat(a[s.XRANGEIDENTIFIERLOOSE],")")+"(?:\\.(".concat(a[s.XRANGEIDENTIFIERLOOSE],")")+"(?:\\.(".concat(a[s.XRANGEIDENTIFIERLOOSE],")")+"(?:".concat(a[s.PRERELEASELOOSE],")?").concat(a[s.BUILD],"?")+")?)?"),c("XRANGE","^".concat(a[s.GTLT],"\\s*").concat(a[s.XRANGEPLAIN],"$")),c("XRANGELOOSE","^".concat(a[s.GTLT],"\\s*").concat(a[s.XRANGEPLAINLOOSE],"$")),c("COERCE","(^|[^\\d])(\\d{1,".concat(r,"})")+"(?:\\.(\\d{1,".concat(r,"}))?")+"(?:\\.(\\d{1,".concat(r,"}))?")+"(?:$|[^\\d])"),c("COERCERTL",a[s.COERCE],!0),c("LONETILDE","(?:~>?)"),c("TILDETRIM","(\\s*)".concat(a[s.LONETILDE],"\\s+"),!0),e.tildeTrimReplace="$1~",c("TILDE","^".concat(a[s.LONETILDE]).concat(a[s.XRANGEPLAIN],"$")),c("TILDELOOSE","^".concat(a[s.LONETILDE]).concat(a[s.XRANGEPLAINLOOSE],"$")),c("LONECARET","(?:\\^)"),c("CARETTRIM","(\\s*)".concat(a[s.LONECARET],"\\s+"),!0),e.caretTrimReplace="$1^",c("CARET","^".concat(a[s.LONECARET]).concat(a[s.XRANGEPLAIN],"$")),c("CARETLOOSE","^".concat(a[s.LONECARET]).concat(a[s.XRANGEPLAINLOOSE],"$")),c("COMPARATORLOOSE","^".concat(a[s.GTLT],"\\s*(").concat(a[s.LOOSEPLAIN],")$|^$")),c("COMPARATOR","^".concat(a[s.GTLT],"\\s*(").concat(a[s.FULLPLAIN],")$|^$")),c("COMPARATORTRIM","(\\s*)".concat(a[s.GTLT],"\\s*(").concat(a[s.LOOSEPLAIN],"|").concat(a[s.XRANGEPLAIN],")"),!0),e.comparatorTrimReplace="$1$2$3",c("HYPHENRANGE","^\\s*(".concat(a[s.XRANGEPLAIN],")")+"\\s+-\\s+"+"(".concat(a[s.XRANGEPLAIN],")")+"\\s*$"),c("HYPHENRANGELOOSE","^\\s*(".concat(a[s.XRANGEPLAINLOOSE],")")+"\\s+-\\s+"+"(".concat(a[s.XRANGEPLAINLOOSE],")")+"\\s*$"),c("STAR","(<|>)?=?\\s*\\*"),c("GTE0","^\\s*>=\\s*0.0.0\\s*$"),c("GTE0PRE","^\\s*>=\\s*0.0.0-0\\s*$");},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(25),i=n(103),o=n(29),a=n(21),s=n(373),u=n(28);function c(t,e,n,o){if(null==o&&(o=a.inferDtype(t)),"complex64"===o)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if(!a.isTypedArray(t)&&!Array.isArray(t)&&"number"!=typeof t&&"boolean"!=typeof t&&"string"!=typeof t)throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(null!=e){a.assertNonNegativeIntegerDimensions(e);var s=a.sizeFromShape(e),u=a.sizeFromShape(n);a.assert(s===u,function(){return "Based on the provided shape, ["+e+"], the tensor should have "+s+" values but has "+u;});for(var c=0;c<n.length;++c){var l=n[c],f=c!==n.length-1||l!==a.sizeFromShape(e.slice(c));a.assert(n[c]===e[c]||!f,function(){return "Error creating a new Tensor. Inferred shape ("+n+") does not match the provided shape ("+e+"). ";});}}return a.isTypedArray(t)||Array.isArray(t)||(t=[t]),e=e||n,t="string"!==o?a.toTypedArray(t,o,i.env().getBool("DEBUG")):a.flatten(t,[],!0),r.ENGINE.makeTensor(t,e,o);}function l(t,e){a.assertNonNull(t);var n=o.inferShape(t,e);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return c(t,null,n,e);}function f(t,e){if(void 0===e&&(e="float32"),"complex64"===e){var n=f(t,"float32"),i=f(t,"float32");return s.complex(n,i);}var o=a.makeZerosTypedArray(a.sizeFromShape(t),e);return r.ENGINE.makeTensor(o,t,e);}e.tensor=function(t,e,n){return c(t,e,o.inferShape(t,n),n);},e.scalar=function(t,e){if((a.isTypedArray(t)&&"string"!==e||Array.isArray(t))&&"complex64"!==e)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===e&&a.isTypedArray(t)&&!(t instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return c(t,[],[],e);},e.tensor1d=l,e.tensor2d=function(t,e,n){if(a.assertNonNull(t),null!=e&&2!==e.length)throw new Error("tensor2d() requires shape to have two numbers");var r=o.inferShape(t,n);if(2!==r.length&&1!==r.length)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return c(t,e,r,n);},e.tensor3d=function(t,e,n){if(a.assertNonNull(t),null!=e&&3!==e.length)throw new Error("tensor3d() requires shape to have three numbers");var r=o.inferShape(t,n);if(3!==r.length&&1!==r.length)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return c(t,e,r,n);},e.tensor4d=function(t,e,n){if(a.assertNonNull(t),null!=e&&4!==e.length)throw new Error("tensor4d() requires shape to have four numbers");var r=o.inferShape(t,n);if(4!==r.length&&1!==r.length)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return c(t,e,r,n);},e.tensor5d=function(t,e,n){if(a.assertNonNull(t),null!=e&&5!==e.length)throw new Error("tensor5d() requires shape to have five numbers");var r=o.inferShape(t,n);if(5!==r.length&&1!==r.length)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return c(t,e,r,n);},e.tensor6d=function(t,e,n){if(a.assertNonNull(t),null!=e&&6!==e.length)throw new Error("tensor6d() requires shape to have six numbers");var r=o.inferShape(t,n);if(6!==r.length&&1!==r.length)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(1===r.length&&null==e)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return c(t,e=e||r,r,n);},e.variable=function(t,e,n,i){return void 0===e&&(e=!0),r.ENGINE.makeVariable(t,e,n,i);},e.ones=function t(e,n){if(void 0===n&&(n="float32"),"complex64"===n){var i=t(e,"float32"),o=f(e,"float32");return s.complex(i,o);}var u=a.makeOnesTypedArray(a.sizeFromShape(e),n);return r.ENGINE.makeTensor(u,e,n);},e.zeros=f,e.fill=function(t,e,n){return r.ENGINE.runKernelFunc(function(r){return r.fill(t,e,n);},{});},e.linspace=function(t,e,n){if(n<=0)throw new Error("The number of values should be positive.");return r.ENGINE.runKernelFunc(function(r){return r.linspace(t,e,n);},{});},e.range=function(t,e,n,r){if(void 0===n&&(n=1),void 0===r&&(r="float32"),0===n)throw new Error("Cannot have a step of zero");if(t===e||t<e&&n<0||e<t&&n>1)return f([0],r);var i=Math.abs(Math.ceil((e-t)/n)),o=a.makeZerosTypedArray(i,r);e<t&&1===n&&(n=-1),o[0]=t;for(var s=1;s<o.length;s++){o[s]=o[s-1]+n;}return l(o,r);},e.onesLike=u.op({onesLike_:function onesLike_(t){var n=o.convertToTensor(t,"x","onesLike");if("complex64"===n.dtype){var i=e.onesLike(s.real(n)),a=e.zerosLike(s.imag(n));return s.complex(i,a);}return r.ENGINE.runKernelFunc(function(t){return t.onesLike(n);},{x:n},function(t,n){return {x:function x(){return e.zerosLike(t);}};},"OnesLike");}}),e.zerosLike=u.op({zerosLike_:function zerosLike_(t){var n=o.convertToTensor(t,"x","zerosLike");return r.ENGINE.runKernelFunc(function(t){return t.zerosLike(n);},{x:n},function(t,n){return {x:function x(){return e.zerosLike(t);}};},"ZerosLike");}});},function(t,e,n){(function(t){/*!
 * The buffer module from node.js, for the browser.
 *
 * @author   Feross Aboukhadijeh <http://feross.org>
 * @license  MIT
 */var r=n(394),i=n(393),o=n(392);function a(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823;}function s(t,e){if(a()<e)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=u.prototype:(null===t&&(t=new u(e)),t.length=e),t;}function u(t,e,n){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(t,e,n);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return f(this,t);}return c(this,t,e,n);}function c(t,e,n,r){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return "undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,n,r){if(e.byteLength,n<0||e.byteLength<n)throw new RangeError("'offset' is out of bounds");if(e.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");e=void 0===n&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,n):new Uint8Array(e,n,r);u.TYPED_ARRAY_SUPPORT?(t=e).__proto__=u.prototype:t=h(t,e);return t;}(t,e,n,r):"string"==typeof e?function(t,e,n){"string"==typeof n&&""!==n||(n="utf8");if(!u.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|p(e,n),i=(t=s(t,r)).write(e,n);i!==r&&(t=t.slice(0,i));return t;}(t,e,n):function(t,e){if(u.isBuffer(e)){var n=0|d(e.length);return 0===(t=s(t,n)).length?t:(e.copy(t,0,0,n),t);}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return "number"!=typeof e.length||function(t){return t!=t;}(e.length)?s(t,0):h(t,e);if("Buffer"===e.type&&o(e.data))return h(t,e.data);}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.");}(t,e);}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative');}function f(t,e){if(l(e),t=s(t,e<0?0:0|d(e)),!u.TYPED_ARRAY_SUPPORT)for(var n=0;n<e;++n){t[n]=0;}return t;}function h(t,e){var n=e.length<0?0:0|d(e.length);t=s(t,n);for(var r=0;r<n;r+=1){t[r]=255&e[r];}return t;}function d(t){if(t>=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|t;}function p(t,e){if(u.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var n=t.length;if(0===n)return 0;for(var r=!1;;){switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return U(t).length;default:if(r)return z(t).length;e=(""+e).toLowerCase(),r=!0;}}}function m(t,e,n){var r=t[e];t[e]=t[n],t[n]=r;}function g(t,e,n,r,i){if(0===t.length)return -1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return -1;n=t.length-1;}else if(n<0){if(!i)return -1;n=0;}if("string"==typeof e&&(e=u.from(e,r)),u.isBuffer(e))return 0===e.length?-1:v(t,e,n,r,i);if("number"==typeof e)return e&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):v(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer");}function v(t,e,n,r,i){var o,a=1,s=t.length,u=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return -1;a=2,s/=2,u/=2,n/=2;}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a);}if(i){var l=-1;for(o=n;o<s;o++){if(c(t,o)===c(e,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===u)return l*a;}else -1!==l&&(o-=o-l),l=-1;}}else for(n+u>s&&(n=s-u),o=n;o>=0;o--){for(var f=!0,h=0;h<u;h++){if(c(t,o+h)!==c(e,h)){f=!1;break;}}if(f)return o;}return -1;}function y(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var a=0;a<r;++a){var s=parseInt(e.substr(2*a,2),16);if(isNaN(s))return a;t[n+a]=s;}return a;}function b(t,e,n,r){return W(z(e,t.length-n),t,n,r);}function x(t,e,n,r){return W(function(t){for(var e=[],n=0;n<t.length;++n){e.push(255&t.charCodeAt(n));}return e;}(e),t,n,r);}function w(t,e,n,r){return x(t,e,n,r);}function k(t,e,n,r){return W(U(e),t,n,r);}function E(t,e,n,r){return W(function(t,e){for(var n,r,i,o=[],a=0;a<t.length&&!((e-=2)<0);++a){n=t.charCodeAt(a),r=n>>8,i=n%256,o.push(i),o.push(r);}return o;}(e,t.length-n),t,n,r);}function C(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n));}function A(t,e,n){n=Math.min(t.length,n);for(var r=[],i=e;i<n;){var o,a,s,u,c=t[i],l=null,f=c>239?4:c>223?3:c>191?2:1;if(i+f<=n)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&c)<<6|63&o)>127&&(l=u);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(u=(15&c)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(l=u);}null===l?(l=65533,f=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),i+=f;}return function(t){var e=t.length;if(e<=O)return String.fromCharCode.apply(String,t);var n="",r=0;for(;r<e;){n+=String.fromCharCode.apply(String,t.slice(r,r+=O));}return n;}(r);}e.Buffer=u,e.SlowBuffer=function(t){+t!=t&&(t=0);return u.alloc(+t);},e.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function foo(){return 42;}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength;}catch(t){return !1;}}(),e.kMaxLength=a(),u.poolSize=8192,u._augment=function(t){return t.__proto__=u.prototype,t;},u.from=function(t,e,n){return c(null,t,e,n);},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(t,e,n){return function(t,e,n,r){return l(e),e<=0?s(t,e):void 0!==n?"string"==typeof r?s(t,e).fill(n,r):s(t,e).fill(n):s(t,e);}(null,t,e,n);},u.allocUnsafe=function(t){return f(null,t);},u.allocUnsafeSlow=function(t){return f(null,t);},u.isBuffer=function(t){return !(null==t||!t._isBuffer);},u.compare=function(t,e){if(!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,r=e.length,i=0,o=Math.min(n,r);i<o;++i){if(t[i]!==e[i]){n=t[i],r=e[i];break;}}return n<r?-1:r<n?1:0;},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return !0;default:return !1;}},u.concat=function(t,e){if(!o(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n){e+=t[n].length;}var r=u.allocUnsafe(e),i=0;for(n=0;n<t.length;++n){var a=t[n];if(!u.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(r,i),i+=a.length;}return r;},u.byteLength=p,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2){m(this,e,e+1);}return this;},u.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4){m(this,e,e+3),m(this,e+1,e+2);}return this;},u.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8){m(this,e,e+7),m(this,e+1,e+6),m(this,e+2,e+5),m(this,e+3,e+4);}return this;},u.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?A(this,0,t):function(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return "";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return "";if((n>>>=0)<=(e>>>=0))return "";for(t||(t="utf8");;){switch(t){case"hex":return D(this,e,n);case"utf8":case"utf-8":return A(this,e,n);case"ascii":return _(this,e,n);case"latin1":case"binary":return S(this,e,n);case"base64":return C(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0;}}}.apply(this,arguments);},u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t);},u.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(t+=" ... ")),"<Buffer "+t+">";},u.prototype.compare=function(t,e,n,r,i){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return -1;if(e>=n)return 1;if(e>>>=0,n>>>=0,r>>>=0,i>>>=0,this===t)return 0;for(var o=i-r,a=n-e,s=Math.min(o,a),c=this.slice(r,i),l=t.slice(e,n),f=0;f<s;++f){if(c[f]!==l[f]){o=c[f],a=l[f];break;}}return o<a?-1:a<o?1:0;},u.prototype.includes=function(t,e,n){return -1!==this.indexOf(t,e,n);},u.prototype.indexOf=function(t,e,n){return g(this,t,e,n,!0);},u.prototype.lastIndexOf=function(t,e,n){return g(this,t,e,n,!1);},u.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else {if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0);}var i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;){switch(r){case"hex":return y(this,t,e,n);case"utf8":case"utf-8":return b(this,t,e,n);case"ascii":return x(this,t,e,n);case"latin1":case"binary":return w(this,t,e,n);case"base64":return k(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0;}}},u.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)};};var O=4096;function _(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i){r+=String.fromCharCode(127&t[i]);}return r;}function S(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;i<n;++i){r+=String.fromCharCode(t[i]);}return r;}function D(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=e;o<n;++o){i+=L(t[o]);}return i;}function F(t,e,n){for(var r=t.slice(e,n),i="",o=0;o<r.length;o+=2){i+=String.fromCharCode(r[o]+256*r[o+1]);}return i;}function T(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length");}function N(t,e,n,r,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range");}function I(t,e,n,r){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-n,2);i<o;++i){t[n+i]=(e&255<<8*(r?i:1-i))>>>8*(r?i:1-i);}}function R(t,e,n,r){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-n,4);i<o;++i){t[n+i]=e>>>8*(r?i:3-i)&255;}}function M(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range");}function j(t,e,n,r,o){return o||M(t,0,n,4),i.write(t,e,n,r,23,4),n+4;}function B(t,e,n,r,o){return o||M(t,0,n,8),i.write(t,e,n,r,52,8),n+8;}u.prototype.slice=function(t,e){var n,r=this.length;if(t=~~t,e=void 0===e?r:~~e,t<0?(t+=r)<0&&(t=0):t>r&&(t=r),e<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t),u.TYPED_ARRAY_SUPPORT)(n=this.subarray(t,e)).__proto__=u.prototype;else {var i=e-t;n=new u(i,void 0);for(var o=0;o<i;++o){n[o]=this[o+t];}}return n;},u.prototype.readUIntLE=function(t,e,n){t|=0,e|=0,n||T(t,e,this.length);for(var r=this[t],i=1,o=0;++o<e&&(i*=256);){r+=this[t+o]*i;}return r;},u.prototype.readUIntBE=function(t,e,n){t|=0,e|=0,n||T(t,e,this.length);for(var r=this[t+--e],i=1;e>0&&(i*=256);){r+=this[t+--e]*i;}return r;},u.prototype.readUInt8=function(t,e){return e||T(t,1,this.length),this[t];},u.prototype.readUInt16LE=function(t,e){return e||T(t,2,this.length),this[t]|this[t+1]<<8;},u.prototype.readUInt16BE=function(t,e){return e||T(t,2,this.length),this[t]<<8|this[t+1];},u.prototype.readUInt32LE=function(t,e){return e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3];},u.prototype.readUInt32BE=function(t,e){return e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3]);},u.prototype.readIntLE=function(t,e,n){t|=0,e|=0,n||T(t,e,this.length);for(var r=this[t],i=1,o=0;++o<e&&(i*=256);){r+=this[t+o]*i;}return r>=(i*=128)&&(r-=Math.pow(2,8*e)),r;},u.prototype.readIntBE=function(t,e,n){t|=0,e|=0,n||T(t,e,this.length);for(var r=e,i=1,o=this[t+--r];r>0&&(i*=256);){o+=this[t+--r]*i;}return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o;},u.prototype.readInt8=function(t,e){return e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t];},u.prototype.readInt16LE=function(t,e){e||T(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n;},u.prototype.readInt16BE=function(t,e){e||T(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n;},u.prototype.readInt32LE=function(t,e){return e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24;},u.prototype.readInt32BE=function(t,e){return e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3];},u.prototype.readFloatLE=function(t,e){return e||T(t,4,this.length),i.read(this,t,!0,23,4);},u.prototype.readFloatBE=function(t,e){return e||T(t,4,this.length),i.read(this,t,!1,23,4);},u.prototype.readDoubleLE=function(t,e){return e||T(t,8,this.length),i.read(this,t,!0,52,8);},u.prototype.readDoubleBE=function(t,e){return e||T(t,8,this.length),i.read(this,t,!1,52,8);},u.prototype.writeUIntLE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||N(this,t,e,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[e]=255&t;++o<n&&(i*=256);){this[e+o]=t/i&255;}return e+n;},u.prototype.writeUIntBE=function(t,e,n,r){(t=+t,e|=0,n|=0,r)||N(this,t,e,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);){this[e+i]=t/o&255;}return e+n;},u.prototype.writeUInt8=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,1,255,0),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1;},u.prototype.writeUInt16LE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2;},u.prototype.writeUInt16BE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2;},u.prototype.writeUInt32LE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):R(this,t,e,!0),e+4;},u.prototype.writeUInt32BE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):R(this,t,e,!1),e+4;},u.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);N(this,t,e,n,i-1,-i);}var o=0,a=1,s=0;for(this[e]=255&t;++o<n&&(a*=256);){t<0&&0===s&&0!==this[e+o-1]&&(s=1),this[e+o]=(t/a>>0)-s&255;}return e+n;},u.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e|=0,!r){var i=Math.pow(2,8*n-1);N(this,t,e,n,i-1,-i);}var o=n-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);){t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;}return e+n;},u.prototype.writeInt8=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,1,127,-128),u.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1;},u.prototype.writeInt16LE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):I(this,t,e,!0),e+2;},u.prototype.writeInt16BE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):I(this,t,e,!1),e+2;},u.prototype.writeInt32LE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):R(this,t,e,!0),e+4;},u.prototype.writeInt32BE=function(t,e,n){return t=+t,e|=0,n||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),u.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):R(this,t,e,!1),e+4;},u.prototype.writeFloatLE=function(t,e,n){return j(this,t,e,!0,n);},u.prototype.writeFloatBE=function(t,e,n){return j(this,t,e,!1,n);},u.prototype.writeDoubleLE=function(t,e,n){return B(this,t,e,!0,n);},u.prototype.writeDoubleBE=function(t,e,n){return B(this,t,e,!1,n);},u.prototype.copy=function(t,e,n,r){if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var i,o=r-n;if(this===t&&n<e&&e<r)for(i=o-1;i>=0;--i){t[i+e]=this[i+n];}else if(o<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i){t[i+e]=this[i+n];}else Uint8Array.prototype.set.call(t,this.subarray(n,n+o),e);return o;},u.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i);}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r);}else "number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var o;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=e;o<n;++o){this[o]=t;}else {var a=u.isBuffer(t)?t:z(new u(t,r).toString()),s=a.length;for(o=0;o<n-e;++o){this[o+e]=a[o%s];}}return this;};var P=/[^+\/0-9A-Za-z-_]/g;function L(t){return t<16?"0"+t.toString(16):t.toString(16);}function z(t,e){var n;e=e||1/0;for(var r=t.length,i=null,o=[],a=0;a<r;++a){if((n=t.charCodeAt(a))>55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue;}if(a+1===r){(e-=3)>-1&&o.push(239,191,189);continue;}i=n;continue;}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue;}n=65536+(i-55296<<10|n-56320);}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n);}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128);}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128);}else {if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128);}}return o;}function U(t){return r.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"");}(t).replace(P,"")).length<2)return "";for(;t.length%4!=0;){t+="=";}return t;}(t));}function W(t,e,n,r){for(var i=0;i<r&&!(i+n>=e.length||i>=t.length);++i){e[i+n]=t[i];}return i;}}).call(this,n(59));},function(t,e,n){var r=n(38);t.exports=function(t,e,n){for(var i in e){r(t,i,e[i],n);}return t;};},function(t,e){t.exports=function(t,e,n,r){if(!(t instanceof e)||void 0!==r&&r in t)throw TypeError(n+": incorrect invocation!");return t;};},function(t,e,n){var r=n(16),i=n(26),o=n(27),a=n(19)("species");t.exports=function(t){var e=r[t];o&&e&&!e[a]&&i.f(e,a,{configurable:!0,get:function get(){return this;}});};},function(t,e){t.exports={};},function(t,e,n){var r=n(8),i=n(61),o=n(15),a=n(169),s="["+a+"]",u=RegExp("^"+s+s+"*"),c=RegExp(s+s+"*$"),l=function l(t,e,n){var i={},s=o(function(){return !!a[t]()||"​"!="​"[t]();}),u=i[t]=s?e(f):a[t];n&&(i[n]=u),r(r.P+r.F*s,"String",i);},f=l.trim=function(t,e){return t=String(i(t)),1&e&&(t=t.replace(u,"")),2&e&&(t=t.replace(c,"")),t;};t.exports=l;},function(t,e,n){var r=n(26).f,i=n(43),o=n(19)("toStringTag");t.exports=function(t,e,n){t&&!i(t=n?t:t.prototype,o)&&r(t,o,{configurable:!0,value:e});};},function(t,e,n){var r,i="object"==(typeof Reflect==="undefined"?"undefined":_typeof$1(Reflect))?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n);};r=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t));}:function(t){return Object.getOwnPropertyNames(t);};var a=Number.isNaN||function(t){return t!=t;};function s(){s.init.call(this);}t.exports=s,t.exports.once=function(t,e){return new Promise(function(n,r){function i(n){t.removeListener(e,o),r(n);}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),n([].slice.call(arguments));}g(t,e,o,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&g(t,"error",e,n);}(t,i,{once:!0});});},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var u=10;function c(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+_typeof$1(t));}function l(t){return void 0===t._maxListeners?s.defaultMaxListeners:t._maxListeners;}function f(t,e,n,r){var i,o,a;if(c(n),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),a=o[e]),void 0===a)a=o[e]=n,++t._eventsCount;else if("function"==typeof a?a=o[e]=r?[n,a]:[a,n]:r?a.unshift(n):a.push(n),(i=l(t))>0&&a.length>i&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=a.length,function(t){console&&console.warn&&console.warn(t);}(s);}return t;}function h(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=function(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments);}.bind(r);return i.listener=n,r.wrapFn=i,i;}function d(t,e,n){var r=t._events;if(void 0===r)return [];var i=r[e];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(t){for(var e=new Array(t.length),n=0;n<e.length;++n){e[n]=t[n].listener||t[n];}return e;}(i):m(i,i.length);}function p(t){var e=this._events;if(void 0!==e){var n=e[t];if("function"==typeof n)return 1;if(void 0!==n)return n.length;}return 0;}function m(t,e){for(var n=new Array(e),r=0;r<e;++r){n[r]=t[r];}return n;}function g(t,e,n,r){if("function"==typeof t.on)r.once?t.once(e,n):t.on(e,n);else {if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+_typeof$1(t));t.addEventListener(e,function i(o){r.once&&t.removeEventListener(e,i),n(o);});}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function get(){return u;},set:function set(t){if("number"!=typeof t||t<0||a(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");u=t;}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0;},s.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||a(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this;},s.prototype.getMaxListeners=function(){return l(this);},s.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++){e.push(arguments[n]);}var r="error"===t,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return !1;if(r){var a;if(e.length>0&&(a=e[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s;}var u=i[t];if(void 0===u)return !1;if("function"==typeof u)o(u,this,e);else {var c=u.length,l=m(u,c);for(n=0;n<c;++n){o(l[n],this,e);}}return !0;},s.prototype.addListener=function(t,e){return f(this,t,e,!1);},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(t,e){return f(this,t,e,!0);},s.prototype.once=function(t,e){return c(e),this.on(t,h(this,t,e)),this;},s.prototype.prependOnceListener=function(t,e){return c(e),this.prependListener(t,h(this,t,e)),this;},s.prototype.removeListener=function(t,e){var n,r,i,o,a;if(c(e),void 0===(r=this._events))return this;if(void 0===(n=r[t]))return this;if(n===e||n.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,n.listener||e));else if("function"!=typeof n){for(i=-1,o=n.length-1;o>=0;o--){if(n[o]===e||n[o].listener===e){a=n[o].listener,i=o;break;}}if(i<0)return this;0===i?n.shift():function(t,e){for(;e+1<t.length;e++){t[e]=t[e+1];}t.pop();}(n,i),1===n.length&&(r[t]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",t,a||e);}return this;},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(t){var e,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[t]),this;if(0===arguments.length){var i,o=Object.keys(n);for(r=0;r<o.length;++r){"removeListener"!==(i=o[r])&&this.removeAllListeners(i);}return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this;}if("function"==typeof(e=n[t]))this.removeListener(t,e);else if(void 0!==e)for(r=e.length-1;r>=0;r--){this.removeListener(t,e[r]);}return this;},s.prototype.listeners=function(t){return d(this,t,!0);},s.prototype.rawListeners=function(t){return d(this,t,!1);},s.listenerCount=function(t,e){return "function"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e);},s.prototype.listenerCount=p,s.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[];};},function(t,e,n){n.d(e,"a",function(){return i;}),n.d(e,"b",function(){return o;}),n.d(e,"c",function(){return a;}),n.d(e,"d",function(){return s;});var r,i,o,a,s,u=n(246);!function(t){r=Object(u.a)(t),i=r.format,o=r.parse,a=r.utcFormat,s=r.utcParse;}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){return "string"==typeof t&&r.test(t);};var r=/-webkit-|-moz-|-ms-/;t.exports=e.default;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.compose=e.merge=e.$=e.style=e.presets=e.keyframes=e.fontFace=e.insertGlobal=e.insertRule=e.plugins=e.styleSheet=void 0,e.speedy=function(t){return f.speedy(t);},e.simulations=function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];g=!!t;},e.simulate=function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++){e[n]=arguments[n];}if(!(e=(0, a.default)(e)))return {};if(!g)return v||(console.warn("can't simulate without once calling simulations(true)"),v=!0),y||(console.warn("don't use simulation outside dev"),y=!0),{};return e.reduce(function(t,e){return t["data-simulate-"+x(e)]="",t;},{});},e.cssLabels=function(t){b=!!t;},e.isLikeRule=k,e.idFor=E,e.css=V,e.rehydrate=function(t){(0, r.default)(F,t.reduce(function(t,e){return t[e]=!0,t;},{}));},e.flush=function(){F=f.inserted={},T=f.registered={},I={},f.flush(),f.inject();},e.select=$,e.parent=function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;r<e;r++){n[r-1]=arguments[r];}return V(l({},t+" &",n));},e.media=function(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;r<e;r++){n[r-1]=arguments[r];}return V(l({},"@media "+t,n));},e.pseudo=H,e.active=function(t){return H(":active",t);},e.any=function(t){return H(":any",t);},e.checked=function(t){return H(":checked",t);},e.disabled=function(t){return H(":disabled",t);},e.empty=function(t){return H(":empty",t);},e.enabled=function(t){return H(":enabled",t);},e._default=function(t){return H(":default",t);},e.first=function(t){return H(":first",t);},e.firstChild=function(t){return H(":first-child",t);},e.firstOfType=function(t){return H(":first-of-type",t);},e.fullscreen=function(t){return H(":fullscreen",t);},e.focus=function(t){return H(":focus",t);},e.hover=function(t){return H(":hover",t);},e.indeterminate=function(t){return H(":indeterminate",t);},e.inRange=function(t){return H(":in-range",t);},e.invalid=function(t){return H(":invalid",t);},e.lastChild=function(t){return H(":last-child",t);},e.lastOfType=function(t){return H(":last-of-type",t);},e.left=function(t){return H(":left",t);},e.link=function(t){return H(":link",t);},e.onlyChild=function(t){return H(":only-child",t);},e.onlyOfType=function(t){return H(":only-of-type",t);},e.optional=function(t){return H(":optional",t);},e.outOfRange=function(t){return H(":out-of-range",t);},e.readOnly=function(t){return H(":read-only",t);},e.readWrite=function(t){return H(":read-write",t);},e.required=function(t){return H(":required",t);},e.right=function(t){return H(":right",t);},e.root=function(t){return H(":root",t);},e.scope=function(t){return H(":scope",t);},e.target=function(t){return H(":target",t);},e.valid=function(t){return H(":valid",t);},e.visited=function(t){return H(":visited",t);},e.dir=function(t,e){return H(":dir("+t+")",e);},e.lang=function(t,e){return H(":lang("+t+")",e);},e.not=function(t,e){var n=t.split(",").map(function(t){return t.trim();}).map(function(t){return ":not("+t+")";});if(1===n.length)return H(":not("+t+")",e);return $(n.join(""),e);},e.nthChild=function(t,e){return H(":nth-child("+t+")",e);},e.nthLastChild=function(t,e){return H(":nth-last-child("+t+")",e);},e.nthLastOfType=function(t,e){return H(":nth-last-of-type("+t+")",e);},e.nthOfType=function(t,e){return H(":nth-of-type("+t+")",e);},e.after=function(t){return H("::after",t);},e.before=function(t){return H("::before",t);},e.firstLetter=function(t){return H("::first-letter",t);},e.firstLine=function(t){return H("::first-line",t);},e.selection=function(t){return H("::selection",t);},e.backdrop=function(t){return H("::backdrop",t);},e.placeholder=function(t){return V({"::placeholder":t});},e.cssFor=function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++){e[n]=arguments[n];}return (e=(0, a.default)(e))?e.map(function(t){var e={label:[]};return B(e,{src:t}),D(w(e),S(e)).join("");}).join(""):"";},e.attribsFor=function(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++){e[n]=arguments[n];}return (e=(0, a.default)(e))?e.map(function(t){E(t);var e=Object.keys(t)[0],n=t[e];return e+'="'+(n||"")+'"';}).join(" "):"";};var r=c(n(139)),i=n(320),o=n(201),a=c(n(311)),s=n(310),u=c(n(293));function c(t){return t&&t.__esModule?t:{default:t};}function l(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t;}var f=e.styleSheet=new i.StyleSheet();f.inject();var h=e.plugins=f.plugins=new s.PluginSet([s.prefixes,s.contentWrap,s.fallbacks]);h.media=new s.PluginSet(),h.fontFace=new s.PluginSet(),h.keyframes=new s.PluginSet([s.prefixes,s.fallbacks]);var d=!1,m="undefined"!=typeof window,g=d,v=!1,y=!1;var b=d;function x(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return t.toLowerCase().replace(/[^a-z0-9]/g,e);}function w(t){var e=JSON.stringify(t),n=(0, u.default)(e).toString(36);return t.label&&t.label.length>0&&d?x(t.label.join("."),"-")+"-"+n:n;}function k(t){var e=Object.keys(t).filter(function(t){return "toString"!==t;});return 1===e.length&&!!/data\-css\-([a-zA-Z0-9\-_]+)/.exec(e[0]);}function E(t){var e=Object.keys(t).filter(function(t){return "toString"!==t;});if(1!==e.length)throw new Error("not a rule");var n=/data\-css\-([a-zA-Z0-9\-_]+)/.exec(e[0]);if(!n)throw new Error("not a rule");return n[1];}var C=/[(),]|"(?:\\.|[^"\n])*"|'(?:\\.|[^'\n])*'|\/\*[\s\S]*?\*\//g;function A(t){if(-1===t.indexOf(","))return [t];for(var e,n=[],r=[],i=0;e=C.exec(t);){switch(e[0]){case"(":i++;break;case")":i--;break;case",":if(i)break;n.push(e.index);}}for(e=n.length;e--;){r.unshift(t.slice(n[e]+1)),t=t.slice(0,n[e]);}return r.unshift(t),r;}function O(t,e){if(!t)return e.replace(/\&/g,"");if(!e)return ".css-"+t+",[data-css-"+t+"]";var n=A(e).map(function(e){return e.indexOf("&")>=0?[e.replace(/\&/gm,".css-"+t),e.replace(/\&/gm,"[data-css-"+t+"]")].join(","):".css-"+t+e+",[data-css-"+t+"]"+e;}).join(",");return g&&/^\&\:/.exec(e)&&!/\s/.exec(e)&&(n+=",.css-"+t+"[data-simulate-"+x(e)+"],[data-css-"+t+"][data-simulate-"+x(e)+"]"),n;}function _(t){var e=t.selector,n=t.style,r=h.transform({selector:e,style:n});return r.selector+"{"+(0, o.createMarkupForStyles)(r.style)+"}";}function S(t){var e=void 0,n=void 0,r=void 0,i=void 0;return Object.keys(t).forEach(function(o){o.indexOf("&")>=0?(n=n||{})[o]=t[o]:0===o.indexOf("@media")?(r=r||{})[o]=S(t[o]):0===o.indexOf("@supports")?(i=i||{})[o]=S(t[o]):"label"===o?t.label.length>0&&((e=e||{}).label=b?t.label.join("."):""):(e=e||{})[o]=t[o];}),{plain:e,selects:n,medias:r,supports:i};}function D(t,e){var n=[],r=e.plain,i=e.selects,o=e.medias,a=e.supports;return r&&n.push(_({style:r,selector:O(t)})),i&&Object.keys(i).forEach(function(e){return n.push(_({style:i[e],selector:O(t,e)}));}),o&&Object.keys(o).forEach(function(e){return n.push(e+"{"+D(t,o[e]).join("")+"}");}),a&&Object.keys(a).forEach(function(e){return n.push(e+"{"+D(t,a[e]).join("")+"}");}),n;}var F=f.inserted={};var T=f.registered={};function N(t){T[t.id]||(T[t.id]=t);}var I={};function R(t){if(N(t),function(t){if(!F[t.id]){F[t.id]=!0;var e=S(t.style),n=D(t.id,e);F[t.id]=!!m||n,n.forEach(function(t){return f.insert(t);});}}(t),I[t.id])return I[t.id];var e=l({},"data-css-"+t.id,b&&t.label||"");return Object.defineProperty(e,"toString",{enumerable:!1,value:function value(){return "css-"+t.id;}}),I[t.id]=e,e;}function M(t,e){var n=A(t).map(function(t){return t.indexOf("&")>=0?t:"&"+t;});return A(e).map(function(t){return t.indexOf("&")>=0?t:"&"+t;}).reduce(function(t,e){return t.concat(n.map(function(t){return e.replace(/\&/g,t);}));},[]).join(",");}var j={"::placeholder":["::-webkit-input-placeholder","::-moz-placeholder","::-ms-input-placeholder"],":fullscreen":[":-webkit-full-screen",":-moz-full-screen",":-ms-fullscreen"]};function B(t,e){var n=e.selector,r=void 0===n?"":n,i=e.mq,o=void 0===i?"":i,s=e.supp,u=void 0===s?"":s,c=e.src,l=void 0===c?{}:c;Array.isArray(l)||(l=[l]),(l=function t(e){for(var n=[],r=0;r<e.length;r++){n=Array.isArray(e[r])?n.concat(t(e[r])):n.concat(e[r]);}return n;}(l)).forEach(function(e){if(k(e)){var n=function(t){if(k(t)){var e=T[E(t)];if(null==e)throw new Error("[glamor] an unexpected rule cache miss occurred. This is probably a sign of multiple glamor instances in your app. See https://github.com/threepointone/glamor/issues/79");return e;}return t;}(e);if("css"!==n.type)throw new Error("cannot merge this rule");e=n.style;}(e=(0, a.default)(e))&&e.composes&&B(t,{selector:r,mq:o,supp:u,src:e.composes}),Object.keys(e||{}).forEach(function(n){if(function(t){for(var e=[":",".","[",">"," "],n=!1,r=t.charAt(0),i=0;i<e.length;i++){if(r===e[i]){n=!0;break;}}return n||t.indexOf("&")>=0;}(n))j[n]&&j[n].forEach(function(i){return B(t,{selector:M(r,i),mq:o,supp:u,src:e[n]});}),B(t,{selector:M(r,n),mq:o,supp:u,src:e[n]});else if(function(t){return 0===t.indexOf("@media");}(n))B(t,{selector:r,mq:function(t,e){return t?"@media "+t.substring(6)+" and "+e.substring(6):e;}(o,n),supp:u,src:e[n]});else if(function(t){return 0===t.indexOf("@supports");}(n))B(t,{selector:r,mq:o,supp:function(t,e){return t?"@supports "+t.substring(9)+" and "+e.substring(9):e;}(u,n),src:e[n]});else if("composes"===n);else {var i=t;u&&(i[u]=i[u]||{},i=i[u]),o&&(i[o]=i[o]||{},i=i[o]),r&&(i[r]=i[r]||{},i=i[r]),"label"===n?b&&(t.label=t.label.concat(e.label)):i[n]=e[n];}});});}function P(t){var e={label:[]};return B(e,{src:t}),R({id:w(e),style:e,label:b?e.label.join("."):"",type:"css"});}var L={};Object.defineProperty(L,"toString",{enumerable:!1,value:function value(){return "css-nil";}});var z="undefined"!=typeof WeakMap?[L,new WeakMap(),new WeakMap(),new WeakMap()]:[L];var W="undefined"!=typeof WeakMap?function(t){return function(e){if(z[e.length]){for(var n=z[e.length],r=0;r<e.length-1;){n.has(e[r])||n.set(e[r],new WeakMap()),n=n.get(e[r]),r++;}if(n.has(e[e.length-1])){var i=n.get(e[r]);if(T[i.toString().substring(4)])return i;}}var o=t(e);if(z[e.length]){for(var a=0,s=z[e.length];a<e.length-1;){s=s.get(e[a]),a++;}try{s.set(e[a],o);}catch(t){}}return o;};}(P):P;function V(){for(var t=arguments.length,e=Array(t),n=0;n<t;n++){e[n]=arguments[n];}if(e[0]&&e[0].length&&e[0].raw)throw new Error("you forgot to include glamor/babel in your babel plugins.");return (e=(0, a.default)(e))?W(e):L;}V.insert=function(t){var e={id:w(t),css:t,type:"raw"};N(e),F[e.id]||(f.insert(e.css),F[e.id]=!!m||[e.css]);};e.insertRule=V.insert;V.global=function(t,e){if(e=(0, a.default)(e))return V.insert(_({selector:t,style:e}));};e.insertGlobal=V.global;V.keyframes=function(t,e){e||(e=t,t="animation");var n={id:w({name:t,kfs:e=(0, a.default)(e)||{}}),type:"keyframes",name:t,keyframes:e};return N(n),function(t){if(!F[t.id]){var e=Object.keys(t.keyframes).map(function(e){var n=h.keyframes.transform({id:t.id,name:e,style:t.keyframes[e]});return n.name+"{"+(0, o.createMarkupForStyles)(n.style)+"}";}).join(""),n=["-webkit-","-moz-","-o-",""].map(function(n){return "@"+n+"keyframes "+t.name+"_"+t.id+"{"+e+"}";});n.forEach(function(t){return f.insert(t);}),F[t.id]=!!m||n;}}(n),t+"_"+n.id;},V.fontFace=function(t){var e={id:w(t=(0, a.default)(t)),type:"font-face",font:t};return N(e),function(t){if(!F[t.id]){var e="@font-face{"+(0, o.createMarkupForStyles)(t.font)+"}";f.insert(e),F[t.id]=!!m||[e];}}(e),t.fontFamily;};e.fontFace=V.fontFace,e.keyframes=V.keyframes;e.presets={mobile:"(min-width: 400px)",Mobile:"@media (min-width: 400px)",phablet:"(min-width: 550px)",Phablet:"@media (min-width: 550px)",tablet:"(min-width: 750px)",Tablet:"@media (min-width: 750px)",desktop:"(min-width: 1000px)",Desktop:"@media (min-width: 1000px)",hd:"(min-width: 1200px)",Hd:"@media (min-width: 1200px)"};var q=e.style=V;function $(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;r<e;r++){n[r-1]=arguments[r];}return t?V(l({},t,n)):q(n);}e.$=$;e.merge=V,e.compose=V;function H(t){for(var e=arguments.length,n=Array(e>1?e-1:0),r=1;r<e;r++){n[r-1]=arguments[r];}return V(l({},t,n));}},function(t,e,n){/**
 * @license
 * Copyright 2017 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t){this.global=t,this.flags={},this.flagRegistry={},this.urlFlags={},this.populateURLFlags();}return t.prototype.setPlatform=function(t,e){null!=this.platform&&console.warn("Platform "+this.platformName+" has already been set. Overwriting the platform with "+e+"."),this.platformName=t,this.platform=e;},t.prototype.registerFlag=function(t,e,n){if(this.flagRegistry[t]={evaluationFn:e,setHook:n},null!=this.urlFlags[t]){var r=this.urlFlags[t];console.warn("Setting feature override from URL "+t+": "+r+"."),this.set(t,r);}},t.prototype.get=function(t){return t in this.flags?this.flags[t]:(this.flags[t]=this.evaluateFlag(t),this.flags[t]);},t.prototype.getNumber=function(t){return this.get(t);},t.prototype.getBool=function(t){return this.get(t);},t.prototype.getFlags=function(){return this.flags;},Object.defineProperty(t.prototype,"features",{get:function get(){return this.flags;},enumerable:!0,configurable:!0}),t.prototype.set=function(t,e){if(null==this.flagRegistry[t])throw new Error("Cannot set flag "+t+" as it has not been registered.");this.flags[t]=e,null!=this.flagRegistry[t].setHook&&this.flagRegistry[t].setHook(e);},t.prototype.evaluateFlag=function(t){if(null==this.flagRegistry[t])throw new Error("Cannot evaluate flag '"+t+"': no evaluation function found.");return this.flagRegistry[t].evaluationFn();},t.prototype.setFlags=function(t){this.flags=Object.assign({},t);},t.prototype.reset=function(){this.flags={},this.urlFlags={},this.populateURLFlags();},t.prototype.populateURLFlags=function(){var t=this;if(void 0!==this.global&&void 0!==this.global.location&&void 0!==this.global.location.search){var e=i(this.global.location.search);if("tfjsflags"in e)e.tfjsflags.split(",").forEach(function(e){var n=e.split(":"),r=n[0],i=n[1];t.urlFlags[r]=function(t,e){if("true"===(e=e.toLowerCase())||"false"===e)return "true"===e;if(""+ +e===e)return +e;throw new Error("Could not parse value flag value "+e+" for flag "+t+".");}(r,i);});}},t;}();function i(t){var e={};return t.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,function(t){for(var n=[],r=1;r<arguments.length;r++){n[r-1]=arguments[r];}return function(t,e,n){t[decodeURIComponent(e)]=decodeURIComponent(n||"");}(e,n[0],n[1]),n.join("=");}),e;}e.Environment=r,e.getQueryParams=i,e.env=function(){return e.ENV;},e.ENV=null,e.setEnvironmentGlobal=function(t){e.ENV=t;};},function(t,e,n){var r=n(14),i=n(55),o=n(19)("species");t.exports=function(t,e){var n,a=r(t).constructor;return void 0===a||void 0==(n=r(a)[o])?e:i(n);};},function(t,e,n){var r=n(62),i=n(19)("toStringTag"),o="Arguments"==r(function(){return arguments;}());t.exports=function(t){var e,n,a;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e];}catch(t){}}(e=Object(t),i))?n:o?r(e):"Object"==(a=r(e))&&"function"==typeof e.callee?"Arguments":a;};},function(t,e){e.f={}.propertyIsEnumerable;},function(t,e,n){var r=n(62);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return "String"==r(t)?t.split(""):Object(t);};},function(t,e,n){var r=n(87);e.a=function(t){var e=t,n=t;function i(t,e,r,i){for(null==r&&(r=0),null==i&&(i=t.length);r<i;){var o=r+i>>>1;n(t[o],e)<0?r=o+1:i=o;}return r;}return 1===t.length&&(e=function e(_e293,n){return t(_e293)-n;},n=function(t){return function(e,n){return Object(r.a)(t(e),n);};}(t)),{left:i,center:function center(t,n,r,o){null==r&&(r=0),null==o&&(o=t.length);var a=i(t,n,r,o-1);return a>r&&e(t[a-1],n)>-e(t[a],n)?a-1:a;},right:function right(t,e,r,i){for(null==r&&(r=0),null==i&&(i=t.length);r<i;){var o=r+i>>>1;n(t[o],e)>0?i=o:r=o+1;}return r;}};};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(50),i=n(247),o=n(102),a=n(46);e.table=function(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};if(e&&null==e.headers)throw new Error('Data to render must have a "headers" property');if(e&&null==e.values)throw new Error('Data to render must have a "values" property');var u=a.getDrawArea(t),c=Object.assign({},s,n);var l=i.select(u).select("table.tf-table");var f=o.css({fontSize:c.fontSize||".875rem",width:"100%",maxWidth:"64rem",marginRight:"auto",marginLeft:"auto"});if(0===l.size()&&((l=i.select(u).append("table")).attr("class"," ".concat(f," tf-table")),l.append("thead").append("tr"),l.append("tbody")),1!==l.size())throw new Error("Error inserting table");var h=o.css({fontWeight:"600",borderBottomStyle:"solid",borderBottomWidth:"1px",borderColor:"rgba( 0, 0, 0, .2 )",textAlign:"left",paddingBottom:"1rem",paddingRight:"1rem",backgroundColor:"#fff"}),d=l.select("thead").select("tr").selectAll("th").data(e.headers),p=d.enter().append("th").attr("class","".concat(h));d.merge(p).html(function(t){return t;}),d.exit().remove();var m=r.format(",.4~f"),g=l.select("tbody").selectAll("tr").data(e.values),v=g.enter().append("tr"),y=o.css({padding:"0.25rem",borderBottomStyle:"solid",borderBottomWidth:"1px",borderColor:"rgba( 0, 0, 0, .2 )"}),b=g.merge(v).selectAll("td").data(function(t){return t;}),x=b.enter().append("td").attr("class","".concat(y));b.merge(x).html(function(t){return "number"==typeof t?m(t):t;}),b.exit().remove(),g.exit().remove();};var s={fontSize:14};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});};Object.defineProperty(e,"__esModule",{value:!0});var i=n(0),o=n(111);e.arrayStats=function(t){if(!Array.isArray(t))throw new Error("input must be an array");if(0===t.length)return {numVals:0,numNans:0,numZeros:0,max:void 0,min:void 0};var e=t.length;var n=-1/0,r=1/0,i=0,o=0,a=0;for(var _s67=0;_s67<e;_s67++){var _e294=t[_s67];_e294>n&&(n=_e294),_e294<r&&(r=_e294),0===_e294&&(i+=1),isNaN(_e294)?o+=1:isFinite(_e294)||(a+=1);}var s={numVals:e,numZeros:i,numNans:o,max:n,min:r,numInfs:a};return s.max===-1/0&&(s.max=NaN),s.min===1/0&&(s.min=NaN),s;},e.tensorStats=function(t){return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee25(){var _i$tidy,_i$tidy2,e,n,r;return regeneratorRuntime.wrap(function _callee25$(_context30){while(1){switch(_context30.prev=_context30.next){case 0:_i$tidy=i.tidy(function(){var e=i.scalar(0,t.dtype);return [t.min(),t.max(),t.equal(e).sum()];}),_i$tidy2=_slicedToArray(_i$tidy,3),e=_i$tidy2[0],n=_i$tidy2[1],r=_i$tidy2[2];return _context30.abrupt("return",Promise.all([t.data(),e.data(),n.data(),r.data()]).then(function(_ref122){var _ref123=_slicedToArray(_ref122,4),t=_ref123[0],e=_ref123[1],n=_ref123[2],r=_ref123[3];var i=t.length;var o=0,a=0;for(var _e295=0;_e295<i;_e295++){var _n230=t[_e295];isNaN(_n230)?o+=1:isFinite(_n230)||(a+=1);}var s=e[0],u=n[0];return o===i&&(s=NaN,u=NaN),{numVals:i,numZeros:r[0],numNans:o,min:s,max:u,numInfs:a};}));case 2:case"end":return _context30.stop();}}},_callee25);}));},e.confusionMatrix=function(t,e,n,a){return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee26(){var r,s,u;return regeneratorRuntime.wrap(function _callee26$(_context31){while(1){switch(_context31.prev=_context31.next){case 0:o.assert(1===t.rank,"labels must be a 1D tensor"),o.assert(1===e.rank,"predictions must be a 1D tensor"),o.assert(t.size===e.size,"labels and predictions must be the same length"),null!=a&&o.assert(a.size===e.size,"labels and predictions must be the same length");r=t.cast("int32"),s=e.cast("int32");null==n&&(n=i.tidy(function(){return i.maximum(r.max(),s.max()).cast("int32").dataSync()[0]+1;}));u=Promise.resolve(null);return _context31.abrupt("return",(null!=a&&(u=a.data()),Promise.all([r.data(),s.data(),u]).then(function(_ref124){var _ref125=_slicedToArray(_ref124,3),t=_ref125[0],e=_ref125[1],r=_ref125[2];var i=Array(n).fill(0);for(var _t294=0;_t294<n;_t294++){i[_t294]=Array(n).fill(0);}for(var _n231=0;_n231<t.length;_n231++){var _o95=t[_n231],_a78=e[_n231];i[_o95][_a78]+=null!=r?r[_n231]:1;}return i;})));case 5:case"end":return _context31.stop();}}},_callee26);}));},e.accuracy=function(t,e){return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee27(){var n,r,a;return regeneratorRuntime.wrap(function _callee27$(_context32){while(1){switch(_context32.prev=_context32.next){case 0:o.assertShapesMatch(t.shape,e.shape,"Error computing accuracy.");n=t.equal(e);r=n.mean();_context32.next=5;return r.data();case 5:a=_context32.sent[0];return _context32.abrupt("return",(i.dispose([n,r]),a));case 7:case"end":return _context32.stop();}}},_callee27);}));},e.perClassAccuracy=function(t,e,n){return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee28(){return regeneratorRuntime.wrap(function _callee28$(_context33){while(1){switch(_context33.prev=_context33.next){case 0:return _context33.abrupt("return",(o.assert(1===t.rank,"labels must be a 1D tensor"),o.assert(1===e.rank,"predictions must be a 1D tensor"),o.assert(t.size===e.size,"labels and predictions must be the same length"),null==n&&(n=i.tidy(function(){return i.maximum(t.max(),e.max()).dataSync()[0]+1;})),Promise.all([t.data(),e.data()]).then(function(_ref126){var _ref127=_slicedToArray(_ref126,2),t=_ref127[0],e=_ref127[1];var r=Array(n).fill(0),i=Array(n).fill(0);for(var _n232=0;_n232<t.length;_n232++){var _o96=t[_n232],a=e[_n232];r[_o96]+=1,_o96===a&&(i[_o96]+=1);}var o=[];for(var _t295=0;_t295<r.length;_t295++){o.push({count:r[_t295],accuracy:0===r[_t295]?0:i[_t295]/r[_t295]});}return o;})));case 1:case"end":return _context33.stop();}}},_callee28);}));};},function(t,e,n){/*
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function r(t,e){if(!t)throw new Error("string"==typeof e?e:e());}function i(t,e){if(t.length!==e.length)return !1;for(var _n233=0;_n233<t.length;_n233++){if(t[_n233]!==e[_n233])return !1;}return !0;}Object.defineProperty(e,"__esModule",{value:!0}),e.assert=r,e.assertShapesMatch=function(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"";r(i(t,e),n+" Shapes ".concat(t," and ").concat(e," must match"));},e.arraysEqual=i,e.DECIMAL_PLACES_TO_CHECK=4;},function(t,e,n){var r=n(47);t.exports=function(t,e,n){try{e=new r(e,n);}catch(t){return !1;}return e.test(t);};},function(t,e,n){var r=Symbol("SemVer ANY");var i=/*#__PURE__*/function(){function i(t,e){_classCallCheck(this,i);if(e=o(e),t instanceof i){if(t.loose===!!e.loose)return t;t=t.value;}c("comparator",t,e),this.options=e,this.loose=!!e.loose,this.parse(t),this.semver===r?this.value="":this.value=this.operator+this.semver.version,c("comp",this);}_createClass(i,[{key:"parse",value:function parse(t){var e=this.options.loose?a[s.COMPARATORLOOSE]:a[s.COMPARATOR],n=t.match(e);if(!n)throw new TypeError("Invalid comparator: ".concat(t));this.operator=void 0!==n[1]?n[1]:"","="===this.operator&&(this.operator=""),n[2]?this.semver=new l(n[2],this.options.loose):this.semver=r;}},{key:"toString",value:function toString(){return this.value;}},{key:"test",value:function test(t){if(c("Comparator.test",t,this.options.loose),this.semver===r||t===r)return !0;if("string"==typeof t)try{t=new l(t,this.options);}catch(t){return !1;}return u(t,this.operator,this.semver,this.options);}},{key:"intersects",value:function intersects(t,e){if(!(t instanceof i))throw new TypeError("a Comparator is required");if(e&&"object"==_typeof$1(e)||(e={loose:!!e,includePrerelease:!1}),""===this.operator)return ""===this.value||new f(t.value,e).test(this.value);if(""===t.operator)return ""===t.value||new f(this.value,e).test(t.semver);var n=!(">="!==this.operator&&">"!==this.operator||">="!==t.operator&&">"!==t.operator),r=!("<="!==this.operator&&"<"!==this.operator||"<="!==t.operator&&"<"!==t.operator),o=this.semver.version===t.semver.version,a=!(">="!==this.operator&&"<="!==this.operator||">="!==t.operator&&"<="!==t.operator),s=u(this.semver,"<",t.semver,e)&&(">="===this.operator||">"===this.operator)&&("<="===t.operator||"<"===t.operator),c=u(this.semver,">",t.semver,e)&&("<="===this.operator||"<"===this.operator)&&(">="===t.operator||">"===t.operator);return n||r||o&&a||s||c;}}],[{key:"ANY",get:function get(){return r;}}]);return i;}();t.exports=i;var o=n(115),_n234=n(90),a=_n234.re,s=_n234.t,u=n(203),c=n(116),l=n(32),f=n(47);},function(t,e,n){var r=n(48);t.exports=function(t,e,n){return r(t,e,n)>0;};},function(t,e){var n=["includePrerelease","loose","rtl"];t.exports=function(t){return t?"object"!=_typeof$1(t)?{loose:!0}:n.filter(function(e){return t[e];}).reduce(function(t,e){return t[e]=!0,t;},{}):{};};},function(t,e,n){(function(e){var n="object"==_typeof$1(e)&&e.env&&e.env.NODE_DEBUG&&/\bsemver\b/i.test(e.env.NODE_DEBUG)?function(){var _console;for(var _len12=arguments.length,t=new Array(_len12),_key12=0;_key12<_len12;_key12++){t[_key12]=arguments[_key12];}return (_console=console).error.apply(_console,["SEMVER"].concat(t));}:function(){};t.exports=n;}).call(this,n(75));},function(t,e){var n=Number.MAX_SAFE_INTEGER||9007199254740991;t.exports={SEMVER_SPEC_VERSION:"2.0.0",MAX_LENGTH:256,MAX_SAFE_INTEGER:n,MAX_SAFE_COMPONENT_LENGTH:16};},function(t,e,n){for(var r,i=n(16),o=n(42),a=n(84),s=a("typed_array"),u=a("view"),c=!(!i.ArrayBuffer||!i.DataView),l=c,f=0,h="Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array".split(",");f<9;){(r=i[h[f++]])?(o(r.prototype,s,!0),o(r.prototype,u,!0)):l=!1;}t.exports={ABV:c,CONSTR:l,TYPED:s,VIEW:u};},function(t,e,n){var r=n(16),i=n(8),o=n(38),a=n(93),s=n(65),u=n(121),c=n(94),l=n(13),f=n(15),h=n(125),d=n(98),p=n(168);t.exports=function(t,e,n,m,g,v){var y=r[t],b=y,x=g?"set":"add",w=b&&b.prototype,k={},E=function E(t){var e=w[t];o(w,t,"delete"==t?function(t){return !(v&&!l(t))&&e.call(this,0===t?0:t);}:"has"==t?function(t){return !(v&&!l(t))&&e.call(this,0===t?0:t);}:"get"==t?function(t){return v&&!l(t)?void 0:e.call(this,0===t?0:t);}:"add"==t?function(t){return e.call(this,0===t?0:t),this;}:function(t,n){return e.call(this,0===t?0:t,n),this;});};if("function"==typeof b&&(v||w.forEach&&!f(function(){new b().entries().next();}))){var C=new b(),A=C[x](v?{}:-0,1)!=C,O=f(function(){C.has(1);}),_=h(function(t){new b(t);}),S=!v&&f(function(){for(var t=new b(),e=5;e--;){t[x](e,e);}return !t.has(-0);});_||((b=e(function(e,n){c(e,b,t);var r=p(new y(),e,b);return void 0!=n&&u(n,g,r[x],r),r;})).prototype=w,w.constructor=b),(O||S)&&(E("delete"),E("has"),g&&E("get")),(S||A)&&E(x),v&&w.clear&&delete w.clear;}else b=m.getConstructor(e,t,g,x),a(b.prototype,n),s.NEED=!0;return d(b,t),k[t]=b,i(i.G+i.W+i.F*(b!=y),k),v||m.setStrong(b,t,g),b;};},function(t,e,n){var r=n(16).navigator;t.exports=r&&r.userAgent||"";},function(t,e,n){var r=n(56),i=n(225),o=n(159),a=n(14),s=n(22),u=n(157),c={},l={};(e=t.exports=function(t,e,n,f,h){var d,p,m,g,v=h?function(){return t;}:u(t),y=r(n,f,e?2:1),b=0;if("function"!=typeof v)throw TypeError(t+" is not iterable!");if(o(v)){for(d=s(t.length);d>b;b++){if((g=e?y(a(p=t[b])[0],p[1]):y(t[b]))===c||g===l)return g;}}else for(m=v.call(t);!(p=m.next()).done;){if((g=i(m,y,p.value,e))===c||g===l)return g;}}).BREAK=c,e.RETURN=l;},function(t,e,n){n(220);var r=n(38),i=n(42),o=n(15),a=n(61),s=n(19),u=n(154),c=s("species"),l=!o(function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t;},"7"!=="".replace(t,"$<a>");}),f=function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments);};var n="ab".split(t);return 2===n.length&&"a"===n[0]&&"b"===n[1];}();t.exports=function(t,e,n){var h=s(t),d=!o(function(){var e={};return e[h]=function(){return 7;},7!=""[t](e);}),p=d?!o(function(){var e=!1,n=/a/;return n.exec=function(){return e=!0,null;},"split"===t&&(n.constructor={},n.constructor[c]=function(){return n;}),n[h](""),!e;}):void 0;if(!d||!p||"replace"===t&&!l||"split"===t&&!f){var m=/./[h],g=n(a,h,""[t],function(t,e,n,r,i){return e.exec===u?d&&!i?{done:!0,value:m.call(e,n,r)}:{done:!0,value:t.call(n,e,r)}:{done:!1};}),v=g[0],y=g[1];r(String.prototype,t,v),i(RegExp.prototype,h,2==e?function(t,e){return y.call(t,this,e);}:function(t){return y.call(t,this);});}};},function(t,e,n){var r=n(105),i=RegExp.prototype.exec;t.exports=function(t,e){var n=t.exec;if("function"==typeof n){var o=n.call(t,e);if("object"!=_typeof$1(o))throw new TypeError("RegExp exec method returned something other than an Object or null");return o;}if("RegExp"!==r(t))throw new TypeError("RegExp#exec called on incompatible receiver");return i.call(t,e);};},function(t,e,n){var r=n(14);t.exports=function(){var t=r(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e;};},function(t,e,n){var r=n(19)("iterator"),i=!1;try{var o=[7][r]();o.return=function(){i=!0;},Array.from(o,function(){throw 2;});}catch(t){}t.exports=function(t,e){if(!e&&!i)return !1;var n=!1;try{var o=[7],a=o[r]();a.next=function(){return {done:n=!0};},o[r]=function(){return a;},t(o);}catch(t){}return n;};},function(t,e,n){var r=n(62);t.exports=Array.isArray||function(t){return "Array"==r(t);};},function(t,e){e.f=Object.getOwnPropertySymbols;},function(t,e,n){var r=n(41),i=n(22),o=n(81);t.exports=function(t){return function(e,n,a){var s,u=r(e),c=i(u.length),l=o(a,c);if(t&&n!=n){for(;c>l;){if((s=u[l++])!=s)return !0;}}else for(;c>l;l++){if((t||l in u)&&u[l]===n)return t||l||0;}return !t&&-1;};};},function(t,e,n){var r=n(24),i=n(16),o=i["__core-js_shared__"]||(i["__core-js_shared__"]={});(t.exports=function(t,e){return o[t]||(o[t]=void 0!==e?e:{});})("versions",[]).push({version:r.version,mode:n(83)?"pure":"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"});},function(t,e,n){n.r(e),function(t,r){n.d(e,"array",function(){return X;}),n.d(e,"Dataset",function(){return G;}),n.d(e,"zip",function(){return Y;}),n.d(e,"CSVDataset",function(){return it;}),n.d(e,"TextLineDataset",function(){return Q;}),n.d(e,"csv",function(){return bt;}),n.d(e,"func",function(){return xt;}),n.d(e,"generator",function(){return wt;}),n.d(e,"microphone",function(){return Et;}),n.d(e,"webcam",function(){return kt;}),n.d(e,"FileDataSource",function(){return vt;}),n.d(e,"URLDataSource",function(){return yt;}),n.d(e,"version_data",function(){return Ct;});var i=n(0),_o97=function o(t,e){return (_o97=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e;}||function(t,e){for(var n in e){e.hasOwnProperty(n)&&(t[n]=e[n]);}})(t,e);};/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */function a(t,e){function n(){this.constructor=t;}_o97(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n());}function s(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});}function u(t,e){var n,r,i,o,a={label:0,sent:function sent(){if(1&i[0])throw i[1];return i[1];},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this;}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;){try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue;}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break;}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break;}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break;}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(t,a);}catch(t){o=[6,t],r=0;}finally{n=i=0;}}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:!0};}([o,s]);};}}function c(t,e){return t(e={exports:{}},e.exports),e.exports;}var l=c(function(t){!function(t,e,n){function r(t,e){return e.c=t.c,e.s0=t.s0,e.s1=t.s1,e.s2=t.s2,e;}function i(t,e){var n=new function(t){var e,n=this,r=(e=4022871197,function(t){t=t.toString();for(var n=0;n<t.length;n++){var r=.02519603282416938*(e+=t.charCodeAt(n));r-=e=r>>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e);}return 2.3283064365386963e-10*(e>>>0);});n.next=function(){var t=2091639*n.s0+2.3283064365386963e-10*n.c;return n.s0=n.s1,n.s1=n.s2,n.s2=t-(n.c=0|t);},n.c=1,n.s0=r(" "),n.s1=r(" "),n.s2=r(" "),n.s0-=r(t),n.s0<0&&(n.s0+=1),n.s1-=r(t),n.s1<0&&(n.s1+=1),n.s2-=r(t),n.s2<0&&(n.s2+=1),r=null;}(t),i=e&&e.state,o=n.next;return o.int32=function(){return 4294967296*n.next()|0;},o.double=function(){return o()+1.1102230246251565e-16*(2097152*o()|0);},o.quick=o,i&&("object"==_typeof$1(i)&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.alea=i;}(0,t);}),f=c(function(t){!function(t,e,n){function r(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e;}function i(t,e){var n=new function(t){var e=this,n="";e.x=0,e.y=0,e.z=0,e.w=0,e.next=function(){var t=e.x^e.x<<11;return e.x=e.y,e.y=e.z,e.z=e.w,e.w^=e.w>>>19^t^t>>>8;},t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++){e.x^=0|n.charCodeAt(r),e.next();}}(t),i=e&&e.state,o=function o(){return (n.next()>>>0)/4294967296;};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);}while(0===t);return t;},o.int32=n.next,o.quick=o,i&&("object"==_typeof$1(i)&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.xor128=i;}(0,t);}),h=c(function(t){!function(t,e,n){function r(t,e){return e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w,e.v=t.v,e.d=t.d,e;}function i(t,e){var n=new function(t){var e=this,n="";e.next=function(){var t=e.x^e.x>>>2;return e.x=e.y,e.y=e.z,e.z=e.w,e.w=e.v,(e.d=e.d+362437|0)+(e.v=e.v^e.v<<4^t^t<<1)|0;},e.x=0,e.y=0,e.z=0,e.w=0,e.v=0,t===(0|t)?e.x=t:n+=t;for(var r=0;r<n.length+64;r++){e.x^=0|n.charCodeAt(r),r==n.length&&(e.d=e.x<<10^e.x>>>4),e.next();}}(t),i=e&&e.state,o=function o(){return (n.next()>>>0)/4294967296;};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);}while(0===t);return t;},o.int32=n.next,o.quick=o,i&&("object"==_typeof$1(i)&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.xorwow=i;}(0,t);}),d=c(function(t){!function(t,e,n){function r(t,e){return e.x=t.x.slice(),e.i=t.i,e;}function i(t,e){null==t&&(t=+new Date());var n=new function(t){var e=this;e.next=function(){var t,n,r=e.x,i=e.i;return t=r[i],n=(t^=t>>>7)^t<<24,n^=(t=r[i+1&7])^t>>>10,n^=(t=r[i+3&7])^t>>>3,n^=(t=r[i+4&7])^t<<7,t=r[i+7&7],n^=(t^=t<<13)^t<<9,r[i]=n,e.i=i+1&7,n;},function(t,e){var n,r=[];if(e===(0|e))r[0]=e;else for(e=""+e,n=0;n<e.length;++n){r[7&n]=r[7&n]<<15^e.charCodeAt(n)+r[n+1&7]<<13;}for(;r.length<8;){r.push(0);}for(n=0;n<8&&0===r[n];++n){}for(8==n?r[7]=-1:r[n],t.x=r,t.i=0,n=256;n>0;--n){t.next();}}(e,t);}(t),i=e&&e.state,o=function o(){return (n.next()>>>0)/4294967296;};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);}while(0===t);return t;},o.int32=n.next,o.quick=o,i&&(i.x&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.xorshift7=i;}(0,t);}),p=c(function(t){!function(t,e,n){function r(t,e){return e.i=t.i,e.w=t.w,e.X=t.X.slice(),e;}function i(t,e){null==t&&(t=+new Date());var n=new function(t){var e=this;e.next=function(){var t,n,r=e.w,i=e.X,o=e.i;return e.w=r=r+1640531527|0,n=i[o+34&127],t=i[o=o+1&127],n^=n<<13,t^=t<<17,n^=n>>>15,t^=t>>>12,n=i[o]=n^t,e.i=o,n+(r^r>>>16)|0;},function(t,e){var n,r,i,o,a,s=[],u=128;for(e===(0|e)?(r=e,e=null):(e+="\0",r=0,u=Math.max(u,e.length)),i=0,o=-32;o<u;++o){e&&(r^=e.charCodeAt((o+32)%e.length)),0===o&&(a=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,o>=0&&(a=a+1640531527|0,i=0==(n=s[127&o]^=r+a)?i+1:0);}for(i>=128&&(s[127&(e&&e.length||0)]=-1),i=127,o=512;o>0;--o){r=s[i+34&127],n=s[i=i+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,s[i]=r^n;}t.w=a,t.X=s,t.i=i;}(e,t);}(t),i=e&&e.state,o=function o(){return (n.next()>>>0)/4294967296;};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);}while(0===t);return t;},o.int32=n.next,o.quick=o,i&&(i.X&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.xor4096=i;}(0,t);}),m=c(function(t){!function(t,e,n){function r(t,e){return e.a=t.a,e.b=t.b,e.c=t.c,e.d=t.d,e;}function i(t,e){var n=new function(t){var e=this,n="";e.next=function(){var t=e.b,n=e.c,r=e.d,i=e.a;return t=t<<25^t>>>7^n,n=n-r|0,r=r<<24^r>>>8^i,i=i-t|0,e.b=t=t<<20^t>>>12^n,e.c=n=n-r|0,e.d=r<<16^n>>>16^i,e.a=i-t|0;},e.a=0,e.b=0,e.c=-1640531527,e.d=1367130551,t===Math.floor(t)?(e.a=t/4294967296|0,e.b=0|t):n+=t;for(var r=0;r<n.length+20;r++){e.b^=0|n.charCodeAt(r),e.next();}}(t),i=e&&e.state,o=function o(){return (n.next()>>>0)/4294967296;};return o.double=function(){do{var t=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);}while(0===t);return t;},o.int32=n.next,o.quick=o,i&&("object"==_typeof$1(i)&&r(i,n),o.state=function(){return r(n,{});}),o;}e&&e.exports?e.exports=i:this.tychei=i;}(0,t);}),g=c(function(t){!function(e,r){var i,o=this,a=256,s=6,u="random",c=r.pow(a,s),l=r.pow(2,52),f=2*l,h=a-1;function d(t,n,d){var v=[],y=m(function t(e,n){var r,i=[],o=_typeof$1(e);if(n&&"object"==o)for(r in e){try{i.push(t(e[r],n-1));}catch(t){}}return i.length?i:"string"==o?e:e+"\0";}((n=1==n?{entropy:!0}:n||{}).entropy?[t,g(e)]:null==t?function(){try{var t;return i&&(t=i.randomBytes)?t=t(a):(t=new Uint8Array(a),(o.crypto||o.msCrypto).getRandomValues(t)),g(t);}catch(t){var n=o.navigator,r=n&&n.plugins;return [+new Date(),o,r,o.screen,g(e)];}}():t,3),v),b=new function(t){var e,n=t.length,r=this,i=0,o=r.i=r.j=0,s=r.S=[];for(n||(t=[n++]);i<a;){s[i]=i++;}for(i=0;i<a;i++){s[i]=s[o=h&o+t[i%n]+(e=s[i])],s[o]=e;}(r.g=function(t){for(var e,n=0,i=r.i,o=r.j,s=r.S;t--;){e=s[i=h&i+1],n=n*a+s[h&(s[i]=s[o=h&o+e])+(s[o]=e)];}return r.i=i,r.j=o,n;})(a);}(v),x=function x(){for(var t=b.g(s),e=c,n=0;t<l;){t=(t+n)*a,e*=a,n=b.g(1);}for(;t>=f;){t/=2,e/=2,n>>>=1;}return (t+n)/e;};return x.int32=function(){return 0|b.g(4);},x.quick=function(){return b.g(4)/4294967296;},x.double=x,m(g(b.S),e),(n.pass||d||function(t,e,n,i){return i&&(i.S&&p(i,b),t.state=function(){return p(b,{});}),n?(r[u]=t,e):t;})(x,y,"global"in n?n.global:this==r,n.state);}function p(t,e){return e.i=t.i,e.j=t.j,e.S=t.S.slice(),e;}function m(t,e){for(var n,r=t+"",i=0;i<r.length;){e[h&i]=h&(n^=19*e[h&i])+r.charCodeAt(i++);}return g(e);}function g(t){return String.fromCharCode.apply(0,t);}if(r["seed"+u]=d,m(r.random(),e),t.exports){t.exports=d;try{i=n(387);}catch(t){}}}([],Math);});g.alea=l,g.xor128=f,g.xorwow=h,g.xorshift7=d,g.xor4096=p,g.tychei=m;var v=g.alea;function y(t,e,n,r){if(void 0===n&&(n=new Map()),void 0===r&&(r=new Set()),null==t)return null;if(r.has(t))throw new Error("Circular references are not supported.");if(n.has(t))return n.get(t);var i=e(t);if(i.recurse&&null!==i.value)throw new Error("A deep map function may not return both a value and recurse=true.");if(i.recurse){if(k(t)){var o=Array.isArray(t)?[]:{};for(var a in r.add(t),t){var s=y(t[a],e,n,r);o[a]=s;}return r.delete(t),o;}throw new Error("Can't recurse into non-iterable type: "+t);}return n.set(t,i.value),i.value;}function b(t,e){return void 0===e&&(e=x),function t(e,n,r){void 0===r&&(r=new Set());var i=e[0];if(r.has(i))throw new Error("Circular references are not supported.");var o=n(e);if(o.recurse&&null!==o.value)throw new Error("A deep zip function may not return both a value and recurse=true.");if(o.recurse){if(k(i)){var a=Array.isArray(i)?[]:{};r.add(i);var s=function s(i){var o=t(e.map(function(t){return t[i];}),n,r);a[i]=o;};for(var u in i){s(u);}return r.delete(i),a;}throw new Error("Can't recurse into non-iterable type: "+i);}return o.value;}(t,e);}function x(t){return null===t?null:k(t[0])?{value:null,recurse:!0}:{value:t,recurse:!1};}function w(t,e){return s(this,void 0,void 0,function(){var n,r,i,o,a,s;return u(this,function(u){switch(u.label){case 0:n=new Map(),y(t,e,n),r=0,i=Array.from(n.keys()),u.label=1;case 1:return r<i.length?(o=i[r],(a=n.get(o))instanceof Promise?[4,a]:[3,3]):[3,4];case 2:s=u.sent(),n.set(o,s),u.label=3;case 3:return r++,[3,1];case 4:return [2,y(t,e,n)];}});});}function k(t){return null!=t&&!ArrayBuffer.isView(t)&&(Array.isArray(t)||"object"==_typeof$1(t)&&!(t instanceof i.Tensor));}function E(t){return function(t,e){return y(t,e);}(t,C);}function C(t){return t instanceof i.Tensor?{value:t.clone(),recurse:!1}:k(t)?{value:null,recurse:!0}:{value:t,recurse:!1};}var A=function(){function t(t){if(this.capacity=t,this.begin=0,this.end=0,null==t)throw new RangeError("Can't create a ring buffer of unknown capacity.");if(t<1)throw new RangeError("Can't create ring buffer of capacity < 1.");this.data=new Array(t),this.doubledCapacity=2*t;}return t.prototype.wrap=function(t){for(;t<0;){t+=this.doubledCapacity;}return t%this.doubledCapacity;},t.prototype.get=function(t){if(t<0)throw new RangeError("Can't get item at a negative index.");return this.data[t%this.capacity];},t.prototype.set=function(t,e){if(t<0)throw new RangeError("Can't set item at a negative index.");this.data[t%this.capacity]=e;},t.prototype.length=function(){var t=this.end-this.begin;return t<0&&(t=this.doubledCapacity+t),t;},t.prototype.isFull=function(){return this.length()===this.capacity;},t.prototype.isEmpty=function(){return 0===this.length();},t.prototype.push=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.set(this.end,t),this.end=this.wrap(this.end+1);},t.prototype.pushAll=function(t){for(var e=0,n=t;e<n.length;e++){var r=n[e];this.push(r);}},t.prototype.pop=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");this.end=this.wrap(this.end-1);var t=this.get(this.end);return this.set(this.end,void 0),t;},t.prototype.unshift=function(t){if(this.isFull())throw new RangeError("Ring buffer is full.");this.begin=this.wrap(this.begin-1),this.set(this.begin,t);},t.prototype.shift=function(){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var t=this.get(this.begin);return this.set(this.begin,void 0),this.begin=this.wrap(this.begin+1),t;},t.prototype.shuffleExcise=function(t){if(this.isEmpty())throw new RangeError("Ring buffer is empty.");var e=this.wrap(this.begin+t),n=this.get(e);return this.set(e,this.pop()),n;},t;}(),O=function(t){function e(){return t.call(this,e.INITIAL_CAPACITY)||this;}return a(e,t),e.prototype.isFull=function(){return !1;},e.prototype.push=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.push.call(this,e);},e.prototype.unshift=function(e){t.prototype.isFull.call(this)&&this.expand(),t.prototype.unshift.call(this,e);},e.prototype.expand=function(){for(var t=2*this.capacity,e=new Array(t),n=this.length(),r=0;r<n;r++){e[r]=this.get(this.wrap(this.begin+r));}this.data=e,this.capacity=t,this.doubledCapacity=2*this.capacity,this.begin=0,this.end=n;},e.INITIAL_CAPACITY=32,e;}(A);function _(t){return new T(t);}function S(t){return new N(t);}var D,F=function(){function t(){}return t.prototype.toArray=function(){return s(this,void 0,void 0,function(){var t,e;return u(this,function(n){switch(n.label){case 0:return t=[],[4,this.next()];case 1:e=n.sent(),n.label=2;case 2:return e.done?[3,4]:(t.push(e.value),[4,this.next()]);case 3:return e=n.sent(),[3,2];case 4:return [2,t];}});});},t.prototype.toArrayForTest=function(){return s(this,void 0,void 0,function(){var t,e,n;return u(this,function(r){switch(r.label){case 0:return t=this.prefetch(100),e=[],[4,t.next()];case 1:n=r.sent(),r.label=2;case 2:return n.done?[3,4]:(e.push(n.value),[4,t.next()]);case 3:return n=r.sent(),[3,2];case 4:return [2,e];}});});},t.prototype.resolveFully=function(){return s(this,void 0,void 0,function(){var t;return u(this,function(e){switch(e.label){case 0:return [4,this.next()];case 1:t=e.sent(),e.label=2;case 2:return t.done?[3,4]:[4,this.next()];case 3:return t=e.sent(),[3,2];case 4:return [2];}});});},t.prototype.resolveWhile=function(t){return s(this,void 0,void 0,function(){var e,n;return u(this,function(r){switch(r.label){case 0:return [4,this.next()];case 1:e=r.sent(),n=t(e.value),r.label=2;case 2:return e.done||!n?[3,4]:[4,this.next()];case 3:return e=r.sent(),n=t(e.value),[3,2];case 4:return [2];}});});},t.prototype.handleErrors=function(t){return new L(this,t);},t.prototype.filter=function(t){return new B(this,t);},t.prototype.map=function(t){return new P(this,t);},t.prototype.mapAsync=function(t){return new z(this,t);},t.prototype.serialMapAsync=function(t){return new z(this,t).serial();},t.prototype.flatmap=function(t){return new W(this,t);},t.prototype.forEachAsync=function(t){return s(this,void 0,void 0,function(){return u(this,function(e){return [2,this.map(t).resolveFully()];});});},t.prototype.serialForEach=function(t){return s(this,void 0,void 0,function(){return u(this,function(e){return [2,this.serialMapAsync(t).resolveWhile(function(t){return !0===t;})];});});},t.prototype.rowMajorBatch=function(t,e){return void 0===e&&(e=!0),new j(this,t,e);},t.prototype.columnMajorBatch=function(t,e,n){return void 0===e&&(e=!0),void 0===n&&(n=x),this.rowMajorBatch(t,e).map(function(t){return b(t,n);});},t.prototype.concatenate=function(t,e){return new V(_([this,t]),e);},t.prototype.take=function(t){return t<0||null==t?this:new M(this,t);},t.prototype.skip=function(t){return t<0||null==t?this:new R(this,t);},t.prototype.prefetch=function(t){return new $(this,t);},t.prototype.shuffle=function(t,e){return new H(this,t,e);},t.prototype.serial=function(){return new I(this);},t;}(),T=function(t){function e(e){var n=t.call(this)||this;return n.items=e,n.trav=0,n;}return a(e,t),e.prototype.summary=function(){return "Array of "+this.items.length+" items";},e.prototype.next=function(){return s(this,void 0,void 0,function(){var t;return u(this,function(e){return this.trav>=this.items.length?[2,{value:null,done:!0}]:(t=this.items[this.trav],this.trav++,[2,{value:E(t),done:!1}]);});});},e;}(F),N=function(t){function e(e){var n=t.call(this)||this;return n.nextFn=e,n;}return a(e,t),e.prototype.summary=function(){return "Function call";},e.prototype.next=function(){return s(this,void 0,void 0,function(){return u(this,function(t){try{return [2,this.nextFn()];}catch(t){throw t.message="Error thrown while iterating through a dataset: "+t.message,t;}return [2];});});},e;}(F),I=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.lastRead=Promise.resolve({value:null,done:!1}),n;}return a(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Serial";},e.prototype.next=function(){return s(this,void 0,void 0,function(){var t=this;return u(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext();}),[2,this.lastRead];});});},e.prototype.serialNext=function(){return s(this,void 0,void 0,function(){return u(this,function(t){return [2,this.upstream.next()];});});},e;}(F),R=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r;}return a(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Skip";},e.prototype.next=function(){return s(this,void 0,void 0,function(){var t=this;return u(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext();}),[2,this.lastRead];});});},e.prototype.serialNext=function(){return s(this,void 0,void 0,function(){var t;return u(this,function(e){switch(e.label){case 0:return this.count++<this.maxCount?[4,this.upstream.next()]:[3,2];case 1:return (t=e.sent()).done?[2,t]:(Object(i.dispose)(t.value),[3,0]);case 2:return [2,this.upstream.next()];}});});},e;}(F),M=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.maxCount=n,r.count=0,r;}return a(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Take";},e.prototype.next=function(){return s(this,void 0,void 0,function(){return u(this,function(t){return this.count++>=this.maxCount?[2,{value:null,done:!0}]:[2,this.upstream.next()];});});},e;}(F),j=function(t){function e(e,n,r){void 0===r&&(r=!0);var i=t.call(this)||this;return i.upstream=e,i.batchSize=n,i.enableSmallLastBatch=r,i.lastRead=Promise.resolve({value:null,done:!1}),i;}return a(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> RowMajorBatch";},e.prototype.next=function(){return s(this,void 0,void 0,function(){var t=this;return u(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext();}),[2,this.lastRead];});});},e.prototype.serialNext=function(){return s(this,void 0,void 0,function(){var t,e;return u(this,function(n){switch(n.label){case 0:t=[],n.label=1;case 1:return t.length<this.batchSize?[4,this.upstream.next()]:[3,3];case 2:return (e=n.sent()).done?this.enableSmallLastBatch&&t.length>0?[2,{value:t,done:!1}]:[2,{value:null,done:!0}]:(t.push(e.value),[3,1]);case 3:return [2,{value:t,done:!1}];}});});},e;}(F),B=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.predicate=n,r.lastRead=Promise.resolve({value:null,done:!1}),r;}return a(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Filter";},e.prototype.next=function(){return s(this,void 0,void 0,function(){var t=this;return u(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext();}),[2,this.lastRead];});});},e.prototype.serialNext=function(){return s(this,void 0,void 0,function(){var t;return u(this,function(e){switch(e.label){case 0:return [4,this.upstream.next()];case 1:return (t=e.sent()).done||this.predicate(t.value)?[2,t]:(Object(i.dispose)(t.value),[3,0]);case 2:return [2];}});});},e;}(F),P=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r;}return a(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Map";},e.prototype.next=function(){return s(this,void 0,void 0,function(){var t,e,n,r,o,a,s;return u(this,function(u){switch(u.label){case 0:return [4,this.upstream.next()];case 1:if((t=u.sent()).done)return [2,{value:null,done:!0}];for(e=i.tensor_util.getTensorsInContainer(t.value),n=this.transform(t.value),r=i.tensor_util.getTensorsInContainer(n),o=0,a=e;o<a.length;o++){s=a[o],i.tensor_util.isTensorInList(s,r)||s.dispose();}return [2,{value:n,done:!1}];}});});},e;}(F),L=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.handler=n,r.count=0,r.lastRead=Promise.resolve({value:null,done:!1}),r;}return a(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> handleErrors";},e.prototype.next=function(){return s(this,void 0,void 0,function(){var t=this;return u(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext();}),[2,this.lastRead];});});},e.prototype.serialNext=function(){return s(this,void 0,void 0,function(){var t;return u(this,function(e){switch(e.label){case 0:e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.upstream.next()];case 2:return [2,e.sent()];case 3:return t=e.sent(),this.handler(t)?[3,4]:[2,{value:null,done:!0}];case 4:return [3,0];case 5:return [2];}});});},e;}(F),z=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r;}return a(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> AsyncMap";},e.prototype.next=function(){return s(this,void 0,void 0,function(){var t,e,n,r,o,a,s;return u(this,function(u){switch(u.label){case 0:return [4,this.upstream.next()];case 1:return (t=u.sent()).done?[2,{value:null,done:!0}]:(e=i.tensor_util.getTensorsInContainer(t.value),[4,this.transform(t.value)]);case 2:for(n=u.sent(),r=i.tensor_util.getTensorsInContainer(n),o=0,a=e;o<a.length;o++){s=a[o],i.tensor_util.isTensorInList(s,r)||s.dispose();}return [2,{value:n,done:!1}];}});});},e;}(F),U=function(t){function e(){var e=t.call(this)||this;return e.outputQueue=new O(),e.lastRead=Promise.resolve({value:null,done:!1}),e;}return a(e,t),e.prototype.next=function(){return s(this,void 0,void 0,function(){var t=this;return u(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext();}),[2,this.lastRead];});});},e.prototype.serialNext=function(){return s(this,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return 0!==this.outputQueue.length()?[3,2]:[4,this.pump()];case 1:return t.sent()?[3,0]:[2,{value:null,done:!0}];case 2:return [2,{value:this.outputQueue.shift(),done:!1}];}});});},e;}(F),W=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.transform=n,r;}return a(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Flatmap";},e.prototype.pump=function(){return s(this,void 0,void 0,function(){var t,e,n,r,o,a,s;return u(this,function(u){switch(u.label){case 0:return [4,this.upstream.next()];case 1:if((t=u.sent()).done)return [2,!1];for(e=i.tensor_util.getTensorsInContainer(t.value),n=this.transform(t.value),r=i.tensor_util.getTensorsInContainer(n),this.outputQueue.pushAll(n),o=0,a=e;o<a.length;o++){s=a[o],i.tensor_util.isTensorInList(s,r)||s.dispose();}return [2,!0];}});});},e;}(U),V=function(t){function e(e,n){var r=t.call(this)||this;return r.baseErrorHandler=n,r.lastRead=null,r.iterator=null,r.moreIterators=e,r;}return a(e,t),e.prototype.summary=function(){return "TODO: fill in upstream of chained summaries -> Chained";},e.prototype.next=function(){return s(this,void 0,void 0,function(){return u(this,function(t){return this.lastRead=this.readFromChain(this.lastRead),[2,this.lastRead];});});},e.prototype.readFromChain=function(t){return s(this,void 0,void 0,function(){var e,n;return u(this,function(r){switch(r.label){case 0:return [4,t];case 1:return r.sent(),null!=this.iterator?[3,3]:[4,this.moreIterators.next()];case 2:if((e=r.sent()).done)return [2,{value:null,done:!0}];this.iterator=e.value,null!=this.baseErrorHandler&&(this.iterator=this.iterator.handleErrors(this.baseErrorHandler)),r.label=3;case 3:return [4,this.iterator.next()];case 4:return (n=r.sent()).done?(this.iterator=null,[2,this.readFromChain(t)]):[2,n];}});});},e;}(F);!function(t){t[t.FAIL=0]="FAIL",t[t.SHORTEST=1]="SHORTEST",t[t.LONGEST=2]="LONGEST";}(D||(D={}));var q=function(t){function e(e,n){void 0===n&&(n=D.FAIL);var r=t.call(this)||this;return r.iterators=e,r.mismatchMode=n,r.count=0,r.currentPromise=null,r;}return a(e,t),e.prototype.summary=function(){return "{TODO: fill in upstream of zip summaries} -> Zip";},e.prototype.nextState=function(t){return s(this,void 0,void 0,function(){function e(t){return t instanceof F?{value:t.next().then(function(t){return n++,t.done&&r++,t.value;}),recurse:!1}:{value:null,recurse:!0};}var n,r,i;return u(this,function(o){switch(o.label){case 0:return [4,t];case 1:return o.sent(),n=0,r=0,[4,w(this.iterators,e)];case 2:if(i=o.sent(),n===r)return [2,{value:null,done:!0}];if(r>0)switch(this.mismatchMode){case D.FAIL:throw new Error("Zipped streams should have the same length. Mismatched at element "+this.count+".");case D.SHORTEST:return [2,{value:null,done:!0}];case D.LONGEST:}return this.count++,[2,{value:i,done:!1}];}});});},e.prototype.next=function(){return s(this,void 0,void 0,function(){return u(this,function(t){return this.currentPromise=this.nextState(this.currentPromise),[2,this.currentPromise];});});},e;}(F),$=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.bufferSize=n,r.buffer=new A(n),r;}return a(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Prefetch";},e.prototype.refill=function(){for(;!this.buffer.isFull();){var t=this.upstream.next();this.buffer.push(t);}},e.prototype.next=function(){return this.refill(),this.buffer.shift();},e;}(F),H=function(t){function e(e,n,r){var o=t.call(this,e,n)||this;return o.upstream=e,o.windowSize=n,o.upstreamExhausted=!1,o.random=v(r||i.util.now().toString()),o.lastRead=Promise.resolve({value:null,done:!1}),o;}return a(e,t),e.prototype.next=function(){return s(this,void 0,void 0,function(){var t=this;return u(this,function(e){return this.lastRead=this.lastRead.then(function(){return t.serialNext();}),[2,this.lastRead];});});},e.prototype.randomInt=function(t){return Math.floor(this.random()*t);},e.prototype.chooseIndex=function(){return this.randomInt(this.buffer.length());},e.prototype.serialNext=function(){return s(this,void 0,void 0,function(){var t,e;return u(this,function(n){switch(n.label){case 0:this.upstreamExhausted||this.refill(),n.label=1;case 1:return this.buffer.isEmpty()?[3,3]:(t=this.chooseIndex(),[4,this.buffer.shuffleExcise(t)]);case 2:return (e=n.sent()).done?(this.upstreamExhausted=!0,[3,1]):(this.refill(),[2,e]);case 3:return [2,{value:null,done:!0}];}});});},e;}($),G=function(){function t(){this.size=null;}return t.prototype.batch=function(t,e){var n=this;void 0===e&&(e=!0);var r=this;return i.util.assert(t>0,function(){return "batchSize needs to be positive, but it is\n      "+t;}),K(function(){return s(n,void 0,void 0,function(){return u(this,function(n){switch(n.label){case 0:return [4,r.iterator()];case 1:return [2,n.sent().columnMajorBatch(t,e,J)];}});});},this.size===1/0||null==this.size?this.size:e?Math.ceil(this.size/t):Math.floor(this.size/t));},t.prototype.concatenate=function(t){var e=this,n=this;return K(function(){return s(e,void 0,void 0,function(){var e,r;return u(this,function(i){switch(i.label){case 0:return [4,n.iterator()];case 1:return r=(e=i.sent()).concatenate,[4,t.iterator()];case 2:return [2,r.apply(e,[i.sent()])];}});});},this.size===1/0||t.size===1/0?1/0:null!=this.size&&null!=t.size?this.size+t.size:null);},t.prototype.filter=function(t){var e=this,n=this;return K(function(){return s(e,void 0,void 0,function(){return u(this,function(e){switch(e.label){case 0:return [4,n.iterator()];case 1:return [2,e.sent().filter(function(e){return Object(i.tidy)(function(){return t(e);});})];}});});},this.size===1/0?1/0:null);},t.prototype.forEachAsync=function(t){return s(this,void 0,void 0,function(){return u(this,function(e){switch(e.label){case 0:return [4,this.iterator()];case 1:return [2,e.sent().forEachAsync(t)];}});});},t.prototype.forEach=function(t){return s(this,void 0,void 0,function(){return u(this,function(e){return Object(i.deprecationWarn)("dataset.forEach() is deprecated and will be removed. Please use dataset.forEachAsync() instead"),[2,this.forEachAsync(t)];});});},t.prototype.map=function(t){var e=this,n=this;return K(function(){return s(e,void 0,void 0,function(){return u(this,function(e){switch(e.label){case 0:return [4,n.iterator()];case 1:return [2,e.sent().map(function(e){return Object(i.tidy)(function(){return t(e);});})];}});});},this.size);},t.prototype.mapAsync=function(t){var e=this,n=this;return K(function(){return s(e,void 0,void 0,function(){return u(this,function(e){switch(e.label){case 0:return [4,n.iterator()];case 1:return [2,e.sent().mapAsync(t)];}});});},this.size);},t.prototype.prefetch=function(t){var e=this;if(null==t)throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");var n=this;return K(function(){return s(e,void 0,void 0,function(){return u(this,function(e){switch(e.label){case 0:return [4,n.iterator()];case 1:return [2,e.sent().prefetch(t)];}});});},this.size);},t.prototype.repeat=function(t){var e=this,n=this;return K(function(){return s(e,void 0,void 0,function(){var e=this;return u(this,function(r){return [2,function(t,e){return new V(t,e);}(S(function(){return s(e,void 0,void 0,function(){var t;return u(this,function(e){switch(e.label){case 0:return t={},[4,n.iterator()];case 1:return [2,(t.value=e.sent(),t.done=!1,t)];}});});}).take(t))];});});},null!=this.size&&t>0?this.size*t:0===t?0:null!=this.size&&(void 0===t||t<0)?1/0:null);},t.prototype.skip=function(t){var e=this,n=this;return K(function(){return s(e,void 0,void 0,function(){return u(this,function(e){switch(e.label){case 0:return [4,n.iterator()];case 1:return [2,e.sent().skip(t)];}});});},null!=this.size&&t>=0&&this.size>=t?this.size-t:null!=this.size&&(this.size<t||void 0===t||t<0)?0:null);},t.prototype.shuffle=function(t,e,n){var r=this;if(void 0===n&&(n=!0),null==t||t<0)throw null==this.size?new RangeError("`Dataset.shuffle()` requires bufferSize to be specified."):new RangeError("`Dataset.shuffle()` requires bufferSize to be specified.  If your data fits in main memory (for regular JS objects), and/or GPU memory (for `tf.Tensor`s), consider setting bufferSize to the dataset size ("+this.size+" elements)");var o=this,a=v(e||i.util.now().toString());return K(function(){return s(r,void 0,void 0,function(){var e;return u(this,function(r){switch(r.label){case 0:return e=a.int32(),n&&(e+=a.int32()),[4,o.iterator()];case 1:return [2,r.sent().shuffle(t,e.toString())];}});});},this.size);},t.prototype.take=function(t){var e=this,n=this;return K(function(){return s(e,void 0,void 0,function(){return u(this,function(e){switch(e.label){case 0:return [4,n.iterator()];case 1:return [2,e.sent().take(t)];}});});},null!=this.size&&this.size>t?t:null!=this.size&&this.size<=t?this.size:null);},t.prototype.toArray=function(){return s(this,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return [4,this.iterator()];case 1:return [2,t.sent().toArray()];}});});},t.prototype.toArrayForTest=function(){return s(this,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:if(this.size===1/0)throw new Error("Can not convert infinite data stream to array.");return [4,this.iterator()];case 1:return [2,t.sent().toArrayForTest()];}});});},t.MAX_BUFFER_SIZE=1e4,t;}();function K(t,e){return void 0===e&&(e=null),new(function(n){function r(){var t=null!==n&&n.apply(this,arguments)||this;return t.size=e,t;}return a(r,n),r.prototype.iterator=function(){return s(this,void 0,void 0,function(){return u(this,function(e){return [2,t()];});});},r;}(G))();}function X(t){var e=this;return K(function(){return s(e,void 0,void 0,function(){return u(this,function(e){return [2,_(t)];});});},t.length);}function Y(t){var e,n=this;if(!k(t))throw new Error("The argument to zip() must be an object or array.");if(Array.isArray(t))for(var r=0;r<t.length;r++){e=null==e?t[r].size:Math.min(e,t[r].size);}else if(t instanceof Object)for(var i in t){e=null==e?t[i].size:Math.min(e,t[i].size);}return K(function(){return s(n,void 0,void 0,function(){return u(this,function(e){switch(e.label){case 0:return [4,w(t,function(t){if(t instanceof G)return {value:t.iterator(),recurse:!1};if(k(t))return {value:null,recurse:!0};throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.");})];case 1:return [2,function(t,e){return void 0===e&&(e=D.FAIL),new q(t,e);}(e.sent(),D.SHORTEST)];}});});},e);}function J(t){return null===t?null:function(t){return null==t||function(t){return null===t||"object"!=_typeof$1(t)&&"function"!=typeof t;}(t)||Array.isArray(t)||"object"==_typeof$1(t)&&t instanceof i.Tensor||i.util.isTypedArray(t);}(t[0])?{value:function(t){if(0===t.length)throw new Error("Can't make a batch of zero elements.");return t[0]instanceof i.Tensor?Object(i.stack)(t):Object(i.tensor)(t);}(t),recurse:!1}:{value:null,recurse:!0};}var Q=function(t){function e(e){var n=t.call(this)||this;return n.input=e,n;}return a(e,t),e.prototype.iterator=function(){return s(this,void 0,void 0,function(){var t;return u(this,function(e){switch(e.label){case 0:return [4,this.input.iterator()];case 1:return t=e.sent(),[2,t.decodeUTF8().split("\n").map(function(t){return t.endsWith("\r")&&(t=t.slice(0,-1)),t;})];}});});},e;}(G),Z=Symbol("out"),tt=Symbol("field"),et=Symbol("quote"),nt=Symbol("quoteafterquote"),rt=Symbol("quoteinquote"),it=function(t){function e(e,n){var r=t.call(this)||this;return r.input=e,r.hasHeader=!0,r.fullColumnNames=null,r.columnNamesValidated=!1,r.columnConfigs=null,r.configuredColumnsOnly=!1,r.delimiter=",",r.delimWhitespace=!1,r.base=new Q(e),n||(n={}),r.hasHeader=!1!==n.hasHeader,r.fullColumnNames=n.columnNames,r.columnConfigs=n.columnConfigs,r.configuredColumnsOnly=n.configuredColumnsOnly,n.delimWhitespace?(i.util.assert(null==n.delimiter,function(){return "Delimiter should not be provided when delimWhitespace is true.";}),r.delimWhitespace=!0,r.delimiter=" "):r.delimiter=n.delimiter?n.delimiter:",",r;}return a(e,t),e.prototype.columnNames=function(){return s(this,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:t.sent(),t.label=2;case 2:return [2,this.configuredColumnsOnly?Object.keys(this.columnConfigs):this.fullColumnNames];}});});},e.prototype.setColumnNames=function(){return s(this,void 0,void 0,function(){var t,e,n,r,o,a,s=this;return u(this,function(u){switch(u.label){case 0:return [4,this.maybeReadHeaderLine()];case 1:if(t=u.sent(),!this.fullColumnNames&&!t)throw new Error("Column names must be provided if there is no header line.");if(this.fullColumnNames&&t&&i.util.assert(t.length===this.fullColumnNames.length,function(){return "The length of provided columnNames ("+s.fullColumnNames.length.toString()+") does not match the length of the header line read from file ("+t.length.toString()+").";}),this.fullColumnNames||(this.fullColumnNames=t),e=this.fullColumnNames.reduce(function(t,e){return t[e]=t[e]+1||1,t;},{}),n=Object.keys(e).filter(function(t){return e[t]>1;}),i.util.assert(0===n.length,function(){return "Duplicate column names found: "+n.toString();}),this.columnConfigs)for(r=0,o=Object.keys(this.columnConfigs);r<o.length;r++){if(a=o[r],-1===this.fullColumnNames.indexOf(a))throw new Error('The key "'+a+'" provided in columnConfigs does not match any of the column names ('+this.fullColumnNames.toString()+").");}return this.columnNamesValidated=!0,[2];}});});},e.prototype.maybeReadHeaderLine=function(){return s(this,void 0,void 0,function(){var t,e;return u(this,function(n){switch(n.label){case 0:return this.hasHeader?[4,this.base.iterator()]:[3,3];case 1:return [4,n.sent().next()];case 2:if((t=n.sent()).done)throw new Error("No data was found for CSV parsing.");return e=t.value,[2,this.parseRow(e,!1)];case 3:return [2,null];}});});},e.prototype.iterator=function(){return s(this,void 0,void 0,function(){var t,e=this;return u(this,function(n){switch(n.label){case 0:return this.columnNamesValidated?[3,2]:[4,this.setColumnNames()];case 1:n.sent(),n.label=2;case 2:return [4,this.base.iterator()];case 3:return t=n.sent(),this.hasHeader&&(t=t.skip(1)),[2,t.map(function(t){return e.makeDataElement(t);})];}});});},e.prototype.makeDataElement=function(t){for(var e=this.parseRow(t),n={},r={},i=0;i<this.fullColumnNames.length;i++){var o=this.fullColumnNames[i],a=this.columnConfigs?this.columnConfigs[o]:null;if(!this.configuredColumnsOnly||a){var s=e[i],u=null;if(""===s){if(a&&void 0!==a.default)u=a.default;else {if(a&&(a.required||a.isLabel))throw new Error("Required column "+o+" is empty in this line: "+t);u=void 0;}}else {var c=Number(s);if(isNaN(c))u=a&&"bool"===a.dtype?this.getBoolean(s):s;else if(a&&a.dtype)switch(a.dtype){case"float32":u=c;break;case"int32":u=Math.floor(c);break;case"bool":u=this.getBoolean(s);break;default:u=c;}else u=c;}a&&a.isLabel?r[o]=u:n[o]=u;}}return 0===Object.keys(r).length?n:{xs:n,ys:r};},e.prototype.getBoolean=function(t){return "1"===t||"true"===t.toLowerCase()?1:0;},e.prototype.parseRow=function(t,e){void 0===e&&(e=!0);for(var n=[],r=0,i=t.length,o=Z,a=0;a<i;a++){switch(o){case Z:switch(t.charAt(a)){case'"':r=a+1,o=et;break;case this.delimiter:if(r=a+1," "===this.delimiter&&this.delimWhitespace)break;n.push(""),o=Z;break;default:o=tt,r=a;}break;case tt:switch(t.charAt(a)){case this.delimiter:n.push(t.substring(r,a)),o=Z,r=a+1;}break;case et:switch(t.charAt(a)){case'"':o=nt;}break;case nt:switch(t.charAt(a)){case this.delimiter:n.push(t.substring(r,a-1)),o=Z,r=a+1;break;case'"':o=et;break;default:o=rt;}break;case rt:switch(t.charAt(a)){case'"':o=et;}}}if(o===nt?n.push(t.substring(r,i-1)):n.push(t.substring(r)),e&&n.length!==this.fullColumnNames.length)throw new Error("Invalid row in csv file. Should have "+this.fullColumnNames.length+" elements in a row, but got "+n);return n;},e;}(G),ot=function(t){function e(e){var n=t.call(this)||this;n.microphoneConfig=e,n.isClosed=!1,n.fftSize=e.fftSize||1024;var r=Math.log2(n.fftSize);if(n.fftSize<0||r<4||r>14||!Number.isInteger(r))throw new Error("Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got "+n.fftSize);if(n.numFrames=e.numFramesPerSpectrogram||43,n.sampleRateHz=e.sampleRateHz,n.columnTruncateLength=e.columnTruncateLength||n.fftSize,n.audioTrackConstraints=e.audioTrackConstraints,n.smoothingTimeConstant=e.smoothingTimeConstant||0,n.includeSpectrogram=!1!==e.includeSpectrogram,n.includeWaveform=!0===e.includeWaveform,!n.includeSpectrogram&&!n.includeWaveform)throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.");return n;}return a(e,t),e.prototype.summary=function(){return "microphone";},e.create=function(t){return void 0===t&&(t={}),s(this,void 0,void 0,function(){var n;return u(this,function(r){switch(r.label){case 0:if(Object(i.env)().get("IS_NODE"))throw new Error("microphone API is only supported in browser environment.");return [4,(n=new e(t)).start()];case 1:return r.sent(),[2,n];}});});},e.prototype.start=function(){return s(this,void 0,void 0,function(){var t,e,n,r;return u(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=this,[4,navigator.mediaDevices.getUserMedia({audio:null==this.audioTrackConstraints||this.audioTrackConstraints,video:!1})];case 1:return t.stream=i.sent(),[3,3];case 2:throw e=i.sent(),new Error("Error thrown while initializing video stream: "+e.message);case 3:if(!this.stream)throw new Error("Could not obtain audio from microphone.");if(n=window.AudioContext||window.webkitAudioContext,this.audioContext=new n(),this.sampleRateHz){if(this.audioContext.sampleRate!==this.sampleRateHz)throw new Error("Mismatch in sampling rate: Expected: "+this.sampleRateHz+"; Actual: "+this.audioContext.sampleRate);}else this.sampleRateHz=this.audioContext.sampleRate;return r=this.audioContext.createMediaStreamSource(this.stream),this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=this.smoothingTimeConstant,r.connect(this.analyser),this.freqData=new Float32Array(this.fftSize),this.timeData=new Float32Array(this.fftSize),[2];}});});},e.prototype.next=function(){return s(this,void 0,void 0,function(){var t,e,n,r,i;return u(this,function(o){switch(o.label){case 0:return this.isClosed?[2,{value:null,done:!0}]:[4,this.getAudioData()];case 1:return n=o.sent(),this.includeSpectrogram&&(r=this.flattenQueue(n.freqDataQueue),t=this.getTensorFromAudioDataArray(r,[this.numFrames,this.columnTruncateLength,1])),this.includeWaveform&&(i=this.flattenQueue(n.timeDataQueue),e=this.getTensorFromAudioDataArray(i,[this.numFrames*this.fftSize,1])),[2,{value:{spectrogram:t,waveform:e},done:!1}];}});});},e.prototype.capture=function(){return s(this,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return [4,this.next()];case 1:return [2,t.sent().value];}});});},e.prototype.getAudioData=function(){return s(this,void 0,void 0,function(){var t,e,n,r=this;return u(this,function(i){return t=[],e=[],n=0,[2,new Promise(function(i){var o=setInterval(function(){r.includeSpectrogram&&(r.analyser.getFloatFrequencyData(r.freqData),r.freqData[0]===-1/0&&i({freqDataQueue:t,timeDataQueue:e}),t.push(r.freqData.slice(0,r.columnTruncateLength))),r.includeWaveform&&(r.analyser.getFloatTimeDomainData(r.timeData),e.push(r.timeData.slice())),++n===r.numFrames&&(clearInterval(o),i({freqDataQueue:t,timeDataQueue:e}));},r.fftSize/r.sampleRateHz*1e3);})];});});},e.prototype.stop=function(){this.isClosed||(this.isClosed=!0,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop());},e.prototype.toArray=function(){throw new Error("Can not convert infinite audio stream to array.");},e.prototype.getSampleRate=function(){return this.sampleRateHz;},e.prototype.flattenQueue=function(t){var e=t[0].length,n=new Float32Array(t.length*e);return t.forEach(function(t,r){return n.set(t,r*e);}),n;},e.prototype.getTensorFromAudioDataArray=function(t,e){var n=new Float32Array(i.util.sizeFromShape(e));return n.set(t,n.length-t.length),Object(i.tensor)(n,e);},e;}(F),at=function(t){function e(e,n){var r=t.call(this)||this;if(r.webcamVideoElement=e,r.webcamConfig=n,r.isClosed=!0,r.resize=!1,r.needToResize())if(r.resize=!0,r.cropSize=[r.webcamConfig.resizeHeight,r.webcamConfig.resizeWidth],r.cropBoxInd=Object(i.tensor1d)([0],"int32"),r.webcamConfig.centerCrop){var o=1*r.webcamConfig.resizeWidth/r.webcamVideoElement.width,a=1*r.webcamConfig.resizeHeight/r.webcamVideoElement.height,s=(1-o)/2,u=(1-a)/2,c=s+o,l=a+u;r.cropBox=Object(i.tensor2d)([u,s,l,c],[1,4]);}else r.cropBox=Object(i.tensor2d)([0,0,1,1],[1,4]);return r;}return a(e,t),e.prototype.summary=function(){return "webcam";},e.create=function(t,n){return void 0===n&&(n={}),s(this,void 0,void 0,function(){var r;return u(this,function(o){switch(o.label){case 0:if(Object(i.env)().get("IS_NODE"))throw new Error("tf.data.webcam is only supported in browser environment.");if(!t){if(t=document.createElement("video"),!n.resizeWidth||!n.resizeHeight)throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element.");t.width=n.resizeWidth,t.height=n.resizeHeight;}return [4,(r=new e(t,n)).start()];case 1:return o.sent(),[2,r];}});});},e.prototype.start=function(){return s(this,void 0,void 0,function(){var t,e,n=this;return u(this,function(r){switch(r.label){case 0:this.webcamConfig.facingMode&&i.util.assert("user"===this.webcamConfig.facingMode||"environment"===this.webcamConfig.facingMode,function(){return "Invalid webcam facing mode: "+n.webcamConfig.facingMode+". Please provide 'user' or 'environment'";}),r.label=1;case 1:return r.trys.push([1,3,,4]),t=this,[4,navigator.mediaDevices.getUserMedia({video:{deviceId:this.webcamConfig.deviceId,facingMode:this.webcamConfig.facingMode?this.webcamConfig.facingMode:"user",width:this.webcamVideoElement.width,height:this.webcamVideoElement.height}})];case 2:return t.stream=r.sent(),[3,4];case 3:throw (e=r.sent()).message="Error thrown while initializing video stream: "+e.message,e;case 4:if(!this.stream)throw new Error("Could not obtain video from webcam.");try{this.webcamVideoElement.srcObject=this.stream;}catch(t){console.log(t),this.webcamVideoElement.src=window.URL.createObjectURL(this.stream);}return this.webcamVideoElement.play(),this.isClosed=!1,[2,new Promise(function(t){n.webcamVideoElement.onloadedmetadata=function(){t();};})];}});});},e.prototype.next=function(){return s(this,void 0,void 0,function(){var t;return u(this,function(e){if(this.isClosed)return [2,{value:null,done:!0}];try{t=i.browser.fromPixels(this.webcamVideoElement);}catch(t){throw new Error("Error thrown converting video to pixels: "+JSON.stringify(t));}if(!this.resize)return [2,{value:t,done:!1}];try{return [2,{value:this.cropAndResizeFrame(t),done:!1}];}catch(t){throw new Error("Error thrown cropping the video: "+t.message);}finally{t.dispose();}return [2];});});},e.prototype.needToResize=function(){return !(!this.webcamConfig.resizeWidth||!this.webcamConfig.resizeHeight||this.webcamVideoElement.width===this.webcamConfig.resizeWidth&&this.webcamVideoElement.height===this.webcamConfig.resizeHeight);},e.prototype.cropAndResizeFrame=function(t){var e=this;return Object(i.tidy)(function(){var n,r=t.toFloat().expandDims(0),o=(n=i.image.cropAndResize(r,e.cropBox,e.cropBoxInd,e.cropSize,"bilinear")).shape;return n.reshape(o.slice(1));});},e.prototype.capture=function(){return s(this,void 0,void 0,function(){return u(this,function(t){switch(t.label){case 0:return [4,this.next()];case 1:return [2,t.sent().value];}});});},e.prototype.stop=function(){this.stream.getTracks().forEach(function(t){return t.stop();});try{this.webcamVideoElement.srcObject=null;}catch(t){console.log(t),this.webcamVideoElement.src=null;}this.isClosed=!0;},e.prototype.toArray=function(){throw new Error("Can not convert infinite video stream to array.");},e;}(F),st=function st(){},ut=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return a(e,t),e.prototype.split=function(t){return new ct(this,t);},e;}(F),ct=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.impl=new lt(e,n),r;}return a(e,t),e.prototype.summary=function(){return this.impl.summary();},e.prototype.next=function(){return s(this,void 0,void 0,function(){return u(this,function(t){return [2,this.impl.next()];});});},e;}(ut),lt=function(t){function e(e,n){var r=t.call(this)||this;return r.upstream=e,r.separator=n,r.carryover="",r;}return a(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Split('"+this.separator+"')";},e.prototype.pump=function(){return s(this,void 0,void 0,function(){var t,e,n,r,i;return u(this,function(o){switch(o.label){case 0:return [4,this.upstream.next()];case 1:if((t=o.sent()).done)return ""===this.carryover?[2,!1]:(this.outputQueue.push(this.carryover),this.carryover="",[2,!0]);for((e=t.value.split(this.separator))[0]=this.carryover+e[0],n=0,r=e.slice(0,-1);n<r.length;n++){i=r[n],this.outputQueue.push(i);}return this.carryover=e[e.length-1],[2,!0];}});});},e;}(U),ft=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return a(e,t),e.prototype.decodeUTF8=function(){return new ht(this);},e;}(F),ht=function(t){function e(e){var n=t.call(this)||this;return n.upstream=e,n.impl=new dt(e),n;}return a(e,t),e.prototype.summary=function(){return this.impl.summary();},e.prototype.next=function(){return s(this,void 0,void 0,function(){return u(this,function(t){return [2,this.impl.next()];});});},e;}(ut),dt=function(t){function e(e){var r=t.call(this)||this;if(r.upstream=e,Object(i.env)().get("IS_BROWSER"))r.decoder=new TextDecoder("utf-8");else {var o=n(386).StringDecoder;r.decoder=new o("utf8");}return r;}return a(e,t),e.prototype.summary=function(){return this.upstream.summary()+" -> Utf8";},e.prototype.pump=function(){return s(this,void 0,void 0,function(){var t,e,n;return u(this,function(o){switch(o.label){case 0:return [4,this.upstream.next()];case 1:return (t=o.sent()).done?[2,!1]:(e=t.value,n=Object(i.env)().get("IS_BROWSER")?this.decoder.decode(e,{stream:!0}):this.decoder.write(r.from(e.buffer)),this.outputQueue.push(n),[2,!0]);}});});},e;}(U),pt=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.file=e,r.options=n,i.util.assert(e instanceof Uint8Array||!!Object(i.env)().get("IS_BROWSER")&&(e instanceof File||e instanceof Blob),function(){return "FileChunkIterator only supports File, Blob and Uint8Array right now.";}),r.offset=n.offset||0,r.chunkSize=n.chunkSize||1048576,r;}return a(e,t),e.prototype.summary=function(){return "FileChunks "+this.file;},e.prototype.next=function(){return s(this,void 0,void 0,function(){var t,e,n=this;return u(this,function(r){switch(r.label){case 0:return this.offset>=(this.file instanceof Uint8Array?this.file.byteLength:this.file.size)?[2,{value:null,done:!0}]:(t=new Promise(function(t,e){var r=n.offset+n.chunkSize;if(n.file instanceof Uint8Array)t(new Uint8Array(n.file.slice(n.offset,r)));else {var i=new FileReader();i.onload=function(n){var r=i.result;if(r instanceof ArrayBuffer&&(r=new Uint8Array(r)),!(r instanceof Uint8Array))return e(new TypeError("FileReader returned unknown type."));t(r);},i.onabort=function(t){return e(new Error("Aborted"));},i.onerror=function(t){return e(new Error(t.type));};var o=n.file.slice(n.offset,r);i.readAsArrayBuffer(o);}n.offset=r;}),e={},[4,t]);case 1:return [2,(e.value=r.sent(),e.done=!1,e)];}});});},e;}(ft);var mt=function mt(t){return {method:t.method,headers:t.headers,body:t.body,mode:t.mode,credentials:t.credentials,cache:t.cache,redirect:t.redirect,referrer:t.referrer,integrity:t.integrity};};function gt(t){return "string"==typeof t&&"file://"===t.substr(0,7);}var vt=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.input=e,r.options=n,r;}return a(e,t),e.prototype.iterator=function(){return s(this,void 0,void 0,function(){var t;return u(this,function(e){return gt(this.input)&&Object(i.env)().get("IS_NODE")&&(t=n(385),this.input=t.readFileSync(this.input.substr(7))),[2,new pt(this.input,this.options)];});});},e;}(st),yt=function(t){function e(e,n){void 0===n&&(n={});var r=t.call(this)||this;return r.url=e,r.fileOptions=n,r;}return a(e,t),e.prototype.iterator=function(){return s(this,void 0,void 0,function(){return u(this,function(t){return gt(this.url)?[2,new vt(this.url,this.fileOptions).iterator()]:[2,function(t,e){return void 0===e&&(e={}),s(this,void 0,void 0,function(){var n,r,o,a,s;return u(this,function(u){switch(u.label){case 0:return "string"==typeof t?n=t:(n=t.url,r=mt(t)),[4,i.util.fetch(n,r)];case 1:return (o=u.sent()).ok?(s=Uint8Array.bind,[4,o.arrayBuffer()]):[3,3];case 2:return a=new(s.apply(Uint8Array,[void 0,u.sent()]))(),[2,new pt(a,e)];case 3:throw new Error(o.statusText);}});});}(this.url,this.fileOptions)];});});},e;}(st);function bt(t,e){return void 0===e&&(e={}),new it(new yt(t),e);}function xt(t){var e=this,n=S(t);return K(function(){return s(e,void 0,void 0,function(){return u(this,function(t){return [2,n];});});});}function wt(t){var e=this;return K(function(){return s(e,void 0,void 0,function(){var e;return u(this,function(n){switch(n.label){case 0:return [4,t()];case 1:return e=n.sent(),[2,S(function(){return e.next();})];}});});});}function kt(t,e){return s(this,void 0,void 0,function(){return u(this,function(n){return [2,at.create(t,e)];});});}function Et(t){return s(this,void 0,void 0,function(){return u(this,function(e){return [2,ot.create(t)];});});}var Ct="1.7.4";}.call(this,n(59),n(92).Buffer);},function(t,e,n){function r(t){var e="";if(!t)try{t=n(185);}catch(t){e=t.toString();}return {readFile:t?function(e){return new Promise(function(n,r){t.readFile(e,function(t,e){return t?r(t):n(e);});});}:function(){throw new Error("readFile - failed to require fs in nodejs environment with error: "+e);}};}n.d(e,"a",function(){return r;});},function(t){t.exports={a:"0.12.2"};},function(t,e,n){var r=/("(?:[^\\"]|\\.)*")|[:,]/g;t.exports=function(t,e){var n,i,o;return e=e||{},n=JSON.stringify([1],void 0,void 0===e.indent?2:e.indent).slice(2,-3),i=""===n?1/0:void 0===e.maxLength?80:e.maxLength,o=e.replacer,function t(e,a,s){var u,c,l,f,h,d,p,m,g,v,y,b;if(e&&"function"==typeof e.toJSON&&(e=e.toJSON()),void 0===(y=JSON.stringify(e,o)))return y;if(p=i-a.length-s,y.length<=p&&(g=y.replace(r,function(t,e){return e||t+" ";})).length<=p)return g;if(null!=o&&(e=JSON.parse(y),o=void 0),"object"==_typeof$1(e)&&null!==e){if(m=a+n,l=[],c=0,Array.isArray(e))for(v="[",u="]",p=e.length;c<p;c++){l.push(t(e[c],m,c===p-1?0:1)||"null");}else for(v="{",u="}",p=(d=Object.keys(e)).length;c<p;c++){f=d[c],h=JSON.stringify(f)+": ",void 0!==(b=t(e[f],m,h.length+(c===p-1?0:1)))&&l.push(h+b);}if(l.length>0)return [v,n+l.join(",\n"+m),u].join("\n"+a);}return y;}(t,"",0);};},function(t,e,n){var r=n(31),i=Object(r.a)(function(t){t.setUTCDate(1),t.setUTCHours(0,0,0,0);},function(t,e){t.setUTCMonth(t.getUTCMonth()+e);},function(t,e){return e.getUTCMonth()-t.getUTCMonth()+12*(e.getUTCFullYear()-t.getUTCFullYear());},function(t){return t.getUTCMonth();});e.a=i;i.range;},function(t,e,n){var r=n(31),i=Object(r.a)(function(t){t.setDate(1),t.setHours(0,0,0,0);},function(t,e){t.setMonth(t.getMonth()+e);},function(t,e){return e.getMonth()-t.getMonth()+12*(e.getFullYear()-t.getFullYear());},function(t){return t.getMonth();});e.a=i;i.range;},function(t,e,n){(function(e){var r=n(36),i=n(275),o=n(193),a={"Content-Type":"application/x-www-form-urlencoded"};function s(t,e){!r.isUndefined(t)&&r.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e);}var u={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:function(){var t;return "undefined"!=typeof XMLHttpRequest?t=n(192):void 0!==e&&"[object process]"===Object.prototype.toString.call(e)&&(t=n(192)),t;}(),transformRequest:[function(t,e){return i(e,"Accept"),i(e,"Content-Type"),r.isFormData(t)||r.isArrayBuffer(t)||r.isBuffer(t)||r.isStream(t)||r.isFile(t)||r.isBlob(t)?t:r.isArrayBufferView(t)?t.buffer:r.isURLSearchParams(t)?(s(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):r.isObject(t)||e&&"application/json"===e["Content-Type"]?(s(e,"application/json"),function(t,e,n){if(r.isString(t))try{return (e||JSON.parse)(t),r.trim(t);}catch(t){if("SyntaxError"!==t.name)throw t;}return (n||JSON.stringify)(t);}(t)):t;}],transformResponse:[function(t){var e=this.transitional,n=e&&e.silentJSONParsing,i=e&&e.forcedJSONParsing,a=!n&&"json"===this.responseType;if(a||i&&r.isString(t)&&t.length)try{return JSON.parse(t);}catch(t){if(a){if("SyntaxError"===t.name)throw o(t,this,"E_JSON_PARSE");throw t;}}return t;}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function validateStatus(t){return t>=200&&t<300;},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],function(t){u.headers[t]={};}),r.forEach(["post","put","patch"],function(t){u.headers[t]=r.merge(a);}),t.exports=u;}).call(this,n(75));},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t};};Object.defineProperty(e,"__esModule",{value:!0});var o=n(50),a=i(n(88)),s=n(64),u=n(110),c=n(109),l={maxBins:12,fontSize:11};e.histogram=function(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee29(){var r,i,f,_e297,h,_t296,_e301,d;return regeneratorRuntime.wrap(function _callee29$(_context34){while(1){switch(_context34.prev=_context34.next){case 0:r=function(t){if(null==t.length)throw new Error("input data must be an array");if(0===t.length)return [];if("object"==_typeof$1(t[0])){if(null==t[0].value)throw new Error("input data must have a value field");return t;}{var _e296=Array(t.length);for(var _n235=0;_n235<t.length;_n235++){_e296[_n235]={value:t[_n235]};}return _e296;}}(e),i=Object.assign({},l,n),f=s.subSurface(t,"histogram");if(!1!==n.stats){_e297=s.subSurface(t,"stats",{prepend:!0});!function(t,e,n){var r=o.format(",.4~f"),i=o.format(".4~p"),a=[],s=[];if(null!=t.numVals&&(a.push("Num Vals"),s.push(r(t.numVals))),null!=t.min&&(a.push("Min"),s.push(r(t.min))),null!=t.max&&(a.push("Max"),s.push(r(t.max))),null!=t.numZeros){a.push("# Zeros");var _e298="";t.numVals&&(_e298=t.numZeros>0?"(".concat(i(t.numZeros/t.numVals),")"):""),s.push("".concat(r(t.numZeros)," ").concat(_e298));}if(null!=t.numNans){a.push("# NaNs");var _e299="";t.numVals&&(_e299=t.numNans>0?"(".concat(i(t.numNans/t.numVals),")"):""),s.push("".concat(r(t.numNans)," ").concat(_e299));}if(null!=t.numInfs){a.push("# Infinity");var _e300="";t.numVals&&(_e300=t.numInfs>0?"(".concat(i(t.numInfs/t.numVals),")"):""),s.push("".concat(r(t.numInfs)," ").concat(_e300));}c.table(e,{headers:a,values:[s]},n);}(n.stats?n.stats:u.arrayStats(r.map(function(t){return t.value;})),_e297,{fontSize:i.fontSize});}if(!(0===r.length)){_context34.next=4;break;}return _context34.abrupt("return");case 4:h=[];for(_t296=0;_t296<r.length;_t296++){_e301=r[_t296].value;null!=_e301&&isFinite(_e301)&&h.push(r[_t296]);}d={width:i.width||s.getDefaultWidth(f),height:i.height||s.getDefaultHeight(f),padding:0,autosize:{type:"fit",contains:"padding",resize:!0},data:{values:h},mark:{type:"bar",tooltip:!0},config:{axis:{labelFontSize:i.fontSize,titleFontSize:i.fontSize},text:{fontSize:i.fontSize},legend:{labelFontSize:i.fontSize,titleFontSize:i.fontSize}},encoding:{x:{bin:{maxbins:i.maxBins},field:"value",type:"quantitative"},y:{aggregate:"count",type:"quantitative"},color:{value:i.color||"#001B44"}}};return _context34.abrupt("return",a.default(f,d,{actions:!1,mode:"vega-lite",defaultStyle:!1}));case 8:case"end":return _context34.stop();}}},_callee29);}));};},function(t,e,n){n.r(e),n.d(e,"h",function(){return a;}),n.d(e,"createElement",function(){return a;}),n.d(e,"cloneElement",function(){return c;}),n.d(e,"Component",function(){return M;}),n.d(e,"render",function(){return j;}),n.d(e,"rerender",function(){return d;}),n.d(e,"options",function(){return r;});var r={},i=[],o=[];function a(t,e){var n,a,s,u,c=o;for(u=arguments.length;u-->2;){i.push(arguments[u]);}for(e&&null!=e.children&&(i.length||i.push(e.children),delete e.children);i.length;){if((a=i.pop())&&void 0!==a.pop)for(u=a.length;u--;){i.push(a[u]);}else "boolean"==typeof a&&(a=null),(s="function"!=typeof t)&&(null==a?a="":"number"==typeof a?a=String(a):"string"!=typeof a&&(s=!1)),s&&n?c[c.length-1]+=a:c===o?c=[a]:c.push(a),n=s;}var l=new function(){}();return l.nodeName=t,l.children=c,l.attributes=null==e?void 0:e,l.key=null==e?void 0:e.key,void 0!==r.vnode&&r.vnode(l),l;}function s(t,e){for(var n in e){t[n]=e[n];}return t;}var u="function"==typeof Promise?Promise.resolve().then.bind(Promise.resolve()):setTimeout;function c(t,e){return a(t.nodeName,s(s({},t.attributes),e),arguments.length>2?[].slice.call(arguments,2):t.children);}var l=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,f=[];function h(t){!t._dirty&&(t._dirty=!0)&&1==f.push(t)&&(r.debounceRendering||u)(d);}function d(){var t,e=f;for(f=[];t=e.pop();){t._dirty&&I(t);}}function p(t,e,n){return "string"==typeof e||"number"==typeof e?void 0!==t.splitText:"string"==typeof e.nodeName?!t._componentConstructor&&m(t,e.nodeName):n||t._componentConstructor===e.nodeName;}function m(t,e){return t.normalizedNodeName===e||t.nodeName.toLowerCase()===e.toLowerCase();}function g(t){var e=s({},t.attributes);e.children=t.children;var n=t.nodeName.defaultProps;if(void 0!==n)for(var r in n){void 0===e[r]&&(e[r]=n[r]);}return e;}function v(t){var e=t.parentNode;e&&e.removeChild(t);}function y(t,e,n,r,i){if("className"===e&&(e="class"),"key"===e);else if("ref"===e)n&&n(null),r&&r(t);else if("class"!==e||i){if("style"===e){if(r&&"string"!=typeof r&&"string"!=typeof n||(t.style.cssText=r||""),r&&"object"==_typeof$1(r)){if("string"!=typeof n)for(var o in n){o in r||(t.style[o]="");}for(var o in r){t.style[o]="number"==typeof r[o]&&!1===l.test(o)?r[o]+"px":r[o];}}}else if("dangerouslySetInnerHTML"===e)r&&(t.innerHTML=r.__html||"");else if("o"==e[0]&&"n"==e[1]){var a=e!==(e=e.replace(/Capture$/,""));e=e.toLowerCase().substring(2),r?n||t.addEventListener(e,b,a):t.removeEventListener(e,b,a),(t._listeners||(t._listeners={}))[e]=r;}else if("list"!==e&&"type"!==e&&!i&&e in t)!function(t,e,n){try{t[e]=n;}catch(t){}}(t,e,null==r?"":r),null!=r&&!1!==r||t.removeAttribute(e);else {var s=i&&e!==(e=e.replace(/^xlink:?/,""));null==r||!1===r?s?t.removeAttributeNS("http://www.w3.org/1999/xlink",e.toLowerCase()):t.removeAttribute(e):"function"!=typeof r&&(s?t.setAttributeNS("http://www.w3.org/1999/xlink",e.toLowerCase(),r):t.setAttribute(e,r));}}else t.className=r||"";}function b(t){return this._listeners[t.type](r.event&&r.event(t)||t);}var x=[],w=0,k=!1,E=!1;function C(){for(var t;t=x.pop();){r.afterMount&&r.afterMount(t),t.componentDidMount&&t.componentDidMount();}}function A(t,e,n,r,i,o){w++||(k=null!=i&&void 0!==i.ownerSVGElement,E=null!=t&&!("__preactattr_"in t));var a=O(t,e,n,r,o);return i&&a.parentNode!==i&&i.appendChild(a),--w||(E=!1,o||C()),a;}function O(t,e,n,r,i){var o=t,a=k;if(null!=e&&"boolean"!=typeof e||(e=""),"string"==typeof e||"number"==typeof e)return t&&void 0!==t.splitText&&t.parentNode&&(!t._component||i)?t.nodeValue!=e&&(t.nodeValue=e):(o=document.createTextNode(e),t&&(t.parentNode&&t.parentNode.replaceChild(o,t),_(t,!0))),o.__preactattr_=!0,o;var s=e.nodeName;if("function"==typeof s)return function(t,e,n,r){var i=t&&t._component,o=i,a=t,s=i&&t._componentConstructor===e.nodeName,u=s,c=g(e);for(;i&&!u&&(i=i._parentComponent);){u=i.constructor===e.nodeName;}i&&u&&(!r||i._component)?(N(i,c,3,n,r),t=i.base):(o&&!s&&(R(o),t=a=null),i=F(e.nodeName,c,n),t&&!i.nextBase&&(i.nextBase=t,a=null),N(i,c,1,n,r),t=i.base,a&&t!==a&&(a._component=null,_(a,!1)));return t;}(t,e,n,r);if(k="svg"===s||"foreignObject"!==s&&k,s=String(s),(!t||!m(t,s))&&(o=function(t,e){var n=e?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t);return n.normalizedNodeName=t,n;}(s,k),t)){for(;t.firstChild;){o.appendChild(t.firstChild);}t.parentNode&&t.parentNode.replaceChild(o,t),_(t,!0);}var u=o.firstChild,c=o.__preactattr_,l=e.children;if(null==c){c=o.__preactattr_={};for(var f=o.attributes,h=f.length;h--;){c[f[h].name]=f[h].value;}}return !E&&l&&1===l.length&&"string"==typeof l[0]&&null!=u&&void 0!==u.splitText&&null==u.nextSibling?u.nodeValue!=l[0]&&(u.nodeValue=l[0]):(l&&l.length||null!=u)&&function(t,e,n,r,i){var o,a,s,u,c,l=t.childNodes,f=[],h={},d=0,m=0,g=l.length,y=0,b=e?e.length:0;if(0!==g)for(var x=0;x<g;x++){var w=l[x],k=w.__preactattr_,E=b&&k?w._component?w._component.__key:k.key:null;null!=E?(d++,h[E]=w):(k||(void 0!==w.splitText?!i||w.nodeValue.trim():i))&&(f[y++]=w);}if(0!==b)for(var x=0;x<b;x++){u=e[x],c=null;var E=u.key;if(null!=E)d&&void 0!==h[E]&&(c=h[E],h[E]=void 0,d--);else if(!c&&m<y)for(o=m;o<y;o++){if(void 0!==f[o]&&p(a=f[o],u,i)){c=a,f[o]=void 0,o===y-1&&y--,o===m&&m++;break;}}c=O(c,u,n,r),s=l[x],c&&c!==t&&c!==s&&(null==s?t.appendChild(c):c===s.nextSibling?v(s):t.insertBefore(c,s));}if(d)for(var x in h){void 0!==h[x]&&_(h[x],!1);}for(;m<=y;){void 0!==(c=f[y--])&&_(c,!1);}}(o,l,n,r,E||null!=c.dangerouslySetInnerHTML),function(t,e,n){var r;for(r in n){e&&null!=e[r]||null==n[r]||y(t,r,n[r],n[r]=void 0,k);}for(r in e){"children"===r||"innerHTML"===r||r in n&&e[r]===("value"===r||"checked"===r?t[r]:n[r])||y(t,r,n[r],n[r]=e[r],k);}}(o,e.attributes,c),k=a,o;}function _(t,e){var n=t._component;n?R(n):(null!=t.__preactattr_&&t.__preactattr_.ref&&t.__preactattr_.ref(null),!1!==e&&null!=t.__preactattr_||v(t),S(t));}function S(t){for(t=t.lastChild;t;){var e=t.previousSibling;_(t,!0),t=e;}}var D={};function F(t,e,n){var r,i=D[t.name];if(t.prototype&&t.prototype.render?(r=new t(e,n),M.call(r,e,n)):((r=new M(e,n)).constructor=t,r.render=T),i)for(var o=i.length;o--;){if(i[o].constructor===t){r.nextBase=i[o].nextBase,i.splice(o,1);break;}}return r;}function T(t,e,n){return this.constructor(t,n);}function N(t,e,n,i,o){t._disable||(t._disable=!0,(t.__ref=e.ref)&&delete e.ref,(t.__key=e.key)&&delete e.key,!t.base||o?t.componentWillMount&&t.componentWillMount():t.componentWillReceiveProps&&t.componentWillReceiveProps(e,i),i&&i!==t.context&&(t.prevContext||(t.prevContext=t.context),t.context=i),t.prevProps||(t.prevProps=t.props),t.props=e,t._disable=!1,0!==n&&(1!==n&&!1===r.syncComponentUpdates&&t.base?h(t):I(t,1,o)),t.__ref&&t.__ref(t));}function I(t,e,n,i){if(!t._disable){var o,a,u,c=t.props,l=t.state,f=t.context,h=t.prevProps||c,d=t.prevState||l,p=t.prevContext||f,m=t.base,v=t.nextBase,y=m||v,b=t._component,k=!1;if(m&&(t.props=h,t.state=d,t.context=p,2!==e&&t.shouldComponentUpdate&&!1===t.shouldComponentUpdate(c,l,f)?k=!0:t.componentWillUpdate&&t.componentWillUpdate(c,l,f),t.props=c,t.state=l,t.context=f),t.prevProps=t.prevState=t.prevContext=t.nextBase=null,t._dirty=!1,!k){o=t.render(c,l,f),t.getChildContext&&(f=s(s({},f),t.getChildContext()));var E,O,S=o&&o.nodeName;if("function"==typeof S){var D=g(o);(a=b)&&a.constructor===S&&D.key==a.__key?N(a,D,1,f,!1):(E=a,t._component=a=F(S,D,f),a.nextBase=a.nextBase||v,a._parentComponent=t,N(a,D,0,f,!1),I(a,1,n,!0)),O=a.base;}else u=y,(E=b)&&(u=t._component=null),(y||1===e)&&(u&&(u._component=null),O=A(u,o,f,n||!m,y&&y.parentNode,!0));if(y&&O!==y&&a!==b){var T=y.parentNode;T&&O!==T&&(T.replaceChild(O,y),E||(y._component=null,_(y,!1)));}if(E&&R(E),t.base=O,O&&!i){for(var M=t,j=t;j=j._parentComponent;){(M=j).base=O;}O._component=M,O._componentConstructor=M.constructor;}}if(!m||n?x.unshift(t):k||(t.componentDidUpdate&&t.componentDidUpdate(h,d,p),r.afterUpdate&&r.afterUpdate(t)),null!=t._renderCallbacks)for(;t._renderCallbacks.length;){t._renderCallbacks.pop().call(t);}w||i||C();}}function R(t){r.beforeUnmount&&r.beforeUnmount(t);var e=t.base;t._disable=!0,t.componentWillUnmount&&t.componentWillUnmount(),t.base=null;var n=t._component;n?R(n):e&&(e.__preactattr_&&e.__preactattr_.ref&&e.__preactattr_.ref(null),t.nextBase=e,v(e),function(t){var e=t.constructor.name;(D[e]||(D[e]=[])).push(t);}(t),S(e)),t.__ref&&t.__ref(null);}function M(t,e){this._dirty=!0,this.context=e,this.props=t,this.state=this.state||{};}function j(t,e,n){return A(n,t,{},!1,e,!1);}s(M.prototype,{setState:function setState(t,e){var n=this.state;this.prevState||(this.prevState=s({},n)),s(n,"function"==typeof t?t(n,this.props):t),e&&(this._renderCallbacks=this._renderCallbacks||[]).push(e),h(this);},forceUpdate:function forceUpdate(t){t&&(this._renderCallbacks=this._renderCallbacks||[]).push(t),I(this,2);},render:function render(){}});var B={h:a,createElement:a,cloneElement:c,Component:M,render:j,rerender:d,options:r};e.default=B;},function(t,e,n){/*
object-assign
(c) Sindre Sorhus
@license MIT
*/var r=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;t.exports=function(){try{if(!Object.assign)return !1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return !1;for(var e={},n=0;n<10;n++){e["_"+String.fromCharCode(n)]=n;}if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t];}).join(""))return !1;var r={};return "abcdefghijklmnopqrst".split("").forEach(function(t){r[t]=t;}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("");}catch(t){return !1;}}()?Object.assign:function(t,e){for(var n,a,s=function(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t);}(t),u=1;u<arguments.length;u++){for(var c in n=Object(arguments[u])){i.call(n,c)&&(s[c]=n[c]);}if(r){a=r(n);for(var l=0;l<a.length;l++){o.call(n,a[l])&&(s[a[l]]=n[a[l]]);}}}return s;};},function(t,e,n){var r=n(32),i=n(113),o=i.ANY,a=n(47),s=n(112),u=n(114),c=n(143),l=n(141),f=n(142);t.exports=function(t,e,n,h){var d,p,m,g,v;switch(t=new r(t,h),e=new a(e,h),n){case">":d=u,p=l,m=c,g=">",v=">=";break;case"<":d=c,p=f,m=u,g="<",v="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"');}if(s(t,e,h))return !1;var _loop11=function _loop11(_n236){var r=null,a=null;if(e.set[_n236].forEach(function(t){t.semver===o&&(t=new i(">=0.0.0")),r=r||t,a=a||t,d(t.semver,r.semver,h)?r=t:m(t.semver,a.semver,h)&&(a=t);}),r.operator===g||r.operator===v)return {v:!1};if((!a.operator||a.operator===g)&&p(t,a.semver))return {v:!1};if(a.operator===v&&m(t,a.semver))return {v:!1};};for(var _n236=0;_n236<e.set.length;++_n236){var _ret2=_loop11(_n236);if(_typeof$1(_ret2)==="object")return _ret2.v;}return !0;};},function(t,e,n){var r=n(48);t.exports=function(t,e,n){return r(t,e,n)<=0;};},function(t,e,n){var r=n(48);t.exports=function(t,e,n){return r(t,e,n)>=0;};},function(t,e,n){var r=n(48);t.exports=function(t,e,n){return r(t,e,n)<0;};},function(t,e,n){var r=n(32);t.exports=function(t,e,n){var i=new r(t,n),o=new r(e,n);return i.compare(o)||i.compareBuild(o);};},function(t,e,n){var r=n(48);t.exports=function(t,e,n){return 0===r(t,e,n);};},function(t,e){var n=/^[0-9]+$/,r=function r(t,e){var r=n.test(t),i=n.test(e);return r&&i&&(t=+t,e=+e),t===e?0:r&&!i?-1:i&&!r?1:t<e?-1:1;};t.exports={compareIdentifiers:r,rcompareIdentifiers:function rcompareIdentifiers(t,e){return r(e,t);}};},function(t,e,n){/**
 * @license
 * Copyright 2017 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0}),e.getBroadcastDims=function(t,e){for(var n=t.length,r=[],i=0;i<n;i++){var o=n-1-i,a=t[o]||1;(e[e.length-1-i]||1)>1&&1===a&&r.unshift(o);}return r;},e.getReductionAxes=function(t,e){for(var n=[],r=0;r<e.length;r++){var i=t[t.length-r-1],o=e.length-r-1,a=e[o];(null==i||1===i&&a>1)&&n.unshift(o);}return n;},e.assertAndGetBroadcastShape=function(t,e){for(var n=[],r=Math.max(t.length,e.length),i=0;i<r;i++){var o=t[t.length-i-1];null==o&&(o=1);var a=e[e.length-i-1];if(null==a&&(a=1),1===o)n.unshift(a);else if(1===a)n.unshift(o);else {if(o!==a)throw Error("Operands could not be broadcast together with shapes "+t+" and "+e+".");n.unshift(o);}}return n;};},function(t,e,n){t.exports=!n(208)(function(){return 7!=Object.defineProperty({},"a",{get:function get(){return 7;}}).a;});},function(t,e){t.exports=function(t){return "object"==_typeof$1(t)?null!==t:"function"==typeof t;};},function(t,e){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n);},function(t,e,n){var r=n(16),i=n(27),o=n(83),a=n(118),s=n(42),u=n(93),c=n(15),l=n(94),f=n(54),h=n(22),d=n(213),p=n(79).f,m=n(26).f,g=n(156),v=n(98),y="prototype",b="Wrong index!",_x33=r.ArrayBuffer,_w4=r.DataView,k=r.Math,E=r.RangeError,C=r.Infinity,A=_x33,O=k.abs,_=k.pow,S=k.floor,D=k.log,F=k.LN2,T=i?"_b":"buffer",N=i?"_l":"byteLength",I=i?"_o":"byteOffset";function R(t,e,n){var r,i,o,a=new Array(n),s=8*n-e-1,u=(1<<s)-1,c=u>>1,l=23===e?_(2,-24)-_(2,-77):0,f=0,h=t<0||0===t&&1/t<0?1:0;for((t=O(t))!=t||t===C?(i=t!=t?1:0,r=u):(r=S(D(t)/F),t*(o=_(2,-r))<1&&(r--,o*=2),(t+=r+c>=1?l/o:l*_(2,1-c))*o>=2&&(r++,o/=2),r+c>=u?(i=0,r=u):r+c>=1?(i=(t*o-1)*_(2,e),r+=c):(i=t*_(2,c-1)*_(2,e),r=0));e>=8;a[f++]=255&i,i/=256,e-=8){}for(r=r<<e|i,s+=e;s>0;a[f++]=255&r,r/=256,s-=8){}return a[--f]|=128*h,a;}function M(t,e,n){var r,i=8*n-e-1,o=(1<<i)-1,a=o>>1,s=i-7,u=n-1,c=t[u--],l=127&c;for(c>>=7;s>0;l=256*l+t[u],u--,s-=8){}for(r=l&(1<<-s)-1,l>>=-s,s+=e;s>0;r=256*r+t[u],u--,s-=8){}if(0===l)l=1-a;else {if(l===o)return r?NaN:c?-C:C;r+=_(2,e),l-=a;}return (c?-1:1)*r*_(2,l-e);}function j(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0];}function B(t){return [255&t];}function P(t){return [255&t,t>>8&255];}function L(t){return [255&t,t>>8&255,t>>16&255,t>>24&255];}function z(t){return R(t,52,8);}function U(t){return R(t,23,4);}function W(t,e,n){m(t[y],e,{get:function get(){return this[n];}});}function V(t,e,n,r){var i=d(+n);if(i+e>t[N])throw E(b);var o=t[T]._b,a=i+t[I],s=o.slice(a,a+e);return r?s:s.reverse();}function q(t,e,n,r,i,o){var a=d(+n);if(a+e>t[N])throw E(b);for(var s=t[T]._b,u=a+t[I],c=r(+i),l=0;l<e;l++){s[u+l]=c[o?l:e-l-1];}}if(a.ABV){if(!c(function(){_x33(1);})||!c(function(){new _x33(-1);})||c(function(){return new _x33(),new _x33(1.5),new _x33(NaN),"ArrayBuffer"!=_x33.name;})){for(var $,H=(_x33=function x(t){return l(this,_x33),new A(d(t));})[y]=A[y],G=p(A),K=0;G.length>K;){($=G[K++])in _x33||s(_x33,$,A[$]);}o||(H.constructor=_x33);}var X=new _w4(new _x33(2)),Y=_w4[y].setInt8;X.setInt8(0,2147483648),X.setInt8(1,2147483649),!X.getInt8(0)&&X.getInt8(1)||u(_w4[y],{setInt8:function setInt8(t,e){Y.call(this,t,e<<24>>24);},setUint8:function setUint8(t,e){Y.call(this,t,e<<24>>24);}},!0);}else _x33=function _x32(t){l(this,_x33,"ArrayBuffer");var e=d(t);this._b=g.call(new Array(e),0),this[N]=e;},_w4=function w(t,e,n){l(this,_w4,"DataView"),l(t,_x33,"DataView");var r=t[N],i=f(e);if(i<0||i>r)throw E("Wrong offset!");if(i+(n=void 0===n?r-i:h(n))>r)throw E("Wrong length!");this[T]=t,this[I]=i,this[N]=n;},i&&(W(_x33,"byteLength","_l"),W(_w4,"buffer","_b"),W(_w4,"byteLength","_l"),W(_w4,"byteOffset","_o")),u(_w4[y],{getInt8:function getInt8(t){return V(this,1,t)[0]<<24>>24;},getUint8:function getUint8(t){return V(this,1,t)[0];},getInt16:function getInt16(t){var e=V(this,2,t,arguments[1]);return (e[1]<<8|e[0])<<16>>16;},getUint16:function getUint16(t){var e=V(this,2,t,arguments[1]);return e[1]<<8|e[0];},getInt32:function getInt32(t){return j(V(this,4,t,arguments[1]));},getUint32:function getUint32(t){return j(V(this,4,t,arguments[1]))>>>0;},getFloat32:function getFloat32(t){return M(V(this,4,t,arguments[1]),23,4);},getFloat64:function getFloat64(t){return M(V(this,8,t,arguments[1]),52,8);},setInt8:function setInt8(t,e){q(this,1,t,B,e);},setUint8:function setUint8(t,e){q(this,1,t,B,e);},setInt16:function setInt16(t,e){q(this,2,t,P,e,arguments[2]);},setUint16:function setUint16(t,e){q(this,2,t,P,e,arguments[2]);},setInt32:function setInt32(t,e){q(this,4,t,L,e,arguments[2]);},setUint32:function setUint32(t,e){q(this,4,t,L,e,arguments[2]);},setFloat32:function setFloat32(t,e){q(this,4,t,U,e,arguments[2]);},setFloat64:function setFloat64(t,e){q(this,8,t,z,e,arguments[2]);}});v(_x33,"ArrayBuffer"),v(_w4,"DataView"),s(_w4[y],a.VIEW,!0),e.ArrayBuffer=_x33,e.DataView=_w4;},function(t,e,n){var r,i,o,a=n(56),s=n(232),u=n(171),c=n(175),l=n(16),f=l.process,h=l.setImmediate,d=l.clearImmediate,p=l.MessageChannel,m=l.Dispatch,g=0,v={},y=function y(){var t=+this;if(v.hasOwnProperty(t)){var e=v[t];delete v[t],e();}},b=function b(t){y.call(t.data);};h&&d||(h=function h(t){for(var e=[],n=1;arguments.length>n;){e.push(arguments[n++]);}return v[++g]=function(){s("function"==typeof t?t:Function(t),e);},r(g),g;},d=function d(t){delete v[t];},"process"==n(62)(f)?r=function r(t){f.nextTick(a(y,t,1));}:m&&m.now?r=function r(t){m.now(a(y,t,1));}:p?(o=(i=new p()).port2,i.port1.onmessage=b,r=a(o.postMessage,o,1)):l.addEventListener&&"function"==typeof postMessage&&!l.importScripts?(r=function r(t){l.postMessage(t+"","*");},l.addEventListener("message",b,!1)):r="onreadystatechange"in c("script")?function(t){u.appendChild(c("script")).onreadystatechange=function(){u.removeChild(this),y.call(t);};}:function(t){setTimeout(a(y,t,1),0);}),t.exports={set:h,clear:d};},function(t,e,n){var r=n(164)(!0);t.exports=function(t,e,n){return e+(n?r(t,e).length:1);};},function(t,e,n){var r=n(124),i=RegExp.prototype.exec,o=String.prototype.replace,a=i,s=function(){var t=/a/,e=/b*/g;return i.call(t,"a"),i.call(e,"a"),0!==t.lastIndex||0!==e.lastIndex;}(),u=void 0!==/()??/.exec("")[1];(s||u)&&(a=function a(t){var e,n,a,c,l=this;return u&&(n=new RegExp("^"+l.source+"$(?!\\s)",r.call(l))),s&&(e=l.lastIndex),a=i.call(l,t),s&&a&&(l.lastIndex=l.global?a.index+a[0].length:e),u&&a&&a.length>1&&o.call(a[0],n,function(){for(c=1;c<arguments.length-2;c++){void 0===arguments[c]&&(a[c]=void 0);}}),a;}),t.exports=a;},function(t,e,n){var r=n(77),i=n(221),o=n(96),a=n(41);t.exports=n(163)(Array,"Array",function(t,e){this._t=a(t),this._i=0,this._k=e;},function(){var t=this._t,e=this._k,n=this._i++;return !t||n>=t.length?(this._t=void 0,i(1)):i(0,"keys"==e?n:"values"==e?t[n]:[n,t[n]]);},"values"),o.Arguments=o.Array,r("keys"),r("values"),r("entries");},function(t,e,n){var r=n(34),i=n(81),o=n(22);t.exports=function(t){for(var e=r(this),n=o(e.length),a=arguments.length,s=i(a>1?arguments[1]:void 0,n),u=a>2?arguments[2]:void 0,c=void 0===u?n:i(u,n);c>s;){e[s++]=t;}return e;};},function(t,e,n){var r=n(105),i=n(19)("iterator"),o=n(96);t.exports=n(24).getIteratorMethod=function(t){if(void 0!=t)return t[i]||t["@@iterator"]||o[r(t)];};},function(t,e,n){var r=n(26),i=n(85);t.exports=function(t,e,n){e in t?r.f(t,e,i(0,n)):t[e]=n;};},function(t,e,n){var r=n(96),i=n(19)("iterator"),o=Array.prototype;t.exports=function(t){return void 0!==t&&(r.Array===t||o[i]===t);};},function(t,e,n){var r=n(19)("match");t.exports=function(t){var e=/./;try{"/./"[t](e);}catch(n){try{return e[r]=!1,!"/./"[t](e);}catch(t){}}return !0;};},function(t,e,n){var r=n(13),i=n(62),o=n(19)("match");t.exports=function(t){var e;return r(t)&&(void 0!==(e=t[o])?!!e:"RegExp"==i(t));};},function(t,e,n){var r=n(161),i=n(61);t.exports=function(t,e,n){if(r(e))throw TypeError("String#"+n+" doesn't accept regex!");return String(i(t));};},function(t,e,n){var r=n(83),i=n(8),o=n(38),a=n(42),s=n(96),u=n(226),c=n(98),l=n(78),f=n(19)("iterator"),h=!([].keys&&"next"in[].keys()),d=function d(){return this;};t.exports=function(t,e,n,p,m,g,v){u(n,e,p);var y,b,x,w=function w(t){if(!h&&t in A)return A[t];switch(t){case"keys":case"values":return function(){return new n(this,t);};}return function(){return new n(this,t);};},k=e+" Iterator",E="values"==m,C=!1,A=t.prototype,O=A[f]||A["@@iterator"]||m&&A[m],_=O||w(m),S=m?E?w("entries"):_:void 0,D="Array"==e&&A.entries||O;if(D&&(x=l(D.call(new t())))!==Object.prototype&&x.next&&(c(x,k,!0),r||"function"==typeof x[f]||a(x,f,d)),E&&O&&"values"!==O.name&&(C=!0,_=function _(){return O.call(this);}),r&&!v||!h&&!C&&A[f]||a(A,f,_),s[e]=_,s[k]=d,m)if(y={values:E?_:w("values"),keys:g?_:w("keys"),entries:S},v)for(b in y){b in A||o(A,b,y[b]);}else i(i.P+i.F*(h||C),e,y);return y;};},function(t,e,n){var r=n(54),i=n(61);t.exports=function(t){return function(e,n){var o,a,s=String(i(e)),u=r(n),c=s.length;return u<0||u>=c?t?"":void 0:(o=s.charCodeAt(u))<55296||o>56319||u+1===c||(a=s.charCodeAt(u+1))<56320||a>57343?t?s.charAt(u):o:t?s.slice(u,u+2):a-56320+(o-55296<<10)+65536;};};},function(t,e){var n=Math.expm1;t.exports=!n||n(10)>22025.465794806718||n(10)<22025.465794806718||-2e-17!=n(-2e-17)?function(t){return 0==(t=+t)?t:t>-1e-6&&t<1e-6?t+t*t/2:Math.exp(t)-1;}:n;},function(t,e){t.exports=Math.sign||function(t){return 0==(t=+t)||t!=t?t:t<0?-1:1;};},function(t,e,n){var r=n(54),i=n(61);t.exports=function(t){var e=String(i(this)),n="",o=r(t);if(o<0||o==1/0)throw RangeError("Count can't be negative");for(;o>0;(o>>>=1)&&(e+=e)){1&o&&(n+=e);}return n;};},function(t,e,n){var r=n(13),i=n(170).set;t.exports=function(t,e,n){var o,a=e.constructor;return a!==n&&"function"==typeof a&&(o=a.prototype)!==n.prototype&&r(o)&&i&&i(t,o),t;};},function(t,e){t.exports="\t\n\x0B\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF";},function(t,e,n){var r=n(13),i=n(14),o=function o(t,e){if(i(t),!r(e)&&null!==e)throw TypeError(e+": can't set as prototype!");};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,e,r){try{(r=n(56)(Function.call,n(53).f(Object.prototype,"__proto__").set,2))(t,[]),e=!(t instanceof Array);}catch(t){e=!0;}return function(t,n){return o(t,n),e?t.__proto__=n:r(t,n),t;};}({},!1):void 0),check:o};},function(t,e,n){var r=n(16).document;t.exports=r&&r.documentElement;},function(t,e){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",");},function(t,e,n){var r=n(129)("keys"),i=n(84);t.exports=function(t){return r[t]||(r[t]=i(t));};},function(t,e,n){e.f=n(19);},function(t,e,n){var r=n(13),i=n(16).document,o=r(i)&&r(i.createElement);t.exports=function(t){return o?i.createElement(t):{};};},function(t,e,n){var r=function r(t){return t;},i=function i(t){if(null==t)return r;var e,n,i=t.scale[0],o=t.scale[1],a=t.translate[0],s=t.translate[1];return function(t,r){r||(e=n=0);var u=2,c=t.length,l=new Array(c);for(l[0]=(e+=t[0])*i+a,l[1]=(n+=t[1])*o+s;u<c;){l[u]=t[u],++u;}return l;};},o=function o(t){var e,n=i(t.transform),r=1/0,o=r,a=-r,s=-r;function u(t){(t=n(t))[0]<r&&(r=t[0]),t[0]>a&&(a=t[0]),t[1]<o&&(o=t[1]),t[1]>s&&(s=t[1]);}function c(t){switch(t.type){case"GeometryCollection":t.geometries.forEach(c);break;case"Point":u(t.coordinates);break;case"MultiPoint":t.coordinates.forEach(u);}}for(e in t.arcs.forEach(function(t){for(var e,i=-1,u=t.length;++i<u;){(e=n(t[i],i))[0]<r&&(r=e[0]),e[0]>a&&(a=e[0]),e[1]<o&&(o=e[1]),e[1]>s&&(s=e[1]);}}),t.objects){c(t.objects[e]);}return [r,o,a,s];},a=function a(t,e){for(var n,r=t.length,i=r-e;i<--r;){n=t[i],t[i++]=t[r],t[r]=n;}},s=function s(t,e){return "string"==typeof e&&(e=t.objects[e]),"GeometryCollection"===e.type?{type:"FeatureCollection",features:e.geometries.map(function(e){return u(t,e);})}:u(t,e);};function u(t,e){var n=e.id,r=e.bbox,i=null==e.properties?{}:e.properties,o=c(t,e);return null==n&&null==r?{type:"Feature",properties:i,geometry:o}:null==r?{type:"Feature",id:n,properties:i,geometry:o}:{type:"Feature",id:n,bbox:r,properties:i,geometry:o};}function c(t,e){var n=i(t.transform),r=t.arcs;function o(t,e){e.length&&e.pop();for(var i=r[t<0?~t:t],o=0,s=i.length;o<s;++o){e.push(n(i[o],o));}t<0&&a(e,s);}function s(t){return n(t);}function u(t){for(var e=[],n=0,r=t.length;n<r;++n){o(t[n],e);}return e.length<2&&e.push(e[0]),e;}function c(t){for(var e=u(t);e.length<4;){e.push(e[0]);}return e;}function l(t){return t.map(c);}return function t(e){var n,r=e.type;switch(r){case"GeometryCollection":return {type:r,geometries:e.geometries.map(t)};case"Point":n=s(e.coordinates);break;case"MultiPoint":n=e.coordinates.map(s);break;case"LineString":n=u(e.arcs);break;case"MultiLineString":n=e.arcs.map(u);break;case"Polygon":n=l(e.arcs);break;case"MultiPolygon":n=e.arcs.map(l);break;default:return null;}return {type:r,coordinates:n};}(e);}var l=function l(t,e){var n={},r={},i={},o=[],a=-1;function s(t,e){for(var r in t){var i=t[r];delete e[i.start],delete i.start,delete i.end,i.forEach(function(t){n[t<0?~t:t]=1;}),o.push(i);}}return e.forEach(function(n,r){var i,o=t.arcs[n<0?~n:n];o.length<3&&!o[1][0]&&!o[1][1]&&(i=e[++a],e[a]=n,e[r]=i);}),e.forEach(function(e){var n,o,a=function(e){var n,r=t.arcs[e<0?~e:e],i=r[0];t.transform?(n=[0,0],r.forEach(function(t){n[0]+=t[0],n[1]+=t[1];})):n=r[r.length-1];return e<0?[n,i]:[i,n];}(e),s=a[0],u=a[1];if(n=i[s]){if(delete i[n.end],n.push(e),n.end=u,o=r[u]){delete r[o.start];var c=o===n?n:n.concat(o);r[c.start=n.start]=i[c.end=o.end]=c;}else r[n.start]=i[n.end]=n;}else if(n=r[u]){if(delete r[n.start],n.unshift(e),n.start=s,o=i[s]){delete i[o.end];var l=o===n?n:o.concat(n);r[l.start=o.start]=i[l.end=n.end]=l;}else r[n.start]=i[n.end]=n;}else r[(n=[e]).start=s]=i[n.end=u]=n;}),s(i,r),s(r,i),e.forEach(function(t){n[t<0?~t:t]||o.push([t]);}),o;},f=function f(t){return c(t,h.apply(this,arguments));};function h(t,e,n){var r,i,o;if(arguments.length>1)r=function(t,e,n){var r,i=[],o=[];function a(t){var e=t<0?~t:t;(o[e]||(o[e]=[])).push({i:t,g:r});}function s(t){t.forEach(a);}function u(t){t.forEach(s);}return function t(e){switch(r=e,e.type){case"GeometryCollection":e.geometries.forEach(t);break;case"LineString":s(e.arcs);break;case"MultiLineString":case"Polygon":u(e.arcs);break;case"MultiPolygon":!function(t){t.forEach(u);}(e.arcs);}}(e),o.forEach(null==n?function(t){i.push(t[0].i);}:function(t){n(t[0].g,t[t.length-1].g)&&i.push(t[0].i);}),i;}(0,e,n);else for(i=0,r=new Array(o=t.arcs.length);i<o;++i){r[i]=i;}return {type:"MultiLineString",arcs:l(t,r)};}var d=function d(t){return c(t,p.apply(this,arguments));};function p(t,e){var n={},r=[],i=[];function o(t){t.forEach(function(e){e.forEach(function(e){(n[e=e<0?~e:e]||(n[e]=[])).push(t);});}),r.push(t);}function a(e){return function(t){for(var e,n=-1,r=t.length,i=t[r-1],o=0;++n<r;){e=i,i=t[n],o+=e[0]*i[1]-e[1]*i[0];}return Math.abs(o);}(c(t,{type:"Polygon",arcs:[e]}).coordinates[0]);}return e.forEach(function t(e){switch(e.type){case"GeometryCollection":e.geometries.forEach(t);break;case"Polygon":o(e.arcs);break;case"MultiPolygon":e.arcs.forEach(o);}}),r.forEach(function(t){if(!t._){var e=[],r=[t];for(t._=1,i.push(e);t=r.pop();){e.push(t),t.forEach(function(t){t.forEach(function(t){n[t<0?~t:t].forEach(function(t){t._||(t._=1,r.push(t));});});});}}}),r.forEach(function(t){delete t._;}),{type:"MultiPolygon",arcs:i.map(function(e){var r,i=[];if(e.forEach(function(t){t.forEach(function(t){t.forEach(function(t){n[t<0?~t:t].length<2&&i.push(t);});});}),(r=(i=l(t,i)).length)>1)for(var o,s,u=1,c=a(i[0]);u<r;++u){(o=a(i[u]))>c&&(s=i[0],i[0]=i[u],i[u]=s,c=o);}return i;}).filter(function(t){return t.length>0;})};}var m=function m(t,e){for(var n=0,r=t.length;n<r;){var i=n+r>>>1;t[i]<e?n=i+1:r=i;}return n;},g=function g(t){var e={},n=t.map(function(){return [];});function r(t,n){t.forEach(function(t){t<0&&(t=~t);var r=e[t];r?r.push(n):e[t]=[n];});}function i(t,e){t.forEach(function(t){r(t,e);});}var o={LineString:r,MultiLineString:i,Polygon:i,MultiPolygon:function MultiPolygon(t,e){t.forEach(function(t){i(t,e);});}};for(var a in t.forEach(function t(e,n){"GeometryCollection"===e.type?e.geometries.forEach(function(e){t(e,n);}):e.type in o&&o[e.type](e.arcs,n);}),e){for(var s=e[a],u=s.length,c=0;c<u;++c){for(var l=c+1;l<u;++l){var f,h=s[c],d=s[l];(f=n[h])[a=m(f,d)]!==d&&f.splice(a,0,d),(f=n[d])[a=m(f,h)]!==h&&f.splice(a,0,h);}}}return n;},v=function v(t){if(null==t)return r;var e,n,i=t.scale[0],o=t.scale[1],a=t.translate[0],s=t.translate[1];return function(t,r){r||(e=n=0);var u=2,c=t.length,l=new Array(c),f=Math.round((t[0]-a)/i),h=Math.round((t[1]-s)/o);for(l[0]=f-e,e=f,l[1]=h-n,n=h;u<c;){l[u]=t[u],++u;}return l;};},y=function y(t,e){if(t.transform)throw new Error("already quantized");if(e&&e.scale)u=t.bbox;else {if(!((n=Math.floor(e))>=2))throw new Error("n must be ≥2");var n,r=(u=t.bbox||o(t))[0],i=u[1],a=u[2],s=u[3];e={scale:[a-r?(a-r)/(n-1):1,s-i?(s-i)/(n-1):1],translate:[r,i]};}var u,c,l=v(e),f=t.objects,h={};function d(t){return l(t);}function p(t){var e;switch(t.type){case"GeometryCollection":e={type:"GeometryCollection",geometries:t.geometries.map(p)};break;case"Point":e={type:"Point",coordinates:d(t.coordinates)};break;case"MultiPoint":e={type:"MultiPoint",coordinates:t.coordinates.map(d)};break;default:return t;}return null!=t.id&&(e.id=t.id),null!=t.bbox&&(e.bbox=t.bbox),null!=t.properties&&(e.properties=t.properties),e;}for(c in f){h[c]=p(f[c]);}return {type:"Topology",bbox:u,transform:e,objects:h,arcs:t.arcs.map(function(t){var e,n=0,r=1,i=t.length,o=new Array(i);for(o[0]=l(t[0],0);++n<i;){((e=l(t[n],n))[0]||e[1])&&(o[r++]=e);}return 1===r&&(o[r++]=[0,0]),o.length=r,o;})};};n.d(e,!1,function(){return o;}),n.d(e,"a",function(){return s;}),n.d(e,"b",function(){return f;}),n.d(e,!1,function(){return h;}),n.d(e,!1,function(){return d;}),n.d(e,!1,function(){return p;}),n.d(e,!1,function(){return g;}),n.d(e,!1,function(){return y;}),n.d(e,!1,function(){return i;}),n.d(e,!1,function(){return v;});},function(t,e,n){(function(r,i){function o(){return "object"==_typeof$1(r)&&void 0!==t&&void 0!==i&&!!i.version;}n.d(e,"a",function(){return o;});}).call(this,n(59),n(75));},function(t,e,n){(function(t){n.d(e,"a",function(){return o;});var r=n(5),i=n(131);function o(){var e=t.Canvas||t.HTMLCanvasElement,n=t.Image||t.HTMLImageElement,o=t.fetch||function(){throw new Error("fetch - missing fetch implementation for nodejs environment");},a=Object(i.a)();return Object(r.a)({Canvas:e||function(){return function(){};}(),CanvasRenderingContext2D:t.CanvasRenderingContext2D||function(){return function(){};}(),Image:n||function(){return function(){};}(),ImageData:t.ImageData||function(){return function(){};}(),Video:t.HTMLVideoElement||function(){return function(){};}(),createCanvasElement:function createCanvasElement(){if(e)return new e();throw new Error("createCanvasElement - missing Canvas implementation for nodejs environment");},createImageElement:function createImageElement(){if(n)return new n();throw new Error("createImageElement - missing Image implementation for nodejs environment");},fetch:o},a);}}).call(this,n(59));},function(t,e,n){var r=n(90);t.exports={re:r.re,src:r.src,tokens:r.t,SEMVER_SPEC_VERSION:n(117).SEMVER_SPEC_VERSION,SemVer:n(32),compareIdentifiers:n(146).compareIdentifiers,rcompareIdentifiers:n(146).rcompareIdentifiers,parse:n(89),valid:n(348),clean:n(347),inc:n(346),diff:n(345),major:n(344),minor:n(343),patch:n(342),prerelease:n(341),compare:n(48),rcompare:n(340),compareLoose:n(339),compareBuild:n(144),sort:n(338),rsort:n(337),gt:n(114),lt:n(143),eq:n(145),neq:n(204),gte:n(142),lte:n(141),cmp:n(203),coerce:n(336),Comparator:n(113),Range:n(47),satisfies:n(112),toComparators:n(332),maxSatisfying:n(331),minSatisfying:n(330),minVersion:n(329),validRange:n(328),outside:n(140),gtr:n(327),ltr:n(326),intersects:n(325),simplifyRange:n(324),subset:n(323)};},function(t,e,n){var r=n(31),i=n(12),o=Object(r.a)(function(t){t.setUTCSeconds(0,0);},function(t,e){t.setTime(+t+e*i.c);},function(t,e){return (e-t)/i.c;},function(t){return t.getUTCMinutes();});e.a=o;o.range;},function(t,e,n){var r=n(31),i=n(12),o=Object(r.a)(function(t){t.setUTCMinutes(0,0,0);},function(t,e){t.setTime(+t+e*i.b);},function(t,e){return (e-t)/i.b;},function(t){return t.getUTCHours();});e.a=o;o.range;},function(t,e,n){var r=n(31),i=Object(r.a)(function(){},function(t,e){t.setTime(+t+e);},function(t,e){return e-t;});i.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?Object(r.a)(function(e){e.setTime(Math.floor(e/t)*t);},function(e,n){e.setTime(+e+n*t);},function(e,n){return (n-e)/t;}):i:null;},e.a=i;i.range;},function(t,e,n){var r=n(31),i=n(12),o=Object(r.a)(function(t){t.setTime(t-t.getMilliseconds()-t.getSeconds()*i.e);},function(t,e){t.setTime(+t+e*i.c);},function(t,e){return (e-t)/i.c;},function(t){return t.getMinutes();});e.a=o;o.range;},function(t,e,n){var r=n(31),i=n(12),o=Object(r.a)(function(t){t.setTime(t-t.getMilliseconds()-t.getSeconds()*i.e-t.getMinutes()*i.c);},function(t,e){t.setTime(+t+e*i.b);},function(t,e){return (e-t)/i.b;},function(t){return t.getHours();});e.a=o;o.range;},function(t,e){},function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++){r[n]=t[n];}return r;},t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e,n){var r=n(186);t.exports=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return "Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0;}},t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e,n){function r(t){this.message=t;}r.prototype.toString=function(){return "Cancel"+(this.message?": "+this.message:"");},r.prototype.__CANCEL__=!0,t.exports=r;},function(t,e,n){var r=n(36);t.exports=function(t,e){e=e||{};var n={},i=["url","method","data"],o=["headers","auth","proxy","params"],a=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],s=["validateStatus"];function u(t,e){return r.isPlainObject(t)&&r.isPlainObject(e)?r.merge(t,e):r.isPlainObject(e)?r.merge({},e):r.isArray(e)?e.slice():e;}function c(i){r.isUndefined(e[i])?r.isUndefined(t[i])||(n[i]=u(void 0,t[i])):n[i]=u(t[i],e[i]);}r.forEach(i,function(t){r.isUndefined(e[t])||(n[t]=u(void 0,e[t]));}),r.forEach(o,c),r.forEach(a,function(i){r.isUndefined(e[i])?r.isUndefined(t[i])||(n[i]=u(void 0,t[i])):n[i]=u(void 0,e[i]);}),r.forEach(s,function(r){r in e?n[r]=u(t[r],e[r]):r in t&&(n[r]=u(void 0,t[r]));});var l=i.concat(o).concat(a).concat(s),f=Object.keys(t).concat(Object.keys(e)).filter(function(t){return -1===l.indexOf(t);});return r.forEach(f,c),n;};},function(t,e,n){t.exports=function(t){return !(!t||!t.__CANCEL__);};},function(t,e,n){var r=n(193);t.exports=function(t,e,n,i,o){var a=new Error(t);return r(a,e,n,i,o);};},function(t,e,n){var r=n(36),i=n(274),o=n(273),a=n(194),s=n(272),u=n(269),c=n(268),l=n(191);t.exports=function(t){return new Promise(function(e,n){var f=t.data,h=t.headers,d=t.responseType;r.isFormData(f)&&delete h["Content-Type"];var p=new XMLHttpRequest();if(t.auth){var m=t.auth.username||"",g=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";h.Authorization="Basic "+btoa(m+":"+g);}var v=s(t.baseURL,t.url);function y(){if(p){var r="getAllResponseHeaders"in p?u(p.getAllResponseHeaders()):null,o={data:d&&"text"!==d&&"json"!==d?p.response:p.responseText,status:p.status,statusText:p.statusText,headers:r,config:t,request:p};i(e,n,o),p=null;}}if(p.open(t.method.toUpperCase(),a(v,t.params,t.paramsSerializer),!0),p.timeout=t.timeout,"onloadend"in p?p.onloadend=y:p.onreadystatechange=function(){p&&4===p.readyState&&(0!==p.status||p.responseURL&&0===p.responseURL.indexOf("file:"))&&setTimeout(y);},p.onabort=function(){p&&(n(l("Request aborted",t,"ECONNABORTED",p)),p=null);},p.onerror=function(){n(l("Network Error",t,null,p)),p=null;},p.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),n(l(e,t,t.transitional&&t.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",p)),p=null;},r.isStandardBrowserEnv()){var b=(t.withCredentials||c(v))&&t.xsrfCookieName?o.read(t.xsrfCookieName):void 0;b&&(h[t.xsrfHeaderName]=b);}"setRequestHeader"in p&&r.forEach(h,function(t,e){void 0===f&&"content-type"===e.toLowerCase()?delete h[e]:p.setRequestHeader(e,t);}),r.isUndefined(t.withCredentials)||(p.withCredentials=!!t.withCredentials),d&&"json"!==d&&(p.responseType=t.responseType),"function"==typeof t.onDownloadProgress&&p.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&p.upload&&p.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then(function(t){p&&(p.abort(),n(t),p=null);}),f||(f=null),p.send(f);});};},function(t,e,n){t.exports=function(t,e,n,r,i){return t.config=e,n&&(t.code=n),t.request=r,t.response=i,t.isAxiosError=!0,t.toJSON=function(){return {message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code};},t;};},function(t,e,n){var r=n(36);function i(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]");}t.exports=function(t,e,n){if(!e)return t;var o;if(n)o=n(e);else if(r.isURLSearchParams(e))o=e.toString();else {var a=[];r.forEach(e,function(t,e){null!==t&&void 0!==t&&(r.isArray(t)?e+="[]":t=[t],r.forEach(t,function(t){r.isDate(t)?t=t.toISOString():r.isObject(t)&&(t=JSON.stringify(t)),a.push(i(e)+"="+i(t));}));}),o=a.join("&");}if(o){var s=t.indexOf("#");-1!==s&&(t=t.slice(0,s)),t+=(-1===t.indexOf("?")?"?":"&")+o;}return t;};},function(t,e,n){t.exports=function(t,e){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++){n[r]=arguments[r];}return t.apply(e,n);};};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t};};Object.defineProperty(e,"__esModule",{value:!0});var o=i(n(88)),a=n(64),s=n(111),u=n(46);e.linechart=function(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee30(){var r,i,l,f,_loop12,_t297,h,d,p,m,g;return regeneratorRuntime.wrap(function _callee30$(_context35){while(1){switch(_context35.prev=_context35.next){case 0:r=Array.isArray(e.values[0])?e.values:[e.values],i=r[0].length,l=e.series?e.series:r.map(function(t,e){return "Series ".concat(e+1);});s.assert(l.length===r.length,"Must have an equal number of series labels as there are data series"),null!=n.seriesColors&&s.assert(n.seriesColors.length===r.length,"Must have an equal number of series colors as there are data series");f=[];_loop12=function _loop12(_t297){var e={x:_t297};l.forEach(function(n,i){var o=r[i][_t297].y;e[n]=o,e["".concat(n,"-name")]=n;}),f.push(e);};for(_t297=0;_t297<i;_t297++){_loop12(_t297);}h=Object.assign({},c,n),d={x:{field:"x",type:h.xType,title:h.xLabel},tooltip:[{field:"x",type:"quantitative"}].concat(_toConsumableArray(l.map(function(t){return {field:t,type:"quantitative"};})))},p=l.map(function(t){return {data:void 0,mark:{type:"line",clip:!0},encoding:{y:{field:t,type:h.yType,title:h.yLabel,scale:h.zoomToFit?{zero:!1}:null!=h.yAxisDomain?{domain:h.yAxisDomain}:void 0},color:{field:"".concat(t,"-name"),type:"nominal",legend:{values:l,title:null},scale:{range:h.seriesColors}}}};}),m=u.getDrawArea(t),g={width:h.width||a.getDefaultWidth(m),height:h.height||a.getDefaultHeight(m),padding:0,autosize:{type:"fit",contains:"padding",resize:!0},config:{axis:{labelFontSize:h.fontSize,titleFontSize:h.fontSize},text:{fontSize:h.fontSize},legend:{labelFontSize:h.fontSize,titleFontSize:h.fontSize}},data:{values:f},encoding:d,layer:[].concat(_toConsumableArray(p),[{mark:"rule",selection:{hover:{type:"single",on:"mouseover",nearest:!0,clear:"mouseout"}},encoding:{color:{value:"grey",condition:{selection:{not:"hover"},value:"transparent"}}}}])};_context35.next=8;return o.default(m,g,{actions:!1,mode:"vega-lite",defaultStyle:!1});case 8:return _context35.abrupt("return",Promise.resolve());case 9:case"end":return _context35.stop();}}},_callee30);}));};var c={xLabel:"x",yLabel:"y",xType:"quantitative",yType:"quantitative",zoomToFit:!1,fontSize:11};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(292);var i;var o="Visor",a="tfjs-visor-container";e.visor=function(){if("undefined"==typeof document)throw new Error("No document defined. This library needs a browser/dom to work");if(document.getElementById(a)&&null!=i)return i;var t,e=document.getElementById(a);function n(e,n){var i=null;return t=r.VisorComponent.render(e,t,{ref:function ref(t){return i=t;},surfaceList:Array.from(n.values())}),i;}null==e&&((e=document.createElement("div")).id=a,document.body.appendChild(e));var o=new Map(),u=n(e,o);return i=new s(u,e,o,n);};var s=/*#__PURE__*/function(){function s(t,e,n,r){_classCallCheck(this,s);this.visorComponent=t,this.el=e,this.surfaceList=n,this.renderVisor=r;}_createClass(s,[{key:"surface",value:function surface(t){var e=t.name,n=null==t.tab?o:t.tab;if(null==e||!("string"==typeof e||e instanceof String))throw new Error("You must pass a config object with a 'name' property to create or retrieve a surface");var r=Object.assign({},t,{tab:n}),i="".concat(e,"-").concat(n);return this.surfaceList.has(i)||this.surfaceList.set(i,r),this.renderVisor(this.el,this.surfaceList),this.visorComponent.getSurface(e,n);}},{key:"isFullscreen",value:function isFullscreen(){return this.visorComponent.isFullscreen();}},{key:"isOpen",value:function isOpen(){return this.visorComponent.isOpen();}},{key:"close",value:function close(){return this.visorComponent.close();}},{key:"open",value:function open(){return this.visorComponent.open();}},{key:"toggle",value:function toggle(){return this.visorComponent.toggle();}},{key:"toggleFullScreen",value:function toggleFullScreen(){return this.visorComponent.toggleFullScreen();}},{key:"bindKeys",value:function bindKeys(){return this.visorComponent.bindKeys();}},{key:"unbindKeys",value:function unbindKeys(){return this.visorComponent.unbindKeys();}},{key:"setActiveTab",value:function setActiveTab(t){if(!this.visorComponent.state.tabs.has(t))throw new Error("Tab '".concat(t,"' does not exist"));this.visorComponent.setState({activeTab:t});}}]);return s;}();e.Visor=s;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.isSurfaceInfo=function(t){return null!=t.name;},e.isSurface=function(t){return t.drawArea instanceof HTMLElement;};},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){return t.charAt(0).toUpperCase()+t.slice(1);},t.exports=e.default;},function(t,e,n){var r=n(315);t.exports=r;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.processStyleName=void 0,e.createMarkupForStyles=function(t,e){var n="";for(var i in t){var o=0===i.indexOf("--");if(t.hasOwnProperty(i)&&"label"!==i){var a=t[i];null!=a&&(o?n+=i+":"+a+";":(n+=s(i)+":",n+=(0, r.default)(i,a,e)+";"));}}return n||null;};a(n(319));var r=a(n(317)),i=a(n(314)),o=a(n(312));a(n(200));function a(t){return t&&t.__esModule?t:{default:t};}var s=e.processStyleName=(0, o.default)(i.default);},function(t,e,n){n.r(e),n.d(e,"default",function(){return a;}),n.d(e,"point",function(){return s;});var r=n(null),i=n(null),o=n(null);function a(){var t,e,n=Object(o.a)().unknown(void 0),s=n.domain,u=n.range,c=0,l=1,f=!1,h=0,d=0,p=.5;function m(){var n=s().length,i=l<c,o=i?l:c,a=i?c:l;t=(a-o)/Math.max(1,n-h+2*d),f&&(t=Math.floor(t)),o+=(a-o-t*(n-h))*p,e=t*(1-h),f&&(o=Math.round(o),e=Math.round(e));var m=Object(r.a)(n).map(function(e){return o+t*e;});return u(i?m.reverse():m);}return delete n.unknown,n.domain=function(t){return arguments.length?(s(t),m()):s();},n.range=function(t){var _t298,_t299;return arguments.length?((_t298=t,_t299=_slicedToArray(_t298,2),c=_t299[0],l=_t299[1],_t298),c=+c,l=+l,m()):[c,l];},n.rangeRound=function(t){var _t300,_t301;return (_t300=t,_t301=_slicedToArray(_t300,2),c=_t301[0],l=_t301[1],_t300),c=+c,l=+l,f=!0,m();},n.bandwidth=function(){return e;},n.step=function(){return t;},n.round=function(t){return arguments.length?(f=!!t,m()):f;},n.padding=function(t){return arguments.length?(h=Math.min(1,d=+t),m()):h;},n.paddingInner=function(t){return arguments.length?(h=Math.min(1,t),m()):h;},n.paddingOuter=function(t){return arguments.length?(d=+t,m()):d;},n.align=function(t){return arguments.length?(p=Math.max(0,Math.min(1,t)),m()):p;},n.copy=function(){return a(s(),[c,l]).round(f).paddingInner(h).paddingOuter(d).align(p);},i.a.apply(m(),arguments);}function s(){return function t(e){var n=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,delete e.paddingOuter,e.copy=function(){return t(n());},e;}(a.apply(null,arguments).paddingInner(1));}},function(t,e,n){var r=n(145),i=n(204),o=n(114),a=n(142),s=n(143),u=n(141);t.exports=function(t,e,n,c){switch(e){case"===":return "object"==_typeof$1(t)&&(t=t.version),"object"==_typeof$1(n)&&(n=n.version),t===n;case"!==":return "object"==_typeof$1(t)&&(t=t.version),"object"==_typeof$1(n)&&(n=n.version),t!==n;case"":case"=":case"==":return r(t,n,c);case"!=":return i(t,n,c);case">":return o(t,n,c);case">=":return a(t,n,c);case"<":return s(t,n,c);case"<=":return u(t,n,c);default:throw new TypeError("Invalid operator: ".concat(e));}};},function(t,e,n){var r=n(48);t.exports=function(t,e,n){return 0!==r(t,e,n);};},function(t,e,n){/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(25),i=n(73),o=n(74),a=n(29),s=n(374),u=n(28);e.div=u.op({div_:function div_(t,e){var n,u=a.convertToTensor(t,"a","div"),c=a.convertToTensor(e,"b","div");if(n=o.makeTypesMatch(u,c),u=n[0],c=n[1],"int32"===u.dtype&&"int32"===c.dtype)return s.floorDiv(u,c);var l={a:u,b:c};return r.ENGINE.runKernelFunc(function(t,e){var n=t.realDivide(u,c);return e([u,c]),n;},l,null,i.Div,{});}});},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0});/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=n(25),i=n(73),o=n(74),a=n(29),s=n(28);e.add=s.op({add_:function add_(t,e){var n,s=a.convertToTensor(t,"a","add"),u=a.convertToTensor(e,"b","add");n=o.makeTypesMatch(s,u),s=n[0],u=n[1];var c={a:s,b:u};return r.ENGINE.runKernelFunc(function(t,e){var n=t.add(s,u);return e([s,u]),n;},c,null,i.Add);}});},function(t,e,n){(function(t){var r=void 0!==t&&t||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(t,e){this._id=t,this._clearFn=e;}e.setTimeout=function(){return new o(i.call(setTimeout,r,arguments),clearTimeout);},e.setInterval=function(){return new o(i.call(setInterval,r,arguments),clearInterval);},e.clearTimeout=e.clearInterval=function(t){t&&t.close();},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(r,this._id);},e.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e;},e.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1;},e._unrefActive=e.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout();},e));},n(391),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate;}).call(this,n(59));},function(t,e){t.exports=function(t){try{return !!t();}catch(t){return !0;}};},function(t,e){var n=t.exports={version:"2.6.12"};"number"==typeof __e&&(__e=n);},function(t,e,n){var r=n(27),i=n(82),o=n(41),a=n(106).f;t.exports=function(t){return function(e){for(var n,s=o(e),u=i(s),c=u.length,l=0,f=[];c>l;){n=u[l++],r&&!a.call(s,n)||f.push(t?[n,s[n]]:s[n]);}return f;};};},function(t,e,n){var r=n(22),i=n(167),o=n(61);t.exports=function(t,e,n,a){var s=String(o(t)),u=s.length,c=void 0===n?" ":String(n),l=r(e);if(l<=u||""==c)return s;var f=l-u,h=i.call(c,Math.ceil(f/c.length));return h.length>f&&(h=h.slice(0,f)),a?h+s:s+h;};},function(t,e,n){var r=n(79),i=n(127),o=n(14),a=n(16).Reflect;t.exports=a&&a.ownKeys||function(t){var e=r.f(o(t)),n=i.f;return n?e.concat(n(t)):e;};},function(t,e,n){var r=n(54),i=n(22);t.exports=function(t){if(void 0===t)return 0;var e=r(t),n=i(e);if(e!==n)throw RangeError("Wrong length!");return n;};},function(t,e,n){var r=n(93),i=n(65).getWeak,o=n(14),a=n(13),s=n(94),u=n(121),c=n(51),l=n(43),f=n(76),h=c(5),d=c(6),p=0,m=function m(t){return t._l||(t._l=new g());},g=function g(){this.a=[];},v=function v(t,e){return h(t.a,function(t){return t[0]===e;});};g.prototype={get:function get(t){var e=v(this,t);if(e)return e[1];},has:function has(t){return !!v(this,t);},set:function set(t,e){var n=v(this,t);n?n[1]=e:this.a.push([t,e]);},delete:function _delete(t){var e=d(this.a,function(e){return e[0]===t;});return ~e&&this.a.splice(e,1),!!~e;}},t.exports={getConstructor:function getConstructor(t,e,n,o){var c=t(function(t,r){s(t,c,e,"_i"),t._t=e,t._i=p++,t._l=void 0,void 0!=r&&u(r,n,t[o],t);});return r(c.prototype,{delete:function _delete(t){if(!a(t))return !1;var n=i(t);return !0===n?m(f(this,e)).delete(t):n&&l(n,this._i)&&delete n[this._i];},has:function has(t){if(!a(t))return !1;var n=i(t);return !0===n?m(f(this,e)).has(t):n&&l(n,this._i);}}),c;},def:function def(t,e,n){var r=i(o(e),!0);return !0===r?m(t).set(e,n):r[t._i]=n,t;},ufstore:m};},function(t,e,n){var r=n(26).f,i=n(80),o=n(93),a=n(56),s=n(94),u=n(121),c=n(163),l=n(221),f=n(95),h=n(27),d=n(65).fastKey,p=n(76),m=h?"_s":"size",g=function g(t,e){var n,r=d(e);if("F"!==r)return t._i[r];for(n=t._f;n;n=n.n){if(n.k==e)return n;}};t.exports={getConstructor:function getConstructor(t,e,n,c){var l=t(function(t,r){s(t,l,e,"_i"),t._t=e,t._i=i(null),t._f=void 0,t._l=void 0,t[m]=0,void 0!=r&&u(r,n,t[c],t);});return o(l.prototype,{clear:function clear(){for(var t=p(this,e),n=t._i,r=t._f;r;r=r.n){r.r=!0,r.p&&(r.p=r.p.n=void 0),delete n[r.i];}t._f=t._l=void 0,t[m]=0;},delete:function _delete(t){var n=p(this,e),r=g(n,t);if(r){var i=r.n,o=r.p;delete n._i[r.i],r.r=!0,o&&(o.n=i),i&&(i.p=o),n._f==r&&(n._f=i),n._l==r&&(n._l=o),n[m]--;}return !!r;},forEach:function forEach(t){p(this,e);for(var n,r=a(t,arguments.length>1?arguments[1]:void 0,3);n=n?n.n:this._f;){for(r(n.v,n.k,this);n&&n.r;){n=n.p;}}},has:function has(t){return !!g(p(this,e),t);}}),h&&r(l.prototype,"size",{get:function get(){return p(this,e)[m];}}),l;},def:function def(t,e,n){var r,i,o=g(t,e);return o?o.v=n:(t._l=o={i:i=d(e,!0),k:e,v:n,p:r=t._l,n:void 0,r:!1},t._f||(t._f=o),r&&(r.n=o),t[m]++,"F"!==i&&(t._i[i]=o)),t;},getEntry:g,setStrong:function setStrong(t,e,n){c(t,e,function(t,n){this._t=p(t,e),this._k=n,this._l=void 0;},function(){for(var t=this._k,e=this._l;e&&e.r;){e=e.p;}return this._t&&(this._l=e=e?e.n:this._t._f)?l(0,"keys"==t?e.k:"values"==t?e.v:[e.k,e.v]):(this._t=void 0,l(1));},n?"entries":"values",!n,!0),f(e);}};},function(t,e,n){var r=n(14),i=n(13),o=n(217);t.exports=function(t,e){if(r(t),i(e)&&e.constructor===t)return e;var n=o.f(t);return (0, n.resolve)(e),n.promise;};},function(t,e,n){var r=n(55);t.exports.f=function(t){return new function(t){var e,n;this.promise=new t(function(t,r){if(void 0!==e||void 0!==n)throw TypeError("Bad Promise constructor");e=t,n=r;}),this.resolve=r(e),this.reject=r(n);}(t);};},function(t,e,n){var r,i,o,a,s=n(83),u=n(16),c=n(56),l=n(105),f=n(8),h=n(13),d=n(55),p=n(94),m=n(121),g=n(104),v=n(152).set,y=n(466)(),b=n(217),x=n(465),w=n(120),k=n(216),E=u.TypeError,C=u.process,A=C&&C.versions,O=A&&A.v8||"",_2=u.Promise,S="process"==l(C),D=function D(){},F=i=b.f,T=!!function(){try{var t=_2.resolve(1),e=(t.constructor={})[n(19)("species")]=function(t){t(D,D);};return (S||"function"==typeof PromiseRejectionEvent)&&t.then(D)instanceof e&&0!==O.indexOf("6.6")&&-1===w.indexOf("Chrome/66");}catch(t){}}(),N=function N(t){var e;return !(!h(t)||"function"!=typeof(e=t.then))&&e;},I=function I(t,e){if(!t._n){t._n=!0;var n=t._c;y(function(){for(var r=t._v,i=1==t._s,o=0,a=function a(e){var n,o,a,s=i?e.ok:e.fail,u=e.resolve,c=e.reject,l=e.domain;try{s?(i||(2==t._h&&j(t),t._h=1),!0===s?n=r:(l&&l.enter(),n=s(r),l&&(l.exit(),a=!0)),n===e.promise?c(E("Promise-chain cycle")):(o=N(n))?o.call(n,u,c):u(n)):c(r);}catch(t){l&&!a&&l.exit(),c(t);}};n.length>o;){a(n[o++]);}t._c=[],t._n=!1,e&&!t._h&&R(t);});}},R=function R(t){v.call(u,function(){var e,n,r,i=t._v,o=M(t);if(o&&(e=x(function(){S?C.emit("unhandledRejection",i,t):(n=u.onunhandledrejection)?n({promise:t,reason:i}):(r=u.console)&&r.error&&r.error("Unhandled promise rejection",i);}),t._h=S||M(t)?2:1),t._a=void 0,o&&e.e)throw e.v;});},M=function M(t){return 1!==t._h&&0===(t._a||t._c).length;},j=function j(t){v.call(u,function(){var e;S?C.emit("rejectionHandled",t):(e=u.onrejectionhandled)&&e({promise:t,reason:t._v});});},B=function B(t){var e=this;e._d||(e._d=!0,(e=e._w||e)._v=t,e._s=2,e._a||(e._a=e._c.slice()),I(e,!0));},P=function P(t){var e,n=this;if(!n._d){n._d=!0,n=n._w||n;try{if(n===t)throw E("Promise can't be resolved itself");(e=N(t))?y(function(){var r={_w:n,_d:!1};try{e.call(t,c(P,r,1),c(B,r,1));}catch(t){B.call(r,t);}}):(n._v=t,n._s=1,I(n,!1));}catch(t){B.call({_w:n,_d:!1},t);}}};T||(_2=function _(t){p(this,_2,"Promise","_h"),d(t),r.call(this);try{t(c(P,this,1),c(B,this,1));}catch(t){B.call(this,t);}},(r=function r(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1;}).prototype=n(93)(_2.prototype,{then:function then(t,e){var n=F(g(this,_2));return n.ok="function"!=typeof t||t,n.fail="function"==typeof e&&e,n.domain=S?C.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&I(this,!1),n.promise;},catch:function _catch(t){return this.then(void 0,t);}}),o=function o(){var t=new r();this.promise=t,this.resolve=c(P,t,1),this.reject=c(B,t,1);},b.f=F=function F(t){return t===_2||t===a?new o(t):i(t);}),f(f.G+f.W+f.F*!T,{Promise:_2}),n(98)(_2,"Promise"),n(95)("Promise"),a=n(24).Promise,f(f.S+f.F*!T,"Promise",{reject:function reject(t){var e=F(this);return (0, e.reject)(t),e.promise;}}),f(f.S+f.F*(s||!T),"Promise",{resolve:function resolve(t){return k(s&&this===a?_2:this,t);}}),f(f.S+f.F*!(T&&n(125)(function(t){_2.all(t).catch(D);})),"Promise",{all:function all(t){var e=this,n=F(e),r=n.resolve,i=n.reject,o=x(function(){var n=[],o=0,a=1;m(t,!1,function(t){var s=o++,u=!1;n.push(void 0),a++,e.resolve(t).then(function(t){u||(u=!0,n[s]=t,--a||r(n));},i);}),--a||r(n);});return o.e&&i(o.v),n.promise;},race:function race(t){var e=this,n=F(e),r=n.reject,i=x(function(){m(t,!1,function(t){e.resolve(t).then(n.resolve,r);});});return i.e&&r(i.v),n.promise;}});},function(t,e,n){n(27)&&"g"!=/./g.flags&&n(26).f(RegExp.prototype,"flags",{configurable:!0,get:n(124)});},function(t,e,n){var r=n(154);n(8)({target:"RegExp",proto:!0,forced:r!==/./.exec},{exec:r});},function(t,e){t.exports=function(t,e){return {value:e,done:!!t};};},function(t,e,n){var r=n(34),i=n(81),o=n(22);t.exports=[].copyWithin||function(t,e){var n=r(this),a=o(n.length),s=i(t,a),u=i(e,a),c=arguments.length>2?arguments[2]:void 0,l=Math.min((void 0===c?a:i(c,a))-u,a-s),f=1;for(u<s&&s<u+l&&(f=-1,u+=l-1,s+=l-1);l-->0;){u in n?n[s]=n[u]:delete n[s],s+=f,u+=f;}return n;};},function(t,e,n){var r=n(55),i=n(34),o=n(107),a=n(22);t.exports=function(t,e,n,s,u){r(e);var c=i(t),l=o(c),f=a(c.length),h=u?f-1:0,d=u?-1:1;if(n<2)for(;;){if(h in l){s=l[h],h+=d;break;}if(h+=d,u?h<0:f<=h)throw TypeError("Reduce of empty array with no initial value");}for(;u?h>=0:f>h;h+=d){h in l&&(s=e(s,l[h],h,c));}return s;};},function(t,e,n){var r=n(486);t.exports=function(t,e){return new(r(t))(e);};},function(t,e,n){var r=n(14);t.exports=function(t,e,n,i){try{return i?e(r(n)[0],n[1]):e(n);}catch(e){var o=t.return;throw void 0!==o&&r(o.call(t)),e;}};},function(t,e,n){var r=n(80),i=n(85),o=n(98),a={};n(42)(a,n(19)("iterator"),function(){return this;}),t.exports=function(t,e,n){t.prototype=r(a,{next:i(1,n)}),o(t,e+" Iterator");};},function(t,e){t.exports=Math.log1p||function(t){return (t=+t)>-1e-8&&t<1e-8?t-t*t/2:Math.log(1+t);};},function(t,e,n){var r=n(13),i=Math.floor;t.exports=function(t){return !r(t)&&isFinite(t)&&i(t)===t;};},function(t,e,n){var r=n(62);t.exports=function(t,e){if("number"!=typeof t&&"Number"!=r(t))throw TypeError(e);return +t;};},function(t,e,n){var r=n(16).parseFloat,i=n(97).trim;t.exports=1/r(n(169)+"-0")!=-1/0?function(t){var e=i(String(t),3),n=r(e);return 0===n&&"-"==e.charAt(0)?-0:n;}:r;},function(t,e,n){var r=n(16).parseInt,i=n(97).trim,o=n(169),a=/^[-+]?0[xX]/;t.exports=8!==r(o+"08")||22!==r(o+"0x16")?function(t,e){var n=i(String(t),3);return r(n,e>>>0||(a.test(n)?16:10));}:r;},function(t,e){t.exports=function(t,e,n){var r=void 0===n;switch(e.length){case 0:return r?t():t.call(n);case 1:return r?t(e[0]):t.call(n,e[0]);case 2:return r?t(e[0],e[1]):t.call(n,e[0],e[1]);case 3:return r?t(e[0],e[1],e[2]):t.call(n,e[0],e[1],e[2]);case 4:return r?t(e[0],e[1],e[2],e[3]):t.call(n,e[0],e[1],e[2],e[3]);}return t.apply(n,e);};},function(t,e,n){var r=n(55),i=n(13),o=n(232),a=[].slice,s={};t.exports=Function.bind||function(t){var e=r(this),n=a.call(arguments,1),u=function u(){var r=n.concat(a.call(arguments));return this instanceof u?function(t,e,n){if(!(e in s)){for(var r=[],i=0;i<e;i++){r[i]="a["+i+"]";}s[e]=Function("F,a","return new F("+r.join(",")+")");}return s[e](t,n);}(e,r.length,r):o(e,r,t);};return i(e.prototype)&&(u.prototype=e.prototype),u;};},function(t,e){t.exports=Object.is||function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e;};},function(t,e,n){var r=n(27),i=n(82),o=n(127),a=n(106),s=n(34),u=n(107),c=Object.assign;t.exports=!c||n(15)(function(){var t={},e={},n=Symbol(),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach(function(t){e[t]=t;}),7!=c({},t)[n]||Object.keys(c({},e)).join("")!=r;})?function(t,e){for(var n=s(t),c=arguments.length,l=1,f=o.f,h=a.f;c>l;){for(var d,p=u(arguments[l++]),m=f?i(p).concat(f(p)):i(p),g=m.length,v=0;g>v;){d=m[v++],r&&!h.call(p,d)||(n[d]=p[d]);}}return n;}:c;},function(t,e,n){var r=n(41),i=n(79).f,o={}.toString,a="object"==(typeof window==="undefined"?"undefined":_typeof$1(window))&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];t.exports.f=function(t){return a&&"[object Window]"==o.call(t)?function(t){try{return i(t);}catch(t){return a.slice();}}(t):i(r(t));};},function(t,e,n){var r=n(26),i=n(14),o=n(82);t.exports=n(27)?Object.defineProperties:function(t,e){i(t);for(var n,a=o(e),s=a.length,u=0;s>u;){r.f(t,n=a[u++],e[n]);}return t;};},function(t,e,n){var r=n(43),i=n(41),o=n(128)(!1),a=n(173)("IE_PROTO");t.exports=function(t,e){var n,s=i(t),u=0,c=[];for(n in s){n!=a&&r(s,n)&&c.push(n);}for(;e.length>u;){r(s,n=e[u++])&&(~o(c,n)||c.push(n));}return c;};},function(t,e,n){var r=n(16),i=n(24),o=n(83),a=n(174),s=n(26).f;t.exports=function(t){var e=i.Symbol||(i.Symbol=o?{}:r.Symbol||{});"_"==t.charAt(0)||t in e||s(e,t,{value:a.f(t)});};},function(t,e,n){t.exports=!n(27)&&!n(15)(function(){return 7!=Object.defineProperty(n(175)("div"),"a",{get:function get(){return 7;}}).a;});},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0});var r=n(2);e.tf=r,function(t){for(var n in t){e.hasOwnProperty(n)||(e[n]=t[n]);}}(n(257));},function(t,e,n){/**
 * @license
 * Copyright 2021 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */!function(t,e,n){var r={1:{name:"/m/01g317",id:1,displayName:"person"},2:{name:"/m/0199g",id:2,displayName:"bicycle"},3:{name:"/m/0k4j",id:3,displayName:"car"},4:{name:"/m/04_sv",id:4,displayName:"motorcycle"},5:{name:"/m/05czz6l",id:5,displayName:"airplane"},6:{name:"/m/01bjv",id:6,displayName:"bus"},7:{name:"/m/07jdr",id:7,displayName:"train"},8:{name:"/m/07r04",id:8,displayName:"truck"},9:{name:"/m/019jd",id:9,displayName:"boat"},10:{name:"/m/015qff",id:10,displayName:"traffic light"},11:{name:"/m/01pns0",id:11,displayName:"fire hydrant"},13:{name:"/m/02pv19",id:13,displayName:"stop sign"},14:{name:"/m/015qbp",id:14,displayName:"parking meter"},15:{name:"/m/0cvnqh",id:15,displayName:"bench"},16:{name:"/m/015p6",id:16,displayName:"bird"},17:{name:"/m/01yrx",id:17,displayName:"cat"},18:{name:"/m/0bt9lr",id:18,displayName:"dog"},19:{name:"/m/03k3r",id:19,displayName:"horse"},20:{name:"/m/07bgp",id:20,displayName:"sheep"},21:{name:"/m/01xq0k1",id:21,displayName:"cow"},22:{name:"/m/0bwd_0j",id:22,displayName:"elephant"},23:{name:"/m/01dws",id:23,displayName:"bear"},24:{name:"/m/0898b",id:24,displayName:"zebra"},25:{name:"/m/03bk1",id:25,displayName:"giraffe"},27:{name:"/m/01940j",id:27,displayName:"backpack"},28:{name:"/m/0hnnb",id:28,displayName:"umbrella"},31:{name:"/m/080hkjn",id:31,displayName:"handbag"},32:{name:"/m/01rkbr",id:32,displayName:"tie"},33:{name:"/m/01s55n",id:33,displayName:"suitcase"},34:{name:"/m/02wmf",id:34,displayName:"frisbee"},35:{name:"/m/071p9",id:35,displayName:"skis"},36:{name:"/m/06__v",id:36,displayName:"snowboard"},37:{name:"/m/018xm",id:37,displayName:"sports ball"},38:{name:"/m/02zt3",id:38,displayName:"kite"},39:{name:"/m/03g8mr",id:39,displayName:"baseball bat"},40:{name:"/m/03grzl",id:40,displayName:"baseball glove"},41:{name:"/m/06_fw",id:41,displayName:"skateboard"},42:{name:"/m/019w40",id:42,displayName:"surfboard"},43:{name:"/m/0dv9c",id:43,displayName:"tennis racket"},44:{name:"/m/04dr76w",id:44,displayName:"bottle"},46:{name:"/m/09tvcd",id:46,displayName:"wine glass"},47:{name:"/m/08gqpm",id:47,displayName:"cup"},48:{name:"/m/0dt3t",id:48,displayName:"fork"},49:{name:"/m/04ctx",id:49,displayName:"knife"},50:{name:"/m/0cmx8",id:50,displayName:"spoon"},51:{name:"/m/04kkgm",id:51,displayName:"bowl"},52:{name:"/m/09qck",id:52,displayName:"banana"},53:{name:"/m/014j1m",id:53,displayName:"apple"},54:{name:"/m/0l515",id:54,displayName:"sandwich"},55:{name:"/m/0cyhj_",id:55,displayName:"orange"},56:{name:"/m/0hkxq",id:56,displayName:"broccoli"},57:{name:"/m/0fj52s",id:57,displayName:"carrot"},58:{name:"/m/01b9xk",id:58,displayName:"hot dog"},59:{name:"/m/0663v",id:59,displayName:"pizza"},60:{name:"/m/0jy4k",id:60,displayName:"donut"},61:{name:"/m/0fszt",id:61,displayName:"cake"},62:{name:"/m/01mzpv",id:62,displayName:"chair"},63:{name:"/m/02crq1",id:63,displayName:"couch"},64:{name:"/m/03fp41",id:64,displayName:"potted plant"},65:{name:"/m/03ssj5",id:65,displayName:"bed"},67:{name:"/m/04bcr3",id:67,displayName:"dining table"},70:{name:"/m/09g1w",id:70,displayName:"toilet"},72:{name:"/m/07c52",id:72,displayName:"tv"},73:{name:"/m/01c648",id:73,displayName:"laptop"},74:{name:"/m/020lf",id:74,displayName:"mouse"},75:{name:"/m/0qjjc",id:75,displayName:"remote"},76:{name:"/m/01m2v",id:76,displayName:"keyboard"},77:{name:"/m/050k8",id:77,displayName:"cell phone"},78:{name:"/m/0fx9l",id:78,displayName:"microwave"},79:{name:"/m/029bxz",id:79,displayName:"oven"},80:{name:"/m/01k6s3",id:80,displayName:"toaster"},81:{name:"/m/0130jx",id:81,displayName:"sink"},82:{name:"/m/040b_t",id:82,displayName:"refrigerator"},84:{name:"/m/0bt_c3",id:84,displayName:"book"},85:{name:"/m/01x3z",id:85,displayName:"clock"},86:{name:"/m/02s195",id:86,displayName:"vase"},87:{name:"/m/01lsmm",id:87,displayName:"scissors"},88:{name:"/m/0kmg4",id:88,displayName:"teddy bear"},89:{name:"/m/03wvsk",id:89,displayName:"hair drier"},90:{name:"/m/012xff",id:90,displayName:"toothbrush"}};var i=/*#__PURE__*/function(){function i(t,e){_classCallCheck(this,i);this.modelPath=e||"https://storage.googleapis.com/tfjs-models/savedmodel/".concat(this.getPrefix(t),"/model.json");}_createClass(i,[{key:"getPrefix",value:function getPrefix(t){return "lite_mobilenet_v2"===t?"ssd".concat(t):"ssd_".concat(t);}},{key:"load",value:function(){var _load2=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee31(){var t,r;return regeneratorRuntime.wrap(function _callee31$(_context36){while(1){switch(_context36.prev=_context36.next){case 0:_context36.next=2;return e.loadGraphModel(this.modelPath);case 2:this.model=_context36.sent;t=n.zeros([1,300,300,3],"int32");_context36.next=6;return this.model.executeAsync(t);case 6:r=_context36.sent;_context36.next=9;return Promise.all(r.map(function(t){return t.data();}));case 9:r.map(function(t){return t.dispose();});t.dispose();case 11:case"end":return _context36.stop();}}},_callee31,this);}));function load(){return _load2.apply(this,arguments);}return load;}()},{key:"infer",value:function(){var _infer=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee32(t,e,r){var _i184,o,a,s,u,c,_this$calculateMaxSco,_this$calculateMaxSco2,l,f,h,d,p;return regeneratorRuntime.wrap(function _callee32$(_context37){while(1){switch(_context37.prev=_context37.next){case 0:_i184=n.tidy(function(){return t instanceof n.Tensor||(t=n.browser.fromPixels(t)),n.expandDims(t);});o=_i184.shape[1];a=_i184.shape[2];_context37.next=5;return this.model.executeAsync(_i184);case 5:s=_context37.sent;u=s[0].dataSync();c=s[1].dataSync();_i184.dispose(),n.dispose(s);_this$calculateMaxSco=this.calculateMaxScores(u,s[0].shape[1],s[0].shape[2]),_this$calculateMaxSco2=_slicedToArray(_this$calculateMaxSco,2),l=_this$calculateMaxSco2[0],f=_this$calculateMaxSco2[1],h=n.getBackend();"webgl"===n.getBackend()&&n.setBackend("cpu");d=n.tidy(function(){var t=n.tensor2d(c,[s[1].shape[1],s[1].shape[3]]);return n.image.nonMaxSuppression(t,l,e,r,r);}),p=d.dataSync();return _context37.abrupt("return",(d.dispose(),h!==n.getBackend()&&n.setBackend(h),this.buildDetectedObjects(a,o,c,l,p,f)));case 13:case"end":return _context37.stop();}}},_callee32,this);}));function infer(_x34,_x35,_x36){return _infer.apply(this,arguments);}return infer;}()},{key:"buildDetectedObjects",value:function buildDetectedObjects(t,e,n,_i185,o,a){var s=o.length,u=[];for(var c=0;c<s;c++){var _s68=[];for(var _t302=0;_t302<4;_t302++){_s68[_t302]=n[4*o[c]+_t302];}var _l18=_s68[0]*e,_f18=_s68[1]*t,h=_s68[2]*e,d=_s68[3]*t;_s68[0]=_f18,_s68[1]=_l18,_s68[2]=d-_f18,_s68[3]=h-_l18,u.push({bbox:_s68,class:r[a[o[c]]+1].displayName,score:_i185[o[c]]});}return u;}},{key:"calculateMaxScores",value:function calculateMaxScores(t,e,n){var r=[],_i186=[];for(var o=0;o<e;o++){var _e302=Number.MIN_VALUE,a=-1;for(var _r218=0;_r218<n;_r218++){t[o*n+_r218]>_e302&&(_e302=t[o*n+_r218],a=_r218);}r[o]=_e302,_i186[o]=a;}return [r,_i186];}},{key:"detect",value:function(){var _detect=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee33(t){var e,n,_args38=arguments;return regeneratorRuntime.wrap(function _callee33$(_context38){while(1){switch(_context38.prev=_context38.next){case 0:e=_args38.length>1&&_args38[1]!==undefined?_args38[1]:20;n=_args38.length>2&&_args38[2]!==undefined?_args38[2]:.5;return _context38.abrupt("return",this.infer(t,e,n));case 3:case"end":return _context38.stop();}}},_callee33,this);}));function detect(_x37){return _detect.apply(this,arguments);}return detect;}()},{key:"dispose",value:function dispose(){null!=this.model&&this.model.dispose();}}]);return i;}();t.ObjectDetection=i,t.load=/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee34(){var t,e,r,o,_args39=arguments;return regeneratorRuntime.wrap(function _callee34$(_context39){while(1){switch(_context39.prev=_context39.next){case 0:t=_args39.length>0&&_args39[0]!==undefined?_args39[0]:{};if(!(null==n)){_context39.next=3;break;}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 model.");case 3:e=t.base||"lite_mobilenet_v2",r=t.modelUrl;if(!(-1===["mobilenet_v1","mobilenet_v2","lite_mobilenet_v2"].indexOf(e))){_context39.next=6;break;}throw new Error("ObjectDetection constructed with invalid base model ".concat(e,". Valid names are 'mobilenet_v1', 'mobilenet_v2' and 'lite_mobilenet_v2'."));case 6:o=new i(e,r);_context39.next=9;return o.load();case 9:return _context39.abrupt("return",o);case 10:case"end":return _context39.stop();}}},_callee34);})),t.version="2.2.2",Object.defineProperty(t,"__esModule",{value:!0});}(e,n(20),n(0));},function(t,e,n){t.exports=function t(e,n){if(e===n)return !0;if(e&&n&&"object"==_typeof$1(e)&&"object"==_typeof$1(n)){if(e.constructor!==n.constructor)return !1;var r,i,o;if(Array.isArray(e)){if((r=e.length)!=n.length)return !1;for(i=r;0!=i--;){if(!t(e[i],n[i]))return !1;}return !0;}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if((r=(o=Object.keys(e)).length)!==Object.keys(n).length)return !1;for(i=r;0!=i--;){if(!Object.prototype.hasOwnProperty.call(n,o[i]))return !1;}for(i=r;0!=i--;){var a=o[i];if(!t(e[a],n[a]))return !1;}return !0;}return e!=e&&n!=n;};},function(t,e,n){(function(e){var n=function(){function t(t,e){return null!=e&&t instanceof e;}var n,r,i;try{n=Map;}catch(t){n=function n(){};}try{r=Set;}catch(t){r=function r(){};}try{i=Promise;}catch(t){i=function i(){};}function o(a,u,c,l,f){"object"==_typeof$1(u)&&(c=u.depth,l=u.prototype,f=u.includeNonEnumerable,u=u.circular);var h=[],d=[],p=void 0!==e;return void 0===u&&(u=!0),void 0===c&&(c=1/0),function a(c,m){if(null===c)return null;if(0===m)return c;var g,v;if("object"!=_typeof$1(c))return c;if(t(c,n))g=new n();else if(t(c,r))g=new r();else if(t(c,i))g=new i(function(t,e){c.then(function(e){t(a(e,m-1));},function(t){e(a(t,m-1));});});else if(o.__isArray(c))g=[];else if(o.__isRegExp(c))g=new RegExp(c.source,s(c)),c.lastIndex&&(g.lastIndex=c.lastIndex);else if(o.__isDate(c))g=new Date(c.getTime());else {if(p&&e.isBuffer(c))return g=e.allocUnsafe?e.allocUnsafe(c.length):new e(c.length),c.copy(g),g;t(c,Error)?g=Object.create(c):void 0===l?(v=Object.getPrototypeOf(c),g=Object.create(v)):(g=Object.create(l),v=l);}if(u){var y=h.indexOf(c);if(-1!=y)return d[y];h.push(c),d.push(g);}for(var b in t(c,n)&&c.forEach(function(t,e){var n=a(e,m-1),r=a(t,m-1);g.set(n,r);}),t(c,r)&&c.forEach(function(t){var e=a(t,m-1);g.add(e);}),c){var x;v&&(x=Object.getOwnPropertyDescriptor(v,b)),x&&null==x.set||(g[b]=a(c[b],m-1));}if(Object.getOwnPropertySymbols){var w=Object.getOwnPropertySymbols(c);for(b=0;b<w.length;b++){var k=w[b];(!(C=Object.getOwnPropertyDescriptor(c,k))||C.enumerable||f)&&(g[k]=a(c[k],m-1),C.enumerable||Object.defineProperty(g,k,{enumerable:!1}));}}if(f){var E=Object.getOwnPropertyNames(c);for(b=0;b<E.length;b++){var C,A=E[b];(C=Object.getOwnPropertyDescriptor(c,A))&&C.enumerable||(g[A]=a(c[A],m-1),Object.defineProperty(g,A,{enumerable:!1}));}}return g;}(a,c);}function a(t){return Object.prototype.toString.call(t);}function s(t){var e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),e;}return o.clonePrototype=function(t){if(null===t)return null;var e=function e(){};return e.prototype=t,new e();},o.__objToStr=a,o.__isDate=function(t){return "object"==_typeof$1(t)&&"[object Date]"===a(t);},o.__isArray=function(t){return "object"==_typeof$1(t)&&"[object Array]"===a(t);},o.__isRegExp=function(t){return "object"==_typeof$1(t)&&"[object RegExp]"===a(t);},o.__getRegExpFlags=s,o;}();"object"==_typeof$1(t)&&t.exports&&(t.exports=n);}).call(this,n(92).Buffer);},function(t){t.exports={name:"vega-lite",author:'Dominik Moritz, Kanit "Ham" Wongsuphasawat, Arvind Satyanarayan, Jeffrey Heer',version:"4.13.1",collaborators:["Kanit Wongsuphasawat (http://kanitw.yellowpigz.com)","Dominik Moritz (https://www.domoritz.de)","Arvind Satyanarayan (https://arvindsatya.com)","Jeffrey Heer (https://jheer.org)"],homepage:"https://vega.github.io/vega-lite/",description:"Vega-Lite is a concise high-level language for interactive visualization.",main:"build/vega-lite.js",unpkg:"build/vega-lite.min.js",jsdelivr:"build/vega-lite.min.js",module:"build/src/index",types:"build/src/index.d.ts",bin:{vl2png:"./bin/vl2png",vl2svg:"./bin/vl2svg",vl2pdf:"./bin/vl2pdf",vl2vg:"./bin/vl2vg"},directories:{test:"test"},scripts:{changelog:"conventional-changelog -p angular -r 2",build:"yarn build:only","build:only":"yarn tsc:src && rollup -c",postbuild:"terser build/vega-lite.js -cm --source-map content=build/vega-lite.js.map,filename=build/vega-lite.min.js.map -o build/vega-lite.min.js && yarn schema && babel build/vega-lite.js --out-dir build-es5 --config-file ./babel.config.js","prebuild:examples":"yarn build:only","build:examples":"yarn data && TZ=America/Los_Angeles scripts/build-examples.sh","prebuild:examples-full":"yarn build:only","build:examples-full":"TZ=America/Los_Angeles scripts/build-examples.sh 1","build:example":"TZ=America/Los_Angeles scripts/build-example.sh","build:toc":"yarn build:jekyll && scripts/generate-toc","build:site":"yarn tsc:site && rollup -c site/rollup.config.js","build:jekyll":"pushd site && bundle exec jekyll build -q && popd","build:versions":"scripts/update-version.sh",clean:"find build ! -name 'vega-lite-schema.json' -type f -delete && rm -rf site/data/* && rm -f examples/compiled/*.png && find site/examples ! -name 'index.md' ! -name 'data' -type f -delete","predeploy:site":"yarn presite","deploy:site":"gh-pages -d site",data:"rsync -r node_modules/vega-datasets/data/* site/data",schema:"mkdir -p build && ts-json-schema-generator -f tsconfig.json -p src/index.ts -t TopLevelSpec --no-type-check --no-ref-encode > build/vega-lite-schema.json && yarn renameschema && cp build/vega-lite-schema.json site/_data/",renameschema:"scripts/rename-schema.sh",presite:"yarn data && yarn schema && yarn build:site && yarn build:versions && scripts/create-example-pages.sh",site:"pushd site && bundle exec jekyll serve -I -l && popd","tsc:src":"tsc -b src/tsconfig.src.json","tsc:site":"tsc -b site/tsconfig.site.json",prettierbase:"prettier '**/*.{md,css,yml}'",eslintbase:"eslint .",format:"yarn eslintbase --fix && yarn prettierbase --write",lint:"yarn eslintbase && yarn prettierbase --check",test:"jest test/ && yarn lint && yarn schema && jest examples/ && yarn test:runtime","test:inspect":"node --inspect-brk ./node_modules/.bin/jest --runInBand test","test:runtime":"TZ=America/Los_Angeles jest test-runtime/","test:runtime:generate":"yarn build:only && rm -Rf test-runtime/resources && VL_GENERATE_TESTS=true yarn test:runtime","watch:build":"yarn build:only && concurrently --kill-others -n Typescript,Rollup 'yarn tsc:src -w' 'rollup -c -w'","watch:site":"concurrently --kill-others -n Typescript,Rollup 'yarn tsc:site -w' 'rollup -c site/rollup.config.js -w'","watch:test":"jest --watch"},repository:{type:"git",url:"https://github.com/vega/vega-lite.git"},license:"BSD-3-Clause",bugs:{url:"https://github.com/vega/vega-lite/issues"},devDependencies:{"@babel/cli":"^7.10.1","@babel/core":"^7.10.1","@babel/preset-env":"^7.10.1","@rollup/plugin-commonjs":"12.0.0","@rollup/plugin-json":"^4.0.3","@rollup/plugin-node-resolve":"^8.0.0","@types/chai":"^4.2.11","@types/d3":"^5.7.2","@types/jest":"^25.2.3","@types/mkdirp":"^1.0.0","@types/puppeteer":"^3.0.0","@typescript-eslint/eslint-plugin":"^3.0.2","@typescript-eslint/parser":"^3.0.2",ajv:"^6.12.2",chai:"^4.2.0",cheerio:"^1.0.0-rc.3",codecov:"^3.7.0",concurrently:"^5.2.0","conventional-changelog-cli":"^2.0.34",d3:"^5.16.0",eslint:"^7.1.0","eslint-config-prettier":"^6.11.0","eslint-plugin-jest":"^23.13.2","eslint-plugin-prettier":"^3.1.3","gh-pages":"^2.2.0","highlight.js":"^10.0.3","http-server":"^0.12.3",jest:"^26.0.1","jest-puppeteer":"^4.4.0",mkdirp:"^1.0.4",prettier:"^2.0.5",puppeteer:"^3.1.0",rollup:"^2.11.0","rollup-plugin-sourcemaps":"^0.6.2","rollup-plugin-terser":"^6.1.0","svg2png-many":"^0.0.7",terser:"^4.7.0","ts-jest":"^26.0.0","ts-json-schema-generator":"^0.68.1",typescript:"~3.9.3","vega-cli":"^5.12.1","vega-datasets":"^1.30.2","vega-embed":"^6.8.0","vega-tooltip":"^0.23.0","vega-typings":"^0.17.0","yaml-front-matter":"^4.1.0"},dependencies:{"@types/clone":"~0.1.30","@types/fast-json-stable-stringify":"^2.0.0","array-flat-polyfill":"^1.0.1",clone:"~2.1.2","fast-deep-equal":"~3.1.1","fast-json-stable-stringify":"~2.1.0","json-stringify-pretty-compact":"~2.0.0",tslib:"~2.0.0","vega-event-selector":"~2.0.3","vega-expression":"~2.6.5","vega-util":"~1.14.0",yargs:"~15.3.1"},peerDependencies:{vega:"^5.12.1"},jest:{preset:"jest-puppeteer",transform:{"^.+\\.tsx?$":"ts-jest"},testRegex:"(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",moduleFileExtensions:["ts","tsx","js","jsx","json","node"],testPathIgnorePatterns:["<rootDir>/node_modules","<rootDir>/build","<rootDir>/_site","<rootDir>/src"],coverageDirectory:"./coverage/",collectCoverage:!1}};},function(t,e,n){n.d(e,"a",function(){return h;});var r=n(39),i=n(71),o=n(40),a=n(72),s=n(70),u=n(68);function c(t){if(0<=t.y&&t.y<100){var e=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return e.setFullYear(t.y),e;}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L);}function l(t){if(0<=t.y&&t.y<100){var e=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return e.setUTCFullYear(t.y),e;}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L));}function f(t,e,n){return {y:t,m:e,d:n,H:0,M:0,S:0,L:0};}function h(t){var e=t.dateTime,n=t.date,s=t.time,u=t.periods,h=t.days,p=t.shortDays,m=t.months,g=t.shortMonths,v=b(u),y=x(u),Q=b(h),yt=x(h),Ft=b(p),Tt=x(p),Nt=b(m),It=x(m),Rt=b(g),Mt=x(g),jt={a:function a(t){return p[t.getDay()];},A:function A(t){return h[t.getDay()];},b:function b(t){return g[t.getMonth()];},B:function B(t){return m[t.getMonth()];},c:null,d:U,e:U,f:H,g:rt,G:ot,H:W,I:V,j:q,L:$,m:G,M:K,p:function p(t){return u[+(t.getHours()>=12)];},q:function q(t){return 1+~~(t.getMonth()/3);},Q:St,s:Dt,S:X,u:Y,U:J,V:Z,w:tt,W:et,x:null,X:null,y:nt,Y:it,Z:at,"%":_t},Bt={a:function a(t){return p[t.getUTCDay()];},A:function A(t){return h[t.getUTCDay()];},b:function b(t){return g[t.getUTCMonth()];},B:function B(t){return m[t.getUTCMonth()];},c:null,d:st,e:st,f:ht,g:Et,G:At,H:ut,I:ct,j:lt,L:ft,m:dt,M:pt,p:function p(t){return u[+(t.getUTCHours()>=12)];},q:function q(t){return 1+~~(t.getUTCMonth()/3);},Q:St,s:Dt,S:mt,u:gt,U:vt,V:bt,w:xt,W:wt,x:null,X:null,y:kt,Y:Ct,Z:Ot,"%":_t},Pt={a:function a(t,e,n){var r=Ft.exec(e.slice(n));return r?(t.w=Tt.get(r[0].toLowerCase()),n+r[0].length):-1;},A:function A(t,e,n){var r=Q.exec(e.slice(n));return r?(t.w=yt.get(r[0].toLowerCase()),n+r[0].length):-1;},b:function b(t,e,n){var r=Rt.exec(e.slice(n));return r?(t.m=Mt.get(r[0].toLowerCase()),n+r[0].length):-1;},B:function B(t,e,n){var r=Nt.exec(e.slice(n));return r?(t.m=It.get(r[0].toLowerCase()),n+r[0].length):-1;},c:function c(t,n,r){return Ut(t,e,n,r);},d:T,e:T,f:B,g:_,G:O,H:I,I:I,j:N,L:j,m:F,M:R,p:function p(t,e,n){var r=v.exec(e.slice(n));return r?(t.p=y.get(r[0].toLowerCase()),n+r[0].length):-1;},q:D,Q:L,s:z,S:M,u:k,U:E,V:C,w:w,W:A,x:function x(t,e,r){return Ut(t,n,e,r);},X:function X(t,e,n){return Ut(t,s,e,n);},y:_,Y:O,Z:S,"%":P};function Lt(t,e){return function(n){var r,i,o,a=[],s=-1,u=0,c=t.length;for(n instanceof Date||(n=new Date(+n));++s<c;){37===t.charCodeAt(s)&&(a.push(t.slice(u,s)),null!=(i=d[r=t.charAt(++s)])?r=t.charAt(++s):i="e"===r?" ":"0",(o=e[r])&&(r=o(n,i)),a.push(r),u=s+1);}return a.push(t.slice(u,s)),a.join("");};}function zt(t,e){return function(n){var s,u,h=f(1900,void 0,1);if(Ut(h,t,n+="",0)!=n.length)return null;if("Q"in h)return new Date(h.Q);if("s"in h)return new Date(1e3*h.s+("L"in h?h.L:0));if(!e||"Z"in h||(h.Z=0),"p"in h&&(h.H=h.H%12+12*h.p),void 0===h.m&&(h.m="q"in h?h.q:0),"V"in h){if(h.V<1||h.V>53)return null;"w"in h||(h.w=1),"Z"in h?(s=(u=(s=l(f(h.y,0,1))).getUTCDay())>4||0===u?r.a.ceil(s):Object(r.a)(s),s=i.a.offset(s,7*(h.V-1)),h.y=s.getUTCFullYear(),h.m=s.getUTCMonth(),h.d=s.getUTCDate()+(h.w+6)%7):(s=(u=(s=c(f(h.y,0,1))).getDay())>4||0===u?o.a.ceil(s):Object(o.a)(s),s=a.a.offset(s,7*(h.V-1)),h.y=s.getFullYear(),h.m=s.getMonth(),h.d=s.getDate()+(h.w+6)%7);}else ("W"in h||"U"in h)&&("w"in h||(h.w="u"in h?h.u%7:"W"in h?1:0),u="Z"in h?l(f(h.y,0,1)).getUTCDay():c(f(h.y,0,1)).getDay(),h.m=0,h.d="W"in h?(h.w+6)%7+7*h.W-(u+5)%7:h.w+7*h.U-(u+6)%7);return "Z"in h?(h.H+=h.Z/100|0,h.M+=h.Z%100,l(h)):c(h);};}function Ut(t,e,n,r){for(var i,o,a=0,s=e.length,u=n.length;a<s;){if(r>=u)return -1;if(37===(i=e.charCodeAt(a++))){if(i=e.charAt(a++),!(o=Pt[i in d?e.charAt(a++):i])||(r=o(t,n,r))<0)return -1;}else if(i!=n.charCodeAt(r++))return -1;}return r;}return jt.x=Lt(n,jt),jt.X=Lt(s,jt),jt.c=Lt(e,jt),Bt.x=Lt(n,Bt),Bt.X=Lt(s,Bt),Bt.c=Lt(e,Bt),{format:function format(t){var e=Lt(t+="",jt);return e.toString=function(){return t;},e;},parse:function parse(t){var e=zt(t+="",!1);return e.toString=function(){return t;},e;},utcFormat:function utcFormat(t){var e=Lt(t+="",Bt);return e.toString=function(){return t;},e;},utcParse:function utcParse(t){var e=zt(t+="",!0);return e.toString=function(){return t;},e;}};}var d={"-":"",_:" ",0:"0"},p=/^\s*\d+/,m=/^%/,g=/[\\^$*+?|[\]().{}]/g;function v(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o<n?new Array(n-o+1).join(e)+i:i);}function y(t){return t.replace(g,"\\$&");}function b(t){return new RegExp("^(?:"+t.map(y).join("|")+")","i");}function x(t){return new Map(t.map(function(t,e){return [t.toLowerCase(),e];}));}function w(t,e,n){var r=p.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1;}function k(t,e,n){var r=p.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1;}function E(t,e,n){var r=p.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1;}function C(t,e,n){var r=p.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1;}function A(t,e,n){var r=p.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1;}function O(t,e,n){var r=p.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1;}function _(t,e,n){var r=p.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1;}function S(t,e,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(e.slice(n,n+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),n+r[0].length):-1;}function D(t,e,n){var r=p.exec(e.slice(n,n+1));return r?(t.q=3*r[0]-3,n+r[0].length):-1;}function F(t,e,n){var r=p.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1;}function T(t,e,n){var r=p.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1;}function N(t,e,n){var r=p.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1;}function I(t,e,n){var r=p.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1;}function R(t,e,n){var r=p.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1;}function M(t,e,n){var r=p.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1;}function j(t,e,n){var r=p.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1;}function B(t,e,n){var r=p.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1;}function P(t,e,n){var r=m.exec(e.slice(n,n+1));return r?n+r[0].length:-1;}function L(t,e,n){var r=p.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1;}function z(t,e,n){var r=p.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1;}function U(t,e){return v(t.getDate(),e,2);}function W(t,e){return v(t.getHours(),e,2);}function V(t,e){return v(t.getHours()%12||12,e,2);}function q(t,e){return v(1+a.a.count(Object(s.a)(t),t),e,3);}function $(t,e){return v(t.getMilliseconds(),e,3);}function H(t,e){return $(t,e)+"000";}function G(t,e){return v(t.getMonth()+1,e,2);}function K(t,e){return v(t.getMinutes(),e,2);}function X(t,e){return v(t.getSeconds(),e,2);}function Y(t){var e=t.getDay();return 0===e?7:e;}function J(t,e){return v(o.b.count(Object(s.a)(t)-1,t),e,2);}function Q(t){var e=t.getDay();return e>=4||0===e?Object(o.c)(t):o.c.ceil(t);}function Z(t,e){return t=Q(t),v(o.c.count(Object(s.a)(t),t)+(4===Object(s.a)(t).getDay()),e,2);}function tt(t){return t.getDay();}function et(t,e){return v(o.a.count(Object(s.a)(t)-1,t),e,2);}function nt(t,e){return v(t.getFullYear()%100,e,2);}function rt(t,e){return v((t=Q(t)).getFullYear()%100,e,2);}function it(t,e){return v(t.getFullYear()%1e4,e,4);}function ot(t,e){var n=t.getDay();return v((t=n>=4||0===n?Object(o.c)(t):o.c.ceil(t)).getFullYear()%1e4,e,4);}function at(t){var e=t.getTimezoneOffset();return (e>0?"-":(e*=-1,"+"))+v(e/60|0,"0",2)+v(e%60,"0",2);}function st(t,e){return v(t.getUTCDate(),e,2);}function ut(t,e){return v(t.getUTCHours(),e,2);}function ct(t,e){return v(t.getUTCHours()%12||12,e,2);}function lt(t,e){return v(1+i.a.count(Object(u.a)(t),t),e,3);}function ft(t,e){return v(t.getUTCMilliseconds(),e,3);}function ht(t,e){return ft(t,e)+"000";}function dt(t,e){return v(t.getUTCMonth()+1,e,2);}function pt(t,e){return v(t.getUTCMinutes(),e,2);}function mt(t,e){return v(t.getUTCSeconds(),e,2);}function gt(t){var e=t.getUTCDay();return 0===e?7:e;}function vt(t,e){return v(r.b.count(Object(u.a)(t)-1,t),e,2);}function yt(t){var e=t.getUTCDay();return e>=4||0===e?Object(r.c)(t):r.c.ceil(t);}function bt(t,e){return t=yt(t),v(r.c.count(Object(u.a)(t),t)+(4===Object(u.a)(t).getUTCDay()),e,2);}function xt(t){return t.getUTCDay();}function wt(t,e){return v(r.a.count(Object(u.a)(t)-1,t),e,2);}function kt(t,e){return v(t.getUTCFullYear()%100,e,2);}function Et(t,e){return v((t=yt(t)).getUTCFullYear()%100,e,2);}function Ct(t,e){return v(t.getUTCFullYear()%1e4,e,4);}function At(t,e){var n=t.getUTCDay();return v((t=n>=4||0===n?Object(r.c)(t):r.c.ceil(t)).getUTCFullYear()%1e4,e,4);}function Ot(){return "+0000";}function _t(){return "%";}function St(t){return +t;}function Dt(t){return Math.floor(+t/1e3);}},function(t,e,n){n.r(e);var r="http://www.w3.org/1999/xhtml",i={svg:"http://www.w3.org/2000/svg",xhtml:r,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},o=function o(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),i.hasOwnProperty(e)?{space:i[e],local:t}:t;};var a=function a(t){var e=o(t);return (e.local?function(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local);};}:function(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===r&&e.documentElement.namespaceURI===r?e.createElement(t):e.createElementNS(n,t);};})(e);};function s(){}var u=function u(t){return null==t?s:function(){return this.querySelector(t);};};function c(){return [];}var l=function l(t){return null==t?c:function(){return this.querySelectorAll(t);};},f=function f(t){return function(){return this.matches(t);};};if("undefined"!=typeof document){var h=document.documentElement;if(!h.matches){var d=h.webkitMatchesSelector||h.msMatchesSelector||h.mozMatchesSelector||h.oMatchesSelector;f=function f(t){return function(){return d.call(this,t);};};}}var p=f,m=function m(t){return new Array(t.length);};function g(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e;}g.prototype={constructor:g,appendChild:function appendChild(t){return this._parent.insertBefore(t,this._next);},insertBefore:function insertBefore(t,e){return this._parent.insertBefore(t,e);},querySelector:function querySelector(t){return this._parent.querySelector(t);},querySelectorAll:function querySelectorAll(t){return this._parent.querySelectorAll(t);}};var v="$";function y(t,e,n,r,i,o){for(var a,s=0,u=e.length,c=o.length;s<c;++s){(a=e[s])?(a.__data__=o[s],r[s]=a):n[s]=new g(t,o[s]);}for(;s<u;++s){(a=e[s])&&(i[s]=a);}}function b(t,e,n,r,i,o,a){var s,u,c,l={},f=e.length,h=o.length,d=new Array(f);for(s=0;s<f;++s){(u=e[s])&&(d[s]=c=v+a.call(u,u.__data__,s,e),c in l?i[s]=u:l[c]=u);}for(s=0;s<h;++s){(u=l[c=v+a.call(t,o[s],s,o)])?(r[s]=u,u.__data__=o[s],l[c]=null):n[s]=new g(t,o[s]);}for(s=0;s<f;++s){(u=e[s])&&l[d[s]]===u&&(i[s]=u);}}function x(t,e){return t<e?-1:t>e?1:t>=e?0:NaN;}var w=function w(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView;};function k(t,e){return t.style.getPropertyValue(e)||w(t).getComputedStyle(t,null).getPropertyValue(e);}function E(t){return t.trim().split(/^|\s+/);}function C(t){return t.classList||new A(t);}function A(t){this._node=t,this._names=E(t.getAttribute("class")||"");}function O(t,e){for(var n=C(t),r=-1,i=e.length;++r<i;){n.add(e[r]);}}function _(t,e){for(var n=C(t),r=-1,i=e.length;++r<i;){n.remove(e[r]);}}A.prototype={add:function add(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")));},remove:function remove(t){var e=this._names.indexOf(t);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")));},contains:function contains(t){return this._names.indexOf(t)>=0;}};function S(){this.textContent="";}function D(){this.innerHTML="";}function F(){this.nextSibling&&this.parentNode.appendChild(this);}function T(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild);}function N(){return null;}function I(){var t=this.parentNode;t&&t.removeChild(this);}function R(){return this.parentNode.insertBefore(this.cloneNode(!1),this.nextSibling);}function M(){return this.parentNode.insertBefore(this.cloneNode(!0),this.nextSibling);}var j={},B=null;"undefined"!=typeof document&&("onmouseenter"in document.documentElement||(j={mouseenter:"mouseover",mouseleave:"mouseout"}));function P(t,e,n){return t=L(t,e,n),function(e){var n=e.relatedTarget;n&&(n===this||8&n.compareDocumentPosition(this))||t.call(this,e);};}function L(t,e,n){return function(r){var i=B;B=r;try{t.call(this,this.__data__,e,n);}finally{B=i;}};}function z(t){return function(){var e=this.__on;if(e){for(var n,r=0,i=-1,o=e.length;r<o;++r){n=e[r],t.type&&n.type!==t.type||n.name!==t.name?e[++i]=n:this.removeEventListener(n.type,n.listener,n.capture);}++i?e.length=i:delete this.__on;}};}function U(t,e,n){var r=j.hasOwnProperty(t.type)?P:L;return function(i,o,a){var s,u=this.__on,c=r(e,o,a);if(u)for(var l=0,f=u.length;l<f;++l){if((s=u[l]).type===t.type&&s.name===t.name)return this.removeEventListener(s.type,s.listener,s.capture),this.addEventListener(s.type,s.listener=c,s.capture=n),void(s.value=e);}this.addEventListener(t.type,c,n),s={type:t.type,name:t.name,value:e,listener:c,capture:n},u?u.push(s):this.__on=[s];};}function W(t,e,n,r){var i=B;t.sourceEvent=B,B=t;try{return e.apply(n,r);}finally{B=i;}}function V(t,e,n){var r=w(t),i=r.CustomEvent;"function"==typeof i?i=new i(e,n):(i=r.document.createEvent("Event"),n?(i.initEvent(e,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(e,!1,!1)),t.dispatchEvent(i);}var q=[null];function $(t,e){this._groups=t,this._parents=e;}function H(){return new $([[document.documentElement]],q);}$.prototype=H.prototype={constructor:$,select:function select(t){"function"!=typeof t&&(t=u(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i){for(var o,a,s=e[i],c=s.length,l=r[i]=new Array(c),f=0;f<c;++f){(o=s[f])&&(a=t.call(o,o.__data__,f,s))&&("__data__"in o&&(a.__data__=o.__data__),l[f]=a);}}return new $(r,this._parents);},selectAll:function selectAll(t){"function"!=typeof t&&(t=l(t));for(var e=this._groups,n=e.length,r=[],i=[],o=0;o<n;++o){for(var a,s=e[o],u=s.length,c=0;c<u;++c){(a=s[c])&&(r.push(t.call(a,a.__data__,c,s)),i.push(a));}}return new $(r,i);},filter:function filter(t){"function"!=typeof t&&(t=p(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i<n;++i){for(var o,a=e[i],s=a.length,u=r[i]=[],c=0;c<s;++c){(o=a[c])&&t.call(o,o.__data__,c,a)&&u.push(o);}}return new $(r,this._parents);},data:function data(t,e){if(!t)return d=new Array(this.size()),c=-1,this.each(function(t){d[++c]=t;}),d;var n=e?b:y,r=this._parents,i=this._groups;"function"!=typeof t&&(t=function(t){return function(){return t;};}(t));for(var o=i.length,a=new Array(o),s=new Array(o),u=new Array(o),c=0;c<o;++c){var l=r[c],f=i[c],h=f.length,d=t.call(l,l&&l.__data__,c,r),p=d.length,m=s[c]=new Array(p),g=a[c]=new Array(p);n(l,f,m,g,u[c]=new Array(h),d,e);for(var v,x,w=0,k=0;w<p;++w){if(v=m[w]){for(w>=k&&(k=w+1);!(x=g[k])&&++k<p;){}v._next=x||null;}}}return (a=new $(a,r))._enter=s,a._exit=u,a;},enter:function enter(){return new $(this._enter||this._groups.map(m),this._parents);},exit:function exit(){return new $(this._exit||this._groups.map(m),this._parents);},merge:function merge(t){for(var e=this._groups,n=t._groups,r=e.length,i=n.length,o=Math.min(r,i),a=new Array(r),s=0;s<o;++s){for(var u,c=e[s],l=n[s],f=c.length,h=a[s]=new Array(f),d=0;d<f;++d){(u=c[d]||l[d])&&(h[d]=u);}}for(;s<r;++s){a[s]=e[s];}return new $(a,this._parents);},order:function order(){for(var t=this._groups,e=-1,n=t.length;++e<n;){for(var r,i=t[e],o=i.length-1,a=i[o];--o>=0;){(r=i[o])&&(a&&a!==r.nextSibling&&a.parentNode.insertBefore(r,a),a=r);}}return this;},sort:function sort(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n;}t||(t=x);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var a,s=n[o],u=s.length,c=i[o]=new Array(u),l=0;l<u;++l){(a=s[l])&&(c[l]=a);}c.sort(e);}return new $(i,this._parents).order();},call:function call(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this;},nodes:function nodes(){var t=new Array(this.size()),e=-1;return this.each(function(){t[++e]=this;}),t;},node:function node(){for(var t=this._groups,e=0,n=t.length;e<n;++e){for(var r=t[e],i=0,o=r.length;i<o;++i){var a=r[i];if(a)return a;}}return null;},size:function size(){var t=0;return this.each(function(){++t;}),t;},empty:function empty(){return !this.node();},each:function each(t){for(var e=this._groups,n=0,r=e.length;n<r;++n){for(var i,o=e[n],a=0,s=o.length;a<s;++a){(i=o[a])&&t.call(i,i.__data__,a,o);}}return this;},attr:function attr(t,e){var n=o(t);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n);}return this.each((null==e?n.local?function(t){return function(){this.removeAttributeNS(t.space,t.local);};}:function(t){return function(){this.removeAttribute(t);};}:"function"==typeof e?n.local?function(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n);};}:function(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n);};}:n.local?function(t,e){return function(){this.setAttributeNS(t.space,t.local,e);};}:function(t,e){return function(){this.setAttribute(t,e);};})(n,e));},style:function style(t,e,n){return arguments.length>1?this.each((null==e?function(t){return function(){this.style.removeProperty(t);};}:"function"==typeof e?function(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n);};}:function(t,e,n){return function(){this.style.setProperty(t,e,n);};})(t,e,null==n?"":n)):k(this.node(),t);},property:function property(t,e){return arguments.length>1?this.each((null==e?function(t){return function(){delete this[t];};}:"function"==typeof e?function(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n;};}:function(t,e){return function(){this[t]=e;};})(t,e)):this.node()[t];},classed:function classed(t,e){var n=E(t+"");if(arguments.length<2){for(var r=C(this.node()),i=-1,o=n.length;++i<o;){if(!r.contains(n[i]))return !1;}return !0;}return this.each(("function"==typeof e?function(t,e){return function(){(e.apply(this,arguments)?O:_)(this,t);};}:e?function(t){return function(){O(this,t);};}:function(t){return function(){_(this,t);};})(n,e));},text:function text(t){return arguments.length?this.each(null==t?S:("function"==typeof t?function(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e;};}:function(t){return function(){this.textContent=t;};})(t)):this.node().textContent;},html:function html(t){return arguments.length?this.each(null==t?D:("function"==typeof t?function(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e;};}:function(t){return function(){this.innerHTML=t;};})(t)):this.node().innerHTML;},raise:function raise(){return this.each(F);},lower:function lower(){return this.each(T);},append:function append(t){var e="function"==typeof t?t:a(t);return this.select(function(){return this.appendChild(e.apply(this,arguments));});},insert:function insert(t,e){var n="function"==typeof t?t:a(t),r=null==e?N:"function"==typeof e?e:u(e);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null);});},remove:function remove(){return this.each(I);},clone:function clone(t){return this.select(t?M:R);},datum:function datum(t){return arguments.length?this.property("__data__",t):this.node().__data__;},on:function on(t,e,n){var r,i,o=function(t){return t.trim().split(/^|\s+/).map(function(t){var e="",n=t.indexOf(".");return n>=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e};});}(t+""),a=o.length;if(!(arguments.length<2)){for(s=e?U:z,null==n&&(n=!1),r=0;r<a;++r){this.each(s(o[r],e,n));}return this;}var s=this.node().__on;if(s)for(var u,c=0,l=s.length;c<l;++c){for(r=0,u=s[c];r<a;++r){if((i=o[r]).type===u.type&&i.name===u.name)return u.value;}}},dispatch:function dispatch(t,e){return this.each(("function"==typeof e?function(t,e){return function(){return V(this,t,e.apply(this,arguments));};}:function(t,e){return function(){return V(this,t,e);};})(t,e));}};var G=H,K=function K(t){return "string"==typeof t?new $([[document.querySelector(t)]],[document.documentElement]):new $([[t]],q);},X=function X(t){return K(a(t).call(document.documentElement));},Y=0;function J(){return new Q();}function Q(){this._="@"+(++Y).toString(36);}Q.prototype=J.prototype={constructor:Q,get:function get(t){for(var e=this._;!(e in t);){if(!(t=t.parentNode))return;}return t[e];},set:function set(t,e){return t[this._]=e;},remove:function remove(t){return this._ in t&&delete t[this._];},toString:function toString(){return this._;}};var Z=function Z(){for(var t,e=B;t=e.sourceEvent;){e=t;}return e;},tt=function tt(t,e){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,[(r=r.matrixTransform(t.getScreenCTM().inverse())).x,r.y];}var i=t.getBoundingClientRect();return [e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop];},et=function et(t){var e=Z();return e.changedTouches&&(e=e.changedTouches[0]),tt(t,e);},nt=function nt(t){return "string"==typeof t?new $([document.querySelectorAll(t)],[document.documentElement]):new $([null==t?[]:t],q);},rt=function rt(t,e,n){arguments.length<3&&(n=e,e=Z().changedTouches);for(var r,i=0,o=e?e.length:0;i<o;++i){if((r=e[i]).identifier===n)return tt(t,r);}return null;},it=function it(t,e){null==e&&(e=Z().touches);for(var n=0,r=e?e.length:0,i=new Array(r);n<r;++n){i[n]=tt(t,e[n]);}return i;};n.d(e,"create",function(){return X;}),n.d(e,"creator",function(){return a;}),n.d(e,"local",function(){return J;}),n.d(e,"matcher",function(){return p;}),n.d(e,"mouse",function(){return et;}),n.d(e,"namespace",function(){return o;}),n.d(e,"namespaces",function(){return i;}),n.d(e,"clientPoint",function(){return tt;}),n.d(e,"select",function(){return K;}),n.d(e,"selectAll",function(){return nt;}),n.d(e,"selection",function(){return G;}),n.d(e,"selector",function(){return u;}),n.d(e,"selectorAll",function(){return l;}),n.d(e,"style",function(){return k;}),n.d(e,"touch",function(){return rt;}),n.d(e,"touches",function(){return it;}),n.d(e,"window",function(){return w;}),n.d(e,"event",function(){return B;}),n.d(e,"customEvent",function(){return W;});},function(t,e,n){n.r(e);var r={};n.d(r,"load",function(){return P;});var i={};n.d(i,"Darknet",function(){return H;}),n.d(i,"load",function(){return G;});var o={};n.d(o,"Doodlenet",function(){return tt;}),n.d(o,"load",function(){return et;});var a={};n.d(a,"array3DToImage",function(){return ot;}),n.d(a,"processVideo",function(){return it;}),n.d(a,"cropImage",function(){return at;}),n.d(a,"imgToTensor",function(){return ut;}),n.d(a,"isInstanceOfSupportedElement",function(){return ct;}),n.d(a,"flipImage",function(){return st;}),n.d(a,"imgToPixelArray",function(){return lt;});var s={};n.d(s,"SpeechCommands",function(){return Gt;}),n.d(s,"load",function(){return Kt;});var u={};n.d(u,"isTensor",function(){return ki;}),n.d(u,"isTensor1D",function(){return Ei;}),n.d(u,"isTensor2D",function(){return Ci;}),n.d(u,"isTensor3D",function(){return Ai;}),n.d(u,"isTensor4D",function(){return Oi;}),n.d(u,"isFloat",function(){return _i;}),n.d(u,"isEven",function(){return Si;}),n.d(u,"round",function(){return Di;}),n.d(u,"isDimensions",function(){return Fi;}),n.d(u,"computeReshapedDimensions",function(){return Ti;}),n.d(u,"getCenterPoint",function(){return Ni;}),n.d(u,"range",function(){return Ii;}),n.d(u,"isValidNumber",function(){return Ri;}),n.d(u,"isValidProbablitiy",function(){return Mi;});var c={};n.d(c,"drawContour",function(){return bi;}),n.d(c,"drawDetections",function(){return ko;}),n.d(c,"drawFaceExpressions",function(){return pa;}),n.d(c,"DrawBoxOptions",function(){return xo;}),n.d(c,"DrawBox",function(){return wo;}),n.d(c,"DrawFaceLandmarksOptions",function(){return va;}),n.d(c,"DrawFaceLandmarks",function(){return ya;}),n.d(c,"drawFaceLandmarks",function(){return ba;}),n.d(c,"AnchorPosition",function(){return po;}),n.d(c,"DrawTextFieldOptions",function(){return yo;}),n.d(c,"DrawTextField",function(){return bo;});var l={};n.d(l,"draw",function(){return c;}),n.d(l,"utils",function(){return u;}),n.d(l,"tf",function(){return yi;}),n.d(l,"env",function(){return mo;}),n.d(l,"FaceLandmarkNet",function(){return Ta;}),n.d(l,"createFaceRecognitionNet",function(){return za;}),n.d(l,"createMtcnn",function(){return Lu;}),n.d(l,"sigmoid",function(){return Gi;}),n.d(l,"inverseSigmoid",function(){return Ki;}),n.d(l,"createSsdMobilenetv1",function(){return rs;}),n.d(l,"createFaceDetectionNet",function(){return is;}),n.d(l,"FaceDetectionNet",function(){return as;}),n.d(l,"createTinyFaceDetector",function(){return zu;}),n.d(l,"TinyYolov2",function(){return xs;}),n.d(l,"createTinyYolov2",function(){return ws;}),n.d(l,"euclideanDistance",function(){return Bu;}),n.d(l,"NeuralNetwork",function(){return Vo;}),n.d(l,"resizeResults",function(){return Uu;}),n.d(l,"AgeGenderNet",function(){return Oa;}),n.d(l,"Gender",function(){return Ca;}),n.d(l,"BoundingBox",function(){return Pi;}),n.d(l,"Box",function(){return Bi;}),n.d(l,"Dimensions",function(){return wi;}),n.d(l,"FaceDetection",function(){return zi;}),n.d(l,"FaceLandmarks",function(){return Yi;}),n.d(l,"FaceLandmarks5",function(){return Ji;}),n.d(l,"FaceLandmarks68",function(){return Qi;}),n.d(l,"FaceMatch",function(){return Zi;}),n.d(l,"LabeledBox",function(){return to;}),n.d(l,"LabeledFaceDescriptors",function(){return eo;}),n.d(l,"ObjectDetection",function(){return Li;}),n.d(l,"Point",function(){return ji;}),n.d(l,"PredictedBox",function(){return no;}),n.d(l,"Rect",function(){return Xi;}),n.d(l,"awaitMediaLoaded",function(){return Co;}),n.d(l,"bufferToImage",function(){return Ao;}),n.d(l,"createCanvas",function(){return _o;}),n.d(l,"createCanvasFromMedia",function(){return So;}),n.d(l,"extractFaces",function(){return Ro;}),n.d(l,"extractFaceTensors",function(){return Mo;}),n.d(l,"fetchImage",function(){return Bo;}),n.d(l,"fetchJson",function(){return Po;}),n.d(l,"fetchNetWeights",function(){return Lo;}),n.d(l,"fetchOrThrow",function(){return jo;}),n.d(l,"getContext2dOrThrow",function(){return vo;}),n.d(l,"getMediaDimensions",function(){return Oo;}),n.d(l,"imageTensorToCanvas",function(){return Do;}),n.d(l,"imageToSquare",function(){return To;}),n.d(l,"isMediaElement",function(){return Fo;}),n.d(l,"isMediaLoaded",function(){return Eo;}),n.d(l,"loadWeightMap",function(){return Uo;}),n.d(l,"matchDimensions",function(){return Wo;}),n.d(l,"NetInput",function(){return No;}),n.d(l,"resolveInput",function(){return go;}),n.d(l,"toNetInput",function(){return Io;}),n.d(l,"FaceExpressionNet",function(){return fa;}),n.d(l,"FACE_EXPRESSION_LABELS",function(){return ca;}),n.d(l,"FaceExpressions",function(){return la;}),n.d(l,"FaceLandmark68Net",function(){return Sa;}),n.d(l,"FaceLandmark68TinyNet",function(){return Fa;}),n.d(l,"FaceRecognitionNet",function(){return La;}),n.d(l,"extendWithFaceDescriptor",function(){return Ua;}),n.d(l,"isWithFaceDetection",function(){return ro;}),n.d(l,"extendWithFaceDetection",function(){return io;}),n.d(l,"isWithFaceExpressions",function(){return ha;}),n.d(l,"extendWithFaceExpressions",function(){return da;}),n.d(l,"isWithFaceLandmarks",function(){return ma;}),n.d(l,"extendWithFaceLandmarks",function(){return ga;}),n.d(l,"isWithAge",function(){return Wa;}),n.d(l,"extendWithAge",function(){return Va;}),n.d(l,"isWithGender",function(){return qa;}),n.d(l,"extendWithGender",function(){return $a;}),n.d(l,"allFacesSsdMobilenetv1",function(){return Iu;}),n.d(l,"allFacesTinyYolov2",function(){return Ru;}),n.d(l,"allFacesMtcnn",function(){return Mu;}),n.d(l,"allFaces",function(){return ju;}),n.d(l,"ComposableTask",function(){return Es;}),n.d(l,"ComputeFaceDescriptorsTaskBase",function(){return ku;}),n.d(l,"ComputeAllFaceDescriptorsTask",function(){return Eu;}),n.d(l,"ComputeSingleFaceDescriptorTask",function(){return Cu;}),n.d(l,"detectSingleFace",function(){return Tu;}),n.d(l,"detectAllFaces",function(){return Nu;}),n.d(l,"DetectFacesTaskBase",function(){return Su;}),n.d(l,"DetectAllFacesTask",function(){return Du;}),n.d(l,"DetectSingleFaceTask",function(){return Fu;}),n.d(l,"DetectFaceLandmarksTaskBase",function(){return Au;}),n.d(l,"DetectAllFaceLandmarksTask",function(){return Ou;}),n.d(l,"DetectSingleFaceLandmarksTask",function(){return _u;}),n.d(l,"FaceMatcher",function(){return Pu;}),n.d(l,"nets",function(){return qs;}),n.d(l,"ssdMobilenetv1",function(){return $s;}),n.d(l,"tinyFaceDetector",function(){return Hs;}),n.d(l,"tinyYolov2",function(){return Gs;}),n.d(l,"mtcnn",function(){return Ks;}),n.d(l,"detectFaceLandmarks",function(){return Xs;}),n.d(l,"detectFaceLandmarksTiny",function(){return Ys;}),n.d(l,"computeFaceDescriptor",function(){return Js;}),n.d(l,"recognizeFaceExpressions",function(){return Qs;}),n.d(l,"predictAgeAndGender",function(){return Zs;}),n.d(l,"loadSsdMobilenetv1Model",function(){return tu;}),n.d(l,"loadTinyFaceDetectorModel",function(){return eu;}),n.d(l,"loadMtcnnModel",function(){return nu;}),n.d(l,"loadTinyYolov2Model",function(){return ru;}),n.d(l,"loadFaceLandmarkModel",function(){return iu;}),n.d(l,"loadFaceLandmarkTinyModel",function(){return ou;}),n.d(l,"loadFaceRecognitionModel",function(){return au;}),n.d(l,"loadFaceExpressionModel",function(){return su;}),n.d(l,"loadAgeGenderModel",function(){return uu;}),n.d(l,"loadFaceDetectionModel",function(){return cu;}),n.d(l,"locateFaces",function(){return lu;}),n.d(l,"detectLandmarks",function(){return fu;}),n.d(l,"Mtcnn",function(){return Ls;}),n.d(l,"MtcnnOptions",function(){return Ha;}),n.d(l,"iou",function(){return Ui;}),n.d(l,"minBbox",function(){return Wi;}),n.d(l,"nonMaxSuppression",function(){return Vi;}),n.d(l,"normalize",function(){return qi;}),n.d(l,"padToSquare",function(){return $i;}),n.d(l,"shuffleArray",function(){return Hi;}),n.d(l,"SsdMobilenetv1",function(){return ns;}),n.d(l,"SsdMobilenetv1Options",function(){return es;}),n.d(l,"TinyFaceDetector",function(){return Vs;}),n.d(l,"TinyFaceDetectorOptions",function(){return ks;}),n.d(l,"TinyYolov2SizeType",function(){return os;}),n.d(l,"TinyYolov2Options",function(){return ys;}),n.d(l,"validateConfig",function(){return hs;});var f={};n.d(f,"getRobin",function(){return Sl;}),n.d(f,"getImageData",function(){return Dl;});var h=n(18),d=n.n(h),p=n(2),m=n(67),g=n(6),v=n.n(g),y=n(10),b=n.n(y),x=n(9),w=n.n(x),k=n(4),E=n.n(k);function C(t,e){return e?new Promise(function(n,r){t.then(function(t){e(void 0,t),n(t);}).catch(function(t){e(t),r(t);});}):t;}var A=function(){function t(e,n,r,i){b()(this,t),this.model=e,this.audioContext=n,this.stream=r,this.frequency=null,this.ready=C(this.loadModel(e),i);}return w()(t,[{key:"loadModel",value:function(){var t=v()(E.a.mark(function t(e){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,p.loadLayersModel("".concat(e,"/model.json"));case 2:if(this.model=t.sent,!this.audioContext){t.next=8;break;}return t.next=6,this.processStream();case 6:t.next=9;break;case 8:throw new Error("Could not access microphone - getUserMedia not available");case 9:return t.abrupt("return",this);case 10:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"processStream",value:function(){var t=v()(E.a.mark(function t(){var e,n,r,i,o;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,p.nextFrame();case 2:for(e=this.audioContext.createMediaStreamSource(this.stream),n=this.audioContext.sampleRate/16e3*1024,r=4;r<n;){r*=2;}(i=this.audioContext.createScriptProcessor(r,1,1)).onaudioprocess=this.processMicrophoneBuffer.bind(this),(o=this.audioContext.createGain()).gain.setValueAtTime(0,this.audioContext.currentTime),e.connect(i),i.connect(o),o.connect(this.audioContext.destination),"running"!==this.audioContext.state&&console.warn("User gesture needed to start AudioContext, please click");case 14:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"processMicrophoneBuffer",value:function(){var e=v()(E.a.mark(function e(n){var r=this;return E.a.wrap(function(e){for(;;){switch(e.prev=e.next){case 0:return e.next=2,p.nextFrame();case 2:this.results={},t.resample(n.inputBuffer,function(t){p.tidy(function(){var e=p.add(p.linspace(0,7180,360),p.tensor(1997.379408437619));r.running=!0;var n=p.tensor(t.slice(0,1024)),i=p.sub(n,p.mean(n)),o=p.tensor(p.norm(i).dataSync()/Math.sqrt(1024)),a=p.div(i,o).reshape([1,1024]),s=r.model.predict([a]).reshape([360]),u=s.max().dataSync()[0],c=s.argMax().dataSync()[0];r.results.confidence=u.toFixed(3);var l=Math.max(0,c-4),f=Math.min(360,c+5),h=s.slice([l],[f-l]),d=e.slice([l],[f-l]),m=p.mul(h,d).dataSync().reduce(function(t,e){return t+e;},0)/h.dataSync().reduce(function(t,e){return t+e;},0),g=10*Math.pow(2,m/1200),v=u>.5?g:null;r.frequency=v;});});case 4:case"end":return e.stop();}}},e,this);}));return function(t){return e.apply(this,arguments);};}()},{key:"getPitch",value:function(){var t=v()(E.a.mark(function t(e){var n;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.ready;case 2:return t.next=4,p.nextFrame();case 4:return n=this.frequency,e&&e(void 0,n),t.abrupt("return",n);case 7:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()}],[{key:"resample",value:function value(t,e){for(var n=t.sampleRate%16e3!=0,r=t.sampleRate/16e3,i=t.getChannelData(0),o=new Float32Array(1024),a=0;a<1024;a+=1){if(n){var s=Math.floor(a*r),u=s+1,c=a*r-s;o[a]=(1-c)*i[s]+c*i[u];}else o[a]=i[a*r];}e(o);}}]),t;}(),O=function O(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"./",e=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0;return new A(t,e,n,r);},_=n(7),S=n.n(_),D=n(17),F=n.n(D),T=n(20),N=n(0);/**
    * @license
    * Copyright 2019 Google LLC. All Rights Reserved.
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    * http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    * =============================================================================
    */function I(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});}function R(t,e){var n,r,i,o,a={label:0,sent:function sent(){if(1&i[0])throw i[1];return i[1];},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this;}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;){try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue;}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break;}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break;}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break;}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(t,a);}catch(t){o=[6,t],r=0;}finally{n=i=0;}}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:!0};}([o,s]);};}}var M={0:"tench, Tinca tinca",1:"goldfish, Carassius auratus",2:"great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias",3:"tiger shark, Galeocerdo cuvieri",4:"hammerhead, hammerhead shark",5:"electric ray, crampfish, numbfish, torpedo",6:"stingray",7:"cock",8:"hen",9:"ostrich, Struthio camelus",10:"brambling, Fringilla montifringilla",11:"goldfinch, Carduelis carduelis",12:"house finch, linnet, Carpodacus mexicanus",13:"junco, snowbird",14:"indigo bunting, indigo finch, indigo bird, Passerina cyanea",15:"robin, American robin, Turdus migratorius",16:"bulbul",17:"jay",18:"magpie",19:"chickadee",20:"water ouzel, dipper",21:"kite",22:"bald eagle, American eagle, Haliaeetus leucocephalus",23:"vulture",24:"great grey owl, great gray owl, Strix nebulosa",25:"European fire salamander, Salamandra salamandra",26:"common newt, Triturus vulgaris",27:"eft",28:"spotted salamander, Ambystoma maculatum",29:"axolotl, mud puppy, Ambystoma mexicanum",30:"bullfrog, Rana catesbeiana",31:"tree frog, tree-frog",32:"tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui",33:"loggerhead, loggerhead turtle, Caretta caretta",34:"leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea",35:"mud turtle",36:"terrapin",37:"box turtle, box tortoise",38:"banded gecko",39:"common iguana, iguana, Iguana iguana",40:"American chameleon, anole, Anolis carolinensis",41:"whiptail, whiptail lizard",42:"agama",43:"frilled lizard, Chlamydosaurus kingi",44:"alligator lizard",45:"Gila monster, Heloderma suspectum",46:"green lizard, Lacerta viridis",47:"African chameleon, Chamaeleo chamaeleon",48:"Komodo dragon, Komodo lizard, dragon lizard, giant lizard, Varanus komodoensis",49:"African crocodile, Nile crocodile, Crocodylus niloticus",50:"American alligator, Alligator mississipiensis",51:"triceratops",52:"thunder snake, worm snake, Carphophis amoenus",53:"ringneck snake, ring-necked snake, ring snake",54:"hognose snake, puff adder, sand viper",55:"green snake, grass snake",56:"king snake, kingsnake",57:"garter snake, grass snake",58:"water snake",59:"vine snake",60:"night snake, Hypsiglena torquata",61:"boa constrictor, Constrictor constrictor",62:"rock python, rock snake, Python sebae",63:"Indian cobra, Naja naja",64:"green mamba",65:"sea snake",66:"horned viper, cerastes, sand viper, horned asp, Cerastes cornutus",67:"diamondback, diamondback rattlesnake, Crotalus adamanteus",68:"sidewinder, horned rattlesnake, Crotalus cerastes",69:"trilobite",70:"harvestman, daddy longlegs, Phalangium opilio",71:"scorpion",72:"black and gold garden spider, Argiope aurantia",73:"barn spider, Araneus cavaticus",74:"garden spider, Aranea diademata",75:"black widow, Latrodectus mactans",76:"tarantula",77:"wolf spider, hunting spider",78:"tick",79:"centipede",80:"black grouse",81:"ptarmigan",82:"ruffed grouse, partridge, Bonasa umbellus",83:"prairie chicken, prairie grouse, prairie fowl",84:"peacock",85:"quail",86:"partridge",87:"African grey, African gray, Psittacus erithacus",88:"macaw",89:"sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita",90:"lorikeet",91:"coucal",92:"bee eater",93:"hornbill",94:"hummingbird",95:"jacamar",96:"toucan",97:"drake",98:"red-breasted merganser, Mergus serrator",99:"goose",100:"black swan, Cygnus atratus",101:"tusker",102:"echidna, spiny anteater, anteater",103:"platypus, duckbill, duckbilled platypus, duck-billed platypus, Ornithorhynchus anatinus",104:"wallaby, brush kangaroo",105:"koala, koala bear, kangaroo bear, native bear, Phascolarctos cinereus",106:"wombat",107:"jelly fish",108:"sea anemone, anemone",109:"brain coral",110:"flatworm, platyhelminth",111:"nematode, nematode worm, roundworm",112:"conch",113:"snail",114:"slug",115:"sea slug, nudibranch",116:"chiton, coat-of-mail shell, sea cradle, polyplacophore",117:"chambered nautilus, pearly nautilus, nautilus",118:"Dungeness crab, Cancer magister",119:"rock crab, Cancer irroratus",120:"fiddler crab",121:"king crab, Alaska crab, Alaskan king crab, Alaska king crab, Paralithodes camtschatica",122:"American lobster, Northern lobster, Maine lobster, Homarus americanus",123:"spiny lobster, langouste, rock lobster, crawfish, crayfish, sea crawfish",124:"crayfish, crawfish, crawdad, crawdaddy",125:"hermit crab",126:"isopod",127:"white stork, Ciconia ciconia",128:"black stork, Ciconia nigra",129:"spoonbill",130:"flamingo",131:"little blue heron, Egretta caerulea",132:"American egret, great white heron, Egretta albus",133:"bittern",134:"crane",135:"limpkin, Aramus pictus",136:"European gallinule, Porphyrio porphyrio",137:"American coot, marsh hen, mud hen, water hen, Fulica americana",138:"bustard",139:"ruddy turnstone, Arenaria interpres",140:"red-backed sandpiper, dunlin, Erolia alpina",141:"redshank, Tringa totanus",142:"dowitcher",143:"oystercatcher, oyster catcher",144:"pelican",145:"king penguin, Aptenodytes patagonica",146:"albatross, mollymawk",147:"grey whale, gray whale, devilfish, Eschrichtius gibbosus, Eschrichtius robustus",148:"killer whale, killer, orca, grampus, sea wolf, Orcinus orca",149:"dugong, Dugong dugon",150:"sea lion",151:"Chihuahua",152:"Japanese spaniel",153:"Maltese dog, Maltese terrier, Maltese",154:"Pekinese, Pekingese, Peke",155:"Shih-Tzu",156:"Blenheim spaniel",157:"papillon",158:"toy terrier",159:"Rhodesian ridgeback",160:"Afghan hound, Afghan",161:"basset, basset hound",162:"beagle",163:"bloodhound, sleuthhound",164:"bluetick",165:"black-and-tan coonhound",166:"Walker hound, Walker foxhound",167:"English foxhound",168:"redbone",169:"borzoi, Russian wolfhound",170:"Irish wolfhound",171:"Italian greyhound",172:"whippet",173:"Ibizan hound, Ibizan Podenco",174:"Norwegian elkhound, elkhound",175:"otterhound, otter hound",176:"Saluki, gazelle hound",177:"Scottish deerhound, deerhound",178:"Weimaraner",179:"Staffordshire bullterrier, Staffordshire bull terrier",180:"American Staffordshire terrier, Staffordshire terrier, American pit bull terrier, pit bull terrier",181:"Bedlington terrier",182:"Border terrier",183:"Kerry blue terrier",184:"Irish terrier",185:"Norfolk terrier",186:"Norwich terrier",187:"Yorkshire terrier",188:"wire-haired fox terrier",189:"Lakeland terrier",190:"Sealyham terrier, Sealyham",191:"Airedale, Airedale terrier",192:"cairn, cairn terrier",193:"Australian terrier",194:"Dandie Dinmont, Dandie Dinmont terrier",195:"Boston bull, Boston terrier",196:"miniature schnauzer",197:"giant schnauzer",198:"standard schnauzer",199:"Scotch terrier, Scottish terrier, Scottie",200:"Tibetan terrier, chrysanthemum dog",201:"silky terrier, Sydney silky",202:"soft-coated wheaten terrier",203:"West Highland white terrier",204:"Lhasa, Lhasa apso",205:"flat-coated retriever",206:"curly-coated retriever",207:"golden retriever",208:"Labrador retriever",209:"Chesapeake Bay retriever",210:"German short-haired pointer",211:"vizsla, Hungarian pointer",212:"English setter",213:"Irish setter, red setter",214:"Gordon setter",215:"Brittany spaniel",216:"clumber, clumber spaniel",217:"English springer, English springer spaniel",218:"Welsh springer spaniel",219:"cocker spaniel, English cocker spaniel, cocker",220:"Sussex spaniel",221:"Irish water spaniel",222:"kuvasz",223:"schipperke",224:"groenendael",225:"malinois",226:"briard",227:"kelpie",228:"komondor",229:"Old English sheepdog, bobtail",230:"Shetland sheepdog, Shetland sheep dog, Shetland",231:"collie",232:"Border collie",233:"Bouvier des Flandres, Bouviers des Flandres",234:"Rottweiler",235:"German shepherd, German shepherd dog, German police dog, alsatian",236:"Doberman, Doberman pinscher",237:"miniature pinscher",238:"Greater Swiss Mountain dog",239:"Bernese mountain dog",240:"Appenzeller",241:"EntleBucher",242:"boxer",243:"bull mastiff",244:"Tibetan mastiff",245:"French bulldog",246:"Great Dane",247:"Saint Bernard, St Bernard",248:"Eskimo dog, husky",249:"malamute, malemute, Alaskan malamute",250:"Siberian husky",251:"dalmatian, coach dog, carriage dog",252:"affenpinscher, monkey pinscher, monkey dog",253:"basenji",254:"pug, pug-dog",255:"Leonberg",256:"Newfoundland, Newfoundland dog",257:"Great Pyrenees",258:"Samoyed, Samoyede",259:"Pomeranian",260:"chow, chow chow",261:"keeshond",262:"Brabancon griffon",263:"Pembroke, Pembroke Welsh corgi",264:"Cardigan, Cardigan Welsh corgi",265:"toy poodle",266:"miniature poodle",267:"standard poodle",268:"Mexican hairless",269:"timber wolf, grey wolf, gray wolf, Canis lupus",270:"white wolf, Arctic wolf, Canis lupus tundrarum",271:"red wolf, maned wolf, Canis rufus, Canis niger",272:"coyote, prairie wolf, brush wolf, Canis latrans",273:"dingo, warrigal, warragal, Canis dingo",274:"dhole, Cuon alpinus",275:"African hunting dog, hyena dog, Cape hunting dog, Lycaon pictus",276:"hyena, hyaena",277:"red fox, Vulpes vulpes",278:"kit fox, Vulpes macrotis",279:"Arctic fox, white fox, Alopex lagopus",280:"grey fox, gray fox, Urocyon cinereoargenteus",281:"tabby, tabby cat",282:"tiger cat",283:"Persian cat",284:"Siamese cat, Siamese",285:"Egyptian cat",286:"cougar, puma, catamount, mountain lion, painter, panther, Felis concolor",287:"lynx, catamount",288:"leopard, Panthera pardus",289:"snow leopard, ounce, Panthera uncia",290:"jaguar, panther, Panthera onca, Felis onca",291:"lion, king of beasts, Panthera leo",292:"tiger, Panthera tigris",293:"cheetah, chetah, Acinonyx jubatus",294:"brown bear, bruin, Ursus arctos",295:"American black bear, black bear, Ursus americanus, Euarctos americanus",296:"ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus",297:"sloth bear, Melursus ursinus, Ursus ursinus",298:"mongoose",299:"meerkat, mierkat",300:"tiger beetle",301:"ladybug, ladybeetle, lady beetle, ladybird, ladybird beetle",302:"ground beetle, carabid beetle",303:"long-horned beetle, longicorn, longicorn beetle",304:"leaf beetle, chrysomelid",305:"dung beetle",306:"rhinoceros beetle",307:"weevil",308:"fly",309:"bee",310:"ant, emmet, pismire",311:"grasshopper, hopper",312:"cricket",313:"walking stick, walkingstick, stick insect",314:"cockroach, roach",315:"mantis, mantid",316:"cicada, cicala",317:"leafhopper",318:"lacewing, lacewing fly",319:"dragonfly, darning needle, devil's darning needle, sewing needle, snake feeder, snake doctor, mosquito hawk, skeeter hawk",320:"damselfly",321:"admiral",322:"ringlet, ringlet butterfly",323:"monarch, monarch butterfly, milkweed butterfly, Danaus plexippus",324:"cabbage butterfly",325:"sulphur butterfly, sulfur butterfly",326:"lycaenid, lycaenid butterfly",327:"starfish, sea star",328:"sea urchin",329:"sea cucumber, holothurian",330:"wood rabbit, cottontail, cottontail rabbit",331:"hare",332:"Angora, Angora rabbit",333:"hamster",334:"porcupine, hedgehog",335:"fox squirrel, eastern fox squirrel, Sciurus niger",336:"marmot",337:"beaver",338:"guinea pig, Cavia cobaya",339:"sorrel",340:"zebra",341:"hog, pig, grunter, squealer, Sus scrofa",342:"wild boar, boar, Sus scrofa",343:"warthog",344:"hippopotamus, hippo, river horse, Hippopotamus amphibius",345:"ox",346:"water buffalo, water ox, Asiatic buffalo, Bubalus bubalis",347:"bison",348:"ram, tup",349:"bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis",350:"ibex, Capra ibex",351:"hartebeest",352:"impala, Aepyceros melampus",353:"gazelle",354:"Arabian camel, dromedary, Camelus dromedarius",355:"llama",356:"weasel",357:"mink",358:"polecat, fitch, foulmart, foumart, Mustela putorius",359:"black-footed ferret, ferret, Mustela nigripes",360:"otter",361:"skunk, polecat, wood pussy",362:"badger",363:"armadillo",364:"three-toed sloth, ai, Bradypus tridactylus",365:"orangutan, orang, orangutang, Pongo pygmaeus",366:"gorilla, Gorilla gorilla",367:"chimpanzee, chimp, Pan troglodytes",368:"gibbon, Hylobates lar",369:"siamang, Hylobates syndactylus, Symphalangus syndactylus",370:"guenon, guenon monkey",371:"patas, hussar monkey, Erythrocebus patas",372:"baboon",373:"macaque",374:"langur",375:"colobus, colobus monkey",376:"proboscis monkey, Nasalis larvatus",377:"marmoset",378:"capuchin, ringtail, Cebus capucinus",379:"howler monkey, howler",380:"titi, titi monkey",381:"spider monkey, Ateles geoffroyi",382:"squirrel monkey, Saimiri sciureus",383:"Madagascar cat, ring-tailed lemur, Lemur catta",384:"indri, indris, Indri indri, Indri brevicaudatus",385:"Indian elephant, Elephas maximus",386:"African elephant, Loxodonta africana",387:"lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens",388:"giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca",389:"barracouta, snoek",390:"eel",391:"coho, cohoe, coho salmon, blue jack, silver salmon, Oncorhynchus kisutch",392:"rock beauty, Holocanthus tricolor",393:"anemone fish",394:"sturgeon",395:"gar, garfish, garpike, billfish, Lepisosteus osseus",396:"lionfish",397:"puffer, pufferfish, blowfish, globefish",398:"abacus",399:"abaya",400:"academic gown, academic robe, judge's robe",401:"accordion, piano accordion, squeeze box",402:"acoustic guitar",403:"aircraft carrier, carrier, flattop, attack aircraft carrier",404:"airliner",405:"airship, dirigible",406:"altar",407:"ambulance",408:"amphibian, amphibious vehicle",409:"analog clock",410:"apiary, bee house",411:"apron",412:"ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin",413:"assault rifle, assault gun",414:"backpack, back pack, knapsack, packsack, rucksack, haversack",415:"bakery, bakeshop, bakehouse",416:"balance beam, beam",417:"balloon",418:"ballpoint, ballpoint pen, ballpen, Biro",419:"Band Aid",420:"banjo",421:"bannister, banister, balustrade, balusters, handrail",422:"barbell",423:"barber chair",424:"barbershop",425:"barn",426:"barometer",427:"barrel, cask",428:"barrow, garden cart, lawn cart, wheelbarrow",429:"baseball",430:"basketball",431:"bassinet",432:"bassoon",433:"bathing cap, swimming cap",434:"bath towel",435:"bathtub, bathing tub, bath, tub",436:"beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon",437:"beacon, lighthouse, beacon light, pharos",438:"beaker",439:"bearskin, busby, shako",440:"beer bottle",441:"beer glass",442:"bell cote, bell cot",443:"bib",444:"bicycle-built-for-two, tandem bicycle, tandem",445:"bikini, two-piece",446:"binder, ring-binder",447:"binoculars, field glasses, opera glasses",448:"birdhouse",449:"boathouse",450:"bobsled, bobsleigh, bob",451:"bolo tie, bolo, bola tie, bola",452:"bonnet, poke bonnet",453:"bookcase",454:"bookshop, bookstore, bookstall",455:"bottlecap",456:"bow",457:"bow tie, bow-tie, bowtie",458:"brass, memorial tablet, plaque",459:"brassiere, bra, bandeau",460:"breakwater, groin, groyne, mole, bulwark, seawall, jetty",461:"breastplate, aegis, egis",462:"broom",463:"bucket, pail",464:"buckle",465:"bulletproof vest",466:"bullet train, bullet",467:"butcher shop, meat market",468:"cab, hack, taxi, taxicab",469:"caldron, cauldron",470:"candle, taper, wax light",471:"cannon",472:"canoe",473:"can opener, tin opener",474:"cardigan",475:"car mirror",476:"carousel, carrousel, merry-go-round, roundabout, whirligig",477:"carpenter's kit, tool kit",478:"carton",479:"car wheel",480:"cash machine, cash dispenser, automated teller machine, automatic teller machine, automated teller, automatic teller, ATM",481:"cassette",482:"cassette player",483:"castle",484:"catamaran",485:"CD player",486:"cello, violoncello",487:"cellular telephone, cellular phone, cellphone, cell, mobile phone",488:"chain",489:"chainlink fence",490:"chain mail, ring mail, mail, chain armor, chain armour, ring armor, ring armour",491:"chain saw, chainsaw",492:"chest",493:"chiffonier, commode",494:"chime, bell, gong",495:"china cabinet, china closet",496:"Christmas stocking",497:"church, church building",498:"cinema, movie theater, movie theatre, movie house, picture palace",499:"cleaver, meat cleaver, chopper",500:"cliff dwelling",501:"cloak",502:"clog, geta, patten, sabot",503:"cocktail shaker",504:"coffee mug",505:"coffeepot",506:"coil, spiral, volute, whorl, helix",507:"combination lock",508:"computer keyboard, keypad",509:"confectionery, confectionary, candy store",510:"container ship, containership, container vessel",511:"convertible",512:"corkscrew, bottle screw",513:"cornet, horn, trumpet, trump",514:"cowboy boot",515:"cowboy hat, ten-gallon hat",516:"cradle",517:"crane",518:"crash helmet",519:"crate",520:"crib, cot",521:"Crock Pot",522:"croquet ball",523:"crutch",524:"cuirass",525:"dam, dike, dyke",526:"desk",527:"desktop computer",528:"dial telephone, dial phone",529:"diaper, nappy, napkin",530:"digital clock",531:"digital watch",532:"dining table, board",533:"dishrag, dishcloth",534:"dishwasher, dish washer, dishwashing machine",535:"disk brake, disc brake",536:"dock, dockage, docking facility",537:"dogsled, dog sled, dog sleigh",538:"dome",539:"doormat, welcome mat",540:"drilling platform, offshore rig",541:"drum, membranophone, tympan",542:"drumstick",543:"dumbbell",544:"Dutch oven",545:"electric fan, blower",546:"electric guitar",547:"electric locomotive",548:"entertainment center",549:"envelope",550:"espresso maker",551:"face powder",552:"feather boa, boa",553:"file, file cabinet, filing cabinet",554:"fireboat",555:"fire engine, fire truck",556:"fire screen, fireguard",557:"flagpole, flagstaff",558:"flute, transverse flute",559:"folding chair",560:"football helmet",561:"forklift",562:"fountain",563:"fountain pen",564:"four-poster",565:"freight car",566:"French horn, horn",567:"frying pan, frypan, skillet",568:"fur coat",569:"garbage truck, dustcart",570:"gasmask, respirator, gas helmet",571:"gas pump, gasoline pump, petrol pump, island dispenser",572:"goblet",573:"go-kart",574:"golf ball",575:"golfcart, golf cart",576:"gondola",577:"gong, tam-tam",578:"gown",579:"grand piano, grand",580:"greenhouse, nursery, glasshouse",581:"grille, radiator grille",582:"grocery store, grocery, food market, market",583:"guillotine",584:"hair slide",585:"hair spray",586:"half track",587:"hammer",588:"hamper",589:"hand blower, blow dryer, blow drier, hair dryer, hair drier",590:"hand-held computer, hand-held microcomputer",591:"handkerchief, hankie, hanky, hankey",592:"hard disc, hard disk, fixed disk",593:"harmonica, mouth organ, harp, mouth harp",594:"harp",595:"harvester, reaper",596:"hatchet",597:"holster",598:"home theater, home theatre",599:"honeycomb",600:"hook, claw",601:"hoopskirt, crinoline",602:"horizontal bar, high bar",603:"horse cart, horse-cart",604:"hourglass",605:"iPod",606:"iron, smoothing iron",607:"jack-o'-lantern",608:"jean, blue jean, denim",609:"jeep, landrover",610:"jersey, T-shirt, tee shirt",611:"jigsaw puzzle",612:"jinrikisha, ricksha, rickshaw",613:"joystick",614:"kimono",615:"knee pad",616:"knot",617:"lab coat, laboratory coat",618:"ladle",619:"lampshade, lamp shade",620:"laptop, laptop computer",621:"lawn mower, mower",622:"lens cap, lens cover",623:"letter opener, paper knife, paperknife",624:"library",625:"lifeboat",626:"lighter, light, igniter, ignitor",627:"limousine, limo",628:"liner, ocean liner",629:"lipstick, lip rouge",630:"Loafer",631:"lotion",632:"loudspeaker, speaker, speaker unit, loudspeaker system, speaker system",633:"loupe, jeweler's loupe",634:"lumbermill, sawmill",635:"magnetic compass",636:"mailbag, postbag",637:"mailbox, letter box",638:"maillot",639:"maillot, tank suit",640:"manhole cover",641:"maraca",642:"marimba, xylophone",643:"mask",644:"matchstick",645:"maypole",646:"maze, labyrinth",647:"measuring cup",648:"medicine chest, medicine cabinet",649:"megalith, megalithic structure",650:"microphone, mike",651:"microwave, microwave oven",652:"military uniform",653:"milk can",654:"minibus",655:"miniskirt, mini",656:"minivan",657:"missile",658:"mitten",659:"mixing bowl",660:"mobile home, manufactured home",661:"Model T",662:"modem",663:"monastery",664:"monitor",665:"moped",666:"mortar",667:"mortarboard",668:"mosque",669:"mosquito net",670:"motor scooter, scooter",671:"mountain bike, all-terrain bike, off-roader",672:"mountain tent",673:"mouse, computer mouse",674:"mousetrap",675:"moving van",676:"muzzle",677:"nail",678:"neck brace",679:"necklace",680:"nipple",681:"notebook, notebook computer",682:"obelisk",683:"oboe, hautboy, hautbois",684:"ocarina, sweet potato",685:"odometer, hodometer, mileometer, milometer",686:"oil filter",687:"organ, pipe organ",688:"oscilloscope, scope, cathode-ray oscilloscope, CRO",689:"overskirt",690:"oxcart",691:"oxygen mask",692:"packet",693:"paddle, boat paddle",694:"paddlewheel, paddle wheel",695:"padlock",696:"paintbrush",697:"pajama, pyjama, pj's, jammies",698:"palace",699:"panpipe, pandean pipe, syrinx",700:"paper towel",701:"parachute, chute",702:"parallel bars, bars",703:"park bench",704:"parking meter",705:"passenger car, coach, carriage",706:"patio, terrace",707:"pay-phone, pay-station",708:"pedestal, plinth, footstall",709:"pencil box, pencil case",710:"pencil sharpener",711:"perfume, essence",712:"Petri dish",713:"photocopier",714:"pick, plectrum, plectron",715:"pickelhaube",716:"picket fence, paling",717:"pickup, pickup truck",718:"pier",719:"piggy bank, penny bank",720:"pill bottle",721:"pillow",722:"ping-pong ball",723:"pinwheel",724:"pirate, pirate ship",725:"pitcher, ewer",726:"plane, carpenter's plane, woodworking plane",727:"planetarium",728:"plastic bag",729:"plate rack",730:"plow, plough",731:"plunger, plumber's helper",732:"Polaroid camera, Polaroid Land camera",733:"pole",734:"police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria",735:"poncho",736:"pool table, billiard table, snooker table",737:"pop bottle, soda bottle",738:"pot, flowerpot",739:"potter's wheel",740:"power drill",741:"prayer rug, prayer mat",742:"printer",743:"prison, prison house",744:"projectile, missile",745:"projector",746:"puck, hockey puck",747:"punching bag, punch bag, punching ball, punchball",748:"purse",749:"quill, quill pen",750:"quilt, comforter, comfort, puff",751:"racer, race car, racing car",752:"racket, racquet",753:"radiator",754:"radio, wireless",755:"radio telescope, radio reflector",756:"rain barrel",757:"recreational vehicle, RV, R.V.",758:"reel",759:"reflex camera",760:"refrigerator, icebox",761:"remote control, remote",762:"restaurant, eating house, eating place, eatery",763:"revolver, six-gun, six-shooter",764:"rifle",765:"rocking chair, rocker",766:"rotisserie",767:"rubber eraser, rubber, pencil eraser",768:"rugby ball",769:"rule, ruler",770:"running shoe",771:"safe",772:"safety pin",773:"saltshaker, salt shaker",774:"sandal",775:"sarong",776:"sax, saxophone",777:"scabbard",778:"scale, weighing machine",779:"school bus",780:"schooner",781:"scoreboard",782:"screen, CRT screen",783:"screw",784:"screwdriver",785:"seat belt, seatbelt",786:"sewing machine",787:"shield, buckler",788:"shoe shop, shoe-shop, shoe store",789:"shoji",790:"shopping basket",791:"shopping cart",792:"shovel",793:"shower cap",794:"shower curtain",795:"ski",796:"ski mask",797:"sleeping bag",798:"slide rule, slipstick",799:"sliding door",800:"slot, one-armed bandit",801:"snorkel",802:"snowmobile",803:"snowplow, snowplough",804:"soap dispenser",805:"soccer ball",806:"sock",807:"solar dish, solar collector, solar furnace",808:"sombrero",809:"soup bowl",810:"space bar",811:"space heater",812:"space shuttle",813:"spatula",814:"speedboat",815:"spider web, spider's web",816:"spindle",817:"sports car, sport car",818:"spotlight, spot",819:"stage",820:"steam locomotive",821:"steel arch bridge",822:"steel drum",823:"stethoscope",824:"stole",825:"stone wall",826:"stopwatch, stop watch",827:"stove",828:"strainer",829:"streetcar, tram, tramcar, trolley, trolley car",830:"stretcher",831:"studio couch, day bed",832:"stupa, tope",833:"submarine, pigboat, sub, U-boat",834:"suit, suit of clothes",835:"sundial",836:"sunglass",837:"sunglasses, dark glasses, shades",838:"sunscreen, sunblock, sun blocker",839:"suspension bridge",840:"swab, swob, mop",841:"sweatshirt",842:"swimming trunks, bathing trunks",843:"swing",844:"switch, electric switch, electrical switch",845:"syringe",846:"table lamp",847:"tank, army tank, armored combat vehicle, armoured combat vehicle",848:"tape player",849:"teapot",850:"teddy, teddy bear",851:"television, television system",852:"tennis ball",853:"thatch, thatched roof",854:"theater curtain, theatre curtain",855:"thimble",856:"thresher, thrasher, threshing machine",857:"throne",858:"tile roof",859:"toaster",860:"tobacco shop, tobacconist shop, tobacconist",861:"toilet seat",862:"torch",863:"totem pole",864:"tow truck, tow car, wrecker",865:"toyshop",866:"tractor",867:"trailer truck, tractor trailer, trucking rig, rig, articulated lorry, semi",868:"tray",869:"trench coat",870:"tricycle, trike, velocipede",871:"trimaran",872:"tripod",873:"triumphal arch",874:"trolleybus, trolley coach, trackless trolley",875:"trombone",876:"tub, vat",877:"turnstile",878:"typewriter keyboard",879:"umbrella",880:"unicycle, monocycle",881:"upright, upright piano",882:"vacuum, vacuum cleaner",883:"vase",884:"vault",885:"velvet",886:"vending machine",887:"vestment",888:"viaduct",889:"violin, fiddle",890:"volleyball",891:"waffle iron",892:"wall clock",893:"wallet, billfold, notecase, pocketbook",894:"wardrobe, closet, press",895:"warplane, military plane",896:"washbasin, handbasin, washbowl, lavabo, wash-hand basin",897:"washer, automatic washer, washing machine",898:"water bottle",899:"water jug",900:"water tower",901:"whiskey jug",902:"whistle",903:"wig",904:"window screen",905:"window shade",906:"Windsor tie",907:"wine bottle",908:"wing",909:"wok",910:"wooden spoon",911:"wool, woolen, woollen",912:"worm fence, snake fence, snake-rail fence, Virginia fence",913:"wreck",914:"yawl",915:"yurt",916:"web site, website, internet site, site",917:"comic book",918:"crossword puzzle, crossword",919:"street sign",920:"traffic light, traffic signal, stoplight",921:"book jacket, dust cover, dust jacket, dust wrapper",922:"menu",923:"plate",924:"guacamole",925:"consomme",926:"hot pot, hotpot",927:"trifle",928:"ice cream, icecream",929:"ice lolly, lolly, lollipop, popsicle",930:"French loaf",931:"bagel, beigel",932:"pretzel",933:"cheeseburger",934:"hotdog, hot dog, red hot",935:"mashed potato",936:"head cabbage",937:"broccoli",938:"cauliflower",939:"zucchini, courgette",940:"spaghetti squash",941:"acorn squash",942:"butternut squash",943:"cucumber, cuke",944:"artichoke, globe artichoke",945:"bell pepper",946:"cardoon",947:"mushroom",948:"Granny Smith",949:"strawberry",950:"orange",951:"lemon",952:"fig",953:"pineapple, ananas",954:"banana",955:"jackfruit, jak, jack",956:"custard apple",957:"pomegranate",958:"hay",959:"carbonara",960:"chocolate sauce, chocolate syrup",961:"dough",962:"meat loaf, meatloaf",963:"pizza, pizza pie",964:"potpie",965:"burrito",966:"red wine",967:"espresso",968:"cup",969:"eggnog",970:"alp",971:"bubble",972:"cliff, drop, drop-off",973:"coral reef",974:"geyser",975:"lakeside, lakeshore",976:"promontory, headland, head, foreland",977:"sandbar, sand bar",978:"seashore, coast, seacoast, sea-coast",979:"valley, vale",980:"volcano",981:"ballplayer, baseball player",982:"groom, bridegroom",983:"scuba diver",984:"rapeseed",985:"daisy",986:"yellow lady's slipper, yellow lady-slipper, Cypripedium calceolus, Cypripedium parviflorum",987:"corn",988:"acorn",989:"hip, rose hip, rosehip",990:"buckeye, horse chestnut, conker",991:"coral fungus",992:"agaric",993:"gyromitra",994:"stinkhorn, carrion fungus",995:"earthstar",996:"hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa",997:"bolete",998:"ear, spike, capitulum",999:"toilet tissue, toilet paper, bathroom tissue"},j={"1.00":"module_apply_default/MobilenetV1/Logits/global_pool","2.00":"module_apply_default/MobilenetV2/Logits/AvgPool"},B={"1.00":{.25:{url:"https://tfhub.dev/google/imagenet/mobilenet_v1_025_224/classification/1",inputRange:[0,1]},"0.50":{url:"https://tfhub.dev/google/imagenet/mobilenet_v1_050_224/classification/1",inputRange:[0,1]},.75:{url:"https://tfhub.dev/google/imagenet/mobilenet_v1_075_224/classification/1",inputRange:[0,1]},"1.00":{url:"https://tfhub.dev/google/imagenet/mobilenet_v1_100_224/classification/1",inputRange:[0,1]}},"2.00":{"0.50":{url:"https://tfhub.dev/google/imagenet/mobilenet_v2_050_224/classification/2",inputRange:[0,1]},.75:{url:"https://tfhub.dev/google/imagenet/mobilenet_v2_075_224/classification/2",inputRange:[0,1]},"1.00":{url:"https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/classification/2",inputRange:[0,1]}}};function P(t){return void 0===t&&(t={version:1,alpha:1}),I(this,void 0,void 0,function(){var e,n,r,i,o,a;return R(this,function(s){switch(s.label){case 0:if(null==N)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 model.");if(n=t.version.toFixed(2),r=t.alpha?t.alpha.toFixed(2):"",i=-1,o=1,null==t.modelUrl){if(!(n in B))throw new Error("Invalid version of MobileNet. Valid versions are: "+Object.keys(B));if(!(r in B[n]))throw new Error("MobileNet constructed with invalid alpha "+t.alpha+". Valid multipliers for this version are: "+Object.keys(B[n])+".");e=B[n][r].inputRange,i=e[0],o=e[1];}return [4,(a=new L(n,r,t.modelUrl,i,o)).load()];case 1:return s.sent(),[2,a];}});});}var L=function(){function t(t,e,n,r,i){void 0===r&&(r=-1),void 0===i&&(i=1),this.version=t,this.alpha=e,this.modelUrl=n,this.inputMin=r,this.inputMax=i,this.inputRange=i-r;}return t.prototype.load=function(){return I(this,void 0,void 0,function(){var t,e,n,r,i=this;return R(this,function(o){switch(o.label){case 0:return this.modelUrl?(t=this,[4,Object(T.loadGraphModel)(this.modelUrl)]):[3,2];case 1:return t.model=o.sent(),[3,4];case 2:return e=B[this.version][this.alpha].url,n=this,[4,Object(T.loadGraphModel)(e,{fromTFHub:!0})];case 3:n.model=o.sent(),o.label=4;case 4:return [4,(r=Object(N.tidy)(function(){return i.model.predict(Object(N.zeros)([1,224,224,3]));})).data()];case 5:return o.sent(),r.dispose(),[2];}});});},t.prototype.infer=function(t,e){var n=this;return void 0===e&&(e=!1),Object(N.tidy)(function(){t instanceof N.Tensor||(t=N.browser.fromPixels(t));var r=t.toFloat().mul(n.inputRange).add(n.inputMin),i=r;224===t.shape[0]&&224===t.shape[1]||(i=N.image.resizeBilinear(r,[224,224],!0));var o,a=i.reshape([-1,224,224,3]);if(e){var s=j[n.version];o=n.model.execute(a,s).squeeze([1,2]);}else o=n.model.predict(a).slice([0,1],[-1,1e3]);return o;});},t.prototype.classify=function(t,e){return void 0===e&&(e=3),I(this,void 0,void 0,function(){var n,r;return R(this,function(i){switch(i.label){case 0:return [4,function(t,e){return I(this,void 0,void 0,function(){var n,r,i,o,a,s,u;return R(this,function(c){switch(c.label){case 0:return [4,(n=t.softmax()).data()];case 1:for(r=c.sent(),n.dispose(),i=[],u=0;u<r.length;u++){i.push({value:r[u],index:u});}for(i.sort(function(t,e){return e.value-t.value;}),o=new Float32Array(e),a=new Int32Array(e),u=0;u<e;u++){o[u]=i[u].value,a[u]=i[u].index;}for(s=[],u=0;u<a.length;u++){s.push({className:M[a[u]],probability:o[u]});}return [2,s];}});});}(n=this.infer(t),e)];case 1:return r=i.sent(),n.dispose(),[2,r];}});});},t;}();function z(t,e,n){for(var r=[],i=0;i<t.length;i+=1){r.push({value:t[i],index:i});}r.sort(function(t,e){return e.value-t.value;});for(var o=new Float32Array(e),a=new Int32Array(e),s=0;s<e;s+=1){o[s]=r[s].value,a[s]=r[s].index;}for(var u=[],c=0;c<a.length;c+=1){u.push({className:n[a[c]],probability:o[c]});}return u;}function U(t,e,n){return W.apply(this,arguments);}function W(){return (W=v()(E.a.mark(function t(e,n,r){var i;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,e.data();case 2:return i=t.sent,t.abrupt("return",z(i,n,r));case 4:case"end":return t.stop();}}},t);}))).apply(this,arguments);}var V=["kit fox","English setter","Siberian husky","Australian terrier","English springer","grey whale","lesser panda","Egyptian cat","ibex","Persian cat","cougar","gazelle","porcupine","sea lion","malamute","badger","Great Dane","Walker hound","Welsh springer spaniel","whippet","Scottish deerhound","killer whale","mink","African elephant","Weimaraner","soft-coated wheaten terrier","Dandie Dinmont","red wolf","Old English sheepdog","jaguar","otterhound","bloodhound","Airedale","hyena","meerkat","giant schnauzer","titi","three-toed sloth","sorrel","black-footed ferret","dalmatian","black-and-tan coonhound","papillon","skunk","Staffordshire bullterrier","Mexican hairless","Bouvier des Flandres","weasel","miniature poodle","Cardigan","malinois","bighorn","fox squirrel","colobus","tiger cat","Lhasa","impala","coyote","Yorkshire terrier","Newfoundland","brown bear","red fox","Norwegian elkhound","Rottweiler","hartebeest","Saluki","grey fox","schipperke","Pekinese","Brabancon griffon","West Highland white terrier","Sealyham terrier","guenon","mongoose","indri","tiger","Irish wolfhound","wild boar","EntleBucher","zebra","ram","French bulldog","orangutan","basenji","leopard","Bernese mountain dog","Maltese dog","Norfolk terrier","toy terrier","vizsla","cairn","squirrel monkey","groenendael","clumber","Siamese cat","chimpanzee","komondor","Afghan hound","Japanese spaniel","proboscis monkey","guinea pig","white wolf","ice bear","gorilla","borzoi","toy poodle","Kerry blue terrier","ox","Scotch terrier","Tibetan mastiff","spider monkey","Doberman","Boston bull","Greater Swiss Mountain dog","Appenzeller","Shih-Tzu","Irish water spaniel","Pomeranian","Bedlington terrier","warthog","Arabian camel","siamang","miniature schnauzer","collie","golden retriever","Irish terrier","affenpinscher","Border collie","hare","boxer","silky terrier","beagle","Leonberg","German short-haired pointer","patas","dhole","baboon","macaque","Chesapeake Bay retriever","bull mastiff","kuvasz","capuchin","pug","curly-coated retriever","Norwich terrier","flat-coated retriever","hog","keeshond","Eskimo dog","Brittany spaniel","standard poodle","Lakeland terrier","snow leopard","Gordon setter","dingo","standard schnauzer","hamster","Tibetan terrier","Arctic fox","wire-haired fox terrier","basset","water buffalo","American black bear","Angora","bison","howler monkey","hippopotamus","chow","giant panda","American Staffordshire terrier","Shetland sheepdog","Great Pyrenees","Chihuahua","tabby","marmoset","Labrador retriever","Saint Bernard","armadillo","Samoyed","bluetick","redbone","polecat","marmot","kelpie","gibbon","llama","miniature pinscher","wood rabbit","Italian greyhound","lion","cocker spaniel","Irish setter","dugong","Indian elephant","beaver","Sussex spaniel","Pembroke","Blenheim spaniel","Madagascar cat","Rhodesian ridgeback","lynx","African hunting dog","langur","Ibizan hound","timber wolf","cheetah","English foxhound","briard","sloth bear","Border terrier","German shepherd","otter","koala","tusker","echidna","wallaby","platypus","wombat","revolver","umbrella","schooner","soccer ball","accordion","ant","starfish","chambered nautilus","grand piano","laptop","strawberry","airliner","warplane","airship","balloon","space shuttle","fireboat","gondola","speedboat","lifeboat","canoe","yawl","catamaran","trimaran","container ship","liner","pirate","aircraft carrier","submarine","wreck","half track","tank","missile","bobsled","dogsled","bicycle-built-for-two","mountain bike","freight car","passenger car","barrow","shopping cart","motor scooter","forklift","electric locomotive","steam locomotive","amphibian","ambulance","beach wagon","cab","convertible","jeep","limousine","minivan","Model T","racer","sports car","go-kart","golfcart","moped","snowplow","fire engine","garbage truck","pickup","tow truck","trailer truck","moving van","police van","recreational vehicle","streetcar","snowmobile","tractor","mobile home","tricycle","unicycle","horse cart","jinrikisha","oxcart","bassinet","cradle","crib","four-poster","bookcase","china cabinet","medicine chest","chiffonier","table lamp","file","park bench","barber chair","throne","folding chair","rocking chair","studio couch","toilet seat","desk","pool table","dining table","entertainment center","wardrobe","Granny Smith","orange","lemon","fig","pineapple","banana","jackfruit","custard apple","pomegranate","acorn","hip","ear","rapeseed","corn","buckeye","organ","upright","chime","drum","gong","maraca","marimba","steel drum","banjo","cello","violin","harp","acoustic guitar","electric guitar","cornet","French horn","trombone","harmonica","ocarina","panpipe","bassoon","oboe","sax","flute","daisy","yellow lady's slipper","cliff","valley","alp","volcano","promontory","sandbar","coral reef","lakeside","seashore","geyser","hatchet","cleaver","letter opener","plane","power drill","lawn mower","hammer","corkscrew","can opener","plunger","screwdriver","shovel","plow","chain saw","cock","hen","ostrich","brambling","goldfinch","house finch","junco","indigo bunting","robin","bulbul","jay","magpie","chickadee","water ouzel","kite","bald eagle","vulture","great grey owl","black grouse","ptarmigan","ruffed grouse","prairie chicken","peacock","quail","partridge","African grey","macaw","sulphur-crested cockatoo","lorikeet","coucal","bee eater","hornbill","hummingbird","jacamar","toucan","drake","red-breasted merganser","goose","black swan","white stork","black stork","spoonbill","flamingo","American egret","little blue heron","bittern","crane","limpkin","American coot","bustard","ruddy turnstone","red-backed sandpiper","redshank","dowitcher","oystercatcher","European gallinule","pelican","king penguin","albatross","great white shark","tiger shark","hammerhead","electric ray","stingray","barracouta","coho","tench","goldfish","eel","rock beauty","anemone fish","lionfish","puffer","sturgeon","gar","loggerhead","leatherback turtle","mud turtle","terrapin","box turtle","banded gecko","common iguana","American chameleon","whiptail","agama","frilled lizard","alligator lizard","Gila monster","green lizard","African chameleon","Komodo dragon","triceratops","African crocodile","American alligator","thunder snake","ringneck snake","hognose snake","green snake","king snake","garter snake","water snake","vine snake","night snake","boa constrictor","rock python","Indian cobra","green mamba","sea snake","horned viper","diamondback","sidewinder","European fire salamander","common newt","eft","spotted salamander","axolotl","bullfrog","tree frog","tailed frog","whistle","wing","paintbrush","hand blower","oxygen mask","snorkel","loudspeaker","microphone","screen","mouse","electric fan","oil filter","strainer","space heater","stove","guillotine","barometer","rule","odometer","scale","analog clock","digital clock","wall clock","hourglass","sundial","parking meter","stopwatch","digital watch","stethoscope","syringe","magnetic compass","binoculars","projector","sunglasses","loupe","radio telescope","bow","cannon","assault rifle","rifle","projectile","computer keyboard","typewriter keyboard","crane","lighter","abacus","cash machine","slide rule","desktop computer","hand-held computer","notebook","web site","harvester","thresher","printer","slot","vending machine","sewing machine","joystick","switch","hook","car wheel","paddlewheel","pinwheel","potter's wheel","gas pump","carousel","swing","reel","radiator","puck","hard disc","sunglass","pick","car mirror","solar dish","remote control","disk brake","buckle","hair slide","knot","combination lock","padlock","nail","safety pin","screw","muzzle","seat belt","ski","candle","jack-o'-lantern","spotlight","torch","neck brace","pier","tripod","maypole","mousetrap","spider web","trilobite","harvestman","scorpion","black and gold garden spider","barn spider","garden spider","black widow","tarantula","wolf spider","tick","centipede","isopod","Dungeness crab","rock crab","fiddler crab","king crab","American lobster","spiny lobster","crayfish","hermit crab","tiger beetle","ladybug","ground beetle","long-horned beetle","leaf beetle","dung beetle","rhinoceros beetle","weevil","fly","bee","grasshopper","cricket","walking stick","cockroach","mantis","cicada","leafhopper","lacewing","dragonfly","damselfly","admiral","ringlet","monarch","cabbage butterfly","sulphur butterfly","lycaenid","jellyfish","sea anemone","brain coral","flatworm","nematode","conch","snail","slug","sea slug","chiton","sea urchin","sea cucumber","iron","espresso maker","microwave","Dutch oven","rotisserie","toaster","waffle iron","vacuum","dishwasher","refrigerator","washer","Crock Pot","frying pan","wok","caldron","coffeepot","teapot","spatula","altar","triumphal arch","patio","steel arch bridge","suspension bridge","viaduct","barn","greenhouse","palace","monastery","library","apiary","boathouse","church","mosque","stupa","planetarium","restaurant","cinema","home theater","lumbermill","coil","obelisk","totem pole","castle","prison","grocery store","bakery","barbershop","bookshop","butcher shop","confectionery","shoe shop","tobacco shop","toyshop","fountain","cliff dwelling","yurt","dock","brass","megalith","bannister","breakwater","dam","chainlink fence","picket fence","worm fence","stone wall","grille","sliding door","turnstile","mountain tent","scoreboard","honeycomb","plate rack","pedestal","beacon","mashed potato","bell pepper","head cabbage","broccoli","cauliflower","zucchini","spaghetti squash","acorn squash","butternut squash","cucumber","artichoke","cardoon","mushroom","shower curtain","jean","carton","handkerchief","sandal","ashcan","safe","plate","necklace","croquet ball","fur coat","thimble","pajama","running shoe","cocktail shaker","chest","manhole cover","modem","tub","tray","balance beam","bagel","prayer rug","kimono","hot pot","whiskey jug","knee pad","book jacket","spindle","ski mask","beer bottle","crash helmet","bottlecap","tile roof","mask","maillot","Petri dish","football helmet","bathing cap","teddy","holster","pop bottle","photocopier","vestment","crossword puzzle","golf ball","trifle","suit","water tower","feather boa","cloak","red wine","drumstick","shield","Christmas stocking","hoopskirt","menu","stage","bonnet","meat loaf","baseball","face powder","scabbard","sunscreen","beer glass","hen-of-the-woods","guacamole","lampshade","wool","hay","bow tie","mailbag","water jug","bucket","dishrag","soup bowl","eggnog","mortar","trench coat","paddle","chain","swab","mixing bowl","potpie","wine bottle","shoji","bulletproof vest","drilling platform","binder","cardigan","sweatshirt","pot","birdhouse","hamper","ping-pong ball","pencil box","pay-phone","consomme","apron","punching bag","backpack","groom","bearskin","pencil sharpener","broom","mosquito net","abaya","mortarboard","poncho","crutch","Polaroid camera","space bar","cup","racket","traffic light","quill","radio","dough","cuirass","military uniform","lipstick","shower cap","monitor","oscilloscope","mitten","brassiere","French loaf","vase","milk can","rugby ball","paper towel","earthstar","envelope","miniskirt","cowboy hat","trolleybus","perfume","bathtub","hotdog","coral fungus","bullet train","pillow","toilet tissue","cassette","carpenter's kit","ladle","stinkhorn","lotion","hair spray","academic gown","dome","crate","wig","burrito","pill bottle","chain mail","theater curtain","window shade","barrel","washbasin","ballpoint","basketball","bath towel","cowboy boot","gown","window screen","agaric","cellular telephone","nipple","barbell","mailbox","lab coat","fire screen","minibus","packet","maze","pole","horizontal bar","sombrero","pickelhaube","rain barrel","wallet","cassette player","comic book","piggy bank","street sign","bell cote","fountain pen","Windsor tie","volleyball","overskirt","sarong","purse","bolo tie","bib","parachute","sleeping bag","television","swimming trunks","measuring cup","espresso","pizza","breastplate","shopping basket","wooden spoon","saltshaker","chocolate sauce","ballplayer","goblet","gyromitra","stretcher","water bottle","dial telephone","soap dispenser","jersey","school bus","jigsaw puzzle","plastic bag","reflex camera","diaper","Band Aid","ice lolly","velvet","tennis ball","gasmask","doormat","Loafer","ice cream","pretzel","quilt","maillot","tape player","clog","iPod","bolete","scuba diver","pitcher","matchstick","bikini","sock","CD player","lens cap","thatch","vault","beaker","bubble","cheeseburger","parallel bars","flagpole","coffee mug","rubber eraser","stole","carbonara","dumbbell"],q={DARKNET_URL:"https://cdn.jsdelivr.net/gh/ml5js/ml5-data-and-models@master/models/darknetclassifier/darknetreference/model.json",DARKNET_TINY_URL:"https://cdn.jsdelivr.net/gh/ml5js/ml5-data-and-models@master/models/darknetclassifier/darknettiny/model.json",IMAGE_SIZE_DARKNET:256,IMAGE_SIZE_DARKNET_TINY:224};function $(t,e){var n;t instanceof p.Tensor?n=t:t instanceof HTMLImageElement||t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof ImageData?n=p.browser.fromPixels(t):"object"===S()(t)&&(t.elt instanceof HTMLImageElement||t.elt instanceof HTMLVideoElement||t.elt instanceof HTMLCanvasElement||t.elt instanceof ImageData)&&(n=p.browser.fromPixels(t.elt));var r=n.toFloat().div(p.scalar(255)),i=r;if(r.shape[0]!==e||r.shape[1]!==e){i=p.image.resizeBilinear(r,[e,e],!0);}return i.reshape([1,e,e,3]);}var H=function(){function t(e){switch(b()(this,t),this.version=e,this.version){case"reference":this.imgSize=q.IMAGE_SIZE_DARKNET;break;case"tiny":this.imgSize=q.IMAGE_SIZE_DARKNET_TINY;}}return w()(t,[{key:"load",value:function(){var t=v()(E.a.mark(function t(){var e,n=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:t.t0=this.version,t.next="reference"===t.t0?3:"tiny"===t.t0?7:11;break;case 3:return t.next=5,p.loadLayersModel(q.DARKNET_URL);case 5:return this.model=t.sent,t.abrupt("break",12);case 7:return t.next=9,p.loadLayersModel(q.DARKNET_TINY_URL);case 9:return this.model=t.sent,t.abrupt("break",12);case 11:return t.abrupt("break",12);case 12:return e=p.tidy(function(){return n.model.predict(p.zeros([1,n.imgSize,n.imgSize,3]));}),t.next=15,e.data();case 15:e.dispose();case 16:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"classify",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i,o=this,a=arguments;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return n=a.length>1&&void 0!==a[1]?a[1]:3,r=p.tidy(function(){var t=$(e,o.imgSize),n=o.model.predict(t);return p.softmax(n);}),t.next=4,U(r,n,V);case 4:return i=t.sent,r.dispose(),t.abrupt("return",i);case 7:case"end":return t.stop();}}},t);}));return function(e){return t.apply(this,arguments);};}()}]),t;}();function G(t){return K.apply(this,arguments);}function K(){return (K=v()(E.a.mark(function t(e){var n,r;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if("reference"===(n=e.version)||"tiny"===n){t.next=3;break;}throw new Error("Please select a version: darknet-reference or darknet-tiny");case 3:return r=new H(n),t.next=6,r.load();case 6:return t.abrupt("return",r);case 7:case"end":return t.stop();}}},t);}))).apply(this,arguments);}var X=n(23),Y=n.n(X),J=["flashlight","belt","mushroom","pond","strawberry","pineapple","sun","cow","ear","bush","pliers","watermelon","apple","baseball","feather","shoe","leaf","lollipop","crown","ocean","horse","mountain","mosquito","mug","hospital","saw","castle","angel","underwear","traffic_light","cruise_ship","marker","blueberry","flamingo","face","hockey_stick","bucket","campfire","asparagus","skateboard","door","suitcase","skull","cloud","paint_can","hockey_puck","steak","house_plant","sleeping_bag","bench","snowman","arm","crayon","fan","shovel","leg","washing_machine","harp","toothbrush","tree","bear","rake","megaphone","knee","guitar","calculator","hurricane","grapes","paintbrush","couch","nose","square","wristwatch","penguin","bridge","octagon","submarine","screwdriver","rollerskates","ladder","wine_bottle","cake","bracelet","broom","yoga","finger","fish","line","truck","snake","bus","stitches","snorkel","shorts","bowtie","pickup_truck","tooth","snail","foot","crab","school_bus","train","dresser","sock","tractor","map","hedgehog","coffee_cup","computer","matches","beard","frog","crocodile","bathtub","rain","moon","bee","knife","boomerang","lighthouse","chandelier","jail","pool","stethoscope","frying_pan","cell_phone","binoculars","purse","lantern","birthday_cake","clarinet","palm_tree","aircraft_carrier","vase","eraser","shark","skyscraper","bicycle","sink","teapot","circle","tornado","bird","stereo","mouth","key","hot_dog","spoon","laptop","cup","bottlecap","The_Great_Wall_of_China","The_Mona_Lisa","smiley_face","waterslide","eyeglasses","ceiling_fan","lobster","moustache","carrot","garden","police_car","postcard","necklace","helmet","blackberry","beach","golf_club","car","panda","alarm_clock","t-shirt","dog","bread","wine_glass","lighter","flower","bandage","drill","butterfly","swan","owl","raccoon","squiggle","calendar","giraffe","elephant","trumpet","rabbit","trombone","sheep","onion","church","flip_flops","spreadsheet","pear","clock","roller_coaster","parachute","kangaroo","duck","remote_control","compass","monkey","rainbow","tennis_racquet","lion","pencil","string_bean","oven","star","cat","pizza","soccer_ball","syringe","flying_saucer","eye","cookie","floor_lamp","mouse","toilet","toaster","The_Eiffel_Tower","airplane","stove","cello","stop_sign","tent","diving_board","light_bulb","hammer","scorpion","headphones","basket","spider","paper_clip","sweater","ice_cream","envelope","sea_turtle","donut","hat","hourglass","broccoli","jacket","backpack","book","lightning","drums","snowflake","radio","banana","camel","canoe","toothpaste","chair","picture_frame","parrot","sandwich","lipstick","pants","violin","brain","power_outlet","triangle","hamburger","dragon","bulldozer","cannon","dolphin","zebra","animal_migration","camouflage","scissors","basketball","elbow","umbrella","windmill","table","rifle","hexagon","potato","anvil","sword","peanut","axe","television","rhinoceros","baseball_bat","speedboat","sailboat","zigzag","garden_hose","river","house","pillow","ant","tiger","stairs","cooler","see_saw","piano","fireplace","popsicle","dumbbell","mailbox","barn","hot_tub","teddy-bear","fork","dishwasher","peas","hot_air_balloon","keyboard","microwave","wheel","fire_hydrant","van","camera","whale","candle","octopus","pig","swing_set","helicopter","saxophone","passport","bat","ambulance","diamond","goatee","fence","grass","mermaid","motorbike","microphone","toe","cactus","nail","telephone","hand","squirrel","streetlight","bed","firetruck"],Q={DOODLENET_URL:"https://cdn.jsdelivr.net/gh/ml5js/ml5-data-and-models@master/models/doodlenet/model.json",IMAGE_SIZE_DOODLENET:28};function Z(t,e){var n;t instanceof p.Tensor?n=t:t instanceof HTMLImageElement||t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof ImageData?n=p.browser.fromPixels(t):"object"===S()(t)&&(t.elt instanceof HTMLImageElement||t.elt instanceof HTMLVideoElement||t.elt instanceof HTMLCanvasElement||t.elt instanceof ImageData)&&(n=p.browser.fromPixels(t.elt));var r=p.scalar(1).sub(n.toFloat().div(p.scalar(255))),i=r;r.shape[0]===e&&r.shape[1]===e||(i=p.image.resizeBilinear(r,[e,e]));var o=p.split(i,3,3),a=Y()(o,3),s=a[0],u=a[1],c=a[2];return s.add(u).add(c).div(p.scalar(3)).floor().reshape([1,e,e,1]);}var tt=function(){function t(){b()(this,t),this.imgSize=Q.IMAGE_SIZE_DOODLENET;}return w()(t,[{key:"load",value:function(){var t=v()(E.a.mark(function t(){var e,n=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,p.loadLayersModel(Q.DOODLENET_URL);case 2:return this.model=t.sent,e=p.tidy(function(){return n.model.predict(p.zeros([1,n.imgSize,n.imgSize,1]));}),t.next=6,e.data();case 6:e.dispose();case 7:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"classify",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i,o=this,a=arguments;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return n=a.length>1&&void 0!==a[1]?a[1]:10,r=p.tidy(function(){var t=Z(e,o.imgSize);return o.model.predict(t);}),t.next=4,U(r,n,J);case 4:return i=t.sent,r.dispose(),t.abrupt("return",i);case 7:case"end":return t.stop();}}},t);}));return function(e){return t.apply(this,arguments);};}()}]),t;}();function et(){return nt.apply(this,arguments);}function nt(){return (nt=v()(E.a.mark(function t(){var e;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return e=new tt(),t.next=3,e.load();case 3:return t.abrupt("return",e);case 4:case"end":return t.stop();}}},t);}))).apply(this,arguments);}var rt=new(function(){function t(){b()(this,t),"undefined"!=typeof window&&(this.m_p5Instance=window);}return w()(t,[{key:"setP5Instance",value:function value(t){this.m_p5Instance=t;}},{key:"p5Instance",get:function get(){return void 0!==this.m_p5Instance&&"function"==typeof this.m_p5Instance.loadImage?this.m_p5Instance:void 0!==this.m_p5Instance.p5&&void 0!==this.m_p5Instance.p5.Image&&"function"==typeof this.m_p5Instance.p5.Image?this.m_p5Instance.p5:void 0;}},{key:"checkP5",value:function value(){return !!this.p5Instance;}},{key:"getBlob",value:function value(t){return new Promise(function(e,n){t.toBlob(function(t){t?e(t):n(new Error("Canvas could not be converted to Blob."));});});}},{key:"loadAsync",value:function value(t){var e=this;return new Promise(function(n,r){e.p5Instance.loadImage(t,function(t){n(t);},function(){r(new Error("Could not load image from url ".concat(t)));});});}},{key:"rawToBlob",value:function(){var t=v()(E.a.mark(function t(e,n,r){var i,o,a,s,u,c;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:for(i=Array.from(e),o=document.createElement("canvas"),a=o.getContext("2d"),o.width=n,o.height=r,s=a.createImageData(n,r),u=s.data,c=0;c<n*r*4;c+=1){u[c]=i[c];}return a.putImageData(s,0,0),t.abrupt("return",this.getBlob(o));case 10:case"end":return t.stop();}}},t,this);}));return function(e,n,r){return t.apply(this,arguments);};}()},{key:"blobToP5Image",value:function(){var t=v()(E.a.mark(function t(e){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(!this.checkP5()||"undefined"==typeof URL){t.next=2;break;}return t.abrupt("return",this.loadAsync(URL.createObjectURL(e)));case 2:return t.abrupt("return",null);case 3:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()}]),t;}())(),it=function it(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){},r=t,i=document.createElement("video");return r.onplay=function(){var t=r.captureStream();i.srcObject=t,i.width=e,i.height=e,i.autoplay=!0,i.playsinline=!0,i.muted=!0,n();},i;},ot=function ot(t){var e=Y()(t.shape,2),n=e[0],r=e[1],i=t.dataSync(),o=document.createElement("canvas");o.width=r,o.height=n;for(var a=o.getContext("2d"),s=a.getImageData(0,0,o.width,o.height),u=0;u<r*n;u+=1){var c=4*u,l=3*u;s.data[c+0]=Math.floor(256*i[l+0]),s.data[c+1]=Math.floor(256*i[l+1]),s.data[c+2]=Math.floor(256*i[l+2]),s.data[c+3]=255;}a.putImageData(s,0,0);var f=o.toDataURL(),h=document.createElement("img");return h.src=f,h.style.width=r,h.style.height=n,t.dispose(),h;},at=function at(t){var e=Math.min(t.shape[0],t.shape[1]),n=t.shape[0]/2-e/2,r=t.shape[1]/2-e/2;return t.slice([n,r,0],[e,e,3]);},st=function st(t){var e,n,r;if(r=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData?t:"object"===S()(t)&&(t.elt instanceof HTMLImageElement||t.elt instanceof HTMLCanvasElement||t.elt instanceof HTMLVideoElement||t.elt instanceof ImageData)?t.elt:"object"===S()(t)&&t.canvas instanceof HTMLCanvasElement?t.canvas:t,e=r.width,n=r.height,rt.checkP5()){var i=rt.p5Instance.createGraphics(e,n);return i.push(),i.translate(e,0),i.scale(-1,1),i.image(t,0,0,e,n),i.pop(),i;}var o=document.createElement("canvas");o.width=e,o.height=n;var a=o.getContext("2d");return a.drawImage(r,0,0,e,n),a.translate(e,0),a.scale(-1,1),a.drawImage(o,-1*e,0,e,n),o;};function ut(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return p.tidy(function(){var n=p.browser.fromPixels(t);return e&&(n=p.image.resizeBilinear(n,e)),at(n).expandDims(0).toFloat().div(p.scalar(127)).sub(p.scalar(1));});}function ct(t){return t instanceof HTMLVideoElement||t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof ImageData;}function lt(t){var e,n,r;r=t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData?t:"object"===S()(t)&&(t.elt instanceof HTMLImageElement||t.elt instanceof HTMLCanvasElement||t.elt instanceof HTMLVideoElement||t.elt instanceof ImageData)?t.elt:"object"===S()(t)&&t.canvas instanceof HTMLCanvasElement?t.canvas:t,e=r.width,n=r.height;var i=document.createElement("canvas");i.width=e,i.height=n;var o=i.getContext("2d");o.drawImage(r,0,0,e,n);var a=o.getImageData(0,0,e,n);return Array.from(a.data);}var ft={mobilenet:{version:2,alpha:1,topk:3}},ht=["mobilenet","darknet","darknet-tiny","doodlenet"],dt=function(){function t(e,n,a,s){if(b()(this,t),this.video=n,this.model=null,this.mapStringToIndex=[],"string"==typeof e)if(ht.includes(e))switch(this.modelName=e,this.modelUrl=null,this.modelName){case"mobilenet":this.modelToUse=r,this.version=a.version||ft.mobilenet.version,this.alpha=a.alpha||ft.mobilenet.alpha,this.topk=a.topk||ft.mobilenet.topk;break;case"darknet":this.version="reference",this.modelToUse=i;break;case"darknet-tiny":this.version="tiny",this.modelToUse=i;break;case"doodlenet":this.modelToUse=o;break;default:this.modelToUse=null;}else this.modelUrl=e,this.modelUrl.endsWith("/")&&(this.modelUrl+="model.json");this.ready=C(this.loadModel(this.modelUrl),s);}return w()(t,[{key:"loadModel",value:function(){var t=v()(E.a.mark(function t(e){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(!e){t.next=6;break;}return t.next=3,this.loadModelFrom(e);case 3:this.model=t.sent,t.next=9;break;case 6:return t.next=8,this.modelToUse.load({version:this.version,alpha:this.alpha});case 8:this.model=t.sent;case 9:return t.abrupt("return",this);case 10:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"loadModelFrom",value:function(){var t=v()(E.a.mark(function t(){var e,n,r,i,o,a,s,u,c=arguments;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(e=c.length>0&&void 0!==c[0]?c[0]:null,t.prev=1,null===e){t.next=7;break;}return t.next=5,F.a.get(e);case 5:r=t.sent,n=r.data;case 7:if(n.ml5Specs&&(this.mapStringToIndex=n.ml5Specs.mapStringToIndex),0!==this.mapStringToIndex.length){t.next=16;break;}return i=e.split("/"),o=i.slice(0,i.length-1).join("/"),a="".concat(o,"/metadata.json"),t.next=14,F.a.get(a).catch(function(t){console.log("Tried to fetch metadata.json, but it seems to be missing.",t);});case 14:(s=t.sent)&&(u=s.data).labels&&(this.mapStringToIndex=u.labels);case 16:return t.next=18,p.loadLayersModel(e);case 18:return this.model=t.sent,t.abrupt("return",this.model);case 22:return t.prev=22,t.t0=t.catch(1),console.error(t.t0),t.abrupt("return",t.t0);case 26:case"end":return t.stop();}}},t,this,[[1,22]]);}));return function(){return t.apply(this,arguments);};}()},{key:"classifyInternal",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i,o,a,s,u,c=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.ready;case 2:return t.next=4,p.nextFrame();case 4:if(!(e instanceof HTMLVideoElement&&0===e.readyState)){t.next=8;break;}return r=e,t.next=8,new Promise(function(t){r.onloadeddata=function(){return t();};});case 8:if(!this.video||0!==this.video.readyState){t.next=11;break;}return t.next=11,new Promise(function(t){c.video.onloadeddata=function(){return t();};});case 11:if(i=[224,224],!this.modelUrl){t.next=20;break;}return t.next=15,p.nextFrame();case 15:return o=p.tidy(function(){var t=ut(e,i),n=c.model.predict(t);return Array.from(n.as1D().dataSync());}),t.next=18,o.map(function(t,e){return {label:c.mapStringToIndex.length>0&&c.mapStringToIndex[e]?c.mapStringToIndex[e]:e,confidence:t};}).sort(function(t,e){return e.confidence-t.confidence;});case 18:return a=t.sent,t.abrupt("return",a);case 20:return s=ut(e,i),u=this.model.classify(s,n).then(function(t){return t.map(function(t){return {label:t.className,confidence:t.probability};});}),s.dispose(),t.abrupt("return",u);case 24:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"classify",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i,o,a,s=arguments;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(n=s.length>1&&void 0!==s[1]?s[1]:null,r=s.length>2?s[2]:void 0,i=this.video,o=this.topk,"function"!=typeof e){t.next=9;break;}i=this.video,a=e,t.next=28;break;case 9:if("number"!=typeof e){t.next=14;break;}i=this.video,o=e,t.next=28;break;case 14:if(!(e instanceof HTMLVideoElement||e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof ImageData)){t.next=18;break;}i=e,t.next=28;break;case 18:if("object"!==S()(e)||!(e.elt instanceof HTMLVideoElement||e.elt instanceof HTMLImageElement||e.elt instanceof HTMLCanvasElement||e.elt instanceof ImageData)){t.next=22;break;}i=e.elt,t.next=28;break;case 22:if(!("object"===S()(e)&&e.canvas instanceof HTMLCanvasElement)){t.next=26;break;}i=e.canvas,t.next=28;break;case 26:if(this.video instanceof HTMLVideoElement){t.next=28;break;}throw new Error("No input image provided. If you want to classify a video, pass the video element in the constructor. ");case 28:return "number"==typeof n?o=n:"function"==typeof n&&(a=n),"function"==typeof r&&(a=r),t.abrupt("return",C(this.classifyInternal(i,o),a));case 31:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"predict",value:function(){var t=v()(E.a.mark(function t(e,n,r){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.abrupt("return",this.classify(e,n||null,r));case 1:case"end":return t.stop();}}},t,this);}));return function(e,n,r){return t.apply(this,arguments);};}()}]),t;}(),pt=function pt(t,e,n,r){var i,o={},a=r,s=t;if("string"!=typeof s)throw new Error('Please specify a model to use. E.g: "MobileNet"');-1===s.indexOf("http")&&(s=t.toLowerCase()),e instanceof HTMLVideoElement?i=e:"object"===S()(e)&&e.elt instanceof HTMLVideoElement?i=e.elt:"object"===S()(e)?o=e:"function"==typeof e&&(a=e),"object"===S()(n)?o=n:"function"==typeof n&&(a=n);var u=new dt(s,i,o,a);return a?u:u.ready;},_mt=function mt(t,e){return (_mt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e;}||function(t,e){for(var n in e){e.hasOwnProperty(n)&&(t[n]=e[n]);}})(t,e);};var _gt=function gt(){return (_gt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){for(var i in e=arguments[n]){Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);}}return t;}).apply(this,arguments);};function vt(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});}function yt(t,e){var n,r,i,o,a={label:0,sent:function sent(){if(1&i[0])throw i[1];return i[1];},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this;}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;){try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue;}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break;}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break;}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break;}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(t,a);}catch(t){o=[6,t],r=0;}finally{n=i=0;}}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:!0};}([o,s]);};}}function bt(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function next(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t};}};}function xt(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-->0)&&!(r=o.next()).done;){a.push(r.value);}}catch(t){i={error:t};}finally{try{r&&!r.done&&(n=o.return)&&n.call(o);}finally{if(i)throw i.error;}}return a;}function wt(){for(var t=[],e=0;e<arguments.length;e++){t=t.concat(xt(arguments[e]));}return t;}var kt=null;function Et(t){return null==kt&&(kt=Object(p.backend)().epsilon()),Object(p.tidy)(function(){var e=Object(p.moments)(t),n=e.mean,r=e.variance;return t.sub(n).div(r.sqrt().add(kt));});}var Ct=function(){function t(t){var e=this;if(null==t)throw new Error("Required configuration object is missing for BrowserFftFeatureExtractor constructor");if(null==t.spectrogramCallback)throw new Error("spectrogramCallback cannot be null or undefined");if(!(t.numFramesPerSpectrogram>0))throw new Error("Invalid value in numFramesPerSpectrogram: "+t.numFramesPerSpectrogram);if(t.suppressionTimeMillis<0)throw new Error("Expected suppressionTimeMillis to be >= 0, but got "+t.suppressionTimeMillis);if(this.suppressionTimeMillis=t.suppressionTimeMillis,this.spectrogramCallback=t.spectrogramCallback,this.numFrames=t.numFramesPerSpectrogram,this.sampleRateHz=t.sampleRateHz||44100,this.fftSize=t.fftSize||1024,this.frameDurationMillis=this.fftSize/this.sampleRateHz*1e3,this.columnTruncateLength=t.columnTruncateLength||this.fftSize,this.overlapFactor=t.overlapFactor,this.includeRawAudio=t.includeRawAudio,p.util.assert(this.overlapFactor>=0&&this.overlapFactor<1,function(){return "Expected overlapFactor to be >= 0 and < 1, but got "+e.overlapFactor;}),this.columnTruncateLength>this.fftSize)throw new Error("columnTruncateLength "+this.columnTruncateLength+" exceeds fftSize ("+this.fftSize+").");this.audioContextConstructor=window.AudioContext||window.webkitAudioContext;}return t.prototype.start=function(t){return vt(this,void 0,void 0,function(){var e,n,r;return yt(this,function(i){switch(i.label){case 0:if(null!=this.frameIntervalTask)throw new Error("Cannot start already-started BrowserFftFeatureExtractor");return e=this,[4,function(t){return vt(this,void 0,void 0,function(){return yt(this,function(e){switch(e.label){case 0:return [4,navigator.mediaDevices.getUserMedia({audio:null==t||t,video:!1})];case 1:return [2,e.sent()];}});});}(t)];case 1:return e.stream=i.sent(),this.audioContext=new this.audioContextConstructor(),this.audioContext.sampleRate!==this.sampleRateHz&&console.warn("Mismatch in sampling rate: Expected: "+this.sampleRateHz+"; Actual: "+this.audioContext.sampleRate),n=this.audioContext.createMediaStreamSource(this.stream),this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=2*this.fftSize,this.analyser.smoothingTimeConstant=0,n.connect(this.analyser),this.freqDataQueue=[],this.freqData=new Float32Array(this.fftSize),this.includeRawAudio&&(this.timeDataQueue=[],this.timeData=new Float32Array(this.fftSize)),r=Math.max(1,Math.round(this.numFrames*(1-this.overlapFactor))),this.tracker=new _t(r,Math.round(this.suppressionTimeMillis/this.frameDurationMillis)),this.frameIntervalTask=setInterval(this.onAudioFrame.bind(this),this.fftSize/this.sampleRateHz*1e3),[2];}});});},t.prototype.onAudioFrame=function(){return vt(this,void 0,void 0,function(){var t,e,n,r;return yt(this,function(i){switch(i.label){case 0:return this.analyser.getFloatFrequencyData(this.freqData),this.freqData[0]===-1/0?[2]:(this.freqDataQueue.push(this.freqData.slice(0,this.columnTruncateLength)),this.includeRawAudio&&(this.analyser.getFloatTimeDomainData(this.timeData),this.timeDataQueue.push(this.timeData.slice())),this.freqDataQueue.length>this.numFrames&&this.freqDataQueue.shift(),this.tracker.tick()?(t=At(this.freqDataQueue),e=Ot(t,[1,this.numFrames,this.columnTruncateLength,1]),n=void 0,this.includeRawAudio&&(r=At(this.timeDataQueue),n=Ot(r,[1,this.numFrames*this.fftSize])),[4,this.spectrogramCallback(e,n)]):[3,2]);case 1:i.sent()&&this.tracker.suppress(),Object(p.dispose)([e,n]),i.label=2;case 2:return [2];}});});},t.prototype.stop=function(){return vt(this,void 0,void 0,function(){return yt(this,function(t){if(null==this.frameIntervalTask)throw new Error("Cannot stop because there is no ongoing streaming activity.");return clearInterval(this.frameIntervalTask),this.frameIntervalTask=null,this.analyser.disconnect(),this.audioContext.close(),null!=this.stream&&this.stream.getTracks().length>0&&this.stream.getTracks()[0].stop(),[2];});});},t.prototype.setConfig=function(t){throw new Error("setConfig() is not implemented for BrowserFftFeatureExtractor.");},t.prototype.getFeatures=function(){throw new Error("getFeatures() is not implemented for BrowserFftFeatureExtractor. Use the spectrogramCallback field of the constructor config instead.");},t;}();function At(t){var e=t[0].length,n=new Float32Array(t.length*e);return t.forEach(function(t,r){return n.set(t,r*e);}),n;}function Ot(t,e){var n=new Float32Array(p.util.sizeFromShape(e));return n.set(t,n.length-t.length),Object(p.tensor)(n,e);}var _t=function(){function t(t,e){var n=this;this.period=t,this.suppressionTime=null==e?0:e,this.counter=0,p.util.assert(this.period>0,function(){return "Expected period to be positive, but got "+n.period;});}return t.prototype.tick=function(){return this.counter++,this.counter%this.period==0&&(null==this.suppressionOnset||this.counter-this.suppressionOnset>this.suppressionTime);},t.prototype.suppress=function(){this.suppressionOnset=this.counter;},t;}();function St(t){var e=0;t.forEach(function(t){e+=t.byteLength;});var n=new Uint8Array(e),r=0;return t.forEach(function(t){n.set(new Uint8Array(t),r),r+=t.byteLength;}),n.buffer;}function Dt(t){var e=0;t.forEach(function(t){return e+=t.length;});var n=new Float32Array(e),r=0;return t.forEach(function(t){n.set(t,r),r+=t.length;}),n;}function Ft(t){if(null==t)throw new Error("Received null or undefind string");for(var e=unescape(encodeURIComponent(t)),n=new Uint8Array(e.length),r=0;r<e.length;++r){n[r]=e.charCodeAt(r);}return n.buffer;}function Tt(t){if(null==t)throw new Error("Received null or undefind buffer");var e=new Uint8Array(t);return decodeURIComponent(escape(String.fromCharCode.apply(String,wt(e))));}var Nt="TFJSSCDS",It=1,Rt=function(){function t(t){if(this.examples={},this.label2Ids={},null!=t)for(var e=function(t){p.util.assert(null!=t,function(){return "Received null or undefined buffer";});var e=0,n=Tt(t.slice(e,Nt.length));p.util.assert(n===Nt,function(){return "Deserialization error: Invalid descriptor";}),e+=Nt.length,e+=4;var r=new Uint32Array(t,e,1),i=e+=4;e=i+r[0];var o=Tt(t.slice(i,e));return {manifest:JSON.parse(o),data:t.slice(e)};}(t),n=0,r=0;r<e.manifest.length;++r){var i=e.manifest[r],o=i.spectrogramNumFrames*i.spectrogramFrameSize;null!=i.rawAudioNumSamples&&(o+=i.rawAudioNumSamples),o*=4,this.addExample(jt({spec:i,data:e.data.slice(n,n+o)})),n+=o;}}return t.prototype.addExample=function(t){p.util.assert(null!=t,function(){return "Got null or undefined example";}),p.util.assert(null!=t.label&&t.label.length>0,function(){return "Expected label to be a non-empty string, but got "+JSON.stringify(t.label);});var e=function(){function t(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1);}return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t();}();return this.examples[e]=t,t.label in this.label2Ids||(this.label2Ids[t.label]=[]),this.label2Ids[t.label].push(e),e;},t.prototype.merge=function(t){var e,n,r,i;p.util.assert(t!==this,function(){return "Cannot merge a dataset into itself";});var o=t.getVocabulary();try{for(var a=bt(o),s=a.next();!s.done;s=a.next()){var u=s.value,c=t.getExamples(u);try{for(var l=bt(c),f=l.next();!f.done;f=l.next()){var h=f.value;this.addExample(h.example);}}catch(t){r={error:t};}finally{try{f&&!f.done&&(i=l.return)&&i.call(l);}finally{if(r)throw r.error;}}}}catch(t){e={error:t};}finally{try{s&&!s.done&&(n=a.return)&&n.call(a);}finally{if(e)throw e.error;}}},t.prototype.getExampleCounts=function(){var t={};for(var e in this.examples){var n=this.examples[e];n.label in t||(t[n.label]=0),t[n.label]++;}return t;},t.prototype.getExamples=function(t){var e=this;p.util.assert(null!=t,function(){return "Expected label to be a string, but got "+JSON.stringify(t);}),p.util.assert(t in this.label2Ids,function(){return 'No example of label "'+t+'" exists in dataset';});var n=[];return this.label2Ids[t].forEach(function(t){n.push({uid:t,example:e.examples[t]});}),n;},t.prototype.getData=function(t,e){var n=this;p.util.assert(this.size()>0,function(){return "Cannot get spectrograms as tensors because the dataset is empty";});var r=this.getVocabulary();null!=t?p.util.assert(-1!==r.indexOf(t),function(){return "Label "+t+" is not in the vocabulary ("+JSON.stringify(r)+")";}):p.util.assert(r.length>1,function(){return "One-hot encoding of labels requires the vocabulary to have at least two words, but it has only "+r.length+" word.";}),null==e&&(e={});var i,o,a=this.getSortedUniqueNumFrames();1===a.length?(i=null==e.numFrames?a[0]:e.numFrames,o=null==e.hopFrames?1:e.hopFrames):(i=e.numFrames,p.util.assert(null!=i&&Number.isInteger(i)&&i>0,function(){return "There are "+a.length+" unique lengths among the "+n.size()+" examples of this Dataset, hence numFrames is required. But it is not provided.";}),p.util.assert(i<=a[0],function(){return "numFrames ("+i+") exceeds the minimum numFrames ("+a[0]+") among the examples of the Dataset.";}),o=e.hopFrames,p.util.assert(null!=o&&Number.isInteger(o)&&o>0,function(){return "There are "+a.length+" unique lengths among the "+n.size()+" examples of this Dataset, hence hopFrames is required. But it is not provided.";}));var s=null==e.normalize||e.normalize;return Object(p.tidy)(function(){for(var a,u,c,l=[],f=[],h=[],d=0;d<r.length;++d){var m=r[d];if(null==t||m===t){var g=n.label2Ids[m],v=function v(r){var a,u,g=n.examples[r].spectrogram,v=g.frameSize;null==c?c=v:p.util.assert(v===c,function(){return "Mismatch in frameSize  ("+v+" vs "+c+")";});var y=g.data.length/v,b=null;"_background_noise_"!==m&&(b=null==g.keyFrameIndex?Pt(g).dataSync()[0]:g.keyFrameIndex);var x=Object(p.tensor3d)(g.data,[y,v,1]),w=Bt(y,b,i,o),k=function k(n){var r=Object(p.tidy)(function(){var t=x.slice([n[0],0,0],[n[1]-n[0],-1,-1]);return s?Et(t):t;});e.getDataset?f.push(r.dataSync()):l.push(r),null==t&&h.push(d);};try{for(var E=bt(w),C=E.next();!C.done;C=E.next()){k(C.value);}}catch(t){a={error:t};}finally{try{C&&!C.done&&(u=E.return)&&u.call(E);}finally{if(a)throw a.error;}}Object(p.dispose)(x);};try{for(var y=bt(g),b=y.next();!b.done;b=y.next()){v(b.value);}}catch(t){a={error:t};}finally{try{b&&!b.done&&(u=y.return)&&u.call(y);}finally{if(a)throw a.error;}}}}null!=e.augmentByMixingNoiseRatio&&n.augmentByMixingNoise(e.getDataset?f:l,h,e.augmentByMixingNoiseRatio);var x=null==e.shuffle||e.shuffle;if(e.getDataset){var w=null==e.datasetBatchSize?32:e.datasetBatchSize,k=null==e.datasetValidationSplit?.15:e.datasetValidationSplit;p.util.assert(k>0&&k<1,function(){return "Invalid dataset validation split: "+k;});var E=f.map(function(t,e){return [t,h[e]];});p.util.shuffle(E),f=E.map(function(t){return t[0];});var C=E.map(function(t){return t[1];}),A=function(t,e,n){var r,i,o,a,s,u,c,l;p.util.assert(n>0&&n<1,function(){return "validationSplit is expected to be >0 and <1, but got "+n;});for(var f=!Array.isArray(t[0]),h=e,d=[],m=0;m<h.length;++m){var g=h[m];null==d[g]&&(d[g]=[]),d[g].push(m);}var v=d.length,y=[],b=[];for(d.map(function(t){return p.util.shuffle(t);}),m=0;m<v;++m){for(var x=d[m],w=Math.round(x.length*(1-n)),k=0;k<x.length;++k){k<w?y.push(x[k]):b.push(x[k]);}}if(f){var E=[],C=[],A=[],O=[];try{for(var _=bt(y),S=_.next();!S.done;S=_.next()){var D=S.value;E.push(t[D]),C.push(e[D]);}}catch(t){r={error:t};}finally{try{S&&!S.done&&(i=_.return)&&i.call(_);}finally{if(r)throw r.error;}}try{for(var F=bt(b),T=F.next();!T.done;T=F.next()){D=T.value,A.push(t[D]),O.push(e[D]);}}catch(t){o={error:t};}finally{try{T&&!T.done&&(a=F.return)&&a.call(F);}finally{if(o)throw o.error;}}return {trainXs:E,trainYs:C,valXs:A,valYs:O};}E=[],C=[],A=[],O=[];try{for(var N=bt(y),I=N.next();!I.done;I=N.next()){D=I.value,E.push(t[D]),C.push(e[D]);}}catch(t){s={error:t};}finally{try{I&&!I.done&&(u=N.return)&&u.call(N);}finally{if(s)throw s.error;}}try{for(var R=bt(b),M=R.next();!M.done;M=R.next()){D=M.value,A.push(t[D]),O.push(e[D]);}}catch(t){c={error:t};}finally{try{M&&!M.done&&(l=R.return)&&l.call(R);}finally{if(c)throw c.error;}}return {trainXs:E,trainYs:C,valXs:A,valYs:O};}(f,C,k),O=A.trainXs,_=A.trainYs,S=A.valXs,D=A.valYs,F=p.data.array(O).map(function(t){return Object(p.tensor3d)(t,[i,c,1]);}),T=p.data.array(_).map(function(t){return Object(p.oneHot)([t],r.length).squeeze([0]);}),N=p.data.zip({xs:F,ys:T});x&&(N=N.shuffle(f.length)),N=N.batch(w).prefetch(4);var I=p.data.array(S).map(function(t){return Object(p.tensor3d)(t,[i,c,1]);}),R=p.data.array(D).map(function(t){return Object(p.oneHot)([t],r.length).squeeze([0]);}),M=p.data.zip({xs:I,ys:R});return [N,M=M.batch(w).prefetch(4)];}if(x){var j=[];l.forEach(function(t,e){j.push({x:t,y:h[e]});}),p.util.shuffle(j),l=j.map(function(t){return t.x;}),h=j.map(function(t){return t.y;});}var B=null==t?Object(p.oneHot)(Object(p.tensor1d)(h,"int32"),r.length).asType("float32"):void 0;return {xs:Object(p.stack)(l),ys:B};});},t.prototype.augmentByMixingNoise=function(t,e,n){var r,i;if(null==t||0===t.length)throw new Error("Cannot perform augmentation because data is null or empty");for(var o=t[0]instanceof Float32Array,a=this.getVocabulary(),s=[],u=[],c=0;c<e.length;++c){"_background_noise_"===a[e[c]]?s.push(c):u.push(c);}if(0===s.length)throw new Error("Cannot perform augmentation by mixing with noise when there is no example with label _background_noise_");var l=[],f=[],h=function h(r){var i=s[function(t,e){return Math.floor((e-t)*Math.random())+t;}(0,s.length)],a=o?Object(p.tensor1d)(t[r]):t[r],u=o?Object(p.tensor1d)(t[i]):t[i],c=Object(p.tidy)(function(){return Et(a.add(u.mul(n)));});o?l.push(c.dataSync()):l.push(c),f.push(e[r]);};try{for(var d=bt(u),m=d.next();!m.done;m=d.next()){h(m.value);}}catch(t){r={error:t};}finally{try{m&&!m.done&&(i=d.return)&&i.call(d);}finally{if(r)throw r.error;}}console.log("Data augmentation: mixing noise: added "+l.length+" examples"),l.forEach(function(e){return t.push(e);}),e.push.apply(e,wt(f));},t.prototype.getSortedUniqueNumFrames=function(){for(var t,e,n=new Set(),r=this.getVocabulary(),i=0;i<r.length;++i){var o=r[i],a=this.label2Ids[o];try{for(var s=bt(a),u=s.next();!u.done;u=s.next()){var c=u.value,l=this.examples[c].spectrogram,f=l.data.length/l.frameSize;n.add(f);}}catch(e){t={error:e};}finally{try{u&&!u.done&&(e=s.return)&&e.call(s);}finally{if(t)throw t.error;}}}var h=wt(n);return h.sort(),h;},t.prototype.removeExample=function(t){if(!(t in this.examples))throw new Error("Nonexistent example UID: "+t);var e=this.examples[t].label;delete this.examples[t];var n=this.label2Ids[e].indexOf(t);this.label2Ids[e].splice(n,1),0===this.label2Ids[e].length&&delete this.label2Ids[e];},t.prototype.setExampleKeyFrameIndex=function(t,e){if(!(t in this.examples))throw new Error("Nonexistent example UID: "+t);var n=this.examples[t].spectrogram,r=n.data.length/n.frameSize;p.util.assert(e>=0&&e<r&&Number.isInteger(e),function(){return "Invalid keyFrameIndex: "+e+". Must be >= 0, < "+r+", and an integer.";}),n.keyFrameIndex=e;},t.prototype.size=function(){return Object.keys(this.examples).length;},t.prototype.durationMillis=function(){var t=0;for(var e in this.examples){var n=this.examples[e].spectrogram,r=23.22|n.frameDurationMillis;t+=n.data.length/n.frameSize*r;}return t;},t.prototype.empty=function(){return 0===this.size();},t.prototype.clear=function(){this.examples={};},t.prototype.getVocabulary=function(){var t=new Set();for(var e in this.examples){var n=this.examples[e];t.add(n.label);}var r=wt(t);return r.sort(),r;},t.prototype.serialize=function(t){var e,n,r,i,o=this.getVocabulary();p.util.assert(!this.empty(),function(){return "Cannot serialize empty Dataset";}),null!=t&&(Array.isArray(t)||(t=[t]),t.forEach(function(t){if(-1===o.indexOf(t))throw new Error('Word label "'+t+'" does not exist in the vocabulary of this dataset. The vocabulary is: '+JSON.stringify(o)+".");}));var a=[],s=[];try{for(var u=bt(o),c=u.next();!c.done;c=u.next()){var l=c.value;if(null==t||-1!==t.indexOf(l)){var f=this.label2Ids[l];try{for(var h=bt(f),d=h.next();!d.done;d=h.next()){var m=d.value,g=Mt(this.examples[m]);a.push(g.spec),s.push(g.data);}}catch(t){r={error:t};}finally{try{d&&!d.done&&(i=h.return)&&i.call(h);}finally{if(r)throw r.error;}}}}}catch(t){e={error:t};}finally{try{c&&!c.done&&(n=u.return)&&n.call(u);}finally{if(e)throw e.error;}}return function(t){var e=Ft(JSON.stringify(t.manifest)),n=Ft(Nt),r=new Uint32Array([It]),i=new Uint32Array([e.byteLength]);return St([St([n,r.buffer,i.buffer]),e,t.data]);}({manifest:a,data:St(s)});},t;}();function Mt(t){var e=null!=t.rawAudio,n={label:t.label,spectrogramNumFrames:t.spectrogram.data.length/t.spectrogram.frameSize,spectrogramFrameSize:t.spectrogram.frameSize};null!=t.spectrogram.keyFrameIndex&&(n.spectrogramKeyFrameIndex=t.spectrogram.keyFrameIndex);var r=t.spectrogram.data.buffer.slice(0);return e&&(n.rawAudioNumSamples=t.rawAudio.data.length,n.rawAudioSampleRateHz=t.rawAudio.sampleRateHz,r=St([r,t.rawAudio.data.buffer])),{spec:n,data:r};}function jt(t){var e={frameSize:t.spec.spectrogramFrameSize,data:new Float32Array(t.data.slice(0,4*t.spec.spectrogramFrameSize*t.spec.spectrogramNumFrames))};null!=t.spec.spectrogramKeyFrameIndex&&(e.keyFrameIndex=t.spec.spectrogramKeyFrameIndex);var n={label:t.spec.label,spectrogram:e};return null!=t.spec.rawAudioNumSamples&&(n.rawAudio={sampleRateHz:t.spec.rawAudioSampleRateHz,data:new Float32Array(t.data.slice(4*t.spec.spectrogramFrameSize*t.spec.spectrogramNumFrames))}),n;}function Bt(t,e,n,r){if(p.util.assert(Number.isInteger(t)&&t>0,function(){return "snippetLength must be a positive integer, but got "+t;}),null!=e&&p.util.assert(Number.isInteger(e)&&e>=0,function(){return "focusIndex must be a non-negative integer, but got "+e;}),p.util.assert(Number.isInteger(n)&&n>0,function(){return "windowLength must be a positive integer, but got "+n;}),p.util.assert(Number.isInteger(r)&&r>0,function(){return "windowHop must be a positive integer, but got "+r;}),p.util.assert(n<=t,function(){return "windowLength ("+n+") exceeds snippetLength ("+t+")";}),p.util.assert(e<t,function(){return "focusIndex ("+e+") equals or exceeds snippetLength ("+t+")";}),n===t)return [[0,t]];var i=[];if(null==e){for(var o=0;o+n<=t;){i.push([o,o+n]),o+=r;}return i;}var a=Math.floor(n/2),s=e-a;for(s<0?s=0:s+n>t&&(s=t-n);!(s-r<0||e>=s-r+n);){s-=r;}for(;s+n<=t&&!(e<s);){i.push([s,s+n]),s+=r;}return i;}function Pt(t){return Object(p.tidy)(function(){return function(t){return Object(p.tidy)(function(){var e=t.data.length/t.frameSize;return Object(p.tensor2d)(t.data,[e,t.frameSize]).mean(-1);});}(t).argMax();});}var Lt="0.3.9",zt="tfjs-speech-commands-saved-model-metadata",Ut="indexeddb://tfjs-speech-commands-model/",Wt={localStorage:"undefined"==typeof window?null:window.localStorage};var Vt=function(){function t(e,n,r){this.MODEL_URL_PREFIX="https://storage.googleapis.com/tfjs-models/tfjs/speech-commands/v"+function(t){return t.split(".").slice(0,2).join(".");}(Lt)+"/browser_fft",this.SAMPLE_RATE_HZ=44100,this.FFT_SIZE=1024,this.DEFAULT_SUPPRESSION_TIME_MILLIS=0,this.streaming=!1,this.transferRecognizers={},p.util.assert(null==n&&null==r||null!=n&&null!=r,function(){return "modelURL and metadataURL must be both provided or both not provided.";}),null==n?(null==e?e=t.DEFAULT_VOCABULARY_NAME:p.util.assert(-1!==t.VALID_VOCABULARY_NAMES.indexOf(e),function(){return "Invalid vocabulary name: '"+e+"'";}),this.vocabulary=e,this.modelArtifactsOrURL=this.MODEL_URL_PREFIX+"/"+this.vocabulary+"/model.json",this.metadataOrURL=this.MODEL_URL_PREFIX+"/"+this.vocabulary+"/metadata.json"):(p.util.assert(null==e,function(){return "vocabulary name must be null or undefined when modelURL is provided";}),this.modelArtifactsOrURL=n,this.metadataOrURL=r),this.parameters={sampleRateHz:this.SAMPLE_RATE_HZ,fftSize:this.FFT_SIZE};}return t.prototype.listen=function(t,e){return vt(this,void 0,void 0,function(){var n,r,i,o,a,s=this;return yt(this,function(u){switch(u.label){case 0:if(this.streaming)throw new Error("Cannot start streaming again when streaming is ongoing.");return [4,this.ensureModelLoaded()];case 1:if(u.sent(),null==e&&(e={}),n=null==e.probabilityThreshold?0:e.probabilityThreshold,e.includeEmbedding&&(n=0),p.util.assert(n>=0&&n<=1,function(){return "Invalid probabilityThreshold value: "+n;}),r=null!=e.invokeCallbackOnNoiseAndUnknown&&e.invokeCallbackOnNoiseAndUnknown,e.includeEmbedding&&(r=!0),e.suppressionTimeMillis<0)throw new Error("suppressionTimeMillis is expected to be >= 0, but got "+e.suppressionTimeMillis);return i=null==e.overlapFactor?.5:e.overlapFactor,p.util.assert(i>=0&&i<1,function(){return "Expected overlapFactor to be >= 0 and < 1, but got "+i;}),o=function o(i,_o98){return vt(s,void 0,void 0,function(){var o,a,s,u,c,l,f,h,d,m,g;return yt(this,function(v){switch(v.label){case 0:return a=Et(i),e.includeEmbedding?[4,this.ensureModelWithEmbeddingOutputCreated()]:[3,2];case 1:return v.sent(),o=xt(this.modelWithEmbeddingOutput.predict(a),2),s=o[0],u=o[1],[3,3];case 2:s=this.model.predict(a),v.label=3;case 3:return [4,s.data()];case 4:return c=v.sent(),[4,(l=s.argMax(-1)).data()];case 5:return f=v.sent()[0],h=Math.max.apply(Math,wt(c)),Object(p.dispose)([s,l,a]),h<n?[2,!1]:[3,6];case 6:return d=void 0,e.includeSpectrogram?(m={},[4,i.data()]):[3,8];case 7:m.data=v.sent(),m.frameSize=this.nonBatchInputShape[1],d=m,v.label=8;case 8:return g=!0,r||"_background_noise_"!==this.words[f]&&"_unknown_"!==this.words[f]||(g=!1),g&&t({scores:c,spectrogram:d,embedding:u}),[2,g];}});});},a=null==e.suppressionTimeMillis?this.DEFAULT_SUPPRESSION_TIME_MILLIS:e.suppressionTimeMillis,this.audioDataExtractor=new Ct({sampleRateHz:this.parameters.sampleRateHz,numFramesPerSpectrogram:this.nonBatchInputShape[0],columnTruncateLength:this.nonBatchInputShape[1],suppressionTimeMillis:a,spectrogramCallback:o,overlapFactor:i}),[4,this.audioDataExtractor.start(e.audioTrackConstraints)];case 2:return u.sent(),this.streaming=!0,[2];}});});},t.prototype.ensureModelLoaded=function(){return vt(this,void 0,void 0,function(){var t,e,n,r,i=this;return yt(this,function(o){switch(o.label){case 0:return null!=this.model?[2]:[4,this.ensureMetadataLoaded()];case 1:return o.sent(),"string"!=typeof this.modelArtifactsOrURL?[3,3]:[4,Object(p.loadLayersModel)(this.modelArtifactsOrURL)];case 2:return t=o.sent(),[3,5];case 3:return [4,Object(p.loadLayersModel)(p.io.fromMemory(this.modelArtifactsOrURL.modelTopology,this.modelArtifactsOrURL.weightSpecs,this.modelArtifactsOrURL.weightData))];case 4:t=o.sent(),o.label=5;case 5:if(1!==t.inputs.length)throw new Error("Expected model to have 1 input, but got a model with "+t.inputs.length+" inputs");if(4!==t.inputs[0].shape.length)throw new Error("Expected model to have an input shape of rank 4, but got an input shape of rank "+t.inputs[0].shape.length);if(1!==t.inputs[0].shape[3])throw new Error("Expected model to have an input shape with 1 as the last dimension, but got input shape"+JSON.stringify(t.inputs[0].shape[3])+"}");if(2!==(e=t.outputShape).length)throw new Error("Expected loaded model to have an output shape of rank 2,but received shape "+JSON.stringify(e));if(e[1]!==this.words.length)throw new Error("Mismatch between the last dimension of model's output shape ("+e[1]+") and number of words ("+this.words.length+").");return this.model=t,this.freezeModel(),this.nonBatchInputShape=t.inputs[0].shape.slice(1),this.elementsPerExample=1,t.inputs[0].shape.slice(1).forEach(function(t){return i.elementsPerExample*=t;}),this.warmUpModel(),n=this.parameters.fftSize/this.parameters.sampleRateHz*1e3,r=t.inputs[0].shape[1],this.parameters.spectrogramDurationMillis=r*n,[2];}});});},t.prototype.ensureModelWithEmbeddingOutputCreated=function(){return vt(this,void 0,void 0,function(){var t,e;return yt(this,function(n){switch(n.label){case 0:return null!=this.modelWithEmbeddingOutput?[2]:[4,this.ensureModelLoaded()];case 1:for(n.sent(),e=this.model.layers.length-2;e>=0;--e){if("Dense"===this.model.layers[e].getClassName()){t=this.model.layers[e];break;}}if(null==t)throw new Error("Failed to find second last dense layer in the original model.");return this.modelWithEmbeddingOutput=Object(p.model)({inputs:this.model.inputs,outputs:[this.model.outputs[0],t.output]}),[2];}});});},t.prototype.warmUpModel=function(){var t=this;Object(p.tidy)(function(){for(var e=Object(p.zeros)([1].concat(t.nonBatchInputShape)),n=0;n<3;++n){t.model.predict(e);}});},t.prototype.ensureMetadataLoaded=function(){return vt(this,void 0,void 0,function(){var t,e,r;return yt(this,function(i){switch(i.label){case 0:return null!=this.words?[2]:"string"!=typeof this.metadataOrURL?[3,2]:[4,function(t){return vt(this,void 0,void 0,function(){return yt(this,function(e){return [2,new Promise(function(e,r){0===t.indexOf("http://")||0===t.indexOf("https://")?fetch(t).then(function(t){t.json().then(function(t){return e(t);});}):0===t.indexOf("file://")?n(185).readFile(t.slice("file://".length),{encoding:"utf-8"},function(t,n){return e(JSON.parse(n));}):r(new Error("Unsupported URL scheme in metadata URL: "+t+". Supported schemes are: http://, https://, and (node.js-only) file://"));})];});});}(this.metadataOrURL)];case 1:return e=i.sent(),[3,3];case 2:e=this.metadataOrURL,i.label=3;case 3:if(null==(t=e).wordLabels){if(null==(r=t.words))throw new Error('Cannot find field "words" or "wordLabels" in metadata JSON file');this.words=r;}else this.words=t.wordLabels;return [2];}});});},t.prototype.stopListening=function(){return vt(this,void 0,void 0,function(){return yt(this,function(t){switch(t.label){case 0:if(!this.streaming)throw new Error("Cannot stop streaming when streaming is not ongoing.");return [4,this.audioDataExtractor.stop()];case 1:return t.sent(),this.streaming=!1,[2];}});});},t.prototype.isListening=function(){return this.streaming;},t.prototype.wordLabels=function(){return this.words;},t.prototype.params=function(){return this.parameters;},t.prototype.modelInputShape=function(){if(null==this.model)throw new Error("Model has not been loaded yet. Load model by calling ensureModelLoaded(), recognize(), or listen().");return this.model.inputs[0].shape;},t.prototype.recognize=function(t,e){return vt(this,void 0,void 0,function(){var n,r,i,o,a,s,u,c,l,f,h,d,m;return yt(this,function(g){switch(g.label){case 0:return null==e&&(e={}),[4,this.ensureModelLoaded()];case 1:return g.sent(),null!=t?[3,3]:[4,this.recognizeOnline()];case 2:n=g.sent(),t=n.data,g.label=3;case 3:if(t instanceof p.Tensor)this.checkInputTensorShape(t),i=t,r=t.shape[0];else {if((t=t).length%this.elementsPerExample)throw new Error("The length of the input Float32Array "+t.length+" is not divisible by the number of tensor elements per per example expected by the model "+this.elementsPerExample+".");r=t.length/this.elementsPerExample,i=Object(p.tensor4d)(t,[r].concat(this.nonBatchInputShape));}return a={scores:null},e.includeEmbedding?[4,this.ensureModelWithEmbeddingOutputCreated()]:[3,5];case 4:return g.sent(),s=this.modelWithEmbeddingOutput.predict(i),o=s[0],a.embedding=s[1],[3,6];case 5:o=this.model.predict(i),g.label=6;case 6:return 1!==r?[3,8]:(u=a,[4,o.data()]);case 7:return u.scores=g.sent(),[3,10];case 8:return c=Object(p.unstack)(o),l=c.map(function(t){return t.data();}),f=a,[4,Promise.all(l)];case 9:f.scores=g.sent(),Object(p.dispose)(c),g.label=10;case 10:return e.includeSpectrogram?(h=a,d={},t instanceof p.Tensor?[4,t.data()]:[3,12]):[3,14];case 11:return m=g.sent(),[3,13];case 12:m=t,g.label=13;case 13:h.spectrogram=(d.data=m,d.frameSize=this.nonBatchInputShape[1],d),g.label=14;case 14:return [2,a];}});});},t.prototype.recognizeOnline=function(){return vt(this,void 0,void 0,function(){var t=this;return yt(this,function(e){return [2,new Promise(function(e,n){t.audioDataExtractor=new Ct({sampleRateHz:t.parameters.sampleRateHz,numFramesPerSpectrogram:t.nonBatchInputShape[0],columnTruncateLength:t.nonBatchInputShape[1],suppressionTimeMillis:0,spectrogramCallback:function spectrogramCallback(n){return vt(t,void 0,void 0,function(){var t,r,i;return yt(this,function(o){switch(o.label){case 0:return t=Et(n),[4,this.audioDataExtractor.stop()];case 1:return o.sent(),r=e,i={},[4,t.data()];case 2:return r.apply(void 0,[(i.data=o.sent(),i.frameSize=this.nonBatchInputShape[1],i)]),t.dispose(),[2,!1];}});});},overlapFactor:0}),t.audioDataExtractor.start();})];});});},t.prototype.createTransfer=function(t){if(null==this.model)throw new Error("Model has not been loaded yet. Load model by calling ensureModelLoaded(), recognizer(), or listen().");p.util.assert(null!=t&&"string"==typeof t&&t.length>1,function(){return "Expected the name for a transfer-learning recognized to be a non-empty string, but got "+JSON.stringify(t);}),p.util.assert(null==this.transferRecognizers[t],function(){return "There is already a transfer-learning model named '"+t+"'";});var e=new qt(t,this.parameters,this.model);return this.transferRecognizers[t]=e,e;},t.prototype.freezeModel=function(){var t,e;try{for(var n=bt(this.model.layers),r=n.next();!r.done;r=n.next()){r.value.trainable=!1;}}catch(e){t={error:e};}finally{try{r&&!r.done&&(e=n.return)&&e.call(n);}finally{if(t)throw t.error;}}},t.prototype.checkInputTensorShape=function(t){var e=this.model.inputs[0].shape.length;if(t.shape.length!==e)throw new Error("Expected input Tensor to have rank "+e+", but got rank "+t.shape.length+" that differs ");var n=t.shape.slice(1),r=this.model.inputs[0].shape.slice(1);if(!p.util.arraysEqual(n,r))throw new Error("Expected input to have shape [null,"+r+"], but got shape [null,"+n+"]");},t.VALID_VOCABULARY_NAMES=["18w","directional4w"],t.DEFAULT_VOCABULARY_NAME="18w",t;}(),qt=function(t){function e(e,n,r){var i=t.call(this)||this;return i.name=e,i.parameters=n,i.baseModel=r,p.util.assert(null!=e&&"string"==typeof e&&e.length>0,function(){return "The name of a transfer model must be a non-empty string, but got "+JSON.stringify(e);}),i.nonBatchInputShape=i.baseModel.inputs[0].shape.slice(1),i.words=null,i.dataset=new Rt(),i;}return function(t,e){function n(){this.constructor=t;}_mt(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n());}(e,t),e.prototype.collectExample=function(t,e){return vt(this,void 0,void 0,function(){var n,r,i,o,a=this;return yt(this,function(s){if(p.util.assert(!this.streaming,function(){return "Cannot start collection of transfer-learning example because a streaming recognition or transfer-learning example collection is ongoing";}),p.util.assert(null!=t&&"string"==typeof t&&t.length>0,function(){return "Must provide a non-empty string when collecting transfer-learning example";}),null==e&&(e={}),null!=e.durationMultiplier&&null!=e.durationSec)throw new Error("durationMultiplier and durationSec are mutually exclusive, but are both specified.");return null!=e.durationSec?(p.util.assert(e.durationSec>0,function(){return "Expected durationSec to be > 0, but got "+e.durationSec;}),r=this.parameters.fftSize/this.parameters.sampleRateHz,n=Math.ceil(e.durationSec/r)):null!=e.durationMultiplier?(p.util.assert(e.durationMultiplier>=1,function(){return "Expected duration multiplier to be >= 1, but got "+e.durationMultiplier;}),n=Math.round(this.nonBatchInputShape[0]*e.durationMultiplier)):n=this.nonBatchInputShape[0],null!=e.snippetDurationSec&&(p.util.assert(e.snippetDurationSec>0,function(){return "snippetDurationSec is expected to be > 0, but got "+e.snippetDurationSec;}),p.util.assert(null!=e.onSnippet,function(){return "onSnippet must be provided if snippetDurationSec is provided.";})),null!=e.onSnippet&&p.util.assert(null!=e.snippetDurationSec,function(){return "snippetDurationSec must be provided if onSnippet is provided.";}),i=this.parameters.fftSize/this.parameters.sampleRateHz,o=i*n,this.streaming=!0,[2,new Promise(function(r){var i=null==e.snippetDurationSec?1:e.snippetDurationSec/o,s=1-i,u=Math.round(1/i),c=0,l=-1,f=[];a.audioDataExtractor=new Ct({sampleRateHz:a.parameters.sampleRateHz,numFramesPerSpectrogram:n,columnTruncateLength:a.nonBatchInputShape[1],suppressionTimeMillis:0,spectrogramCallback:function spectrogramCallback(n,i){return vt(a,void 0,void 0,function(){var o,a,s,h,d,m,g,v,y,b,x,w,k,E,C,A,O,_,S,D;return yt(this,function(F){switch(F.label){case 0:return null!=e.onSnippet?[3,7]:(o=Et(n),s=(a=this.dataset).addExample,h={label:t},d={},[4,o.data()]);case 1:return h.spectrogram=(d.data=F.sent(),d.frameSize=this.nonBatchInputShape[1],d),e.includeRawAudio?(g={},[4,i.data()]):[3,3];case 2:return g.data=F.sent(),g.sampleRateHz=this.audioDataExtractor.sampleRateHz,m=g,[3,4];case 3:m=void 0,F.label=4;case 4:return s.apply(a,[(h.rawAudio=m,h)]),o.dispose(),[4,this.audioDataExtractor.stop()];case 5:return F.sent(),this.streaming=!1,this.collateTransferWords(),v=r,y={},[4,n.data()];case 6:return v.apply(void 0,[(y.data=F.sent(),y.frameSize=this.nonBatchInputShape[1],y)]),[3,13];case 7:return [4,n.data()];case 8:for(b=F.sent(),-1===l&&(l=b.length),x=l-1;0!==b[x]&&x>=0;){x--;}return w=l-x-1,l=x+1,k=b.slice(b.length-w,b.length),f.push(k),null!=e.onSnippet&&e.onSnippet({data:k,frameSize:this.nonBatchInputShape[1]}),c++!==u?[3,13]:[4,this.audioDataExtractor.stop()];case 9:return F.sent(),this.streaming=!1,this.collateTransferWords(),E=function(t){if(t.length<2)throw new Error("Cannot normalize a Float32Array with fewer than 2 elements.");return null==kt&&(kt=Object(p.backend)().epsilon()),Object(p.tidy)(function(){var e=Object(p.moments)(Object(p.tensor1d)(t)),n=e.mean,r=e.variance,i=n.arraySync(),o=Math.sqrt(r.arraySync()),a=Array.from(t).map(function(t){return (t-i)/(o+kt);});return new Float32Array(a);});}(Dt(f)),C={data:E,frameSize:this.nonBatchInputShape[1]},O=(A=this.dataset).addExample,_={label:t,spectrogram:C},e.includeRawAudio?(D={},[4,i.data()]):[3,11];case 10:return D.data=F.sent(),D.sampleRateHz=this.audioDataExtractor.sampleRateHz,S=D,[3,12];case 11:S=void 0,F.label=12;case 12:O.apply(A,[(_.rawAudio=S,_)]),r(C),F.label=13;case 13:return [2,!1];}});});},overlapFactor:s,includeRawAudio:e.includeRawAudio}),a.audioDataExtractor.start(e.audioTrackConstraints);})];});});},e.prototype.clearExamples=function(){var t=this;p.util.assert(null!=this.words&&this.words.length>0&&!this.dataset.empty(),function(){return "No transfer learning examples exist for model name "+t.name;}),this.dataset.clear(),this.words=null;},e.prototype.countExamples=function(){if(this.dataset.empty())throw new Error("No examples have been collected for transfer-learning model named '"+this.name+"' yet.");return this.dataset.getExampleCounts();},e.prototype.getExamples=function(t){return this.dataset.getExamples(t);},e.prototype.setExampleKeyFrameIndex=function(t,e){this.dataset.setExampleKeyFrameIndex(t,e);},e.prototype.removeExample=function(t){this.dataset.removeExample(t),this.collateTransferWords();},e.prototype.isDatasetEmpty=function(){return this.dataset.empty();},e.prototype.loadExamples=function(t,e){var n,r,i,o;void 0===e&&(e=!1);var a=new Rt(t);e&&this.clearExamples();var s=a.getVocabulary();try{for(var u=bt(s),c=u.next();!c.done;c=u.next()){var l=c.value,f=a.getExamples(l);try{for(var h=bt(f),d=h.next();!d.done;d=h.next()){var p=d.value;this.dataset.addExample(p.example);}}catch(t){i={error:t};}finally{try{d&&!d.done&&(o=h.return)&&o.call(h);}finally{if(i)throw i.error;}}}}catch(t){n={error:t};}finally{try{c&&!c.done&&(r=u.return)&&r.call(u);}finally{if(n)throw n.error;}}this.collateTransferWords();},e.prototype.serializeExamples=function(t){return this.dataset.serialize(t);},e.prototype.collateTransferWords=function(){this.words=this.dataset.getVocabulary();},e.prototype.collectTransferDataAsTensors=function(t,e){var n=this.nonBatchInputShape[0];t=t||.25;var r=Math.round(t*n),i=this.dataset.getData(null,_gt({numFrames:n,hopFrames:r},e));return {xs:i.xs,ys:i.ys};},e.prototype.collectTransferDataAsTfDataset=function(t,e,n,r){void 0===e&&(e=.15),void 0===n&&(n=32);var i=this.nonBatchInputShape[0];t=t||.25;var o=Math.round(t*i);return this.dataset.getData(null,_gt({numFrames:i,hopFrames:o,getDataset:!0,datasetBatchSize:n,datasetValidationSplit:e},r));},e.prototype.train=function(t){return vt(this,void 0,void 0,function(){var e,n=this;return yt(this,function(r){switch(r.label){case 0:return p.util.assert(null!=this.words&&this.words.length>0,function(){return "Cannot train transfer-learning model '"+n.name+"' because no transfer learning example has been collected.";}),p.util.assert(this.words.length>1,function(){return "Cannot train transfer-learning model '"+n.name+"' because only 1 word label ('"+JSON.stringify(n.words)+"') has been collected for transfer learning. Requires at least 2.";}),null!=t.fineTuningEpochs&&p.util.assert(t.fineTuningEpochs>=0&&Number.isInteger(t.fineTuningEpochs),function(){return "If specified, fineTuningEpochs must be a non-negative integer, but received "+t.fineTuningEpochs;}),null==t&&(t={}),null==this.model&&this.createTransferModelFromBaseModel(),this.secondLastBaseDenseLayer.trainable=!1,this.model.compile({loss:"categoricalCrossentropy",optimizer:t.optimizer||"sgd",metrics:["acc"]}),e=null==t.fitDatasetDurationMillisThreshold?6e4:t.fitDatasetDurationMillisThreshold,this.dataset.durationMillis()>e?(console.log("Detected large dataset: total duration = "+this.dataset.durationMillis()+" ms > "+e+" ms. Training transfer model using fitDataset() instead of fit()"),[4,this.trainOnDataset(t)]):[3,2];case 1:return [2,r.sent()];case 2:return [4,this.trainOnTensors(t)];case 3:return [2,r.sent()];}});});},e.prototype.trainOnDataset=function(t){return vt(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,c;return yt(this,function(l){switch(l.label){case 0:return p.util.assert(t.epochs>0,function(){return "Invalid config.epochs";}),e=null==t.batchSize?32:t.batchSize,n=t.windowHopRatio||.25,r=xt(this.collectTransferDataAsTfDataset(n,t.validationSplit,e,{augmentByMixingNoiseRatio:t.augmentByMixingNoiseRatio}),2),i=r[0],o=r[1],a=p.util.now(),[4,this.model.fitDataset(i,{epochs:t.epochs,validationData:t.validationSplit>0?o:null,callbacks:null==t.callback?null:[t.callback]})];case 1:return s=l.sent(),console.log("fitDataset() took "+(p.util.now()-a).toFixed(2)+" ms"),null!=t.fineTuningEpochs&&t.fineTuningEpochs>0?(u=p.util.now(),[4,this.fineTuningUsingTfDatasets(t,i,o)]):[3,3];case 2:return c=l.sent(),console.log("fitDataset() (fine-tuning) took "+(p.util.now()-u).toFixed(2)+" ms"),[2,[s,c]];case 3:return [2,s];}});});},e.prototype.trainOnTensors=function(t){return vt(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,c,l;return yt(this,function(f){switch(f.label){case 0:e=t.windowHopRatio||.25,n=this.collectTransferDataAsTensors(e,{augmentByMixingNoiseRatio:t.augmentByMixingNoiseRatio}),r=n.xs,i=n.ys,console.log("Training data: xs.shape = "+r.shape+", ys.shape = "+i.shape),f.label=1;case 1:return f.trys.push([1,,6,7]),null!=t.validationSplit?(u=function(t,e,n){return p.util.assert(n>0&&n<1,function(){return "validationSplit is expected to be >0 and <1, but got "+n;}),Object(p.tidy)(function(){for(var r=e.argMax(-1).dataSync(),i=[],o=0;o<r.length;++o){var a=r[o];null==i[a]&&(i[a]=[]),i[a].push(o);}var s=i.length,u=[],c=[];for(i.map(function(t){return p.util.shuffle(t);}),o=0;o<s;++o){for(var l=i[o],f=Math.round(l.length*(1-n)),h=0;h<l.length;++h){h<f?u.push(l[h]):c.push(l[h]);}}return {trainXs:Object(p.gather)(t,u),trainYs:Object(p.gather)(e,u),valXs:Object(p.gather)(t,c),valYs:Object(p.gather)(e,c)};});}(r,i,t.validationSplit),o=u.trainXs,a=u.trainYs,s=[u.valXs,u.valYs]):(o=r,a=i),[4,this.model.fit(o,a,{epochs:null==t.epochs?20:t.epochs,validationData:s,batchSize:t.batchSize,callbacks:null==t.callback?null:[t.callback]})];case 2:return c=f.sent(),null!=t.fineTuningEpochs&&t.fineTuningEpochs>0?[4,this.fineTuningUsingTensors(t,o,a,s)]:[3,4];case 3:return l=f.sent(),[2,[c,l]];case 4:return [2,c];case 5:return [3,7];case 6:return Object(p.dispose)([r,i,o,a,s]),[7];case 7:return [2];}});});},e.prototype.fineTuningUsingTfDatasets=function(t,e,n){return vt(this,void 0,void 0,function(){var r,i,o;return yt(this,function(a){switch(a.label){case 0:return r=this.secondLastBaseDenseLayer.trainable,this.secondLastBaseDenseLayer.trainable=!0,i=null==t.fineTuningOptimizer?"sgd":t.fineTuningOptimizer,this.model.compile({loss:"categoricalCrossentropy",optimizer:i,metrics:["acc"]}),[4,this.model.fitDataset(e,{epochs:t.fineTuningEpochs,validationData:n,callbacks:null==t.callback?null:[t.callback]})];case 1:return o=a.sent(),this.secondLastBaseDenseLayer.trainable=r,[2,o];}});});},e.prototype.fineTuningUsingTensors=function(t,e,n,r){return vt(this,void 0,void 0,function(){var i,o,a;return yt(this,function(s){switch(s.label){case 0:return i=this.secondLastBaseDenseLayer.trainable,this.secondLastBaseDenseLayer.trainable=!0,o=null==t.fineTuningOptimizer?"sgd":t.fineTuningOptimizer,this.model.compile({loss:"categoricalCrossentropy",optimizer:o,metrics:["acc"]}),[4,this.model.fit(e,n,{epochs:t.fineTuningEpochs,validationData:r,batchSize:t.batchSize,callbacks:null==t.fineTuningCallback?null:[t.fineTuningCallback]})];case 1:return a=s.sent(),this.secondLastBaseDenseLayer.trainable=i,[2,a];}});});},e.prototype.evaluate=function(t){return vt(this,void 0,void 0,function(){var e,n=this;return yt(this,function(r){return p.util.assert(null!=t.wordProbThresholds&&t.wordProbThresholds.length>0,function(){return "Received null or empty wordProbThresholds";}),e=0,p.util.assert("_background_noise_"===this.words[e],function(){return "Cannot perform evaluation when the first tag is not _background_noise_";}),[2,Object(p.tidy)(function(){for(var r=[],i=0,o=n.collectTransferDataAsTensors(t.windowHopRatio),a=o.xs,s=o.ys.argMax(-1).dataSync(),u=n.model.predict(a),c=u.slice([0,1],[u.shape[0],u.shape[1]-1]).max(-1),l=u.shape[0],f=0;f<t.wordProbThresholds.length;++f){for(var h=t.wordProbThresholds[f],d=c.greater(Object(p.scalar)(h)).dataSync(),m=0,g=0,v=0,y=0,b=0;b<l;++b){s[b]===e?(m++,d[b]&&v++):(g++,d[b]&&y++);}var x=v/m,w=y/g;r.push({probThreshold:h,fpr:x,tpr:w}),console.log("ROC thresh="+h+": fpr="+x.toFixed(4)+", tpr="+w.toFixed(4)),f>0&&(i+=Math.abs(r[f-1].fpr-r[f].fpr)*(r[f-1].tpr+r[f].tpr)/2);}return {rocCurve:r,auc:i};})];});});},e.prototype.createTransferModelFromBaseModel=function(){var t=this;p.util.assert(null!=this.words,function(){return "No word example is available for tranfer-learning model of name "+t.name;});for(var e=this.baseModel.layers,n=e.length-2;n>=0&&"dense"!==e[n].getClassName().toLowerCase();){n--;}if(n<0)throw new Error("Cannot find a hidden dense layer in the base model.");this.secondLastBaseDenseLayer=e[n];var r=this.secondLastBaseDenseLayer.output;this.transferHead=Object(p.sequential)(),this.transferHead.add(p.layers.dense({units:this.words.length,activation:"softmax",inputShape:r.shape.slice(1),name:"NewHeadDense"}));var i=this.transferHead.apply(r);this.model=Object(p.model)({inputs:this.baseModel.inputs,outputs:i});},e.prototype.modelInputShape=function(){return this.baseModel.inputs[0].shape;},e.prototype.getMetadata=function(){return {tfjsSpeechCommandsVersion:Lt,modelName:this.name,timeStamp:new Date().toISOString(),wordLabels:this.wordLabels()};},e.prototype.save=function(t){return vt(this,void 0,void 0,function(){var e,n,r;return yt(this,function(i){return e=null!=t,t=t||$t(this.name),e||(n=Wt.localStorage.getItem(zt),(r=null==n?{}:JSON.parse(n))[this.name]=this.getMetadata(),Wt.localStorage.setItem(zt,JSON.stringify(r))),console.log("Saving model to "+t),[2,this.model.save(t)];});});},e.prototype.load=function(t){return vt(this,void 0,void 0,function(){var e,n,r;return yt(this,function(i){switch(i.label){case 0:if(e=null!=t,t=t||$t(this.name),!e){if(null==(n=JSON.parse(Wt.localStorage.getItem(zt)))||null==n[this.name])throw new Error("Cannot find metadata for transfer model named "+this.name+'"');this.words=n[this.name].wordLabels,console.log("Loaded word list for model named "+this.name+": "+this.words);}return r=this,[4,Object(p.loadLayersModel)(t)];case 1:return r.model=i.sent(),console.log("Loaded model from "+t+":"),this.model.summary(),[2];}});});},e.prototype.createTransfer=function(t){throw new Error("Creating transfer-learned recognizer from a transfer-learned recognizer is not supported.");},e;}(Vt);function $t(t){return ""+Ut+t;}function Ht(t,e,n,r){if(p.util.assert(null==n&&null==r||null!=n&&null!=r,function(){return "customModelURL and customMetadataURL must be both provided or both not provided.";}),null!=n&&p.util.assert(null==e,function(){return "vocabulary name must be null or undefined when modelURL is provided.";}),"BROWSER_FFT"===t)return new Vt(e,n,r);throw "SOFT_FFT"===t?new Error("SOFT_FFT SpeechCommandRecognizer has not been implemented yet."):new Error("Invalid fftType: '"+t+"'");}var Gt=function(){function t(e){b()(this,t),this.options=e;}return w()(t,[{key:"load",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return e?(n=e.split("/"),r=n.slice(0,n.length-1).join("/"),i="".concat(r,"/metadata.json"),this.model=Ht("BROWSER_FFT",void 0,e,i)):this.model=Ht("BROWSER_FFT"),t.next=3,this.model.ensureModelLoaded();case 3:this.allLabels=this.model.wordLabels();case 4:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"classify",value:function value(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.allLabels.length,n=arguments.length>1?arguments[1]:void 0;return this.model.listen(function(r){if(r.scores){var i=z(r.scores,e,t.allLabels).map(function(t){return {label:t.className,confidence:t.probability};});return n(null,i);}return n("ERROR: Cannot find scores in result: ".concat(r));},this.options).catch(function(t){return n("ERROR: ".concat(t.message));});}}]),t;}();function Kt(t,e){return Xt.apply(this,arguments);}function Xt(){return (Xt=v()(E.a.mark(function t(e,n){var r;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return r=new Gt(e),t.next=3,r.load(n);case 3:return t.abrupt("return",r);case 4:case"end":return t.stop();}}},t);}))).apply(this,arguments);}var Yt=["speechcommands18w"],Jt=function(){function t(e,n,r){if(b()(this,t),this.model=null,this.options=n,"string"==typeof e)if(Yt.includes(e))switch(this.modelName=e,this.modelUrl=null,this.modelName){case"speechcommands18w":this.modelToUse=s;break;default:this.modelToUse=null;}else this.modelToUse=s,this.modelUrl=e;this.ready=C(this.loadModel(n,this.modelUrl),r);}return w()(t,[{key:"loadModel",value:function(){var t=v()(E.a.mark(function t(e){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.modelToUse.load(e,this.modelUrl);case 2:return this.model=t.sent,t.abrupt("return",this);case 4:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"classifyInternal",value:function(){var t=v()(E.a.mark(function t(e,n){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.ready;case 2:return t.next=4,p.nextFrame();case 4:return t.abrupt("return",this.model.classify(e,n));case 5:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"classify",value:function(){var t=v()(E.a.mark(function t(){var e,n,r,i,o=arguments;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return e=o.length>0&&void 0!==o[0]?o[0]:null,n=o.length>1?o[1]:void 0,r=this.topk,"number"==typeof e?r=e:"function"==typeof e&&(i=e),"function"==typeof n&&(i=n),t.abrupt("return",this.classifyInternal(r,i));case 6:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()}]),t;}(),Qt=function Qt(t,e,n){var r={},i=n,o=t;if("string"!=typeof o)throw new Error('Please specify a model to use. E.g: "SpeechCommands18w"');-1===o.indexOf("http")&&(o=t.toLowerCase()),"object"===S()(e)?r=e:"function"==typeof e&&(i=e);var a=new Jt(o,r,i);return i?a:a.ready;};function Zt(t,e){return null==t&&null==e?null:null==t?e.clone():null===e?t.clone():t.concat(e,0);}function te(t,e){for(var n=[],r=0;r<t.length;r++){n.push({value:t[r],index:r});}n.sort(function(t,e){return e.value-t.value;});var i=new Float32Array(e),o=new Int32Array(e);for(r=0;r<e;r++){i[r]=n[r].value,o[r]=n[r].index;}return {values:i,indices:o};}var ee=function(){function t(){this.classDatasetMatrices={},this.classExampleCount={},this.labelToClassId={},this.nextClassId=0;}return t.prototype.addExample=function(t,e){var n=this;if(null==this.exampleShape&&(this.exampleShape=t.shape),!N.util.arraysEqual(this.exampleShape,t.shape))throw new Error("Example shape provided, "+t.shape+" does not match previously provided example shapes "+this.exampleShape+".");this.clearTrainDatasetMatrix(),e in this.labelToClassId||(this.labelToClassId[e]=this.nextClassId++),Object(N.tidy)(function(){var r=n.normalizeVectorToUnitLength(t.flatten()),i=r.shape[0];if(null==n.classDatasetMatrices[e])n.classDatasetMatrices[e]=r.as2D(1,i);else {var o=n.classDatasetMatrices[e].as2D(n.classExampleCount[e],i).concat(r.as2D(1,i),0);n.classDatasetMatrices[e].dispose(),n.classDatasetMatrices[e]=o;}Object(N.keep)(n.classDatasetMatrices[e]),null==n.classExampleCount[e]&&(n.classExampleCount[e]=0),n.classExampleCount[e]++;});},t.prototype.similarities=function(t){var e=this;return Object(N.tidy)(function(){var n=e.normalizeVectorToUnitLength(t.flatten()),r=n.shape[0];if(null==e.trainDatasetMatrix){var i=null;for(var o in e.classDatasetMatrices){i=Zt(i,e.classDatasetMatrices[o]);}e.trainDatasetMatrix=i;}if(null==e.trainDatasetMatrix)return console.warn("Cannot predict without providing training examples."),null;Object(N.keep)(e.trainDatasetMatrix);var a=e.getNumExamples();return e.trainDatasetMatrix.as2D(a,r).matMul(n.as2D(r,1)).as1D();});},t.prototype.predictClass=function(t,e){return void 0===e&&(e=3),function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});}(this,void 0,void 0,function(){var n,r,i,o,a=this;return function(t,e){var n,r,i,o,a={label:0,sent:function sent(){if(1&i[0])throw i[1];return i[1];},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this;}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;){try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue;}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break;}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break;}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break;}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(t,a);}catch(t){o=[6,t],r=0;}finally{n=i=0;}}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:!0};}([o,s]);};}}(this,function(s){switch(s.label){case 0:if(e<1)throw new Error("Please provide a positive integer k value to predictClass.");if(0===this.getNumExamples())throw new Error("You have not added any examples to the KNN classifier. Please add examples before calling predictClass.");return n=Object(N.tidy)(function(){return a.similarities(t).asType("float32");}),r=Math.min(e,this.getNumExamples()),o=te,[4,n.data()];case 1:return i=o.apply(void 0,[s.sent(),r]).indices,n.dispose(),[2,this.calculateTopClass(i,r)];}});});},t.prototype.clearClass=function(t){if(null==this.classDatasetMatrices[t])throw new Error("Cannot clear invalid class "+t);delete this.classDatasetMatrices[t],delete this.classExampleCount[t],this.clearTrainDatasetMatrix();},t.prototype.clearAllClasses=function(){for(var t in this.classDatasetMatrices){this.clearClass(t);}},t.prototype.getClassExampleCount=function(){return this.classExampleCount;},t.prototype.getClassifierDataset=function(){return this.classDatasetMatrices;},t.prototype.getNumClasses=function(){return Object.keys(this.classExampleCount).length;},t.prototype.setClassifierDataset=function(t){for(var e in this.clearTrainDatasetMatrix(),this.classDatasetMatrices=t,t){this.classExampleCount[e]=t[e].shape[0];}},t.prototype.calculateTopClass=function(t,e){var n,r={};if(null==t)return {classIndex:this.labelToClassId[n],label:n,confidences:r};var i={},o=0;for(var a in this.classDatasetMatrices){o+=this.classExampleCount[a],i[a]=o;}var s={};for(var a in this.classDatasetMatrices){s[a]=0;}for(var u=0;u<t.length;u++){var c=t[u];for(var a in this.classDatasetMatrices){if(c<i[a]){s[a]++;break;}}}var l=0;for(var a in this.classDatasetMatrices){var f=s[a]/e;f>l&&(l=f,n=a),r[a]=f;}return {classIndex:this.labelToClassId[n],label:n,confidences:r};},t.prototype.clearTrainDatasetMatrix=function(){null!=this.trainDatasetMatrix&&(this.trainDatasetMatrix.dispose(),this.trainDatasetMatrix=null);},t.prototype.normalizeVectorToUnitLength=function(t){return Object(N.tidy)(function(){var e=t.norm();return Object(N.div)(t,e);});},t.prototype.getNumExamples=function(){var t=0;for(var e in this.classDatasetMatrices){t+=this.classExampleCount[e];}return t;},t.prototype.dispose=function(){for(var t in this.clearTrainDatasetMatrix(),this.classDatasetMatrices){this.classDatasetMatrices[t].dispose();}},t;}();var ne=function(){var t=v()(E.a.mark(function t(e,n,r){var i,o;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:(i=document.createElement("a")).style.display="none",document.body.appendChild(i),o=new Blob([e],{type:r}),i.href=URL.createObjectURL(o),i.download=n,i.click();case 7:case"end":return t.stop();}}},t);}));return function(e,n,r){return t.apply(this,arguments);};}(),re=function(){var t=v()(E.a.mark(function t(e,n){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.abrupt("return",F.a.get(e).then(function(t){return t.data;}).then(function(t){return n&&n(null,t),t;}).catch(function(t){throw n&&n(t),console.error("There has been a problem loading the file: ".concat(t.message)),t;}));case 1:case"end":return t.stop();}}},t);}));return function(e,n){return t.apply(this,arguments);};}(),ie=function(){function t(){b()(this,t),this.knnClassifier=new ee(),this.mapStringToIndex=[];}return w()(t,[{key:"addExample",value:function value(t,e){var n,r;"string"==typeof e?n=this.mapStringToIndex.includes(e)?this.mapStringToIndex.indexOf(e):this.mapStringToIndex.push(e)-1:"number"==typeof e&&(n=e),r=Array.isArray(t)?p.tensor(t):t,this.knnClassifier.addExample(r,n);}},{key:"classify",value:function(){var t=v()(E.a.mark(function t(e,n,r){var i,o,a;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return i=3,o=r,"number"==typeof n?i=n:"function"==typeof n&&(o=n),a=Array.isArray(e)?p.tensor(e):e,t.abrupt("return",C(this.classifyInternal(a,i),o));case 5:case"end":return t.stop();}}},t,this);}));return function(e,n,r){return t.apply(this,arguments);};}()},{key:"classifyInternal",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i,o,a=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(!(this.knnClassifier.getNumClasses()<=0)){t.next=5;break;}throw new Error("There is no example in any class");case 5:return t.next=7,this.knnClassifier.predictClass(e,n);case 7:return r=t.sent,this.mapStringToIndex.length>0&&((r.classIndex||0===r.classIndex)&&(i=this.mapStringToIndex[r.classIndex])&&(r.label=i),r.confidences&&(r.confidencesByLabel={},o=r.confidences,Object.keys(o).forEach(function(t){var e=a.mapStringToIndex[t];r.confidencesByLabel[e]=o[t];}))),t.abrupt("return",r);case 10:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"clearLabel",value:function value(t){var e;"string"==typeof t?this.mapStringToIndex.includes(t)&&(e=this.mapStringToIndex.indexOf(t)):"number"==typeof t&&(e=t),this.knnClassifier.clearClass(e);}},{key:"clearAllLabels",value:function value(){this.mapStringToIndex=[],this.knnClassifier.clearAllClasses();}},{key:"getCountByLabel",value:function value(){var t=this,e=this.knnClassifier.getClassExampleCount();if(this.mapStringToIndex.length>0){var n={};return Object.keys(e).forEach(function(r){if(t.mapStringToIndex[r]){var i=t.mapStringToIndex[r];n[i]=e[r];}}),n;}return e;}},{key:"getCount",value:function value(){return this.knnClassifier.getClassExampleCount();}},{key:"getClassifierDataset",value:function value(){return this.knnClassifier.getClassifierDataset();}},{key:"setClassifierDataset",value:function value(t){this.knnClassifier.setClassifierDataset(t);}},{key:"getNumLabels",value:function value(){return this.knnClassifier.getNumClasses();}},{key:"dispose",value:function value(){this.knnClassifier.dispose();}},{key:"save",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i,o=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return n=this.knnClassifier.getClassifierDataset(),this.mapStringToIndex.length>0&&Object.keys(n).forEach(function(t){o.mapStringToIndex[t]&&(n[t].label=o.mapStringToIndex[t]);}),r=Object.keys(n).map(function(t){var e=n[t];return e?e.dataSync():null;}),i="myKNN.json",e&&(i=e.endsWith(".json")?e:"".concat(e,".json")),t.next=7,ne(JSON.stringify({dataset:n,tensors:r}),i,"application/octet-stream");case 7:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"load",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i,o,a,s;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if("object"!==S()(e)){t.next=4;break;}r=e,t.next=7;break;case 4:return t.next=6,re(e);case 6:r=t.sent;case 7:r&&(o=(i=r).dataset,a=i.tensors,this.mapStringToIndex=Object.keys(o).map(function(t){return o[t].label;}),s=a.map(function(t,e){if(t){var n=Object.keys(t).map(function(e){return t[e];});return p.tensor(n,o[e].shape,o[e].dtype);}return null;}).reduce(function(t,e,n){return t[n]=e,t;},{}),this.knnClassifier.setClassifierDataset(s),n&&n());case 8:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()}]),t;}(),oe=function oe(){return new ie();},ae=function(){function t(e,n){b()(this,t),this.videoElt=null,this.size=n,this.videoReady=!1,"undefined"!=typeof HTMLVideoElement&&(e instanceof HTMLVideoElement?this.videoElt=e:null!==e&&"object"===S()(e)&&e.elt instanceof HTMLVideoElement&&(this.videoElt=e.elt));}return w()(t,[{key:"loadVideo",value:function(){var t=v()(E.a.mark(function t(){var e,n=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(t,r){n.videoElt||r(new Error("No video was passed to the constructor.")),n.video=document.createElement("video");var i=navigator.userAgent;e=i.indexOf("Firefox")>-1?n.videoElt.mozCaptureStream():n.videoElt.captureStream(),n.video.srcObject=e,n.size&&(n.video.width=n.size,n.video.height=n.size),n.video.autoplay=!0,n.video.playsinline=!0,n.video.muted=!0;var o=n.video.play();void 0!==o&&o.then(function(){n.videoReady=!0,t(n.video);});}));case 1:case"end":return t.stop();}}},t);}));return function(){return t.apply(this,arguments);};}()}]),t;}(),se=224,ue=[se,se],ce="https://storage.googleapis.com/tfjs-models/tfjs/mobilenet_v",le={version:1,alpha:.25,topk:3,learningRate:1e-4,hiddenUnits:100,epochs:20,numLabels:2,batchSize:.4,layer:"conv_pw_13_relu"},fe={1:{.25:"https://tfhub.dev/google/imagenet/mobilenet_v1_025_224/classification/1",.5:"https://tfhub.dev/google/imagenet/mobilenet_v1_050_224/classification/1",.75:"https://tfhub.dev/google/imagenet/mobilenet_v1_075_224/classification/1",1:"https://tfhub.dev/google/imagenet/mobilenet_v1_100_224/classification/1"},2:{.5:"https://tfhub.dev/google/imagenet/mobilenet_v2_050_224/classification/2",.75:"https://tfhub.dev/google/imagenet/mobilenet_v2_075_224/classification/2",1:"https://tfhub.dev/google/imagenet/mobilenet_v2_100_224/classification/2"}},he={1:"module_apply_default/MobilenetV1/Logits/global_pool",2:"module_apply_default/MobilenetV2/Logits/AvgPool"},de=function(){function t(e,n){b()(this,t),this.mobilenet=null,this.topKPredictions=10,this.hasAnyTrainedClass=!1,this.customModel=null,this.jointModel=null,this.config={epochs:e.epochs||le.epochs,version:e.version||le.version,hiddenUnits:e.hiddenUnits||le.hiddenUnits,numLabels:e.numLabels||le.numLabels,learningRate:e.learningRate||le.learningRate,batchSize:e.batchSize||le.batchSize,layer:e.layer||le.layer,alpha:e.alpha||le.alpha},this.model=null,this.url=fe[this.config.version][this.config.alpha],this.normalizationOffset=p.scalar(127.5),this.mobilenetURL=e.mobilenetURL||"".concat(ce).concat(this.config.version,"_").concat(this.config.alpha,"_").concat(se,"/model.json"),this.graphModelURL=e.graphModelURL||this.url,this.isPredicting=!1,this.mapStringToIndex=[],this.usageType=null,this.ready=C(this.loadModel(),n);}return w()(t,[{key:"loadModel",value:function(){var t=v()(E.a.mark(function t(){var e;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,p.loadLayersModel(this.mobilenetURL);case 2:if(this.mobilenet=t.sent,!this.graphModelURL.includes("https://tfhub.dev/")){t.next=9;break;}return t.next=6,p.loadGraphModel(this.graphModelURL,{fromTFHub:!0});case 6:this.model=t.sent,t.next=12;break;case 9:return t.next=11,p.loadGraphModel(this.graphModelURL,{fromTFHub:!1});case 11:this.model=t.sent;case 12:return e=this.mobilenet.getLayer(this.config.layer),t.next=15,p.model({inputs:this.mobilenet.inputs,outputs:e.output});case 15:if(this.mobilenetFeatures=t.sent,!this.video){t.next=19;break;}return t.next=19,this.mobilenetFeatures.predict(ut(this.video,ue));case 19:return t.abrupt("return",this);case 20:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"classification",value:function value(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2?arguments[2]:void 0;return this.usageType="classifier","object"===S()(n)?Object.assign(this.config,n):"function"==typeof n&&(e=n),"function"==typeof r&&(e=r),t&&C(this.loadVideo(t),e),this;}},{key:"regression",value:function value(t,e){return this.usageType="regressor",t&&C(this.loadVideo(t),e),this;}},{key:"loadVideo",value:function(){var t=v()(E.a.mark(function t(e){var n,r;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(n=null,e instanceof HTMLVideoElement?n=e:"object"===S()(e)&&e.elt instanceof HTMLVideoElement&&(n=e.elt),!n){t.next=7;break;}return r=new ae(n,se),t.next=6,r.loadVideo();case 6:this.video=t.sent;case 7:return t.abrupt("return",this);case 8:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"addImage",value:function(){var t=v()(E.a.mark(function t(e,n,r){var i,o,a;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return a=r,e instanceof HTMLImageElement||e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement||e.elt instanceof ImageData?i=e:"object"===S()(e)&&(e.elt instanceof HTMLImageElement||e.elt instanceof HTMLVideoElement||e.elt instanceof HTMLCanvasElement||e.elt instanceof ImageData)?i=e.elt:"string"!=typeof e&&"number"!=typeof e||(i=this.video,o=e),"string"==typeof n||"number"==typeof n?o=n:"function"==typeof n&&(a=n),"string"==typeof o&&(o=this.mapStringToIndex.includes(o)?this.mapStringToIndex.indexOf(o):this.mapStringToIndex.push(o)-1),t.abrupt("return",C(this.addImageInternal(i,o),a));case 5:case"end":return t.stop();}}},t,this);}));return function(e,n,r){return t.apply(this,arguments);};}()},{key:"addImageInternal",value:function(){var t=v()(E.a.mark(function t(e,n){var r=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.ready;case 2:return p.tidy(function(){var t,i=ut(e,ue),o=r.mobilenetFeatures.predict(i);if("classifier"===r.usageType?t=p.tidy(function(){return p.oneHot(p.tensor1d([n],"int32"),r.config.numLabels);}):"regressor"===r.usageType&&(t=p.tensor2d([[n]])),null==r.xs)r.xs=p.keep(o),r.ys=p.keep(t),r.hasAnyTrainedClass=!0;else {var a=r.xs;r.xs=p.keep(a.concat(o,0));var s=r.ys;r.ys=p.keep(s.concat(t,0)),a.dispose(),s.dispose(),t.dispose();}}),t.abrupt("return",this);case 4:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"train",value:function(){var t=v()(E.a.mark(function t(e){var n,r;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(this.hasAnyTrainedClass){t.next=2;break;}throw new Error("Add some examples before training!");case 2:if(this.isPredicting=!1,"classifier"===this.usageType?(this.loss="categoricalCrossentropy",this.customModel=p.sequential({layers:[p.layers.flatten({inputShape:[7,7,256]}),p.layers.dense({units:this.config.hiddenUnits,activation:"relu",kernelInitializer:"varianceScaling",useBias:!0}),p.layers.dense({units:this.config.numLabels,kernelInitializer:"varianceScaling",useBias:!1,activation:"softmax"})]})):"regressor"===this.usageType&&(this.loss="meanSquaredError",this.customModel=p.sequential({layers:[p.layers.flatten({inputShape:[7,7,256]}),p.layers.dense({units:this.config.hiddenUnits,activation:"relu",kernelInitializer:"varianceScaling",useBias:!0}),p.layers.dense({units:1,useBias:!1,kernelInitializer:"Zeros",activation:"linear"})]})),this.jointModel=p.sequential(),this.jointModel.add(this.mobilenetFeatures),this.jointModel.add(this.customModel),n=p.train.adam(this.config.learningRate),this.customModel.compile({optimizer:n,loss:this.loss}),(r=Math.floor(this.xs.shape[0]*this.config.batchSize))>0){t.next=12;break;}throw new Error("Batch size is 0 or NaN. Please choose a non-zero fraction.");case 12:return t.abrupt("return",this.customModel.fit(this.xs,this.ys,{batchSize:r,epochs:this.config.epochs,callbacks:{onBatchEnd:function(){var t=v()(E.a.mark(function t(n,r){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return e(r.loss.toFixed(5)),t.next=3,p.nextFrame();case 3:case"end":return t.stop();}}},t);}));return function(e,n){return t.apply(this,arguments);};}(),onTrainEnd:function onTrainEnd(){return e(null);}}}));case 13:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"classify",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return e instanceof HTMLImageElement||e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement||e instanceof ImageData?r=e:"object"===S()(e)&&(e.elt instanceof HTMLImageElement||e.elt instanceof HTMLVideoElement||e.elt instanceof HTMLCanvasElement||e.elt instanceof ImageData)?r=e.elt:"function"==typeof e&&(r=this.video,i=e),"function"==typeof n&&(i=n),t.abrupt("return",C(this.classifyInternal(r),i));case 3:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"classifyInternal",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if("classifier"===this.usageType){t.next=2;break;}throw new Error("Mobilenet Feature Extraction has not been set to be a classifier.");case 2:return t.next=4,p.nextFrame();case 4:return this.isPredicting=!0,n=p.tidy(function(){var t=ut(e,ue),n=i.jointModel.predict(t);return Array.from(n.as1D().dataSync());}),t.next=8,n.map(function(t,e){return {label:i.mapStringToIndex.length>0&&i.mapStringToIndex[e]?i.mapStringToIndex[e]:e,confidence:t};}).sort(function(t,e){return e.confidence-t.confidence;});case 8:return r=t.sent,t.abrupt("return",r);case 10:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"predict",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return e instanceof HTMLImageElement||e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement||e instanceof ImageData?r=e:"object"===S()(e)&&(e.elt instanceof HTMLImageElement||e.elt instanceof HTMLVideoElement||e.elt instanceof HTMLCanvasElement||e.elt instanceof ImageData)?r=e.elt:"function"==typeof e&&(r=this.video,i=e),"function"==typeof n&&(i=n),t.abrupt("return",C(this.predictInternal(r),i));case 3:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"predictInternal",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if("regressor"===this.usageType){t.next=2;break;}throw new Error("Mobilenet Feature Extraction has not been set to be a regressor.");case 2:return t.next=4,p.nextFrame();case 4:return this.isPredicting=!0,n=p.tidy(function(){var t=ut(e,ue);return i.jointModel.predict(t).as1D();}),t.next=8,n.data();case 8:return r=t.sent,n.dispose(),t.abrupt("return",{value:r[0]});case 11:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"load",value:function(){var t=v()(E.a.mark(function t(){var e,n,r,i,o,a,s=this,u=arguments;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(e=u.length>0&&void 0!==u[0]?u[0]:null,n=u.length>1?u[1]:void 0,"string"==typeof e){t.next=11;break;}return r=null,i=null,Array.from(e).forEach(function(t){if(t.name.includes(".json")){r=t;var e=new FileReader();e.onload=function(t){JSON.parse(t.target.result).ml5Specs&&(s.mapStringToIndex=JSON.parse(t.target.result).ml5Specs.mapStringToIndex);},e.readAsText(t);}else t.name.includes(".bin")&&(i=t);}),t.next=8,p.loadLayersModel(p.io.browserFiles([r,i]));case 8:this.jointModel=t.sent,t.next=20;break;case 11:return t.next=13,F.a.get(e);case 13:return o=t.sent,(a=o.data).ml5Specs&&(this.mapStringToIndex=a.ml5Specs.mapStringToIndex),t.next=18,p.loadLayersModel(e);case 18:this.jointModel=t.sent,n&&n();case 20:return t.abrupt("return",this.jointModel);case 21:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"save",value:function(){var t=v()(E.a.mark(function t(e,n){var r=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(this.jointModel){t.next=2;break;}throw new Error("No model found.");case 2:this.jointModel.save(p.io.withSaveHandler(function(){var t=v()(E.a.mark(function t(i){var o;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return o="model",n&&(o=n),r.weightsManifest={modelTopology:i.modelTopology,weightsManifest:[{paths:["./".concat(o,".weights.bin")],weights:i.weightSpecs}],ml5Specs:{mapStringToIndex:r.mapStringToIndex}},t.next=5,ne(i.weightData,"".concat(o,".weights.bin"),"application/octet-stream");case 5:return t.next=7,ne(JSON.stringify(r.weightsManifest),"".concat(o,".json"),"text/plain");case 7:e&&e();case 8:case"end":return t.stop();}}},t);}));return function(e){return t.apply(this,arguments);};}()));case 3:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"mobilenetInfer",value:function value(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=t;return r instanceof p.Tensor||r instanceof ImageData||r instanceof HTMLImageElement||r instanceof HTMLCanvasElement||r instanceof HTMLVideoElement?p.tidy(function(){r instanceof p.Tensor||(r=p.browser.fromPixels(r));var t=r.toFloat().sub(e.normalizationOffset).div(e.normalizationOffset),i=t;if(r.shape[0]!==se||r.shape[1]!==se){i=p.image.resizeBilinear(t,ue,!0);}var o,a=i.reshape([-1,se,se,3]);if(n){var s=he[e.config.version];o=e.model.execute(a,s).squeeze([1,2]);}else {o=e.model.predict(a).slice([0,1],[-1,1e3]);}return o;}):null;}},{key:"infer",value:function value(t,e){var n,r;if(t instanceof HTMLImageElement||t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof ImageData)n=t;else {if("object"!==S()(t)||!(t.elt instanceof HTMLImageElement||t.elt instanceof HTMLVideoElement||t.elt instanceof HTMLCanvasElement||t.elt instanceof ImageData))throw new Error("No input image found.");n=t.elt;}return r=e&&"string"==typeof e?e:"conv_preds",this.mobilenetInfer(n,r);}}]),t;}(),pe=function pe(t,e,n){var r;if("string"!=typeof t)throw new Error('Please specify a model to use. E.g: "MobileNet"');r=t.toLowerCase();var i={},o=n;if("object"===S()(e)?i=e:"function"==typeof e&&(o=e),"mobilenet"===r)return new de(i,o);throw new Error("".concat(r," is not a valid model."));},me=function me(){console.log("%cword2vec has been disabled","color: #A155FF; font-size: 16px"),console.log("We've intentionally disabled the word2vec function after recognizing it has the potential to produce harmful outputs while using the model files included in our examples. We'll consider reenabling the word2vec function along with changes to address these issues in a future release of ml5.js. You can find further updates about this topic on our Twitter account (https://twitter.com/ml5js/status/1445762321444315147) and GitHub (https://github.com/ml5js/ml5-library/issues/1238).");},ge=n(58),ve=n.n(ge),ye=n(57),be=n.n(ye),xe=n(35),we=n.n(xe),ke=["person","bicycle","car","motorbike","aeroplane","bus","train","truck","boat","traffic light","fire hydrant","stop sign","parking meter","bench","bird","cat","dog","horse","sheep","cow","elephant","bear","zebra","giraffe","backpack","umbrella","handbag","tie","suitcase","frisbee","skis","snowboard","sports ball","kite","baseball bat","baseball glove","skateboard","surfboard","tennis racket","bottle","wine glass","cup","fork","knife","spoon","bowl","banana","apple","sandwich","orange","broccoli","carrot","hot dog","pizza","donut","cake","chair","sofa","pottedplant","bed","diningtable","toilet","tvmonitor","laptop","mouse","remote","keyboard","cell phone","microwave","oven","toaster","sink","refrigerator","book","clock","vase","scissors","teddy bear","hair drier","toothbrush"];function Ee(t){return new RegExp("^(?:[a-z]+:)?//","i").test(t);}var Ce={isAbsoluteURL:Ee,getModelPath:function getModelPath(t){return Ee(t)||"undefined"==typeof window?t:window.location.pathname+t;}},Ae=function Ae(t,e){var n=Math.min(t[3],e[3])-Math.max(t[1],e[1]),r=Math.min(t[2],e[2])-Math.max(t[0],e[0]);return n<0||r<0?0:n*r;},Oe=function Oe(t,e){return Ae(t,e)/function(t,e){var n=Ae(t,e);return (t[3]-t[1])*(t[2]-t[0])+(e[3]-e[1])*(e[2]-e[0])-n;}(t,e);};function _e(t,e,n,r){return Se.apply(this,arguments);}function Se(){return (Se=v()(E.a.mark(function t(e,n,r,i){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.abrupt("return",p.tidy(function(){for(var t=p.mul(n,r),o=p.argMax(t,-1),a=p.max(t,-1),s=p.greaterEqual(a,p.scalar(i)).dataSync(),u=[],c=0;c<s.length;c+=1){s[c]&&u.push(c);}if(0===u.length)return [null,null,null];var l=p.tensor1d(u,"int32");return [p.gather(e.reshape([s.length,4]),l),p.gather(a.flatten(),l),p.gather(o.flatten(),l)];}));case 1:case"end":return t.stop();}}},t);}))).apply(this,arguments);}var De=function De(t,e){return p.tidy(function(){var n=p.tensor1d([2]),r=p.sub(t,p.div(e,n)),i=p.add(t,p.div(e,n)),o=[r.shape[0],r.shape[1],r.shape[2],1];return p.concat([r.slice([0,0,0,1],o),r.slice([0,0,0,0],o),i.slice([0,0,0,1],o),i.slice([0,0,0,0],o)],3);});},Fe=function Fe(t,e,n){return p.tidy(function(){for(var r=[],i=0;i<e.length;i+=1){r.push([e[i],[t[4*i],t[4*i+1],t[4*i+2],t[4*i+3]],i]);}var o=[];return r.sort(function(t,e){return e[0]-t[0];}).forEach(function(t){for(var e=!0,r=0;r<o.length;r+=1){if(Oe(t[1],o[r][1])>n){e=!1;break;}}e&&o.push(t);}),[o.map(function(t){return t[2];}),o.map(function(t){return t[1];}),o.map(function(t){return t[0];})];});};function Te(t,e,n){return p.tidy(function(){var r=e.shape[0],i=p.reshape(e,[1,1,r,2]),o=t.shape.slice(1,3),a=o[0],s=o[1],u=p.range(0,o[0]),c=p.range(0,o[1]);u=p.tile(u,[o[1]]),c=p.tile(p.expandDims(c,0),[o[0],1]),c=p.transpose(c).flatten();var l=p.transpose(p.stack([u,c]));l=p.reshape(l,[o[0],o[1],1,2]),l=p.cast(l,t.dtype),t=p.reshape(t,[o[0],o[1],r,n+5]),o=p.cast(p.reshape(p.tensor1d(o),[1,1,1,2]),t.dtype);var f=p.sigmoid(t.slice([0,0,0,0],[a,s,r,2])),h=p.exp(t.slice([0,0,0,2],[a,s,r,2])),d=p.sigmoid(t.slice([0,0,0,4],[a,s,r,1])),m=p.softmax(t.slice([0,0,0,5],[a,s,r,n]));return [f=p.div(p.add(f,l),o),h=p.div(p.mul(h,i),o),d,m];});}function Ne(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0;}catch(t){return !1;}}();return function(){var n,r=we()(t);if(e){var i=we()(this).constructor;n=Reflect.construct(r,arguments,i);}else n=r.apply(this,arguments);return be()(this,n);};}var Ie={modelUrl:"https://raw.githubusercontent.com/ml5js/ml5-data-and-training/master/models/YOLO/model.json",filterBoxesThreshold:.01,IOUThreshold:.4,classProbThreshold:.4},Re=416,Me=function(t){ve()(n,t);var e=Ne(n);function n(t,r,i){var o;return b()(this,n),(o=e.call(this,t,Re)).modelUrl=r.modelUrl||Ie.modelUrl,o.filterBoxesThreshold=r.filterBoxesThreshold||Ie.filterBoxesThreshold,o.IOUThreshold=r.IOUThreshold||Ie.IOUThreshold,o.classProbThreshold=r.classProbThreshold||Ie.classProbThreshold,o.modelReady=!1,o.isPredicting=!1,o.callback=i,o.ready=C(o.loadModel(),o.callback),r.disableDeprecationNotice||console.warn("WARNING! Function YOLO has been deprecated, please use the new ObjectDetector function instead"),o;}return w()(n,[{key:"loadModel",value:function(){var t=v()(E.a.mark(function t(){var e;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(!this.videoElt||this.video){t.next=4;break;}return t.next=3,this.loadVideo();case 3:this.video=t.sent;case 4:if(!0!==Ce.isAbsoluteURL(this.modelUrl)){t.next=10;break;}return t.next=7,p.loadLayersModel(this.modelUrl);case 7:this.model=t.sent,t.next=15;break;case 10:return e=Ce.getModelPath(this.modelUrl),this.modelUrl="".concat(e,"/model.json"),t.next=14,p.loadLayersModel(this.modelUrl);case 14:this.model=t.sent;case 15:return this.modelReady=!0,t.abrupt("return",this);case 17:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"detect",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.ready;case 2:if(i=n,!ct(e)){t.next=7;break;}r=e,t.next=21;break;case 7:if("object"!==S()(e)||!ct(e.elt)){t.next=11;break;}r=e.elt,t.next=21;break;case 11:if("object"!==S()(e)||!ct(e.canvas)){t.next=15;break;}r=e.canvas,t.next=21;break;case 15:if("function"!=typeof e){t.next=20;break;}r=this.video,i=e,t.next=21;break;case 20:throw new Error("Detection subject not supported");case 21:return t.abrupt("return",C(this.detectInternal(r),i));case 22:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"detectInternal",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i,o,a,s,u,c,l,f,h,d=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.ready;case 2:return t.next=4,p.nextFrame();case 4:return n=p.tensor2d([[.57273,.677385],[1.87446,2.06253],[3.33843,5.47434],[7.88282,3.52778],[9.77052,9.16828]]),this.isPredicting=!0,r=p.tidy(function(){var t=ut(e,[Re,Re]),r=Te(d.model.predict(t),n,80),i=Y()(r,4),o=i[0],a=i[1],s=i[2],u=i[3];return [De(o,a),s,u];}),i=Y()(r,3),o=i[0],a=i[1],s=i[2],t.next=9,_e(o,a,s,this.filterBoxesThreshold);case 9:if(u=t.sent,c=Y()(u,3),l=c[0],f=c[1],h=c[2],o.dispose(),a.dispose(),s.dispose(),null!=l){t.next=19;break;}return t.abrupt("return",[]);case 19:return t.abrupt("return",p.tidy(function(){var t=p.scalar(Re),e=p.scalar(Re),r=p.stack([e,t,e,t]).reshape([1,4]),i=p.mul(l,r),o=i.dataSync(),a=f.dataSync(),s=Fe(o,a,d.IOUThreshold),u=Y()(s,3),c=u[0],m=u[1],g=u[2],v=[];return h.gather(p.tensor1d(c,"int32")).dataSync().forEach(function(t,e){var n=g[e];if(!(n<d.classProbThreshold)){var r=ke[t],i=Y()(m[e],4),o=i[0],a=i[1],s=i[2],u=i[3];o=Math.max(0,o),a=Math.max(0,a),s=Math.min(Re,s)-o;var c={label:r,confidence:n,x:a,y:o,width:u=Math.min(Re,u)-a,height:s,normalized:{x:a/Re,y:o/Re,width:u/Re,height:s/Re}};v.push(c);}}),d.isPredicting=!1,t.dispose(),e.dispose(),r.dispose(),i.dispose(),l.dispose(),f.dispose(),h.dispose(),n.dispose(),v;}));case 20:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()}]),n;}(ae),je=function je(t,e,n){var r=null,i={},o=n;return t instanceof HTMLVideoElement?r=t:"object"===S()(t)&&t.elt instanceof HTMLVideoElement?r=t.elt:"function"==typeof t?o=t:"object"===S()(t)&&(i=t),"object"===S()(e)?i=e:"function"==typeof e&&(o=e),new Me(r,i,o);},Be=n(242),Pe={base:"lite_mobilenet_v2",modelUrl:void 0},Le=function(){function t(e,n,r){b()(this,t),this.video=e||null,this.modelReady=!1,this.isPredicting=!1,this.config={base:n.base||Pe.base,modelUrl:n.modelUrl||Pe.modelUrl},this.callback=r,this.ready=C(this.loadModel(),this.callback);}return w()(t,[{key:"loadModel",value:function(){var t=v()(E.a.mark(function t(){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,Be.load(this.config);case 2:return this.model=t.sent,this.modelReady=!0,t.abrupt("return",this);case 5:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"detectInternal",value:function(){var t=v()(E.a.mark(function t(e){var n,r;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return this.isPredicting=!0,t.next=3,this.model.detect(e);case 3:return n=t.sent,r=n.map(function(t){return {label:t.class,confidence:t.score,x:t.bbox[0],y:t.bbox[1],width:t.bbox[2],height:t.bbox[3],normalized:{x:t.bbox[0]/e.width,y:t.bbox[1]/e.height,width:t.bbox[2]/e.width,height:t.bbox[3]/e.height}};}),this.isPredicting=!1,t.abrupt("return",r);case 7:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"detect",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.ready;case 2:return t.next=4,p.nextFrame();case 4:if(i=n,!ct(e)){t.next=9;break;}r=e,t.next=23;break;case 9:if("object"!==S()(e)||!ct(e.elt)){t.next=13;break;}r=e.elt,t.next=23;break;case 13:if("object"!==S()(e)||!ct(e.canvas)){t.next=17;break;}r=e.canvas,t.next=23;break;case 17:if("function"!=typeof e){t.next=22;break;}r=this.video,i=e,t.next=23;break;case 22:throw new Error("Detection subject not supported");case 23:return t.abrupt("return",C(this.detectInternal(r),i));case 24:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()}]),t;}(),ze=function ze(t,e,n){var r=null,i={},o=n;return t instanceof HTMLVideoElement?r=t:"object"===S()(t)&&t.elt instanceof HTMLVideoElement?r=t.elt:"function"==typeof t?o=t:"object"===S()(t)&&(i=t),"object"===S()(e)?i=e:"function"==typeof e&&(o=e),new Le(r,i,o);};function Ue(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable;})),n.push.apply(n,r);}return n;}var We=w()(function t(e,n,r,i){switch(b()(this,t),this.video=n,this.modelNameOrUrl=e,this.options=r||{},this.callback=i,e){case"yolo":return this.model=new je(this.video,function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Ue(Object(n),!0).forEach(function(e){d()(t,e,n[e]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ue(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e));});}return t;}({disableDeprecationNotice:!0},this.options),i),this;case"cocossd":default:return this.model=new ze(this.video,this.options,i),this;}}),Ve=function Ve(t,e,n,r){var i,o={},a=r,s=t;if("string"!=typeof s)throw new Error('Please specify a model to use. E.g: "YOLO"');-1===s.indexOf("http")&&(s=t.toLowerCase()),e instanceof HTMLVideoElement?i=e:"object"===S()(e)&&e.elt instanceof HTMLVideoElement?i=e.elt:"object"===S()(e)?o=e:"function"==typeof e&&(a=e),"object"===S()(n)?o=n:"function"==typeof n&&(a=n);var u=new We(s,i,o,a);return u.model.callback?u.model:u.model.ready;},qe=n(99),$e=n.n(qe),_He=function He(t,e){return (_He=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e;}||function(t,e){for(var n in e){e.hasOwnProperty(n)&&(t[n]=e[n]);}})(t,e);};function Ge(t,e){function n(){this.constructor=t;}_He(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n());}var _Ke=function Ke(){return (_Ke=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){for(var i in e=arguments[n]){Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);}}return t;}).apply(this,arguments);};function Xe(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});}function Ye(t,e){var n,r,i,o,a={label:0,sent:function sent(){if(1&i[0])throw i[1];return i[1];},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this;}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;){try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue;}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break;}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break;}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break;}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(t,a);}catch(t){o=[6,t],r=0;}finally{n=i=0;}}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:!0};}([o,s]);};}}var Je=function(){function t(t,e){this.model=t,this.outputStride=e;var n=this.model.inputs[0].shape;N.util.assert(-1===n[1]&&-1===n[2],function(){return "Input shape ["+n[1]+", "+n[2]+"] must both be equal to or -1";});}return t.prototype.predict=function(t){var e=this;return Object(N.tidy)(function(){var n=e.preprocessInput(Object(N.cast)(t,"float32")),r=Object(N.expandDims)(n,0),i=e.model.predict(r).map(function(t){return Object(N.squeeze)(t,[0]);}),o=e.nameOutputResults(i);return {heatmapScores:Object(N.sigmoid)(o.heatmap),offsets:o.offsets,displacementFwd:o.displacementFwd,displacementBwd:o.displacementBwd};});},t.prototype.dispose=function(){this.model.dispose();},t;}(),Qe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Ge(e,t),e.prototype.preprocessInput=function(t){return Object(N.tidy)(function(){return Object(N.sub)(Object(N.div)(t,127.5),1);});},e.prototype.nameOutputResults=function(t){return {offsets:t[0],heatmap:t[1],displacementFwd:t[2],displacementBwd:t[3]};},e;}(Je);function Ze(t){return Math.floor(t/2);}var tn=function(){function t(t,e){this.priorityQueue=new Array(t),this.numberOfElements=-1,this.getElementValue=e;}return t.prototype.enqueue=function(t){this.priorityQueue[++this.numberOfElements]=t,this.swim(this.numberOfElements);},t.prototype.dequeue=function(){var t=this.priorityQueue[0];return this.exchange(0,this.numberOfElements--),this.sink(0),this.priorityQueue[this.numberOfElements+1]=null,t;},t.prototype.empty=function(){return -1===this.numberOfElements;},t.prototype.size=function(){return this.numberOfElements+1;},t.prototype.all=function(){return this.priorityQueue.slice(0,this.numberOfElements+1);},t.prototype.max=function(){return this.priorityQueue[0];},t.prototype.swim=function(t){for(;t>0&&this.less(Ze(t),t);){this.exchange(t,Ze(t)),t=Ze(t);}},t.prototype.sink=function(t){for(;2*t<=this.numberOfElements;){var e=2*t;if(e<this.numberOfElements&&this.less(e,e+1)&&e++,!this.less(t,e))break;this.exchange(t,e),t=e;}},t.prototype.getValueAt=function(t){return this.getElementValue(this.priorityQueue[t]);},t.prototype.less=function(t,e){return this.getValueAt(t)<this.getValueAt(e);},t.prototype.exchange=function(t,e){var n=this.priorityQueue[t];this.priorityQueue[t]=this.priorityQueue[e],this.priorityQueue[e]=n;},t;}();function en(t,e,n,r,i,o){for(var a=o.shape,s=a[0],u=a[1],c=!0,l=Math.max(n-i,0),f=Math.min(n+i+1,s),h=l;h<f;++h){for(var d=Math.max(r-i,0),p=Math.min(r+i+1,u),m=d;m<p;++m){if(o.get(h,m,t)>e){c=!1;break;}}if(!c)break;}return c;}var nn=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],rn=nn.length,on=nn.reduce(function(t,e,n){return t[e]=n,t;},{}),an=[["leftHip","leftShoulder"],["leftElbow","leftShoulder"],["leftElbow","leftWrist"],["leftHip","leftKnee"],["leftKnee","leftAnkle"],["rightHip","rightShoulder"],["rightElbow","rightShoulder"],["rightElbow","rightWrist"],["rightHip","rightKnee"],["rightKnee","rightAnkle"],["leftShoulder","rightShoulder"],["leftHip","rightHip"]].map(function(t){var e=t[0],n=t[1];return [on[e],on[n]];});function sn(t,e,n,r){return {y:r.get(t,e,n),x:r.get(t,e,n+rn)};}function un(t,e,n){var r=sn(t.heatmapY,t.heatmapX,t.id,n),i=r.y,o=r.x;return {x:t.heatmapX*e+o,y:t.heatmapY*e+i};}function cn(t,e,n){return t<e?e:t>n?n:t;}function ln(t,e){return {x:t.x+e.x,y:t.y+e.y};}var fn=[["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"]].map(function(t){var e=t[0],n=t[1];return [on[e],on[n]];}),hn=fn.map(function(t){return t[1];}),dn=fn.map(function(t){return t[0];});function pn(t,e,n,r){return {y:cn(Math.round(t.y/e),0,n-1),x:cn(Math.round(t.x/e),0,r-1)};}function mn(t,e,n,r,i,o,a,s){void 0===s&&(s=2);for(var u=r.shape,c=u[0],l=u[1],f=function(t,e,n){var r=n.shape[2]/2;return {y:n.get(e.y,e.x,t),x:n.get(e.y,e.x,r+t)};}(t,pn(e.position,o,c,l),a),h=ln(e.position,f),d=0;d<s;d++){var p=pn(h,o,c,l),m=sn(p.y,p.x,n,i);h=ln({x:p.x*o,y:p.y*o},{x:m.x,y:m.y});}var g=pn(h,o,c,l),v=r.get(g.y,g.x,n);return {position:h,part:nn[n],score:v};}function gn(t,e,n,r,i,o){var a=e.shape[2],s=hn.length,u=new Array(a),c=t.part,l=t.score,f=un(c,r,n);u[c.id]={score:l,part:nn[c.id],position:f};for(var h=s-1;h>=0;--h){var d=hn[h],p=dn[h];u[d]&&!u[p]&&(u[p]=mn(h,u[d],p,e,n,r,o));}for(h=0;h<s;++h){d=dn[h],p=hn[h],u[d]&&!u[p]&&(u[p]=mn(h,u[d],p,e,n,r,i));}return u;}function vn(t,e,n,r){var i=n.x,o=n.y;return t.some(function(t){var n=t.keypoints[r].position;return function(t,e,n,r){var i=n-t,o=r-e;return i*i+o*o;}(o,i,n.y,n.x)<=e;});}function yn(t,e,n){return n.reduce(function(n,r,i){var o=r.position,a=r.score;return vn(t,e,o,i)||(n+=a),n;},0)/n.length;}var bn=1;function xn(t,e,n,r,i,o,a,s){void 0===a&&(a=.5),void 0===s&&(s=20);for(var u=[],c=function(t,e,n){for(var r=n.shape,i=r[0],o=r[1],a=r[2],s=new tn(i*o*a,function(t){return t.score;}),u=0;u<i;++u){for(var c=0;c<o;++c){for(var l=0;l<a;++l){var f=n.get(u,c,l);f<t||en(l,f,u,c,e,n)&&s.enqueue({score:f,part:{heatmapY:u,heatmapX:c,id:l}});}}}return s;}(a,bn,t),l=s*s;u.length<o&&!c.empty();){var f=c.dequeue();if(!vn(u,l,un(f.part,i,e),f.part.id)){var h=gn(f,t,e,i,n,r),d=yn(u,l,h);u.push({keypoints:h,score:d});}}return u;}function wn(t){var e=t.shape,n=e[0],r=e[1],i=e[2];return Object(N.tidy)(function(){var e=Object(N.reshape)(t,[n*r,i]),o=Object(N.argMax)(e,0),a=Object(N.expandDims)(Object(N.div)(o,Object(N.scalar)(r,"int32")),1),s=Object(N.expandDims)(function(t,e){return Object(N.tidy)(function(){var n=Object(N.div)(t,Object(N.scalar)(e,"int32"));return Object(N.sub)(t,Object(N.mul)(n,Object(N.scalar)(e,"int32")));});}(o,r),1);return Object(N.concat)([a,s],1);});}function kn(t,e,n,r){return {y:r.get(t,e,n),x:r.get(t,e,n+rn)};}function En(t,e,n){return Object(N.tidy)(function(){var r=function(t,e){for(var n=[],r=0;r<rn;r++){var i=kn(t.get(r,0).valueOf(),t.get(r,1).valueOf(),r,e),o=i.x,a=i.y;n.push(a),n.push(o);}return Object(N.tensor2d)(n,[rn,2]);}(t,n);return Object(N.add)(Object(N.cast)(Object(N.mul)(t.toTensor(),Object(N.scalar)(e,"int32")),"float32"),r);});}function Cn(t,e,n){return Xe(this,void 0,void 0,function(){var r,i,o,a,s,u,c,l,f,h;return Ye(this,function(d){switch(d.label){case 0:return r=0,i=wn(t),[4,Promise.all([t.buffer(),e.buffer(),i.buffer()])];case 1:return o=d.sent(),a=o[0],s=o[1],u=o[2],[4,(c=En(u,n,s)).buffer()];case 2:return l=d.sent(),f=Array.from(function(t,e){for(var n=e.shape[0],r=new Float32Array(n),i=0;i<n;i++){var o=e.get(i,0),a=e.get(i,1);r[i]=t.get(o,a,i);}return r;}(a,u)),h=f.map(function(t,e){return r+=t,{position:{y:l.get(e,0),x:l.get(e,1)},part:nn[e],score:t};}),i.dispose(),c.dispose(),[2,{keypoints:h,score:r/h.length}];}});});}var An="https://storage.googleapis.com/tfjs-models/savedmodel/posenet/mobilenet/",On="https://storage.googleapis.com/tfjs-models/savedmodel/posenet/resnet50/";var _n=[-123.15,-115.9,-103.06],Sn=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Ge(e,t),e.prototype.preprocessInput=function(t){return Object(N.add)(t,_n);},e.prototype.nameOutputResults=function(t){var e=t[0],n=t[1];return {offsets:t[2],heatmap:t[3],displacementFwd:e,displacementBwd:n};},e;}(Je);function Dn(t,e){return In(t,e)?t:Math.floor(t/e)*e+1;}function Fn(t){N.util.assert("number"==typeof t||"object"==_typeof$1(t),function(){return "Invalid inputResolution "+t+". Should be a number or an object with width and height";}),"object"==_typeof$1(t)&&(N.util.assert("number"==typeof t.width,function(){return "inputResolution.width has a value of "+t.width+" which is invalid; it must be a number";}),N.util.assert("number"==typeof t.height,function(){return "inputResolution.height has a value of "+t.height+" which is invalid; it must be a number";}));}function Tn(t,e){return Fn(t),"object"==_typeof$1(t)?[Dn(t.height,e),Dn(t.width,e)]:[Dn(t,e),Dn(t,e)];}var Nn=[8,16,32];function In(t,e){return (t-1)%e==0;}function Rn(t){return t instanceof N.Tensor?[t.shape[0],t.shape[1]]:[t.height,t.width];}function Mn(t,e){var n=e[0],r=e[1],i=Rn(t),o=i[0],a=i[1],s=r/n,u=[0,0,0,0],c=u[0],l=u[1],f=u[2],h=u[3];return a/o<s?(c=0,l=0,f=Math.round(.5*(s*o-a)),h=Math.round(.5*(s*o-a))):(c=Math.round(.5*(1/s*a-o)),l=Math.round(.5*(1/s*a-o)),f=0,h=0),{resized:Object(N.tidy)(function(){var e=function(t){return t instanceof N.Tensor?t:N.browser.fromPixels(t);}(t);return e=Object(N.pad3d)(e,[[c,l],[f,h],[0,0]]),N.image.resizeBilinear(e,[n,r]);}),padding:{top:c,left:f,right:h,bottom:l}};}function jn(t,e,n,r,i){var o=e[0],a=e[1],s=n[0],u=n[1],c=function(t,e,n,r,i){return void 0===r&&(r=0),void 0===i&&(i=0),1===n&&1===e&&0===r&&0===i?t:t.map(function(t){return function(t,e,n,r,i){return void 0===r&&(r=0),void 0===i&&(i=0),{score:t.score,keypoints:t.keypoints.map(function(t){var o=t.score,a=t.part,s=t.position;return {score:o,part:a,position:{x:s.x*n+i,y:s.y*e+r}};})};}(t,e,n,r,i);});}(t,(o+r.top+r.bottom)/s,(a+r.left+r.right)/u,-r.top,-r.left);return i?function(t,e){return e<=0?t:t.map(function(t){return function(t,e){return {score:t.score,keypoints:t.keypoints.map(function(t){var n=t.score,r=t.part,i=t.position;return {score:n,part:r,position:{x:e-1-i.x,y:i.y}};})};}(t,e);});}(c,a):c;}var Bn={architecture:"MobileNetV1",outputStride:16,multiplier:.75,inputResolution:257},Pn=["MobileNetV1","ResNet50"],Ln={MobileNetV1:[8,16,32],ResNet50:[32,16]},zn={MobileNetV1:[.5,.75,1],ResNet50:[1]},Un=[1,2,4];var Wn={flipHorizontal:!1},Vn={flipHorizontal:!1,maxDetections:5,scoreThreshold:.5,nmsRadius:20};var qn=function(){function t(t,e){(function(t){N.util.assert("number"==typeof t,function(){return "outputStride is not a number";}),N.util.assert(Nn.indexOf(t)>=0,function(){return "outputStride of "+t+" is invalid. It must be either 8, 16, or 32";});})(t.outputStride),function(t,e){N.util.assert("number"==typeof t[0]&&"number"==typeof t[1],function(){return "both resolution values must be a number but had values "+t;}),N.util.assert(In(t[0],e),function(){return "height of "+t[0]+" is invalid for output stride "+e+".";}),N.util.assert(In(t[1],e),function(){return "width of "+t[1]+" is invalid for output stride "+e+".";});}(e,t.outputStride),this.baseModel=t,this.inputResolution=e;}return t.prototype.estimateMultiplePoses=function(t,e){return void 0===e&&(e=Vn),Xe(this,void 0,void 0,function(){var n,r,i,o,a,s,u,c,l,f,h,d,p,m,g,v,y,b,x,w,k;return Ye(this,function(E){switch(E.label){case 0:return n=_Ke({},Vn,e),function(t){var e=t.maxDetections,n=t.scoreThreshold,r=t.nmsRadius;if(e<=0)throw new Error("Invalid maxDetections "+e+". Should be > 0");if(n<0||n>1)throw new Error("Invalid scoreThreshold "+n+". Should be in range [0.0, 1.0]");if(r<=0)throw new Error("Invalid nmsRadius "+r+".");}(e),r=this.baseModel.outputStride,i=this.inputResolution,o=Rn(t),a=o[0],s=o[1],u=Mn(t,i),c=u.resized,l=u.padding,f=this.baseModel.predict(c),h=f.heatmapScores,d=f.offsets,p=f.displacementFwd,m=f.displacementBwd,[4,function(t){return Xe(this,void 0,void 0,function(){return Ye(this,function(e){return [2,Promise.all(t.map(function(t){return t.buffer();}))];});});}([h,d,p,m])];case 1:return g=E.sent(),v=g[0],y=g[1],b=g[2],x=g[3],[4,xn(v,y,b,x,r,n.maxDetections,n.scoreThreshold,n.nmsRadius)];case 2:return w=E.sent(),k=jn(w,[a,s],i,l,n.flipHorizontal),h.dispose(),d.dispose(),p.dispose(),m.dispose(),c.dispose(),[2,k];}});});},t.prototype.estimateSinglePose=function(t,e){return void 0===e&&(e=Wn),Xe(this,void 0,void 0,function(){var n,r,i,o,a,s,u,c,l,f,h,d,p,m,g,v;return Ye(this,function(y){switch(y.label){case 0:return n=_Ke({},Wn,e),r=this.baseModel.outputStride,i=this.inputResolution,o=Rn(t),a=o[0],s=o[1],u=Mn(t,i),c=u.resized,l=u.padding,f=this.baseModel.predict(c),h=f.heatmapScores,d=f.offsets,p=f.displacementFwd,m=f.displacementBwd,[4,Cn(h,d,r)];case 1:return g=y.sent(),v=jn([g],[a,s],i,l,n.flipHorizontal),h.dispose(),d.dispose(),p.dispose(),m.dispose(),c.dispose(),[2,v[0]];}});});},t.prototype.estimatePoses=function(t,e){return Xe(this,void 0,void 0,function(){return Ye(this,function(n){switch(n.label){case 0:return "single-person"!==e.decodingMethod?[3,2]:[4,this.estimateSinglePose(t,e)];case 1:return [2,[n.sent()]];case 2:return [2,this.estimateMultiplePoses(t,e)];}});});},t.prototype.dispose=function(){this.baseModel.dispose();},t;}();function $n(t){return Xe(this,void 0,void 0,function(){var e,n,r,i,o,a,s;return Ye(this,function(u){switch(u.label){case 0:if(e=t.outputStride,n=t.quantBytes,r=t.multiplier,null==N)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.");return i=function(t,e,n){var r={1:"100",.75:"075",.5:"050"},i="model-stride"+t+".json";return 4===n?An+"float/"+r[e]+"/"+i:An+"quant"+n+"/"+r[e]+"/"+i;}(e,r,n),[4,Object(T.loadGraphModel)(t.modelUrl||i)];case 1:return o=u.sent(),a=new Qe(o,e),s=Tn(t.inputResolution,a.outputStride),[2,new qn(a,s)];}});});}function Hn(t){return Xe(this,void 0,void 0,function(){var e,n,r,i,o,a;return Ye(this,function(s){switch(s.label){case 0:if(e=t.outputStride,n=t.quantBytes,null==N)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.");return r=function(t,e){var n="model-stride"+t+".json";return 4===e?On+"float/"+n:On+"quant"+e+"/"+n;}(e,n),[4,Object(T.loadGraphModel)(t.modelUrl||r)];case 1:return i=s.sent(),o=new Sn(i,e),a=Tn(t.inputResolution,o.outputStride),[2,new qn(o,a)];}});});}function Gn(t){return void 0===t&&(t=Bn),Xe(this,void 0,void 0,function(){return Ye(this,function(e){return "ResNet50"===(t=function(t){if(null==(t=t||Bn).architecture&&(t.architecture="MobileNetV1"),Pn.indexOf(t.architecture)<0)throw new Error("Invalid architecture "+t.architecture+". Should be one of "+Pn);if(null==t.inputResolution&&(t.inputResolution=257),Fn(t.inputResolution),null==t.outputStride&&(t.outputStride=16),Ln[t.architecture].indexOf(t.outputStride)<0)throw new Error("Invalid outputStride "+t.outputStride+". Should be one of "+Ln[t.architecture]+" for architecture "+t.architecture+".");if(null==t.multiplier&&(t.multiplier=1),zn[t.architecture].indexOf(t.multiplier)<0)throw new Error("Invalid multiplier "+t.multiplier+". Should be one of "+zn[t.architecture]+" for architecture "+t.architecture+".");if(null==t.quantBytes&&(t.quantBytes=4),Un.indexOf(t.quantBytes)<0)throw new Error("Invalid quantBytes "+t.quantBytes+". Should be one of "+Un+" for architecture "+t.architecture+".");if("MobileNetV1"===t.architecture&&32===t.outputStride&&1!==t.multiplier)throw new Error("When using an output stride of 32, you must select 1 as the multiplier.");return t;}(t)).architecture?[2,Hn(t)]:"MobileNetV1"===t.architecture?[2,$n(t)]:[2,null];});});}function Kn(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0;}catch(t){return !1;}}();return function(){var n,r=we()(t);if(e){var i=we()(this).constructor;n=Reflect.construct(r,arguments,i);}else n=r.apply(this,arguments);return be()(this,n);};}var Xn={architecture:"MobileNetV1",outputStride:16,flipHorizontal:!1,minConfidence:.5,maxPoseDetections:5,scoreThreshold:.5,nmsRadius:20,detectionType:"multiple",inputResolution:256,multiplier:.75,quantBytes:2,modelUrl:null},Yn=function(t){ve()(n,t);var e=Kn(n);function n(t,r,i,o){var a;return b()(this,n),(a=e.call(this)).video=t,a.modelUrl=r.modelUrl||null,a.architecture=r.architecture||Xn.architecture,a.detectionType=i||r.detectionType||Xn.detectionType,a.outputStride=r.outputStride||Xn.outputStride,a.flipHorizontal=r.flipHorizontal||Xn.flipHorizontal,a.scoreThreshold=r.scoreThreshold||Xn.scoreThreshold,a.minConfidence=r.minConfidence||Xn.minConfidence,a.maxPoseDetections=r.maxPoseDetections||Xn.maxPoseDetections,a.multiplier=r.multiplier||Xn.multiplier,a.inputResolution=r.inputResolution||Xn.inputResolution,a.quantBytes=r.quantBytes||Xn.quantBytes,a.nmsRadius=r.nmsRadius||Xn.nmsRadius,a.ready=C(a.load(),o),a;}return w()(n,[{key:"load",value:function(){var t=v()(E.a.mark(function t(){var e,n=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return e="mobilenetv1"===this.architecture.toLowerCase()?{architecture:this.architecture,outputStride:this.outputStride,inputResolution:this.inputResolution,multiplier:this.multiplier,quantBytes:this.quantBytes,modelUrl:this.modelUrl}:{architecture:this.architecture,outputStride:this.outputStride,inputResolution:this.inputResolution,quantBytes:this.quantBytes},t.next=3,Gn(e);case 3:if(this.net=t.sent,!this.video){t.next=9;break;}if(0!==this.video.readyState){t.next=8;break;}return t.next=8,new Promise(function(t){n.video.onloadeddata=function(){return t();};});case 8:"single"===this.detectionType?this.singlePose():this.multiPose();case 9:return t.abrupt("return",this);case 10:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"skeleton",value:function value(t){return function(t,e){return an.reduce(function(n,r){var i=r[0],o=r[1];return function(t,e,n){return t<n||e<n;}(t[i].score,t[o].score,e)?n:(n.push([t[i],t[o]]),n);},[]);}(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.minConfidence);}},{key:"mapParts",value:function value(t){var e=JSON.parse(JSON.stringify(t));return e.keypoints.forEach(function(t){e[t.part]={x:t.position.x,y:t.position.y,confidence:t.score};}),e;}},{key:"getInput",value:function value(t){return t instanceof HTMLImageElement||t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof ImageData?t:"object"===S()(t)&&(t.elt instanceof HTMLImageElement||t.elt instanceof HTMLVideoElement||t.elt instanceof ImageData)?t.elt:"object"===S()(t)&&t.canvas instanceof HTMLCanvasElement?t.canvas:this.video;}},{key:"singlePose",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i,o,a,s=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return r=this.getInput(e),t.next=3,this.net.estimateSinglePose(r,{flipHorizontal:this.flipHorizontal});case 3:if(i=t.sent,o=this.mapParts(i),a=[{pose:o,skeleton:this.skeleton(i.keypoints)}],this.emit("pose",a),!this.video){t.next=9;break;}return t.abrupt("return",p.nextFrame().then(function(){return s.singlePose();}));case 9:return "function"==typeof n&&n(a),t.abrupt("return",a);case 11:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"multiPose",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i,o,a,s=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return r=this.getInput(e),t.next=3,this.net.estimateMultiplePoses(r,{flipHorizontal:this.flipHorizontal,maxDetections:this.maxPoseDetections,scoreThreshold:this.scoreThreshold,nmsRadius:this.nmsRadius});case 3:if(i=t.sent,o=i.map(function(t){return s.mapParts(t);}),a=o.map(function(t){return {pose:t,skeleton:s.skeleton(t.keypoints)};}),this.emit("pose",a),!this.video){t.next=9;break;}return t.abrupt("return",p.nextFrame().then(function(){return s.multiPose();}));case 9:return "function"==typeof n&&n(a),t.abrupt("return",a);case 11:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()}]),n;}($e.a),Jn=function Jn(t,e,n){var r,i={},o=n,a=null;return t instanceof HTMLVideoElement?r=t:"object"===S()(t)&&t.elt instanceof HTMLVideoElement?r=t.elt:"object"===S()(t)?i=t:"function"==typeof t&&(o=t),"object"===S()(e)?i=e:"string"==typeof e&&(a=e),"function"==typeof e&&(o=e),new Yn(r,i,a,o);},Qn=function(){function t(e){b()(this,t),this.urlPath=e.endsWith("/")?e:"".concat(e,"/"),this.variables={};}return w()(t,[{key:"loadManifest",value:function(){var t=v()(E.a.mark(function t(){var e;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,F.a.get(this.urlPath+"manifest.json");case 3:return e=t.sent,t.abrupt("return",e.data);case 7:throw t.prev=7,t.t0=t.catch(0),new Error("".concat("manifest.json"," not found at ").concat(this.urlPath,". ").concat(t.t0));case 10:case"end":return t.stop();}}},t,this,[[0,7]]);}));return function(){return t.apply(this,arguments);};}()},{key:"loadVariable",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i,o,a,s,u;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.getCheckpointManifest();case 2:if(n=t.sent,e in n){t.next=5;break;}throw new Error("Cannot load non-existent variable ".concat(e));case 5:return r=n[e],i=r.filename,o=r.shape,a=this.urlPath+i,t.prev=7,t.next=10,F.a.get(a,{responseType:"arraybuffer"});case 10:return s=t.sent,u=new Float32Array(s.data),t.abrupt("return",p.tensor(u,o));case 15:throw t.prev=15,t.t0=t.catch(7),new Error("Error loading variable ".concat(e," from URL ").concat(a,": ").concat(t.t0));case 18:case"end":return t.stop();}}},t,this,[[7,15]]);}));return function(e){return t.apply(this,arguments);};}()},{key:"getCheckpointManifest",value:function(){var t=v()(E.a.mark(function t(){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(this.checkpointManifest){t.next=4;break;}return t.next=3,this.loadManifest();case 3:this.checkpointManifest=t.sent;case 4:return t.abrupt("return",this.checkpointManifest);case 5:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"getKeys",value:function(){var t=v()(E.a.mark(function t(){var e;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.getCheckpointManifest();case 2:return e=t.sent,t.abrupt("return",Object.keys(e));case 4:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"getAllVariables",value:function(){var t=v()(E.a.mark(function t(){var e,n,r=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.getKeys();case 2:return e=t.sent,n=e.map(function(t){return r.getVariable(t);}),t.next=6,Promise.all(n);case 6:return t.abrupt("return",this.variables);case 7:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"getVariable",value:function(){var t=v()(E.a.mark(function t(e){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(this.variables[e]){t.next=4;break;}return t.next=3,this.loadVariable(e);case 3:this.variables[e]=t.sent;case 4:return t.abrupt("return",this.variables[e]);case 5:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()}]),t;}();function Zn(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0;}catch(t){return !1;}}();return function(){var n,r=we()(t);if(e){var i=we()(this).constructor;n=Reflect.construct(r,arguments,i);}else n=r.apply(this,arguments);return be()(this,n);};}var tr=200,er=function er(t){return new Promise(function(e){var n=new Image(tr,tr);n.onload=function(){return e(n);},n.src=t.toDataURL();});},nr=function(t){ve()(n,t);var e=Zn(n);function n(t,r,i){var o;return b()(this,n),(o=e.call(this,r,tr)).ready=!1,o.variableDictionary={},o.timesScalar=p.scalar(150),o.plusScalar=p.scalar(127.5),o.epsilonScalar=p.scalar(.001),o.video=null,o.ready=C(o.load(t),i),o;}return w()(n,[{key:"load",value:function(){var t=v()(E.a.mark(function t(e){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(!this.videoElt){t.next=3;break;}return t.next=3,this.loadVideo();case 3:return t.next=5,this.loadCheckpoints(e);case 5:return t.abrupt("return",this);case 6:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"loadCheckpoints",value:function(){var t=v()(E.a.mark(function t(e){var n;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return n=new Qn(e),t.next=3,n.getAllVariables();case 3:this.variables=t.sent;case 4:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"instanceNorm",value:function value(t,e){var r=this;return p.tidy(function(){var i=Y()(t.shape,3),o=i[0],a=i[1],s=i[2],u=p.moments(t,[0,1]),c=u.mean,l=u.variance,f=r.variables[n.getVariableName(e)],h=r.variables[n.getVariableName(e+1)],d=r.epsilonScalar,m=p.div(p.sub(t.asType("float32"),c),p.sqrt(p.add(l,d)));return p.add(p.mul(h,m),f).as3D(o,a,s);});}},{key:"convLayer",value:function value(t,e,r,i){var o=p.conv2d(t,this.variables[n.getVariableName(i)],[e,e],"same"),a=this.instanceNorm(o,i+1);return r?p.relu(a):a;}},{key:"residualBlock",value:function value(t,e){var n=this.convLayer(t,1,!0,e),r=this.convLayer(n,1,!1,e+3);return p.add(r,t);}},{key:"convTransposeLayer",value:function value(t,e,r,i){var o=Y()(t.shape,2),a=[o[0]*r,o[1]*r,e],s=p.conv2dTranspose(t,this.variables[n.getVariableName(i)],a,[r,r],"same"),u=this.instanceNorm(s,i+1);return p.relu(u);}},{key:"transfer",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(i=n,!(e instanceof HTMLVideoElement||e instanceof HTMLImageElement||e instanceof ImageData)){t.next=5;break;}r=e,t.next=18;break;case 5:if(!(e instanceof HTMLCanvasElement)){t.next=11;break;}return t.next=8,er(e);case 8:r=t.sent,t.next=18;break;case 11:if(!("object"===S()(e)&&e.elt instanceof HTMLCanvasElement)){t.next=17;break;}return t.next=14,er(e.elt);case 14:r=t.sent,t.next=18;break;case 17:"object"===S()(e)&&(e.elt instanceof HTMLVideoElement||e.elt instanceof HTMLImageElement||e.elt instanceof ImageData)?r=e.elt:"function"==typeof e&&(r=this.video,i=e);case 18:return t.abrupt("return",C(this.transferInternal(r),i));case 19:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"transferInternal",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return n=p.browser.fromPixels(e),r=ot(p.tidy(function(){var t=i.convLayer(n,1,!0,0),e=i.convLayer(t,2,!0,3),r=i.convLayer(e,2,!0,6),o=i.residualBlock(r,9),a=i.residualBlock(o,15),s=i.residualBlock(a,21),u=i.residualBlock(s,27),c=i.residualBlock(u,33),l=i.convTransposeLayer(c,64,2,39),f=i.convTransposeLayer(l,32,2,42),h=i.convLayer(f,1,!1,45),d=p.tanh(h),m=p.mul(i.timesScalar,d),g=p.add(i.plusScalar,m),v=p.clipByValue(g,0,255);return p.div(v,p.scalar(255));})),n.dispose(),t.next=5,p.nextFrame();case 5:return t.abrupt("return",r);case 6:case"end":return t.stop();}}},t);}));return function(e){return t.apply(this,arguments);};}()}],[{key:"getVariableName",value:function value(t){return 0===t?"Variable":"Variable_".concat(t);}}]),n;}(ae),rr=function rr(t,e,n){var r=n;"function"==typeof e&&(r=e);var i=new nr(t,e,r);return r?i:i.ready;},ir=function ir(t){for(var e,n=Math.random(),r=0,i=0;i<t.length;i+=1){if(n<(r+=t[i])){e=i;break;}}return e;},or=/cell_[0-9]|lstm_[0-9]/gi,ar=/weights|weight|kernel|kernels|w/gi,sr=/softmax/gi,ur=function(){function t(e,n){b()(this,t),this.ready=!1,this.model={},this.cellsAmount=0,this.cells=[],this.zeroState={c:[],h:[]},this.state={c:[],h:[]},this.vocab={},this.vocabSize=0,this.probabilities=[],this.defaults={seed:"a",length:20,temperature:.5,stateful:!1},this.ready=C(this.loadCheckpoints(e),n);}return w()(t,[{key:"resetState",value:function value(){this.state=this.zeroState;}},{key:"setState",value:function value(t){this.state=t;}},{key:"getState",value:function value(){return this.state;}},{key:"loadCheckpoints",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return n=new Qn(e),t.next=3,n.getAllVariables();case 3:return r=t.sent,Object.keys(r).forEach(function(t){t.match(or)?t.match(ar)?(i.model["Kernel_".concat(t.match(/[0-9]/)[0])]=r[t],i.cellsAmount+=1):i.model["Bias_".concat(t.match(/[0-9]/)[0])]=r[t]:t.match(sr)?t.match(ar)?i.model.fullyConnectedWeights=r[t]:i.model.fullyConnectedBiases=r[t]:i.model[t]=r[t];}),t.next=7,this.loadVocab(e);case 7:return t.next=9,this.initCells();case 9:return t.abrupt("return",this);case 10:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"loadVocab",value:function(){var t=v()(E.a.mark(function t(e){var n,r;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,F.a.get("".concat(e,"/vocab.json"));case 3:return n=t.sent,r=n.data,this.vocab=r,this.vocabSize=Object.keys(r).length,t.abrupt("return",this.vocab);case 10:return t.prev=10,t.t0=t.catch(0),t.abrupt("return",t.t0);case 13:case"end":return t.stop();}}},t,this,[[0,10]]);}));return function(e){return t.apply(this,arguments);};}()},{key:"initCells",value:function(){var t=v()(E.a.mark(function t(){var e,n,r,i=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:for(this.cells=[],this.zeroState={c:[],h:[]},e=p.tensor(1),n=function n(t){return function(n,r,o){return p.basicLSTMCell(e,i.model["Kernel_".concat(t)],i.model["Bias_".concat(t)],n,r,o);};},r=0;r<this.cellsAmount;r+=1){this.zeroState.c.push(p.zeros([1,this.model["Bias_".concat(r)].shape[0]/4])),this.zeroState.h.push(p.zeros([1,this.model["Bias_".concat(r)].shape[0]/4])),this.cells.push(n(r));}this.state=this.zeroState;case 6:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"generateInternal",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i,o,a,s,u,c,l,f,h,d,m,g,v,y,b,x,w,k=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.ready;case 2:n=e.seed||this.defaults.seed,r=+e.length||this.defaults.length,i=+e.temperature||this.defaults.temperature,e.stateful||this.defaults.stateful||(this.state=this.zeroState),o=[],a=Array.from(n),s=[],a.forEach(function(t){s.push(k.vocab[t]);}),u=s[0],c=[],l=0;case 14:if(!(l<a.length+r+-1)){t.next=36;break;}return t.next=17,p.buffer([1,this.vocabSize]);case 17:return (f=t.sent).set(1,0,u),h=f.toTensor(),d=void 0,this.model.embedding?(m=p.matMul(h,this.model.embedding),d=p.multiRNNCell(this.cells,m,this.state.c,this.state.h)):d=p.multiRNNCell(this.cells,h,this.state.c,this.state.h),this.state.c=d[0],this.state.h=d[1],g=this.state.h[1],v=p.matMul(g,this.model.fullyConnectedWeights),y=p.add(v,this.model.fullyConnectedBiases),b=p.div(y,p.tensor(i)),x=p.exp(b),t.next=31,p.div(x,p.sum(x)).data();case 31:c=t.sent,l<a.length-1?u=s[l+1]:(u=ir(c),o.push(u));case 33:l+=1,t.next=14;break;case 36:return w="",o.forEach(function(t){var e=Object.keys(k.vocab).find(function(e){return k.vocab[e]===t;});e&&(w+=e);}),this.probabilities=c,t.abrupt("return",{sample:w,state:this.state});case 40:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"reset",value:function value(){this.state=this.zeroState;}},{key:"generate",value:function(){var t=v()(E.a.mark(function t(e,n){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return this.reset(),t.abrupt("return",C(this.generateInternal(e),n));case 2:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"predict",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i,o,a,s,u,c,l,f,h,d=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return r=[],i=e>0?e:.1,o=this.state.h[1],a=p.matMul(o,this.model.fullyConnectedWeights),s=p.add(a,this.model.fullyConnectedBiases),u=p.div(s,p.tensor(i)),c=p.exp(u),t.next=9,p.div(c,p.sum(c)).data();case 9:return r=t.sent,l=ir(r),f=Object.keys(this.vocab).find(function(t){return d.vocab[t]===l;}),this.probabilities=r,n&&n(f),h=Object.keys(this.vocab).map(function(t){return {char:t,probability:d.probabilities[d.vocab[t]]};}),t.abrupt("return",{sample:f,probabilities:h});case 16:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"feed",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i,o,a,s,u,c,l,f=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.ready;case 2:r=Array.from(e),i=[],r.forEach(function(t){i.push(f.vocab[t]);}),o=i[0],a=0;case 7:if(!(a<r.length)){t.next=21;break;}return t.next=10,p.buffer([1,this.vocabSize]);case 10:(s=t.sent).set(1,0,o),u=s.toTensor(),c=void 0,this.model.embedding?(l=p.matMul(u,this.model.embedding),c=p.multiRNNCell(this.cells,l,this.state.c,this.state.h)):c=p.multiRNNCell(this.cells,u,this.state.c,this.state.h),this.state.c=c[0],this.state.h=c[1],o=i[a];case 18:a+=1,t.next=7;break;case 21:n&&n();case 22:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()}]),t;}(),cr=function cr(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"./",e=arguments.length>1?arguments[1]:void 0;return new ur(t,e);},lr=function(){function t(e){b()(this,t),this.urlPath=e;}return w()(t,[{key:"getAllVariables",value:function(){var t=v()(E.a.mark(function t(){var e,n,r,i,o,a,s,u,c,l;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,F.a.get(this.urlPath,{responseType:"arraybuffer"}).catch(function(t){throw new Error("No model found. Failed with error ".concat(t));});case 2:for(e=t.sent,n=e.data,r=[],i=0;i<n.byteLength;){o=new Uint8Array(n.slice(i,i+4)),i+=4,a=(o[0]<<24)+(o[1]<<16)+(o[2]<<8)+o[3],r.push(n.slice(i,i+a)),i+=a;}return s=JSON.parse(new TextDecoder("utf8").decode(r[0])),u=new Float32Array(r[1]),c=new Uint8Array(r[2]),l={},i=0,s.forEach(function(t){var e=t.shape,n=t.name,r=e.reduce(function(t,e){return t*e;}),o=c.slice(i,i+r),a=new Float32Array(o.length);o.forEach(function(t,e){a[e]=u[t];}),l[n]=p.tensor(a,e,"float32"),i+=r;}),t.abrupt("return",l);case 14:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()}]),t;}(),fr=function(){function t(e,n){b()(this,t),this.ready=C(this.loadCheckpoints(e),n);}return w()(t,[{key:"loadCheckpoints",value:function(){var t=v()(E.a.mark(function t(e){var n;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return n=new lr(e),t.next=3,n.getAllVariables();case 3:return this.variables=t.sent,t.abrupt("return",this);case 5:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"transfer",value:function(){var t=v()(E.a.mark(function t(e,n){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.abrupt("return",C(this.transferInternal(e),n));case 1:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"transferInternal",value:function(){var e=v()(E.a.mark(function e(n){var r,i=this;return E.a.wrap(function(e){for(;;){switch(e.prev=e.next){case 0:return r=ot(p.tidy(function(){var e=p.browser.fromPixels(n),r=e.dataSync(),o=p.tensor3d(r,e.shape),a=p.div(o,p.scalar(255)),s=t.preprocess(a),u=[],c=i.variables["generator/encoder_1/conv2d/kernel"],l=i.variables["generator/encoder_1/conv2d/bias"],f=t.conv2d(s,c,l);u.push(f);for(var h=2;h<=8;h+=1){var d="generator/encoder_".concat(h.toString());c=i.variables["".concat(d,"/conv2d/kernel")];var m=i.variables["".concat(d,"/conv2d/bias")],g=u[u.length-1],v=p.leakyRelu(g,.2);f=t.conv2d(v,c,m);var y=i.variables["".concat(d,"/batch_normalization/gamma")],b=i.variables["".concat(d,"/batch_normalization/beta")],x=t.batchnorm(f,y,b);u.push(x);}for(var w=8;w>=2;w-=1){var k=void 0;if(8===w)k=u[u.length-1];else {var E=w-1;k=p.concat([u[u.length-1],u[E]],2);}var C=p.relu(k),A="generator/decoder_".concat(w.toString());c=i.variables["".concat(A,"/conv2d_transpose/kernel")],l=i.variables["".concat(A,"/conv2d_transpose/bias")],f=t.deconv2d(C,c,l);var O=i.variables["".concat(A,"/batch_normalization/gamma")],_=i.variables["".concat(A,"/batch_normalization/beta")],S=t.batchnorm(f,O,_);u.push(S);}var D=p.concat([u[u.length-1],u[0]],2),F=p.relu(D);c=i.variables["generator/decoder_1/conv2d_transpose/kernel"];var T=i.variables["generator/decoder_1/conv2d_transpose/bias"];f=t.deconv2d(F,c,T),F=p.tanh(f),u.push(F);var N=u[u.length-1];return t.deprocess(N);})),e.next=3,p.nextFrame();case 3:return e.abrupt("return",r);case 4:case"end":return e.stop();}}},e);}));return function(t){return e.apply(this,arguments);};}()}],[{key:"preprocess",value:function value(t){var e=p.tidy(function(){return p.sub(p.mul(t,p.scalar(2)),p.scalar(1));});return t.dispose(),e;}},{key:"deprocess",value:function value(t){var e=p.tidy(function(){return p.div(p.add(t,p.scalar(1)),p.scalar(2));});return t.dispose(),e;}},{key:"batchnorm",value:function value(t,e,n){var r=p.tidy(function(){var r=p.moments(t,[0,1]);return p.batchNorm(t,r.mean,r.variance,n,e,1e-5);});return t.dispose(),r;}},{key:"conv2d",value:function value(t,e){var n=e.clone(),r=p.tidy(function(){return p.conv2d(t,n,[2,2],"same");});return t.dispose(),n.dispose(),r;}},{key:"deconv2d",value:function value(t,e,n){var r=p.tidy(function(){var r=p.conv2dTranspose(t,e,[2*t.shape[0],2*t.shape[1],e.shape[2]],[2,2],"same");return p.add(r,n);});return t.dispose(),e.dispose(),n.dispose(),r;}}]),t;}(),hr=function hr(t,e){var n=new fr(t,e);return e?n:n.ready;},dr=n(241),pr=new Set(["alarm_clock","ambulance","angel","ant","antyoga","backpack","barn","basket","bear","bee","beeflower","bicycle","bird","book","brain","bridge","bulldozer","bus","butterfly","cactus","calendar","castle","cat","catbus","catpig","chair","couch","crab","crabchair","crabrabbitfacepig","cruise_ship","diving_board","dog","dogbunny","dolphin","duck","elephant","elephantpig","eye","face","fan","fire_hydrant","firetruck","flamingo","flower","floweryoga","frog","frogsofa","garden","hand","hedgeberry","hedgehog","helicopter","kangaroo","key","lantern","lighthouse","lion","lionsheep","lobster","map","mermaid","monapassport","monkey","mosquito","octopus","owl","paintbrush","palm_tree","parrot","passport","peas","penguin","pig","pigsheep","pineapple","pool","postcard","power_outlet","rabbit","rabbitturtle","radio","radioface","rain","rhinoceros","rifle","roller_coaster","sandwich","scorpion","sea_turtle","sheep","skull","snail","snowflake","speedboat","spider","squirrel","steak","stove","strawberry","swan","swing_set","the_mona_lisa","tiger","toothbrush","toothpaste","tractor","trombone","truck","whale","windmill","yoga","yogabicycle","everything"]),mr={modelPath:"https://storage.googleapis.com/quickdraw-models/sketchRNN/large_models/",modelPath_large:"https://storage.googleapis.com/quickdraw-models/sketchRNN/models/",modelPath_small:"https://storage.googleapis.com/quickdraw-models/sketchRNN/models/",PATH_END:".gen.json",temperature:.65,pixelFactor:3},gr=function(){function t(e,n){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];b()(this,t);var i=e;if(this.config={temperature:.65,pixelFactor:3,modelPath:mr.modelPath,modelPath_small:mr.modelPath_small,modelPath_large:mr.modelPath_large,PATH_END:mr.PATH_END},!0===Ce.isAbsoluteURL(i)){var o=Ce.getModelPath(i);this.config.modelPath=o;}else {if(!pr.has(i))return console.log("no model found!"),this;i=(r?this.config.modelPath:this.config.modelPath_small)+i+this.config.PATH_END,this.config.modelPath=i;}this.model=new dr.SketchRNN(this.config.modelPath),this.penState=this.model.zeroInput(),this.ready=C(this.model.initialize(),n);}return w()(t,[{key:"generateInternal",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i,o,a;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return r=+e.temperature||this.config.temperature,i=+e.pixelFactor||this.config.pixelFactor,t.next=4,this.ready;case 4:return this.rnnState||(this.rnnState=this.model.zeroState(),this.model.setPixelFactor(i)),Array.isArray(n)&&n.length&&(this.rnnState=this.model.updateStrokes(n,this.rnnState)),this.rnnState=this.model.update(this.penState,this.rnnState),o=this.model.getPDF(this.rnnState,r),this.penState=this.model.sample(o),a={dx:this.penState[0],dy:this.penState[1]},1===this.penState[2]?a.pen="down":1===this.penState[3]?a.pen="up":1===this.penState[4]&&(a.pen="end"),t.abrupt("return",a);case 12:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"generate",value:function(){var t=v()(E.a.mark(function t(e,n,r){var i,o,a,s;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return "function"==typeof e?(o={},a=[],i=e):Array.isArray(e)?(o={},a=e,i=n):"function"==typeof n?(o=e||{},a=[],i=n):(o=e||{},a=n||[],i=r),s=a.map(function(t){var e="up"===t.pen?1:0,n="down"===t.pen?1:0,r="end"===t.pen?1:0;return [t.dx,t.dy,n,e,r];}),t.abrupt("return",C(this.generateInternal(o,s),i));case 3:case"end":return t.stop();}}},t,this);}));return function(e,n,r){return t.apply(this,arguments);};}()},{key:"reset",value:function value(){this.penState=this.model.zeroInput(),this.rnnState&&(this.rnnState=this.model.zeroState());}}]),t;}(),vr=function vr(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return new gr(t,e,n);},yr={modelPath:"https://raw.githubusercontent.com/zaidalyafeai/HostedModels/master/unet-128/model.json",imageSize:128,returnTensors:!1},br=function(){function t(e,n,r){b()(this,t),this.modelReady=!1,this.isPredicting=!1,this.config={modelPath:void 0!==n.modelPath?n.modelPath:yr.modelPath,imageSize:void 0!==n.imageSize?n.imageSize:yr.imageSize,returnTensors:void 0!==n.returnTensors?n.returnTensors:yr.returnTensors},this.ready=C(this.loadModel(),r);}return w()(t,[{key:"loadModel",value:function(){var t=v()(E.a.mark(function t(){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,p.loadLayersModel(this.config.modelPath);case 2:return this.model=t.sent,this.modelReady=!0,t.abrupt("return",this);case 5:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"segment",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.ready;case 2:return i=n,e instanceof HTMLImageElement||e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement||e instanceof ImageData?r=e:"object"===S()(e)&&(e.elt instanceof HTMLImageElement||e.elt instanceof HTMLVideoElement||e.elt instanceof HTMLCanvasElement||e.elt instanceof ImageData)?r=e.elt:"function"==typeof e&&(r=this.video,i=e),t.abrupt("return",C(this.segmentInternal(r),i));case 5:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"convertToP5Image",value:function(){var t=v()(E.a.mark(function t(e){var n,r;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,rt.rawToBlob(e,this.config.imageSize,this.config.imageSize);case 2:return n=t.sent,t.next=5,rt.blobToP5Image(n);case 5:return r=t.sent,t.abrupt("return",r);case 7:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"segmentInternal",value:function(){var e=v()(E.a.mark(function e(n){var r,i,o,a,s,u,c,l,f,h,d,m,g,v,y=this;return E.a.wrap(function(e){for(;;){switch(e.prev=e.next){case 0:return e.next=2,this.ready;case 2:if(!(n instanceof HTMLVideoElement)){e.next=5;break;}return e.next=5,p.nextFrame();case 5:return this.isPredicting=!0,r=p.tidy(function(){var t=p.browser.fromPixels(n).toFloat(),e=p.image.resizeBilinear(t,[y.config.imageSize,y.config.imageSize]).div(p.scalar(255)),r=e.expandDims(0),i=y.model.predict(r),o=p.ones([128,128,1]).tile([1,1,1]);e=e.concat(o,2);var a=i.squeeze([0]),s=(a=(a=a.tile([1,1,4])).sub(.3).sign().relu().neg().add(1)).mul(e),u=i.squeeze([0]),c=(u=(u=u.tile([1,1,4])).sub(.3).sign().relu()).mul(e),l=p.ones([128,128,1]).tile([1,1,1]).mul(255),f=i.squeeze([0]);return {featureMask:s,backgroundMask:c,segmentation:f=(f=p.cast(f.tile([1,1,3]).sub(.3).sign().relu().mul(255),"int32")).concat(l,2)};}),i=r.featureMask,o=r.backgroundMask,a=r.segmentation,this.isPredicting=!1,e.next=10,p.browser.toPixels(i);case 10:return s=e.sent,e.next=13,p.browser.toPixels(o);case 13:return u=e.sent,e.next=16,p.browser.toPixels(a);case 16:if(c=e.sent,l=ot(i),f=ot(o),h=t.dataURLtoBlob(l.src),d=t.dataURLtoBlob(f.src),!rt.checkP5()){e.next=31;break;}return e.next=24,this.convertToP5Image(s);case 24:return m=e.sent,e.next=27,this.convertToP5Image(u);case 27:return g=e.sent,e.next=30,this.convertToP5Image(c);case 30:v=e.sent;case 31:return this.config.returnTensors||(i.dispose(),o.dispose(),a.dispose()),e.abrupt("return",{segmentation:c,blob:{featureMask:h,backgroundMask:d},tensor:{featureMask:i,backgroundMask:o},raw:{featureMask:s,backgroundMask:u},featureMask:m,backgroundMask:g,mask:v});case 33:case"end":return e.stop();}}},e,this);}));return function(t){return e.apply(this,arguments);};}()}],[{key:"dataURLtoBlob",value:function value(t){for(var e=t.split(","),n=e[0].match(/:(.*?);/)[1],r=atob(e[1]),i=r.length,o=new Uint8Array(i);i;){o[i]=r.charCodeAt(i),i-=1;}return new Blob([o],{type:n});}}]),t;}(),xr=function xr(t,e,n){var r=null,i={},o=n;return t instanceof HTMLVideoElement?r=t:"object"===S()(t)&&t.elt instanceof HTMLVideoElement?r=t.elt:"function"==typeof t?o=t:"object"===S()(t)&&(i=t),"object"===S()(e)?i=e:"function"==typeof e&&(o=e),new br(r,i,o);},wr=function(){function t(e,n){var r=this;b()(this,t),this.ready=!1,this.model={},this.latentDim=p.randomUniform([1,16]);var i=e.split("manifest.json"),o=Y()(i,1)[0];F.a.get(e).then(function(t){var e=t.data;r.ready=C(r.loadCVAEModel(o+e.model),n),r.labels=e.labels,r.labelVector=Array(r.labels.length+1).fill(0);});}return w()(t,[{key:"loadCVAEModel",value:function(){var t=v()(E.a.mark(function t(e){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,p.loadLayersModel(e);case 2:return this.model=t.sent,t.abrupt("return",this);case 4:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"generate",value:function(){var t=v()(E.a.mark(function t(e,n){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.abrupt("return",C(this.generateInternal(e),n));case 1:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"loadAsync",value:function value(t){var e=this;return new Promise(function(n,r){e.ready||r(),loadImage(t,function(t){n(t);});});}},{key:"getBlob",value:function value(t){var e=this;return new Promise(function(n,r){e.ready||r(),t.toBlob(function(t){n(t);});});}},{key:"generateInternal",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i,o,a,s,u,c,l,f,h,d,m=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return n=p.tidy(function(){m.latentDim=p.randomUniform([1,16]);var t=m.labels.indexOf(e);if(t<0)return console.log("Wrong input of the label!"),[void 0,void 0];m.labelVector=m.labelVector.map(function(){return 0;}),m.labelVector[t+1]=1;var n=p.tensor([m.labelVector]),r=m.model.predict([m.latentDim,n]);return r.reshape([r.shape[1],r.shape[2],r.shape[3]]);}),t.next=3,p.browser.toPixels(n);case 3:for(r=t.sent,n.dispose(),i=document.createElement("canvas"),o=i.getContext("2d"),a=Y()(n.shape,2),s=a[0],u=a[1],i.width=s,i.height=u,c=o.createImageData(s,u),l=c.data,f=0;f<s*u*4;f+=1){l[f]=r[f];}return o.putImageData(c,0,0),t.t0=URL,t.next=17,this.getBlob(i);case 17:if(t.t1=t.sent,h=t.t0.createObjectURL.call(t.t0,t.t1),!rt.checkP5()){t.next=23;break;}return t.next=22,this.loadAsync(h);case 22:d=t.sent;case 23:return t.abrupt("return",{src:h,raws:r,image:d});case 24:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()}]),t;}(),kr=function kr(t,e){return new wr(t,e);},Er=function(){function t(e,n,r){b()(this,t),this.model={},this.modelPath=e,this.modelInfo={},this.modelPathPrefix="",this.modelReady=!1,this.config={returnTensors:n.returnTensors||!1},this.ready=C(this.loadModel(),r);}return w()(t,[{key:"loadModel",value:function(){var t=v()(E.a.mark(function t(){var e,n,r,i,o,a;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,F.a.get(this.modelPath);case 2:return e=t.sent,n=e.data,this.modelInfo=n,r=this.modelPath.split("manifest.json"),i=Y()(r,1),o=i[0],a=this.isAbsoluteURL(o)?this.modelInfo.model:this.modelPathPrefix+this.modelInfo.model,t.next=9,p.loadLayersModel(a);case 9:return this.model=t.sent,this.modelReady=!0,t.abrupt("return",this);case 12:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"generate",value:function(){var t=v()(E.a.mark(function t(e,n){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.ready;case 2:return t.abrupt("return",C(this.generateInternal(n),e));case 3:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"compute",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return r=p.tidy(function(){var t;if(!1===Array.isArray(n))t=p.randomNormal([1,e]);else {for(var r=p.buffer([1,e]),o=0;o<e;o+=1){r.set(n[o],0,o);}t=r.toTensor();}return i.model.predict(t).squeeze().transpose([1,2,0]).div(p.scalar(2)).add(p.scalar(.5));}),t.abrupt("return",r);case 2:case"end":return t.stop();}}},t);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"generateInternal",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i,o,a,s,u,c,l;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return n=this.modelInfo.modelLatentDim,t.next=3,this.compute(n,e);case 3:return r=t.sent,t.next=6,p.browser.toPixels(r);case 6:return i=t.sent,o=Y()(r.shape,2),a=o[0],s=o[1],t.next=10,rt.rawToBlob(i,s,a);case 10:if(u=t.sent,!rt.checkP5()){t.next=15;break;}return t.next=14,rt.blobToP5Image(u);case 14:c=t.sent;case 15:return (l={}).blob=u,l.raw=i,rt.checkP5()&&(l.image=c),this.config.returnTensors?l.tensor=r:(l.tensor=null,r.dispose()),t.abrupt("return",l);case 21:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"isAbsoluteURL",value:function value(t){return !!new RegExp("^(?:[a-z]+:)?//","i").test(t);}}]),t;}(),Cr=function Cr(t,e,n){var r,i={};if("string"!=typeof t)throw new Error('Please specify a path to a "manifest.json" file: \n\n         "models/face/manifest.json" \n\n\n         This "manifest.json" file should include:\n\n         {\n            "description": "DCGAN, human faces, 64x64",\n            "model": "https://raw.githubusercontent.com/viztopia/ml5dcgan/master/model/model.json", // "https://github.com/viztopia/ml5dcgan/blob/master/model/model.json",\n            "modelSize": 64,\n            "modelLatentDim": 128 \n         }\n         ');"function"==typeof e?r=e:"object"===S()(e)&&(i=e,r=n);var o=new Er(t,i,r);return r?o:o.ready;},Ar=n(30),Or=n.n(Ar);var _r=n(132),Sr=0;var Dr=function(){function t(e,n){b()(this,t),this.ready=C(this.loadModel(e),n);}return w()(t,[{key:"loadModel",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i,o;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(n={model:null,metadata:null},"moviereviews"!==e.toLowerCase()){t.next=6;break;}n.model="https://storage.googleapis.com/tfjs-models/tfjs/sentiment_cnn_v1/model.json",n.metadata="https://storage.googleapis.com/tfjs-models/tfjs/sentiment_cnn_v1/metadata.json",t.next=14;break;case 6:if(!0!==Ce.isAbsoluteURL(e)){t.next=12;break;}r=Ce.getModelPath(e),n.model="".concat(r,"/model.json"),n.metadata="".concat(r,"/metadata.json"),t.next=14;break;case 12:return console.error("problem loading model"),t.abrupt("return",this);case 14:return t.next=16,p.loadLayersModel(n.model);case 16:return this.model=t.sent,t.next=19,F.a.get(n.metadata);case 19:return i=t.sent,o=i.data,this.indexFrom=o.index_from,this.maxLen=o.max_len,this.wordIndex=o.word_index,this.vocabularySize=o.vocabulary_size,t.abrupt("return",this);case 26:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"predict",value:function value(t){var e=this,n=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"pre",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"pre",i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Sr;return t.map(function(t){if(t.length>e&&("pre"===r?t.splice(0,t.length-e):t.splice(e,t.length-e)),t.length<e){for(var o=[],a=0;a<e-t.length;a+=1){o.push(i);}t="pre"===n?o.concat(t):t.concat(o);}return t;});}([t.trim().toLowerCase().replace(/[.,?!]/g,"").split(" ").map(function(t){var n=e.wordIndex[t]+e.indexFrom;return n>e.vocabularySize&&(n=2),n;})],this.maxLen),r=p.tensor2d(n,[1,this.maxLen]),i=this.model.predict(r),o=i.dataSync()[0];return i.dispose(),r.dispose(),{score:o};}}]),t;}(),Fr=function Fr(t,e){return new Dr(t,e);};/**
    * @license
    * Copyright 2019 Google LLC. All Rights Reserved.
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    * http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    * =============================================================================
    */function Tr(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});}function Nr(t,e){var n,r,i,o,a={label:0,sent:function sent(){if(1&i[0])throw i[1];return i[1];},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this;}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;){try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue;}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break;}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break;}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break;}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(t,a);}catch(t){o=[6,t],r=0;}finally{n=i=0;}}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:!0};}([o,s]);};}}var Ir=[["conv2d",2],["separableConv",1],["separableConv",2],["separableConv",1],["separableConv",2],["separableConv",1],["separableConv",2],["separableConv",1],["separableConv",1],["separableConv",1],["separableConv",1],["separableConv",1],["separableConv",1],["separableConv",1]],Rr=[8,16,32];function Mr(t){N.util.assert("number"==typeof t,function(){return "outputStride is not a number";}),N.util.assert(Rr.indexOf(t)>=0,function(){return "outputStride of "+t+" is invalid. It must be either 8, 16, or 32";});}var jr={100:[["conv2d",2],["separableConv",1],["separableConv",2],["separableConv",1],["separableConv",2],["separableConv",1],["separableConv",2],["separableConv",1],["separableConv",1],["separableConv",1],["separableConv",1],["separableConv",1],["separableConv",2],["separableConv",1]],75:[["conv2d",2],["separableConv",1],["separableConv",2],["separableConv",1],["separableConv",2],["separableConv",1],["separableConv",2],["separableConv",1],["separableConv",1],["separableConv",1],["separableConv",1],["separableConv",1],["separableConv",1],["separableConv",1]],50:Ir,25:Ir};var Br=function(){function t(t,e){this.PREPROCESS_DIVISOR=Object(N.scalar)(127.5),this.ONE=Object(N.scalar)(1),this.modelWeights=t,this.convolutionDefinitions=e;}return t.prototype.predict=function(t,e){var n=this,r=Object(N.div)(t.toFloat(),this.PREPROCESS_DIVISOR),i=Object(N.sub)(r,this.ONE);return function(t,e){var n=1,r=1;return t.map(function(t,i){var o,a,s=t[0],u=t[1];return n===e?(o=1,a=r,r*=u):(o=u,a=1,n*=u),{blockId:i,convType:s,stride:o,rate:a,outputStride:n};});}(this.convolutionDefinitions,e).reduce(function(t,e){var r=e.blockId,i=e.stride,o=e.convType,a=e.rate;if("conv2d"===o)return n.conv(t,i,r);if("separableConv"===o)return n.separableConv(t,i,r,a);throw Error("Unknown conv type of "+o);},i);},t.prototype.convToOutput=function(t,e){return t.conv2d(this.weights(e),1,"same").add(this.convBias(e,!1));},t.prototype.conv=function(t,e,n){var r=this.weights("Conv2d_"+String(n));return t.conv2d(r,e,"same").add(this.convBias("Conv2d_"+String(n))).clipByValue(0,6);},t.prototype.separableConv=function(t,e,n,r){void 0===r&&(r=1);var i="Conv2d_"+String(n)+"_depthwise",o="Conv2d_"+String(n)+"_pointwise";return t.depthwiseConv2D(this.depthwiseWeights(i),e,"same","NHWC",r).add(this.depthwiseBias(i)).clipByValue(0,6).conv2d(this.weights(o),[1,1],"same").add(this.convBias(o)).clipByValue(0,6);},t.prototype.weights=function(t){return this.modelWeights.weights(t);},t.prototype.convBias=function(t,e){return void 0===e&&(e=!0),this.modelWeights.convBias(t,e);},t.prototype.depthwiseBias=function(t){return this.modelWeights.depthwiseBias(t);},t.prototype.depthwiseWeights=function(t){return this.modelWeights.depthwiseWeights(t);},t.prototype.dispose=function(){this.modelWeights.dispose();},t;}(),Pr="https://storage.googleapis.com/tfjs-models/savedmodel/",Lr={1:{url:Pr+"posenet_mobilenet_100_partmap/",architecture:jr[100]},.75:{url:Pr+"posenet_mobilenet_075_partmap/",architecture:jr[75]},.5:{url:Pr+"posenet_mobilenet_050_partmap/",architecture:jr[50]},.25:{url:Pr+"posenet_mobilenet_025_partmap/",architecture:jr[25]}};function zr(t,e){return Object(N.tidy)(function(){return t.greater(Object(N.scalar)(e)).toInt();});}function Ur(t,e){var n=e.shape,r=n[0],i=n[1],o=n[2];return Object(N.tidy)(function(){var n=function(t){var e=t.shape[2],n=t.argMax(2).reshape([-1]);return Object(N.oneHot)(n,e);}(e),a=Object(N.range)(0,o,1,"int32").expandDims(1);return function(t,e){return t.mul(e);}(n.matMul(a).toInt().reshape([r,i]).add(Object(N.scalar)(1,"int32")),t).sub(Object(N.scalar)(1,"int32"));});}var Wr=function(){function t(t){this.graphModel=t;}return t.prototype.weights=function(t){return this.getVariable("MobilenetV1/"+t+"/weights");},t.prototype.convBias=function(t,e){return this.getVariable("MobilenetV1/"+t+"/Conv2D_bias");},t.prototype.depthwiseBias=function(t){return this.getVariable("MobilenetV1/"+t+"/depthwise_bias");},t.prototype.depthwiseWeights=function(t){return this.getVariable("MobilenetV1/"+t+"/depthwise_weights");},t.prototype.getVariable=function(t){return this.graphModel.weights[""+t][0];},t.prototype.dispose=function(){this.graphModel.dispose();},t;}();function Vr(t){return t instanceof N.Tensor?t:N.browser.fromPixels(t);}function qr(t,e,n){var r=e[0],i=e[1];void 0===n&&(n=!1);var o,a,s,u,c,l,f=t.shape,h=f[0],d=f[1]/h;if(d>i/r){o=i;var p=r-(a=Math.ceil(o/d));s=0,u=0,c=Math.floor(p/2),l=r-(a+c);}else {a=r;var m=i-(o=Math.ceil(r*d));s=Math.floor(m/2),u=i-(o+s),c=0,l=0;}return {resizedAndPadded:Object(N.tidy)(function(){var e;return e=n?t.reverse(1).resizeBilinear([a,o]):t.resizeBilinear([a,o]),Object(N.pad3d)(e,[[c,l],[s,u],[0,0]]);}),paddedBy:[[c,l],[s,u]]};}function $r(t,e,n,r){var i=e[0],o=e[1],a=n[0],s=n[1],u=r[0],c=u[0],l=u[1],f=r[1],h=f[0],d=f[1];return Object(N.tidy)(function(){return function(t,e,n){var r=e[0],i=e[1],o=n[0],a=o[0],s=o[1],u=n[1],c=u[0],l=u[1],f=t.shape,h=f[0],d=f[1],p=h-(a+s),m=d-(c+l);return Object(N.tidy)(function(){return Object(N.slice3d)(t,[a,c,0],[p,m,t.shape[2]]).resizeBilinear([r,i],!0);});}(t.resizeBilinear([a,s],!0),[i,o],[[c,l],[h,d]]);});}var Hr=[353,257],Gr=function(){function t(t){this.mobileNet=t;}return t.prototype.predictForSegmentation=function(t,e){var n=this;return void 0===e&&(e=16),Mr(e),Object(N.tidy)(function(){var r=n.mobileNet.predict(t,e);return n.mobileNet.convToOutput(r,"segment_2").sigmoid();});},t.prototype.predictForPartMap=function(t,e){var n=this;return void 0===e&&(e=16),Mr(e),Object(N.tidy)(function(){var r=n.mobileNet.predict(t,e),i=n.mobileNet.convToOutput(r,"segment_2"),o=n.mobileNet.convToOutput(r,"part_heatmap_2");return {segmentScores:i.sigmoid(),partHeatmapScores:o.sigmoid()};});},t.prototype.estimatePersonSegmentationActivation=function(t,e,n){var r=this;return void 0===e&&(e=16),void 0===n&&(n=.5),Mr(e),Object(N.tidy)(function(){var i=Vr(t),o=qr(i,Hr),a=o.resizedAndPadded,s=o.paddedBy,u=r.predictForSegmentation(a,e),c=a.shape,l=c[0],f=c[1],h=i.shape;return zr($r(u,[h[0],h[1]],[l,f],s).squeeze(),n);});},t.prototype.estimatePersonSegmentation=function(t,e,n){return void 0===e&&(e=16),void 0===n&&(n=.5),Tr(this,void 0,void 0,function(){var r,i,o,a,s;return Nr(this,function(u){switch(u.label){case 0:return r=this.estimatePersonSegmentationActivation(t,e,n),i=r.shape,o=i[0],a=i[1],[4,r.data()];case 1:return s=u.sent(),r.dispose(),[2,{height:o,width:a,data:s}];}});});},t.prototype.estimatePartSegmentationActivation=function(t,e,n){var r=this;return void 0===e&&(e=16),void 0===n&&(n=.5),Mr(e),Object(N.tidy)(function(){var i=Vr(t),o=qr(i,Hr),a=o.resizedAndPadded,s=o.paddedBy,u=r.predictForPartMap(a,e),c=u.segmentScores,l=u.partHeatmapScores,f=a.shape,h=f[0],d=f[1],p=i.shape,m=p[0],g=p[1],v=$r(c,[m,g],[h,d],s),y=$r(l,[m,g],[h,d],s);return Ur(zr(v.squeeze(),n),y);});},t.prototype.estimatePartSegmentation=function(t,e,n){return void 0===e&&(e=16),void 0===n&&(n=.5),Tr(this,void 0,void 0,function(){var r,i,o,a,s;return Nr(this,function(u){switch(u.label){case 0:return r=this.estimatePartSegmentationActivation(t,e,n),i=r.shape,o=i[0],a=i[1],[4,r.data()];case 1:return s=u.sent(),r.dispose(),[2,{height:o,width:a,data:s}];}});});},t.prototype.dispose=function(){this.mobileNet.dispose();},t;}();function Kr(t){return void 0===t&&(t=.75),Tr(this,void 0,void 0,function(){var e,n;return Nr(this,function(r){switch(r.label){case 0:if(null==N)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 model.");return e=Object.keys(Lr),N.util.assert("number"==typeof t,function(){return "got multiplier type of "+_typeof$1(t)+" when it should be a number.";}),N.util.assert(e.indexOf(t.toString())>=0,function(){return "invalid multiplier value of "+t+".  No checkpoint exists for that multiplier. Must be one of "+e.join(",")+".";}),[4,Xr.load(t)];case 1:return n=r.sent(),[2,new Gr(n)];}});});}var Xr={load:function load(t){return Tr(void 0,void 0,void 0,function(){var e,n,r,i;return Nr(this,function(o){switch(o.label){case 0:return e=Lr[t],n=e.url,[4,Object(T.loadGraphModel)(n+"model.json")];case 1:return r=o.sent(),i=new Wr(r),[2,new Br(i,e.architecture)];}});});}};function Yr(t,e){void 0===e&&(e=!0);for(var n=t.width,r=t.height,i=t.data,o=new Uint8ClampedArray(n*r*4),a=0;a<r*n;++a){var s=255*(e?1-i[a]:i[a]),u=4*a;o[u+0]=0,o[u+1]=0,o[u+2]=0,o[u+3]=Math.round(s);}return new ImageData(o,n,r);}function Jr(t,e){for(var n=t.width,r=t.height,i=t.data,o=new Uint8ClampedArray(n*r*4),a=0;a<r*n;++a){var s=Math.round(i[a]),u=4*a;if(-1===s)o[u+0]=255,o[u+1]=255,o[u+2]=255,o[u+3]=255;else {var c=e[s];if(!c)throw new Error("No color could be found for part id "+s);o[u+0]=c[0],o[u+1]=c[1],o[u+2]=c[2],o[u+3]=255;}}return new ImageData(o,n,r);}var Qr={multiplier:.75,outputStride:16,segmentationThreshold:.5,palette:{leftFace:{id:0,color:[110,64,170]},rightFace:{id:1,color:[106,72,183]},rightUpperLegFront:{id:2,color:[100,81,196]},rightLowerLegBack:{id:3,color:[92,91,206]},rightUpperLegBack:{id:4,color:[84,101,214]},leftLowerLegFront:{id:5,color:[75,113,221]},leftUpperLegFront:{id:6,color:[66,125,224]},leftUpperLegBack:{id:7,color:[56,138,226]},leftLowerLegBack:{id:8,color:[48,150,224]},rightFeet:{id:9,color:[40,163,220]},rightLowerLegFront:{id:10,color:[33,176,214]},leftFeet:{id:11,color:[29,188,205]},torsoFront:{id:12,color:[26,199,194]},torsoBack:{id:13,color:[26,210,182]},rightUpperArmFront:{id:14,color:[28,219,169]},rightUpperArmBack:{id:15,color:[33,227,155]},rightLowerArmBack:{id:16,color:[41,234,141]},leftLowerArmFront:{id:17,color:[51,240,128]},leftUpperArmFront:{id:18,color:[64,243,116]},leftUpperArmBack:{id:19,color:[79,246,105]},leftLowerArmBack:{id:20,color:[96,247,97]},rightHand:{id:21,color:[115,246,91]},rightLowerArmFront:{id:22,color:[134,245,88]},leftHand:{id:23,color:[155,243,88]}},returnTensors:!1},Zr=function(){function t(e,n,r){b()(this,t),this.video=e,this.model=null,this.modelReady=!1,this.modelPath="",this.config={multiplier:n.multiplier||Qr.multiplier,outputStride:n.outputStride||Qr.outputStride,segmentationThreshold:n.segmentationThreshold||Qr.segmentationThreshold,palette:n.palette||Qr.palette,returnTensors:n.returnTensors||Qr.returnTensors},this.ready=C(this.loadModel(),r);}return w()(t,[{key:"loadModel",value:function(){var t=v()(E.a.mark(function t(){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,Kr(this.config.multiplier);case 2:return this.model=t.sent,this.modelReady=!0,t.abrupt("return",this);case 5:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"p5Color2RGB",value:function value(t){var e=/\(([^)]+)\)/.exec(t.toString("rgb"))[1].split(","),n=Y()(e,3);return [n[0],n[1],n[2]];}},{key:"convertToP5Image",value:function(){var t=v()(E.a.mark(function t(e,n,r){var i,o;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,rt.rawToBlob(e,n,r);case 2:return i=t.sent,t.next=5,rt.blobToP5Image(i);case 5:return o=t.sent,t.abrupt("return",o);case 7:case"end":return t.stop();}}},t);}));return function(e,n,r){return t.apply(this,arguments);};}()},{key:"bodyPartsSpec",value:function value(t){var e=this,n=void 0!==t||Object.keys(t).length>=24?t:this.config.palette,r=rt.p5Instance;return r&&void 0!==n&&Object.keys(n).length>=24&&Object.keys(n).forEach(function(t){n[t].color instanceof r.Color&&(n[t].color=e.p5Color2RGB(n[t].color));}),n;}},{key:"segmentWithPartsInternal",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i,o,a,s,u,c,l,f,h,d,m=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.ready;case 2:return t.next=4,p.nextFrame();case 4:if(!this.video||0!==this.video.readyState){t.next=7;break;}return t.next=7,new Promise(function(t){m.video.onloadeddata=function(){return t();};});case 7:return this.config.palette=n.palette||this.config.palette,this.config.outputStride=n.outputStride||this.config.outputStride,this.config.segmentationThreshold=n.segmentationThreshold||this.config.segmentationThreshold,t.next=12,this.model.estimatePartSegmentation(e,this.config.outputStride,this.config.segmentationThreshold);case 12:return r=t.sent,i=this.bodyPartsSpec(this.config.palette),o=Object.keys(i).map(function(t){return i[t].color;}),(a={segmentation:r,raw:{personMask:null,backgroundMask:null,partMask:null},tensor:{personMask:null,backgroundMask:null,partMask:null},personMask:null,backgroundMask:null,partMask:null,bodyParts:i}).raw.backgroundMask=Yr(r,!0),a.raw.personMask=Yr(r,!1),a.raw.partMask=Jr(r,o),s=p.tidy(function(){var t=p.browser.fromPixels(e),n=p.ones([r.height,r.width,1]).tile([1,1,1]).mul(255);t=t.concat(n,2);var i=p.tensor(r.data,[r.height,r.width,1]),o=p.tensor(r.data,[r.height,r.width,1]),s=p.tensor(Or()(a.raw.partMask.data),[r.height,r.width,4]);return {personMask:i=p.cast(i.add(.2).sign().relu().mul(t),"int32"),backgroundMask:o=p.cast(o.add(.2).sign().neg().relu().mul(t),"int32"),partMask:s=p.cast(s,"int32")};}),u=s.personMask,c=s.backgroundMask,l=s.partMask,t.next=22,p.browser.toPixels(u);case 22:return f=t.sent,t.next=25,p.browser.toPixels(c);case 25:return h=t.sent,t.next=28,p.browser.toPixels(l);case 28:if(d=t.sent,a.personMask=f,a.backgroundMask=h,a.partMask=d,!rt.checkP5()){t.next=42;break;}return t.next=35,this.convertToP5Image(f,r.width,r.height);case 35:return a.personMask=t.sent,t.next=38,this.convertToP5Image(h,r.width,r.height);case 38:return a.backgroundMask=t.sent,t.next=41,this.convertToP5Image(d,r.width,r.height);case 41:a.partMask=t.sent;case 42:return this.config.returnTensors?(a.tensor.personMask=u,a.tensor.backgroundMask=c,a.tensor.partMask=l):(u.dispose(),c.dispose(),l.dispose()),t.abrupt("return",a);case 44:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"segmentWithParts",value:function(){var t=v()(E.a.mark(function t(e,n,r){var i,o,a;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(i=this.video,a=this.config,"function"!=typeof e){t.next=7;break;}i=this.video,o=e,t.next=25;break;case 7:if(!(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData)){t.next=11;break;}i=e,t.next=25;break;case 11:if("object"!==S()(e)||!(e.elt instanceof HTMLImageElement||e.elt instanceof HTMLCanvasElement||e.elt instanceof ImageData)){t.next=15;break;}i=e.elt,t.next=25;break;case 15:if(!("object"===S()(e)&&e.canvas instanceof HTMLCanvasElement)){t.next=19;break;}i=e.canvas,t.next=25;break;case 19:if(!("object"===S()(e)&&e.elt instanceof HTMLVideoElement)){t.next=23;break;}i=e.elt,t.next=25;break;case 23:if(this.video instanceof HTMLVideoElement){t.next=25;break;}throw new Error("No input image provided. If you want to classify a video, pass the video element in the constructor. ");case 25:return "object"===S()(n)?a=n:"function"==typeof n&&(o=n),"function"==typeof r&&(o=r),t.abrupt("return",C(this.segmentWithPartsInternal(i,a),o));case 28:case"end":return t.stop();}}},t,this);}));return function(e,n,r){return t.apply(this,arguments);};}()},{key:"segmentInternal",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i,o,a,s,u,c,l=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.ready;case 2:return t.next=4,p.nextFrame();case 4:if(!this.video||0!==this.video.readyState){t.next=7;break;}return t.next=7,new Promise(function(t){l.video.onloadeddata=function(){return t();};});case 7:return this.config.outputStride=n.outputStride||this.config.outputStride,this.config.segmentationThreshold=n.segmentationThreshold||this.config.segmentationThreshold,t.next=11,this.model.estimatePersonSegmentation(e,this.config.outputStride,this.config.segmentationThreshold);case 11:return r=t.sent,(i={segmentation:r,raw:{personMask:null,backgroundMask:null},tensor:{personMask:null,backgroundMask:null},personMask:null,backgroundMask:null}).raw.backgroundMask=Yr(r,!0),i.raw.personMask=Yr(r,!1),o=p.tidy(function(){var t=p.browser.fromPixels(e),n=p.ones([r.height,r.width,1]).tile([1,1,1]).mul(255);t=t.concat(n,2);var i=p.tensor(r.data,[r.height,r.width,1]),o=p.tensor(r.data,[r.height,r.width,1]);return {personMask:i=p.cast(i.neg().add(1).mul(t),"int32"),backgroundMask:o=p.cast(o.mul(t),"int32")};}),a=o.personMask,s=o.backgroundMask,t.next=18,p.browser.toPixels(a);case 18:return u=t.sent,t.next=21,p.browser.toPixels(s);case 21:if(c=t.sent,!rt.checkP5()){t.next=31;break;}return t.next=25,this.convertToP5Image(u,r.width,r.height);case 25:return i.personMask=t.sent,t.next=28,this.convertToP5Image(c,r.width,r.height);case 28:i.backgroundMask=t.sent,t.next=33;break;case 31:i.personMask=u,i.backgroundMask=c;case 33:return this.config.returnTensors?(i.tensor.personMask=a,i.tensor.backgroundMask=s):(a.dispose(),s.dispose()),t.abrupt("return",i);case 35:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"segment",value:function(){var t=v()(E.a.mark(function t(e,n,r){var i,o,a;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(i=this.video,a=this.config,"function"!=typeof e){t.next=7;break;}i=this.video,o=e,t.next=25;break;case 7:if(!(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData)){t.next=11;break;}i=e,t.next=25;break;case 11:if("object"!==S()(e)||!(e.elt instanceof HTMLImageElement||e.elt instanceof HTMLCanvasElement||e.elt instanceof ImageData)){t.next=15;break;}i=e.elt,t.next=25;break;case 15:if(!("object"===S()(e)&&e.canvas instanceof HTMLCanvasElement)){t.next=19;break;}i=e.canvas,t.next=25;break;case 19:if(!("object"===S()(e)&&e.elt instanceof HTMLVideoElement)){t.next=23;break;}i=e.elt,t.next=25;break;case 23:if(this.video instanceof HTMLVideoElement){t.next=25;break;}throw new Error("No input image provided. If you want to classify a video, pass the video element in the constructor. ");case 25:return "object"===S()(n)?a=n:"function"==typeof n&&(o=n),"function"==typeof r&&(o=r),t.abrupt("return",C(this.segmentInternal(i,a),o));case 28:case"end":return t.stop();}}},t,this);}));return function(e,n,r){return t.apply(this,arguments);};}()}]),t;}(),ti=function ti(t,e,n){var r,i={},o=n;t instanceof HTMLVideoElement?r=t:"object"===S()(t)&&t.elt instanceof HTMLVideoElement?r=t.elt:"object"===S()(t)?i=t:"function"==typeof t&&(o=t),"object"===S()(e)?i=e:"function"==typeof e&&(o=e);var a=new Zr(r,i,o);return o?a:a.ready;},ei=function ei(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return Math.random()*(e-t)+t;},ni=function ni(){var t,e,n,r,i,o,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(o)t=e,o=!1;else {do{i=(n=ei(0,2)-1)*n+(r=ei(0,2)-1)*r;}while(i>=1);t=n*(i=Math.sqrt(-2*Math.log(i)/i)),e=r*i,o=!0;}return t*s+a;},ri=function ri(t,e){var n;if(!0===(arguments.length>2&&void 0!==arguments[2]&&arguments[2]))n=Array.from({length:e},function(){return t[Math.floor(Math.random()*t.length)];});else {if(e>t.length)throw new RangeError("Sample size must be less than or equal to array length when sampling without replacement.");n=t.map(function(t){return [t,Math.random()];}).sort(function(t,e){return t[1]<e[1]?-1:1;}).slice(0,e).map(function(t){return t[0];});}return n;},ii=function(){function t(){b()(this,t),this.isTrained=!1,this.isCompiled=!1,this.isLayered=!1,this.model=null,this.init=this.init.bind(this),this.createModel=this.createModel.bind(this),this.addLayer=this.addLayer.bind(this),this.compile=this.compile.bind(this),this.setOptimizerFunction=this.setOptimizerFunction.bind(this),this.train=this.train.bind(this),this.trainInternal=this.trainInternal.bind(this),this.predict=this.predict.bind(this),this.classify=this.classify.bind(this),this.save=this.save.bind(this),this.load=this.load.bind(this),this.init();}return w()(t,[{key:"init",value:function value(){this.createModel();}},{key:"createModel",value:function value(){switch((arguments.length>0&&void 0!==arguments[0]?arguments[0]:"sequential").toLowerCase()){case"sequential":default:return this.model=p.sequential(),this.model;}}},{key:"addLayer",value:function value(t){var e=t||{};this.model.add(e),this.model.layers.length>=2&&(this.isLayered=!0);}},{key:"compile",value:function value(t){this.model.compile(t),this.isCompiled=!0;}},{key:"setOptimizerFunction",value:function value(t,e){return e.call(this,t);}},{key:"train",value:function value(t,e){return C(this.trainInternal(t),e);}},{key:"trainInternal",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i,o,a,s,u,c;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return r=(n=e).inputs,i=n.outputs,o=n.batchSize,a=n.epochs,s=n.shuffle,u=n.validationSplit,c=n.whileTraining,t.next=6,this.model.fit(r,i,{batchSize:o,epochs:a,shuffle:s,validationSplit:u,callbacks:c});case 6:r.dispose(),i.dispose(),this.isTrained=!0;case 9:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"predictSync",value:function value(t){var e=this,n=p.tidy(function(){return e.model.predict(t);}),r=n.arraySync();return n.dispose(),t.dispose(),r;}},{key:"predict",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return n=p.tidy(function(){return i.model.predict(e);}),t.next=3,n.array();case 3:return r=t.sent,n.dispose(),e.dispose(),t.abrupt("return",r);case 7:case"end":return t.stop();}}},t);}));return function(e){return t.apply(this,arguments);};}()},{key:"classify",value:function(){var t=v()(E.a.mark(function t(e){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.abrupt("return",this.predict(e));case 1:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"classifySync",value:function value(t){return this.predictSync(t);}},{key:"save",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i,o=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:"function"==typeof e?(r="model",i=e):"string"==typeof e?(r=e,"function"==typeof n&&(i=n)):r="model",this.model.save(p.io.withSaveHandler(function(){var t=v()(E.a.mark(function t(e){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return o.weightsManifest={modelTopology:e.modelTopology,weightsManifest:[{paths:["./".concat(r,".weights.bin")],weights:e.weightSpecs}]},t.next=3,ne(e.weightData,"".concat(r,".weights.bin"),"application/octet-stream");case 3:return t.next=5,ne(JSON.stringify(o.weightsManifest),"".concat(r,".json"),"text/plain");case 5:i&&i();case 6:case"end":return t.stop();}}},t);}));return function(e){return t.apply(this,arguments);};}()));case 2:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"load",value:function(){var t=v()(E.a.mark(function t(){var e,n,r,i,o,a,s,u,c,l,f,h=arguments;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(e=h.length>0&&void 0!==h[0]?h[0]:null,n=h.length>1?h[1]:void 0,!(e instanceof FileList)){t.next=13;break;}return t.next=5,Promise.all(Array.from(e).map(function(){var t=v()(E.a.mark(function t(e){var n;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(!e.name.includes(".json")||e.name.includes("_meta")){t.next=4;break;}return t.abrupt("return",{name:"model",file:e});case 4:if(!e.name.includes(".json")||!e.name.includes("_meta.json")){t.next=11;break;}return t.next=7,e.text();case 7:return n=t.sent,t.abrupt("return",{name:"metadata",file:n});case 11:if(!e.name.includes(".bin")){t.next=13;break;}return t.abrupt("return",{name:"weights",file:e});case 13:return t.abrupt("return",{name:null,file:null});case 14:case"end":return t.stop();}}},t);}));return function(e){return t.apply(this,arguments);};}()));case 5:return r=t.sent,i=r.find(function(t){return "model"===t.name;}).file,o=r.find(function(t){return "weights"===t.name;}).file,t.next=10,p.loadLayersModel(p.io.browserFiles([i,o]));case 10:this.model=t.sent,t.next=32;break;case 13:if(!(e instanceof Object)){t.next=29;break;}return t.next=16,F.a.get(e.model,{responseType:"text"});case 16:return a=t.sent,s=JSON.stringify(a.data),u=new File([s],"model.json",{type:"application/json"}),t.next=21,F.a.get(e.weights,{responseType:"blob"});case 21:return c=t.sent,l=c.data,f=new File([l],"model.weights.bin",{type:"application/macbinary"}),t.next=26,p.loadLayersModel(p.io.browserFiles([u,f]));case 26:this.model=t.sent,t.next=32;break;case 29:return t.next=31,p.loadLayersModel(e);case 31:this.model=t.sent;case 32:return this.isCompiled=!0,this.isLayered=!0,this.isTrained=!0,n&&n(),t.abrupt("return",this.model);case 37:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"dispose",value:function value(){this.model.dispose();}},{key:"mutate",value:function value(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.1,n=arguments.length>1?arguments[1]:void 0;p.tidy(function(){for(var r=t.model.getWeights(),i=[],o=0;o<r.length;o+=1){for(var a=r[o],s=r[o].shape,u=a.dataSync().slice(),c=0;c<u.length;c+=1){Math.random()<e&&(u[c]=n?n(u[c]):Math.min(Math.max(u[c]+ni(),-1),1));}var l=p.tensor(u,s);i[o]=l;}t.model.setWeights(i);});}},{key:"crossover",value:function value(t){var e=this;return p.tidy(function(){for(var n=e.model.getWeights(),r=t.model.getWeights(),i=[],o=0;o<n.length;o+=1){for(var a=n[o],s=r[o],u=n[o].shape,c=a.dataSync().slice(),l=s.dataSync().slice(),f=0;f<c.length;f+=1){Math.random()<.5&&(c[f]=l[f]);}var h=p.tensor(c,u);i[o]=h;}e.model.setWeights(i);});}}]),t;}();function oi(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable;})),n.push.apply(n,r);}return n;}function ai(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?oi(Object(n),!0).forEach(function(e){d()(t,e,n[e]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):oi(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e));});}return t;}var si=new(function(){function t(e){b()(this,t),this.options=e||{};}return w()(t,[{key:"normalizeValue",value:function value(t,e,n){return (t-e)/(n-e);}},{key:"unnormalizeValue",value:function value(t,e,n){return t*(n-e)+e;}},{key:"getMin",value:function value(t){return t.reduce(function(t,e){return Math.min(t,e);});}},{key:"getMax",value:function value(t){return t.reduce(function(t,e){return Math.max(t,e);});}},{key:"isJsonOrString",value:function value(t){try{JSON.parse(t);}catch(t){return !1;}return !0;}},{key:"zipArrays",value:function value(t,e){return t.length!==e.length?(console.error("arrays do not have the same length"),[]):Or()(new Array(t.length).fill(null)).map(function(n,r){return ai(ai({},t[r]),e[r]);});}},{key:"createLabelsFromArrayValues",value:function value(t,e){var n;return Array.isArray(t)&&(n=t.map(function(t,n){return "".concat(e,"_").concat(n);})),n;}},{key:"formatDataAsObject",value:function value(t,e){var n={};if(Array.isArray(t))return t.forEach(function(t,r){var i=e[r];n[i]=t;}),n;if("object"===S()(t))return n=t;throw new Error("input provided is not supported or does not match your output label specifications");}},{key:"getDataType",value:function value(t){var e=S()(t);return "object"===e&&Array.isArray(t)&&(e="array"),e;}}]),t;}())();function ui(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable;})),n.push.apply(n,r);}return n;}function ci(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ui(Object(n),!0).forEach(function(e){d()(t,e,n[e]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ui(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e));});}return t;}var li=function(){function t(){b()(this,t),this.meta={inputUnits:null,outputUnits:null,inputs:{},outputs:{},isNormalized:!1},this.isMetadataReady=!1,this.isWarmedUp=!1,this.data={raw:[]},this.createMetadata=this.createMetadata.bind(this),this.getDataStats=this.getDataStats.bind(this),this.getInputMetaStats=this.getInputMetaStats.bind(this),this.getDataUnits=this.getDataUnits.bind(this),this.getInputMetaUnits=this.getInputMetaUnits.bind(this),this.getDTypesFromData=this.getDTypesFromData.bind(this),this.addData=this.addData.bind(this),this.convertRawToTensors=this.convertRawToTensors.bind(this),this.normalizeDataRaw=this.normalizeDataRaw.bind(this),this.normalizeInputData=this.normalizeInputData.bind(this),this.normalizeArray=this.normalizeArray.bind(this),this.unnormalizeArray=this.unnormalizeArray.bind(this),this.applyOneHotEncodingsToDataRaw=this.applyOneHotEncodingsToDataRaw.bind(this),this.getDataOneHot=this.getDataOneHot.bind(this),this.getInputMetaOneHot=this.getInputMetaOneHot.bind(this),this.createOneHotEncodings=this.createOneHotEncodings.bind(this),this.loadDataFromUrl=this.loadDataFromUrl.bind(this),this.loadJSON=this.loadJSON.bind(this),this.loadCSV=this.loadCSV.bind(this),this.loadBlob=this.loadBlob.bind(this),this.loadData=this.loadData.bind(this),this.saveData=this.saveData.bind(this),this.saveMeta=this.saveMeta.bind(this),this.loadMeta=this.loadMeta.bind(this),this.findEntries=this.findEntries.bind(this),this.formatRawData=this.formatRawData.bind(this),this.csvToJSON=this.csvToJSON.bind(this);}return w()(t,[{key:"createMetadata",value:function value(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.getDTypesFromData(t),this.getDataStats(t),this.getDataOneHot(t),this.getDataUnits(t,e),this.isMetadataReady=!0,ci({},this.meta);}},{key:"getDataStats",value:function value(t){var e=Object.assign({},this.meta),n=this.getInputMetaStats(t,e.inputs,"xs"),r=this.getInputMetaStats(t,e.outputs,"ys");return e.inputs=n,e.outputs=r,this.meta=ci(ci({},this.meta),e),e;}},{key:"getInputMetaStats",value:function value(t,e,n){var r=Object.assign({},e);return Object.keys(r).forEach(function(e){if("string"===r[e].dtype)r[e].min=0,r[e].max=1;else if("number"===r[e].dtype){var i=t.map(function(t){return t[n][e];});r[e].min=si.getMin(i),r[e].max=si.getMax(i);}else if("array"===r[e].dtype){var o=t.map(function(t){return t[n][e];}).flat();r[e].min=si.getMin(o),r[e].max=si.getMax(o);}}),r;}},{key:"getDataUnits",value:function value(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=null!==n?n:void 0,i=Object.assign({},this.meta);e=r||[this.getInputMetaUnits(t,i.inputs)].flat();var o=this.getInputMetaUnits(t,i.outputs);return i.inputUnits=e,i.outputUnits=o,this.meta=ci(ci({},this.meta),i),i;}},{key:"getInputMetaUnits",value:function value(t,e){var n=0,r=Object.assign({},e);return Object.entries(r).forEach(function(t){var e=t[1].dtype;if("number"===e)n+=1;else if("string"===e){var r=t[1].uniqueValues.length;n+=r;}else "array"===e&&(n=[]);}),n;}},{key:"getDTypesFromData",value:function value(t){var e=ci(ci({},this.meta),{},{inputs:{},outputs:{}}),n=t[0],r=Object.keys(n.xs),i=Object.keys(n.ys);return r.forEach(function(t){e.inputs[t]={dtype:si.getDataType(n.xs[t])};}),i.forEach(function(t){e.outputs[t]={dtype:si.getDataType(n.ys[t])};}),this.meta=e,e;}},{key:"addData",value:function value(t,e){this.data.raw.push({xs:t,ys:e});}},{key:"convertRawToTensors",value:function value(t){var e=Object.assign({},this.meta),n=t.length;return p.tidy(function(){var r=[],i=[];return t.forEach(function(t){var n=Object.keys(e.inputs).map(function(e){return t.xs[e];}).flat();r.push(n);var o=Object.keys(e.outputs).map(function(e){return t.ys[e];}).flat();i.push(o);}),{inputs:p.tensor(r.flat(),[n].concat(Or()(e.inputUnits))),outputs:p.tensor(i.flat(),[n,e.outputUnits])};});}},{key:"normalizeDataRaw",value:function value(t){var e=Object.assign({},this.meta),n=this.normalizeInputData(t,e.inputs,"xs"),r=this.normalizeInputData(t,e.outputs,"ys");return si.zipArrays(n,r);}},{key:"normalizeInputData",value:function value(t,e,n){var r=this,i=t.length,o=Object.assign({},e),a={};return Object.keys(o).forEach(function(e){var i={min:o[e].min,max:o[e].max},s=t.map(function(t){return t[n][e];});"string"===o[e].dtype?(i.legend=o[e].legend,a[e]=r.normalizeArray(s,i)):"number"===o[e].dtype?a[e]=r.normalizeArray(s,i):"array"===o[e].dtype&&(a[e]=s.map(function(t){return r.normalizeArray(t,i);}));}),Or()(new Array(i).fill(null)).map(function(t,e){var r=d()({},n,{});return Object.keys(o).forEach(function(t){r[n][t]=a[t][e];}),r;});}},{key:"normalizeArray",value:function value(t,e){var n=e.min,r=e.max;if(e.legend)return t.map(function(t){return e.legend[t]?e.legend[t]:t;});if(t.every(function(t){return "number"==typeof t;}))return t.map(function(t){return si.normalizeValue(t,n,r);});throw new Error("error in inputArray of normalizeArray() function");}},{key:"unnormalizeArray",value:function value(t,e){var n=e.min,r=e.max;if(e.legend)return t.map(function(t){var n;return Object.entries(e.legend).forEach(function(e){var r=e[0],i=e[1];t.map(function(t,e){return t===i[e];}).every(function(t){return !0===t;})&&(n=r);}),n;});if(t.every(function(t){return "number"==typeof t;}))return t.map(function(t){return si.unnormalizeValue(t,n,r);});throw new Error("error in inputArray of normalizeArray() function");}},{key:"applyOneHotEncodingsToDataRaw",value:function value(t){var e=Object.assign({},this.meta);return t.map(function(t){var n=ci({},t.xs),r=ci({},t.ys);return Object.keys(e.inputs).forEach(function(r){e.inputs[r].legend&&(n[r]=e.inputs[r].legend[t.xs[r]]);}),Object.keys(e.outputs).forEach(function(n){e.outputs[n].legend&&(r[n]=e.outputs[n].legend[t.ys[n]]);}),{xs:n,ys:r};});}},{key:"getDataOneHot",value:function value(t){var e=Object.assign({},this.meta),n=this.getInputMetaOneHot(t,e.inputs,"xs"),r=this.getInputMetaOneHot(t,e.outputs,"ys");return e.inputs=n,e.outputs=r,this.meta=ci(ci({},this.meta),e),e;}},{key:"getInputMetaOneHot",value:function value(t,e,n){var r=this,i=Object.assign({},e);return Object.entries(i).forEach(function(e){var o=e[0];if("string"===e[1].dtype){var a=Or()(new Set(t.map(function(t){return t[n][o];}))),s=r.createOneHotEncodings(a);i[o]=ci(ci({},i[o]),s);}}),i;}},{key:"createOneHotEncodings",value:function value(t){return p.tidy(function(){var e={uniqueValues:t,legend:{}},n=t,r=n.map(function(t,e){return e;}),i=p.oneHot(p.tensor1d(r,"int32"),n.length).arraySync();return n.forEach(function(t,n){e.legend[t]=i[n];}),e;});}},{key:"loadDataFromUrl",value:function(){var t=v()(E.a.mark(function t(e,n,r){var i;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(t.prev=0,!e.endsWith(".csv")){t.next=7;break;}return t.next=4,this.loadCSV(e,n,r);case 4:i=t.sent,t.next=20;break;case 7:if(!e.endsWith(".json")){t.next=13;break;}return t.next=10,this.loadJSON(e,n,r);case 10:i=t.sent,t.next=20;break;case 13:if(!e.includes("blob")){t.next=19;break;}return t.next=16,this.loadBlob(e,n,r);case 16:i=t.sent,t.next=20;break;case 19:throw new Error("Not a valid data format. Must be csv or json");case 20:return t.abrupt("return",i);case 23:throw t.prev=23,t.t0=t.catch(0),console.error(t.t0),new Error(t.t0);case 27:case"end":return t.stop();}}},t,this,[[0,23]]);}));return function(e,n,r){return t.apply(this,arguments);};}()},{key:"loadJSON",value:function(){var t=v()(E.a.mark(function t(e,n,r){var i,o,a,s;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(t.prev=0,!(e instanceof Object)){t.next=5;break;}i=Object.assign({},e),t.next=10;break;case 5:return t.next=7,F.a.get(e);case 7:o=t.sent,a=o.data,i=a;case 10:return s=this.formatRawData(i,n,r),t.abrupt("return",s);case 14:throw t.prev=14,t.t0=t.catch(0),console.error("error loading json"),new Error(t.t0);case 18:case"end":return t.stop();}}},t,this,[[0,14]]);}));return function(e,n,r){return t.apply(this,arguments);};}()},{key:"loadCSV",value:function(){var t=v()(E.a.mark(function t(e,n,r){var i,o,a,s;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.prev=0,i=p.data.csv(e),t.next=4,i.toArray();case 4:return o=t.sent,a={entries:o},s=this.formatRawData(a,n,r),t.abrupt("return",s);case 10:throw t.prev=10,t.t0=t.catch(0),console.error("error loading csv",t.t0),new Error(t.t0);case 14:case"end":return t.stop();}}},t,this,[[0,10]]);}));return function(e,n,r){return t.apply(this,arguments);};}()},{key:"loadBlob",value:function(){var t=v()(E.a.mark(function t(e,n,r){var i,o,a,s,u,c;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,F.a.get(e);case 3:if(i=t.sent,o=i.data,a=o,!si.isJsonOrString(a)){t.next=13;break;}return u=JSON.parse(a),t.next=10,this.loadJSON(u,n,r);case 10:s=t.sent,t.next=17;break;case 13:return c=this.csvToJSON(a),t.next=16,this.loadJSON(c,n,r);case 16:s=t.sent;case 17:return t.abrupt("return",s);case 20:throw t.prev=20,t.t0=t.catch(0),console.log("mmm might be passing in a string or something!",t.t0),new Error(t.t0);case 24:case"end":return t.stop();}}},t,this,[[0,20]]);}));return function(e,n,r){return t.apply(this,arguments);};}()},{key:"loadData",value:function(){var t=v()(E.a.mark(function t(){var e,n,r,i,o,a,s=arguments;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(e=s.length>0&&void 0!==s[0]?s[0]:null,n=s.length>1?s[1]:void 0,t.prev=2,"string"==typeof e){t.next=17;break;}if(i=e[0],new FileReader().readAsText(i),!i.name.includes(".json")){t.next=14;break;}return t.next=10,i.text();case 10:o=t.sent,r=JSON.parse(o),t.next=15;break;case 14:console.log('data must be a json object containing an array called "data" or "entries');case 15:t.next=22;break;case 17:return t.next=19,F.a.get(e,{responseType:"text"});case 19:r=t.sent,a=JSON.stringify(r.data),si.isJsonOrString(a)?r=JSON.parse(a):console.log("Whoops! something went wrong. Either this kind of data is not supported yet or there is an issue with .loadData");case 22:this.data.raw=this.findEntries(r),!this.data.raw.length>0&&console.log('data must be a json object containing an array called "data" '),n&&n(),t.next=30;break;case 27:throw t.prev=27,t.t0=t.catch(2),new Error(t.t0);case 30:case"end":return t.stop();}}},t,this,[[2,27]]);}));return function(){return t.apply(this,arguments);};}()},{key:"saveData",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i,o,a,s;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return n=new Date(),r="".concat(String(n.getFullYear()),"-").concat(String(n.getMonth()+1),"-").concat(String(n.getDate())),i="".concat(String(n.getHours()),"-").concat(String(n.getMinutes()),"-").concat(String(n.getSeconds())),o="".concat(r,"_").concat(i),a=o,e&&(a=e),s={data:this.data.raw},t.next=9,ne(JSON.stringify(s),"".concat(a,".json"),"text/plain");case 9:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"saveMeta",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return "function"==typeof e?(r="model",i=e):"string"==typeof e?(r=e,"function"==typeof n&&(i=n)):r="model",t.next=3,ne(JSON.stringify(this.meta),"".concat(r,"_meta.json"),"text/plain");case 3:i&&i();case 4:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"loadMeta",value:function(){var t=v()(E.a.mark(function t(){var e,n,r,i,o,a,s,u=arguments;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(e=u.length>0&&void 0!==u[0]?u[0]:null,n=u.length>1?u[1]:void 0,!(e instanceof FileList)){t.next=10;break;}return t.next=5,Promise.all(Array.from(e).map(function(){var t=v()(E.a.mark(function t(e){var n;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(!e.name.includes(".json")||e.name.includes("_meta")){t.next=4;break;}return t.abrupt("return",{name:"model",file:e});case 4:if(!e.name.includes(".json")||!e.name.includes("_meta.json")){t.next=11;break;}return t.next=7,e.text();case 7:return n=t.sent,t.abrupt("return",{name:"metadata",file:n});case 11:if(!e.name.includes(".bin")){t.next=13;break;}return t.abrupt("return",{name:"weights",file:e});case 13:return t.abrupt("return",{name:null,file:null});case 14:case"end":return t.stop();}}},t);}));return function(e){return t.apply(this,arguments);};}()));case 5:r=t.sent,i=JSON.parse(r.find(function(t){return "metadata"===t.name;}).file),this.meta=i,t.next=25;break;case 10:if(!(e instanceof Object)){t.next=19;break;}return t.next=13,F.a.get(e.metadata,{responseType:"text"});case 13:o=t.sent,o=JSON.stringify(o.data),o=JSON.parse(o),this.meta=o,t.next=25;break;case 19:return a="".concat(e.substring(0,e.lastIndexOf("/")),"/model_meta.json"),t.next=22,F.a.get(a);case 22:s=(s=t.sent).data,this.meta=s;case 25:return this.isMetadataReady=!0,this.isWarmedUp=!0,n&&n(),t.abrupt("return",this.meta);case 29:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"formatRawData",value:function value(t,e,n){var r=this.findEntries(t);!r.length>0&&console.log("your data must be contained in an array in \n\n        a property called 'entries' or 'data' of your json object");var i=r.map(function(t,r){var i={xs:{},ys:{}};return e.forEach(function(e){void 0!==t[e]?i.xs[e]=t[e]:console.error("the input label ".concat(e," does not exist at row ").concat(r));}),n.forEach(function(e){void 0!==t[e]?i.ys[e]=t[e]:console.error("the output label ".concat(e," does not exist at row ").concat(r));}),i;});return this.data.raw=i,i;}},{key:"csvToJSON",value:function value(t){for(var e=t.split("\n"),n=[],r=e[0].split(","),i=function i(t){var i={},o=e[t].split(",");r.forEach(function(t,e){i[t]=o[e];}),n.push(i);},o=1;o<e.length;o+=1){i(o);}return {entries:n};}},{key:"findEntries",value:function value(t){var e=this,n=Object.assign({},t);return n.entries&&n.entries instanceof Array?n.entries:n.data&&n.data instanceof Array?n.data:(Object.keys(n).forEach(function(t){if("object"===S()(n[t]))return e.findEntries(n[t]);}),n);}},{key:"getData",value:function value(){return this.data.raw;}}]),t;}();function fi(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable;})),n.push.apply(n,r);}return n;}var hi=function(){function t(){b()(this,t),this.config={height:300};}return w()(t,[{key:"modelSummary",value:function value(t,e){var n=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?fi(Object(n),!0).forEach(function(e){d()(t,e,n[e]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):fi(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e));});}return t;}({},t);m.show.modelSummary(n,e);}},{key:"scatterplot",value:function value(t,e,n){var r=n.map(function(n){return {x:n.xs[t],y:n.ys[e]};}),i={xLabel:"X",yLabel:"Y",height:this.config.height};m.render.scatterplot({name:"debug mode"},r,i);}},{key:"scatterplotAll",value:function value(t,e,n){var r=[];t.forEach(function(t){e.forEach(function(e){var i=n.map(function(n){return {x:n.xs[t],y:n.ys[e]};});r=[].concat(Or()(r),Or()(i));});});var i={xLabel:"X",yLabel:"Y",height:this.config.height};m.render.scatterplot({name:"debug mode"},r,i);}},{key:"barchart",value:function value(t,e,n){var r=n.map(function(n){return {value:n.xs[t],index:n.ys[e]};}),i={xLabel:"label",yLabel:"value",height:this.config.height};console.log(i);m.render.barchart({name:"Bar chart"},r);}},{key:"trainingVis",value:function value(){return m.show.fitCallbacks({name:"Training Performance"},["loss","accuracy"],{height:this.config.height,callbacks:["onEpochEnd"]});}}]),t;}();function di(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable;})),n.push.apply(n,r);}return n;}function pi(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?di(Object(n),!0).forEach(function(e){d()(t,e,n[e]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):di(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e));});}return t;}var mi={inputs:[],outputs:[],dataUrl:null,modelUrl:null,layers:[],task:null,debug:!1,learningRate:.2,hiddenUnits:16,noTraining:!1},gi=function(){function t(e,n){b()(this,t),this.callback=n,"imageClassification"===e.task&&(mi.learningRate=.02),this.options=pi(pi({},mi),e)||mi,this.neuralNetwork=new ii(),this.neuralNetworkData=new li(),this.neuralNetworkVis=new hi(),this.data={training:[]},this.ready=!1,this.init=this.init.bind(this),this.addData=this.addData.bind(this),this.loadDataFromUrl=this.loadDataFromUrl.bind(this),this.loadDataInternal=this.loadDataInternal.bind(this),this.createMetaData=this.createMetaData.bind(this),this.prepareForTraining=this.prepareForTraining.bind(this),this.normalizeData=this.normalizeData.bind(this),this.normalizeInput=this.normalizeInput.bind(this),this.searchAndFormat=this.searchAndFormat.bind(this),this.formatInputItem=this.formatInputItem.bind(this),this.convertTrainingDataToTensors=this.convertTrainingDataToTensors.bind(this),this.formatInputsForPrediction=this.formatInputsForPrediction.bind(this),this.formatInputsForPredictionAll=this.formatInputsForPredictionAll.bind(this),this.isOneHotEncodedOrNormalized=this.isOneHotEncodedOrNormalized.bind(this),this.train=this.train.bind(this),this.trainInternal=this.trainInternal.bind(this),this.addLayer=this.addLayer.bind(this),this.createNetworkLayers=this.createNetworkLayers.bind(this),this.addDefaultLayers=this.addDefaultLayers.bind(this),this.compile=this.compile.bind(this),this.predict=this.predict.bind(this),this.predictMultiple=this.predictMultiple.bind(this),this.classify=this.classify.bind(this),this.classifyMultiple=this.classifyMultiple.bind(this),this.predictInternal=this.predictInternal.bind(this),this.classifyInternal=this.classifyInternal.bind(this),this.saveData=this.saveData.bind(this),this.loadData=this.loadData.bind(this),this.save=this.save.bind(this),this.load=this.load.bind(this),this.dispose=this.dispose.bind(this),this.mutate=this.mutate.bind(this),this.crossover=this.crossover.bind(this),this.init(this.callback);}return w()(t,[{key:"init",value:function value(t){!0===this.options.noTraining&&this.createLayersNoTraining(),null!==this.options.dataUrl?this.ready=this.loadDataFromUrl(this.options,t):null!==this.options.modelUrl?this.ready=this.load(this.options.modelUrl,t):this.ready=!0;}},{key:"createLayersNoTraining",value:function value(){var t=this.options,e=t.inputs,n=t.outputs;if("classification"===t.task)for(var r=0;r<n.length;r+=1){var i=new Array(e).fill(0);this.addData(i,[n[r]]);}else {var o=new Array(e).fill(0),a=new Array(n).fill(0);this.addData(o,a);}this.neuralNetworkData.createMetadata(this.neuralNetworkData.data.raw),this.addDefaultLayers(this.options.task,this.neuralNetworkData.meta);}},{key:"copy",value:function value(){var e=this,n=new t(this.options);return p.tidy(function(){for(var t=e.neuralNetwork.model.getWeights(),r=[],i=0;i<t.length;i+=1){r[i]=t[i].clone();}return n.neuralNetwork.model.setWeights(r),n;});}},{key:"addData",value:function value(t,e){var n,r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=this.options,a=o.inputs,s=o.outputs;if(null!==i?(n=i.inputLabels,r=i.outputLabels):a.length>0&&s.length>0?(a.every(function(t){return "string"==typeof t;})&&(n=a),s.every(function(t){return "string"==typeof t;})&&(r=s)):"object"===S()(t)&&"object"===S()(e)?(n=Object.keys(t),r=Object.keys(e)):(n=si.createLabelsFromArrayValues(t,"input"),r=si.createLabelsFromArrayValues(e,"output")),!(n instanceof Array))throw new Error("inputLabels must be an array");if(!(r instanceof Array))throw new Error("outputLabels must be an array");var u=this.searchAndFormat(t),c=si.formatDataAsObject(u,n),l=si.formatDataAsObject(e,r);this.neuralNetworkData.addData(c,l);}},{key:"loadDataFromUrl",value:function value(t,e){return C(this.loadDataInternal(t),e);}},{key:"loadDataInternal",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i,o;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return n=e.dataUrl,r=e.inputs,i=e.outputs,t.next=3,this.neuralNetworkData.loadDataFromUrl(n,r,i);case 3:o=t.sent,this.createMetadata(o),this.prepareForTraining(o);case 6:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"createMetaData",value:function value(t){var e,n=this.options.inputs;Array.isArray(n)&&n.length>0&&(e=n.every(function(t){return "number"==typeof t;})&&n.length>0?n:null),this.neuralNetworkData.createMetadata(t,e);}},{key:"prepareForTraining",value:function value(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=null===t?this.neuralNetworkData.data.raw:t,n=this.neuralNetworkData.applyOneHotEncodingsToDataRaw(e);return this.data.training=n,this.neuralNetworkData.isWarmedUp=!0,n;}},{key:"normalizeData",value:function value(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=null===t?this.neuralNetworkData.data.raw:t;this.neuralNetworkData.isMetadataReady||this.createMetaData(e),this.neuralNetworkData.isWarmedUp||this.prepareForTraining(e);var n=this.neuralNetworkData.normalizeDataRaw(e);return this.data.training=n,this.neuralNetworkData.meta.isNormalized=!0,n;}},{key:"normalizeInput",value:function value(t,e,n){var r=n[e],i=r.min,o=r.max;return si.normalizeValue(t,i,o);}},{key:"searchAndFormat",value:function value(t){var e,n=this;if(Array.isArray(t))e=t.map(function(t){return n.formatInputItem(t);});else if("object"===S()(t)){var r=Object.assign({},t);Object.keys(t).forEach(function(e){var i=t[e];r[e]=n.formatInputItem(i);}),e=r;}return e;}},{key:"formatInputItem",value:function value(t){var e;return ct(t)?e=t:"object"===S()(t)&&ct(t.elt)?e=t.elt:"object"===S()(t)&&ct(t.canvas)&&(e=t.canvas),e?lt(e):t;}},{key:"convertTrainingDataToTensors",value:function value(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=null===t?this.data.training:t,r=null===e?this.neuralNetworkData.meta:e;return this.neuralNetworkData.convertRawToTensors(n,r);}},{key:"formatInputsForPrediction",value:function value(t,e,n){var r=this,i=[];return t instanceof Array?i=n.map(function(n,i){return r.isOneHotEncodedOrNormalized(t[i],n,e.inputs);}):t instanceof Object&&(i=n.map(function(n){return r.isOneHotEncodedOrNormalized(t[n],n,e.inputs);})),i=i.flat();}},{key:"formatInputsForPredictionAll",value:function value(t,e,n){var r,i=this;return t instanceof Array&&t.every(function(t){return Array.isArray(t);})?(r=t.map(function(t){return i.formatInputsForPrediction(t,e,n);}),p.tensor(r,[t.length,n.length])):(r=this.formatInputsForPrediction(t,e,n),p.tensor([r]));}},{key:"isOneHotEncodedOrNormalized",value:function value(t,e,n){var r,i=t,o=e;return "number"!=typeof t?r=n[o].legend[i]:(r=t,this.neuralNetworkData.meta.isNormalized&&(r=this.normalizeInput(t,o,n))),r;}},{key:"train",value:function value(t,e,n){var r,i,o;"object"===S()(t)&&"function"==typeof e&&"function"==typeof n?(r=t,i=e,o=n):"object"===S()(t)&&"function"==typeof e?(r=t,i=null,o=e):"function"==typeof t&&"function"==typeof e?(r={},i=t,o=e):(r={},i=null,o=t),this.trainInternal(r,i,o);}},{key:"trainInternal",value:function value(t,e,n){var r=pi({epochs:10,batchSize:32,validationSplit:.1,whileTraining:null},t);if(!0===this.options.debug||"true"===this.options.debug?r.whileTraining=[this.neuralNetworkVis.trainingVis(),{onEpochEnd:e}]:r.whileTraining=[{onEpochEnd:e}],this.neuralNetworkData.isMetadataReady||this.createMetaData(this.neuralNetworkData.data.raw),this.neuralNetworkData.isWarmedUp||this.prepareForTraining(this.neuralNetworkData.data.raw),!r.inputs&&!r.outputs){var i=this.convertTrainingDataToTensors(),o=i.inputs,a=i.outputs;r.inputs=o,r.outputs=a;}this.neuralNetwork.isLayered||(this.options.layers=this.createNetworkLayers(this.options.layers,this.neuralNetworkData.meta)),this.neuralNetwork.isLayered||(this.options.layers=this.addDefaultLayers(this.options.task,this.neuralNetworkData.meta)),this.neuralNetwork.isCompiled||this.compile(),this.neuralNetwork.train(r,n);}},{key:"addLayer",value:function value(t){this.neuralNetwork.addLayer(t);}},{key:"createNetworkLayers",value:function value(t,e){var n=this,r=Or()(t),i=Object.assign({},e),o=i.inputUnits,a=i.outputUnits,s=r.length;if(!(r.length>=2))return !1;r[0].inputShape=r[0].inputShape?r[0].inputShape:o;var u=r[s-1];return u.units=u.units?u.units:a,r.forEach(function(t){n.addLayer(p.layers[t.type](t));}),r;}},{key:"addDefaultLayers",value:function value(t,e){var n;switch(t.toLowerCase()){case"classification":return n=[{type:"dense",units:this.options.hiddenUnits,activation:"relu"},{type:"dense",activation:"softmax"}],this.createNetworkLayers(n,e);case"regression":return n=[{type:"dense",units:this.options.hiddenUnits,activation:"relu"},{type:"dense",activation:"sigmoid"}],this.createNetworkLayers(n,e);case"imageclassification":return n=[{type:"conv2d",filters:8,kernelSize:5,strides:1,activation:"relu",kernelInitializer:"varianceScaling"},{type:"maxPooling2d",poolSize:[2,2],strides:[2,2]},{type:"conv2d",filters:16,kernelSize:5,strides:1,activation:"relu",kernelInitializer:"varianceScaling"},{type:"maxPooling2d",poolSize:[2,2],strides:[2,2]},{type:"flatten"},{type:"dense",kernelInitializer:"varianceScaling",activation:"softmax"}],this.createNetworkLayers(n,e);default:return console.log("no imputUnits or outputUnits defined"),n=[{type:"dense",units:this.options.hiddenUnits,activation:"relu"},{type:"dense",activation:"sigmoid"}],this.createNetworkLayers(n,e);}}},{key:"compile",value:function value(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=null===e?this.options.learningRate:e,r={};null!==t?r=pi({},t):"classification"===this.options.task||"imageClassification"===this.options.task?r={loss:"categoricalCrossentropy",optimizer:p.train.sgd,metrics:["accuracy"]}:"regression"===this.options.task&&(r={loss:"meanSquaredError",optimizer:p.train.adam,metrics:["accuracy"]}),r.optimizer=r.optimizer?this.neuralNetwork.setOptimizerFunction(n,r.optimizer):this.neuralNetwork.setOptimizerFunction(n,p.train.sgd),this.neuralNetwork.compile(r),this.options.debug&&this.neuralNetworkVis.modelSummary({name:"Model Summary"},this.neuralNetwork.model);}},{key:"predictSync",value:function value(t){return this.predictSyncInternal(t);}},{key:"predict",value:function value(t,e){return C(this.predictInternal(t),e);}},{key:"predictMultiple",value:function value(t,e){return C(this.predictInternal(t),e);}},{key:"classifySync",value:function value(t){return this.classifySyncInternal(t);}},{key:"classify",value:function value(t,e){return C(this.classifyInternal(t),e);}},{key:"classifyMultiple",value:function value(t,e){return C(this.classifyInternal(t),e);}},{key:"predictSyncInternal",value:function value(t){var e=this.neuralNetworkData.meta,n=Object.keys(e.inputs),r=this.formatInputsForPredictionAll(t,e,n),i=this.neuralNetwork.predictSync(r);if(r.dispose(),null!==e){var o=Object.keys(e.outputs),a=i.map(function(t){return o.map(function(n,r){var i,a,s;if(e.isNormalized){var u=e.outputs[n],c=u.min,l=u.max;a=si.unnormalizeValue(t[r],c,l),s=t[r];}else a=t[r];var f=(i={},d()(i,o[r],a),d()(i,"label",n),d()(i,"value",a),i);return s&&(f.unNormalizedValue=s),f;});});return a.length<2?a[0]:a;}return i;}},{key:"predictInternal",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i,o,a,s;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return n=this.neuralNetworkData.meta,r=Object.keys(n.inputs),i=this.formatInputsForPredictionAll(e,n,r),t.next=5,this.neuralNetwork.predict(i);case 5:if(o=t.sent,i.dispose(),null===n){t.next=13;break;}if(a=Object.keys(n.outputs),!((s=o.map(function(t){return a.map(function(e,r){var i,o,s;if(n.isNormalized){var u=n.outputs[e],c=u.min,l=u.max;o=si.unnormalizeValue(t[r],c,l),s=t[r];}else o=t[r];var f=(i={},d()(i,a[r],o),d()(i,"label",e),d()(i,"value",o),i);return s&&(f.unNormalizedValue=s),f;});})).length<2)){t.next=12;break;}return t.abrupt("return",s[0]);case 12:return t.abrupt("return",s);case 13:return t.abrupt("return",o);case 14:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"classifySyncInternal",value:function value(t){var e,n=this.neuralNetworkData.meta,r=Object.keys(n.inputs);if("imageClassification"===this.options.task){if(e=this.searchAndFormat(t),e=Array.isArray(e)?e.flat():e[r[0]],n.isNormalized){var i=n.inputs[r[0]],o=i.min,a=i.max;e=this.neuralNetworkData.normalizeArray(Array.from(e),{min:o,max:a});}else e=Array.from(e);e=p.tensor([e],[1].concat(Or()(n.inputUnits)));}else e=this.formatInputsForPredictionAll(t,n,r);var s=this.neuralNetwork.classifySync(e);if(e.dispose(),null!==n){var u=Object.keys(n.outputs)[0],c=Object.entries(n.outputs[u].legend),l=s.map(function(t){return c.map(function(e,n){var r;return r={},d()(r,e[0],t[n]),d()(r,"label",e[0]),d()(r,"confidence",t[n]),r;}).sort(function(t,e){return e.confidence-t.confidence;});});return l.length<2?l[0]:l;}return s;}},{key:"classifyInternal",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i,o,a,s,u,c,l,f;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return n=this.neuralNetworkData.meta,r=Object.keys(n.inputs),"imageClassification"===this.options.task?(i=this.searchAndFormat(e),i=Array.isArray(i)?i.flat():i[r[0]],n.isNormalized?(o=n.inputs[r[0]],a=o.min,s=o.max,i=this.neuralNetworkData.normalizeArray(Array.from(i),{min:a,max:s})):i=Array.from(i),i=p.tensor([i],[1].concat(Or()(n.inputUnits)))):i=this.formatInputsForPredictionAll(e,n,r),t.next=5,this.neuralNetwork.classify(i);case 5:if(u=t.sent,i.dispose(),null===n){t.next=14;break;}if(c=Object.keys(n.outputs)[0],l=Object.entries(n.outputs[c].legend),!((f=u.map(function(t){return l.map(function(e,n){var r;return r={},d()(r,e[0],t[n]),d()(r,"label",e[0]),d()(r,"confidence",t[n]),r;}).sort(function(t,e){return e.confidence-t.confidence;});})).length<2)){t.next=13;break;}return t.abrupt("return",f[0]);case 13:return t.abrupt("return",f);case 14:return t.abrupt("return",u);case 15:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"saveData",value:function value(t){this.neuralNetworkData.saveData(t);}},{key:"loadData",value:function(){var t=v()(E.a.mark(function t(){var e,n,r=arguments;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:e=r.length>0&&void 0!==r[0]?r[0]:null,n=r.length>1?r[1]:void 0,this.neuralNetworkData.loadData(e,n);case 3:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"save",value:function value(t,e){var n,r,i=this;"function"==typeof t?(n="model",r=t):"string"==typeof t?(n=t,"function"==typeof e&&(r=e)):n="model",this.neuralNetwork.save(n,function(){i.neuralNetworkData.saveMeta(n,r);});}},{key:"load",value:function(){var t=v()(E.a.mark(function t(){var e,n,r,i=this,o=arguments;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:e=o.length>0&&void 0!==o[0]?o[0]:null,(n=o.length>1?o[1]:void 0)&&(r=n),this.neuralNetwork.load(e,function(){return i.neuralNetworkData.loadMeta(e,r),i.neuralNetwork.model;});case 4:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"dispose",value:function value(){this.neuralNetwork.dispose();}},{key:"mutate",value:function value(t,e){this.neuralNetwork.mutate(t,e);}},{key:"crossover",value:function value(t){var e=this.copy();return e.neuralNetwork.crossover(t.neuralNetwork),e;}}]),t;}(),vi=function vi(t,e,n){var r,i;return t instanceof Object?(r=t,i=e):(r={inputs:t,outputs:e},i=n),new gi(r,i);},yi=n(3);function bi(t,e,n){if(void 0===n&&(n=!1),t.beginPath(),e.slice(1).forEach(function(n,r){var i=n.x,o=n.y,a=e[r];t.moveTo(a.x,a.y),t.lineTo(i,o);}),n){var r=e[e.length-1],i=e[0];if(!r||!i)return;t.moveTo(r.x,r.y),t.lineTo(i.x,i.y);}t.stroke();}var xi=n(5),wi=function(){function t(t,e){if(!Ri(t)||!Ri(e))throw new Error("Dimensions.constructor - expected width and height to be valid numbers, instead have "+JSON.stringify({width:t,height:e}));this._width=t,this._height=e;}return Object.defineProperty(t.prototype,"width",{get:function get(){return this._width;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function get(){return this._height;},enumerable:!0,configurable:!0}),t.prototype.reverse=function(){return new t(1/this.width,1/this.height);},t;}();function ki(t,e){return t instanceof yi.Tensor&&t.shape.length===e;}function Ei(t){return ki(t,1);}function Ci(t){return ki(t,2);}function Ai(t){return ki(t,3);}function Oi(t){return ki(t,4);}function _i(t){return t%1!=0;}function Si(t){return t%2==0;}function Di(t,e){void 0===e&&(e=2);var n=Math.pow(10,e);return Math.floor(t*n)/n;}function Fi(t){return t&&t.width&&t.height;}function Ti(t,e){var n=t.width,r=t.height,i=e/Math.max(r,n);return new wi(Math.round(n*i),Math.round(r*i));}function Ni(t){return t.reduce(function(t,e){return t.add(e);},new ji(0,0)).div(new ji(t.length,t.length));}function Ii(t,e,n){return Array(t).fill(0).map(function(t,r){return e+r*n;});}function Ri(t){return !!t&&t!==1/0&&t!==-1/0&&!isNaN(t)||0===t;}function Mi(t){return Ri(t)&&0<=t&&t<=1;}var ji=function(){function t(t,e){this._x=t,this._y=e;}return Object.defineProperty(t.prototype,"x",{get:function get(){return this._x;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function get(){return this._y;},enumerable:!0,configurable:!0}),t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y);},t.prototype.sub=function(e){return new t(this.x-e.x,this.y-e.y);},t.prototype.mul=function(e){return new t(this.x*e.x,this.y*e.y);},t.prototype.div=function(e){return new t(this.x/e.x,this.y/e.y);},t.prototype.abs=function(){return new t(Math.abs(this.x),Math.abs(this.y));},t.prototype.magnitude=function(){return Math.sqrt(Math.pow(this.x,2)+Math.pow(this.y,2));},t.prototype.floor=function(){return new t(Math.floor(this.x),Math.floor(this.y));},t;}(),Bi=function(){function t(e,n){void 0===n&&(n=!0);var r=e||{},i=[r.left,r.top,r.right,r.bottom].every(Ri),o=[r.x,r.y,r.width,r.height].every(Ri);if(!o&&!i)throw new Error("Box.constructor - expected box to be IBoundingBox | IRect, instead have "+JSON.stringify(r));var a=o?[r.x,r.y,r.width,r.height]:[r.left,r.top,r.right-r.left,r.bottom-r.top],s=a[0],u=a[1],c=a[2],l=a[3];t.assertIsValidBox({x:s,y:u,width:c,height:l},"Box.constructor",n),this._x=s,this._y=u,this._width=c,this._height=l;}return t.isRect=function(t){return !!t&&[t.x,t.y,t.width,t.height].every(Ri);},t.assertIsValidBox=function(e,n,r){if(void 0===r&&(r=!1),!t.isRect(e))throw new Error(n+" - invalid box: "+JSON.stringify(e)+", expected object with properties x, y, width, height");if(!r&&(e.width<0||e.height<0))throw new Error(n+" - width ("+e.width+") and height ("+e.height+") must be positive numbers");},Object.defineProperty(t.prototype,"x",{get:function get(){return this._x;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function get(){return this._y;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function get(){return this._width;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function get(){return this._height;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function get(){return this.x;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function get(){return this.y;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function get(){return this.x+this.width;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bottom",{get:function get(){return this.y+this.height;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"area",{get:function get(){return this.width*this.height;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"topLeft",{get:function get(){return new ji(this.left,this.top);},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"topRight",{get:function get(){return new ji(this.right,this.top);},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bottomLeft",{get:function get(){return new ji(this.left,this.bottom);},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bottomRight",{get:function get(){return new ji(this.right,this.bottom);},enumerable:!0,configurable:!0}),t.prototype.round=function(){var e=[this.x,this.y,this.width,this.height].map(function(t){return Math.round(t);});return new t({x:e[0],y:e[1],width:e[2],height:e[3]});},t.prototype.floor=function(){var e=[this.x,this.y,this.width,this.height].map(function(t){return Math.floor(t);});return new t({x:e[0],y:e[1],width:e[2],height:e[3]});},t.prototype.toSquare=function(){var e=this.x,n=this.y,r=this.width,i=this.height,o=Math.abs(r-i);return r<i&&(e-=o/2,r+=o),i<r&&(n-=o/2,i+=o),new t({x:e,y:n,width:r,height:i});},t.prototype.rescale=function(e){var n=Fi(e)?e.width:e,r=Fi(e)?e.height:e;return new t({x:this.x*n,y:this.y*r,width:this.width*n,height:this.height*r});},t.prototype.pad=function(e,n){var r=[this.x-e/2,this.y-n/2,this.width+e,this.height+n];return new t({x:r[0],y:r[1],width:r[2],height:r[3]});},t.prototype.clipAtImageBorders=function(e,n){var r=this.x,i=this.y,o=this.right,a=this.bottom,s=Math.max(r,0),u=Math.max(i,0),c=o-s,l=a-u;return new t({x:s,y:u,width:Math.min(c,e-s),height:Math.min(l,n-u)}).floor();},t.prototype.shift=function(e,n){var r=this.width,i=this.height;return new t({x:this.x+e,y:this.y+n,width:r,height:i});},t.prototype.padAtBorders=function(t,e){var n=this.width+1,r=this.height+1,i=n,o=r,a=this.left,s=this.top,u=this.right,c=this.bottom;return u>e&&(i=-u+e+n,u=e),c>t&&(o=-c+t+r,c=t),a<1&&(o=2-a,a=1),s<1&&(o=2-s,s=1),{dy:1,edy:o,dx:1,edx:i,y:s,ey:c,x:a,ex:u,w:n,h:r};},t.prototype.calibrate=function(e){return new t({left:this.left+e.left*this.width,top:this.top+e.top*this.height,right:this.right+e.right*this.width,bottom:this.bottom+e.bottom*this.height}).toSquare().round();},t;}(),Pi=function(t){function e(e,n,r,i,o){return void 0===o&&(o=!1),t.call(this,{left:e,top:n,right:r,bottom:i},o)||this;}return Object(xi.c)(e,t),e;}(Bi),Li=function(){function t(t,e,n,r,i){this._imageDims=new wi(i.width,i.height),this._score=t,this._classScore=e,this._className=n,this._box=new Bi(r).rescale(this._imageDims);}return Object.defineProperty(t.prototype,"score",{get:function get(){return this._score;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"classScore",{get:function get(){return this._classScore;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"className",{get:function get(){return this._className;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"box",{get:function get(){return this._box;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageDims",{get:function get(){return this._imageDims;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageWidth",{get:function get(){return this.imageDims.width;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageHeight",{get:function get(){return this.imageDims.height;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"relativeBox",{get:function get(){return new Bi(this._box).rescale(this.imageDims.reverse());},enumerable:!0,configurable:!0}),t.prototype.forSize=function(e,n){return new t(this.score,this.classScore,this.className,this.relativeBox,{width:e,height:n});},t;}(),zi=function(t){function e(e,n,r){return t.call(this,e,e,"",n,r)||this;}return Object(xi.c)(e,t),e.prototype.forSize=function(n,r){var i=t.prototype.forSize.call(this,n,r);return new e(i.score,i.relativeBox,i.imageDims);},e;}(Li);function Ui(t,e,n){void 0===n&&(n=!0);var r=Math.max(0,Math.min(t.right,e.right)-Math.max(t.left,e.left))*Math.max(0,Math.min(t.bottom,e.bottom)-Math.max(t.top,e.top));return n?r/(t.area+e.area-r):r/Math.min(t.area,e.area);}function Wi(t){var e=t.map(function(t){return t.x;}),n=t.map(function(t){return t.y;}),r=e.reduce(function(t,e){return e<t?e:t;},1/0),i=n.reduce(function(t,e){return e<t?e:t;},1/0),o=e.reduce(function(t,e){return t<e?e:t;},0),a=n.reduce(function(t,e){return t<e?e:t;},0);return new Pi(r,i,o,a);}function Vi(t,e,n,r){void 0===r&&(r=!0);for(var i=e.map(function(t,e){return {score:t,boxIndex:e};}).sort(function(t,e){return t.score-e.score;}).map(function(t){return t.boxIndex;}),o=[],a=function a(){var e=i.pop();o.push(e);for(var a=i,s=[],u=0;u<a.length;u++){var c=a[u],l=t[e],f=t[c];s.push(Ui(l,f,r));}i=i.filter(function(t,e){return s[e]<=n;});};i.length>0;){a();}return o;}function qi(t,e){return yi.tidy(function(){var n=e[0],r=e[1],i=e[2],o=yi.fill(Object(xi.e)(t.shape.slice(0,3),[1]),n),a=yi.fill(Object(xi.e)(t.shape.slice(0,3),[1]),r),s=yi.fill(Object(xi.e)(t.shape.slice(0,3),[1]),i),u=yi.concat([o,a,s],3);return yi.sub(t,u);});}function $i(t,e){return void 0===e&&(e=!1),yi.tidy(function(){var n=t.shape.slice(1),r=n[0],i=n[1];if(r===i)return t;var o=Math.abs(r-i),a=Math.round(o*(e?.5:1)),s=r>i?2:1,u=function u(e){var n=t.shape.slice();return n[s]=e,yi.fill(n,0);},c=u(a),l=o-c.shape[s],f=[e&&l?u(l):null,t,c].filter(function(t){return !!t;}).map(function(t){return t.toFloat();});return yi.concat(f,s);});}function Hi(t){for(var e=t.slice(),n=e.length-1;n>0;n--){var r=Math.floor(Math.random()*(n+1)),i=e[n];e[n]=e[r],e[r]=i;}return e;}function Gi(t){return 1/(1+Math.exp(-t));}function Ki(t){return Math.log(t/(1-t));}var Xi=function(t){function e(e,n,r,i,o){return void 0===o&&(o=!1),t.call(this,{x:e,y:n,width:r,height:i},o)||this;}return Object(xi.c)(e,t),e;}(Bi),Yi=function(){function t(t,e,n){void 0===n&&(n=new ji(0,0));var r=e.width,i=e.height;this._imgDims=new wi(r,i),this._shift=n,this._positions=t.map(function(t){return t.mul(new ji(r,i)).add(n);});}return Object.defineProperty(t.prototype,"shift",{get:function get(){return new ji(this._shift.x,this._shift.y);},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageWidth",{get:function get(){return this._imgDims.width;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageHeight",{get:function get(){return this._imgDims.height;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"positions",{get:function get(){return this._positions;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"relativePositions",{get:function get(){var t=this;return this._positions.map(function(e){return e.sub(t._shift).div(new ji(t.imageWidth,t.imageHeight));});},enumerable:!0,configurable:!0}),t.prototype.forSize=function(t,e){return new this.constructor(this.relativePositions,{width:t,height:e});},t.prototype.shiftBy=function(t,e){return new this.constructor(this.relativePositions,this._imgDims,new ji(t,e));},t.prototype.shiftByPoint=function(t){return this.shiftBy(t.x,t.y);},t.prototype.align=function(t,e){if(void 0===e&&(e={}),t){var n=t instanceof zi?t.box.floor():new Bi(t);return this.shiftBy(n.x,n.y).align(null,e);}var r=Object.assign({},{useDlibAlignment:!1,minBoxPadding:.2},e),i=r.useDlibAlignment,o=r.minBoxPadding;return i?this.alignDlib():this.alignMinBbox(o);},t.prototype.alignDlib=function(){var t=this.getRefPointsForAlignment(),e=t[0],n=t[1],r=t[2],i=function i(t){return r.sub(t).magnitude();},o=(i(e)+i(n))/2,a=Math.floor(o/.45),s=Ni(t),u=Math.floor(Math.max(0,s.x-.5*a)),c=Math.floor(Math.max(0,s.y-.43*a));return new Xi(u,c,Math.min(a,this.imageWidth+u),Math.min(a,this.imageHeight+c));},t.prototype.alignMinBbox=function(t){var e=Wi(this.positions);return e.pad(e.width*t,e.height*t);},t.prototype.getRefPointsForAlignment=function(){throw new Error("getRefPointsForAlignment not implemented by base class");},t;}(),Ji=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e.prototype.getRefPointsForAlignment=function(){var t=this.positions;return [t[0],t[1],Ni([t[3],t[4]])];},e;}(Yi),Qi=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e.prototype.getJawOutline=function(){return this.positions.slice(0,17);},e.prototype.getLeftEyeBrow=function(){return this.positions.slice(17,22);},e.prototype.getRightEyeBrow=function(){return this.positions.slice(22,27);},e.prototype.getNose=function(){return this.positions.slice(27,36);},e.prototype.getLeftEye=function(){return this.positions.slice(36,42);},e.prototype.getRightEye=function(){return this.positions.slice(42,48);},e.prototype.getMouth=function(){return this.positions.slice(48,68);},e.prototype.getRefPointsForAlignment=function(){return [this.getLeftEye(),this.getRightEye(),this.getMouth()].map(Ni);},e;}(Yi),Zi=function(){function t(t,e){this._label=t,this._distance=e;}return Object.defineProperty(t.prototype,"label",{get:function get(){return this._label;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"distance",{get:function get(){return this._distance;},enumerable:!0,configurable:!0}),t.prototype.toString=function(t){return void 0===t&&(t=!0),this.label+(t?" ("+Di(this.distance)+")":"");},t;}(),to=function(t){function e(e,n){var r=t.call(this,e)||this;return r._label=n,r;}return Object(xi.c)(e,t),e.assertIsValidLabeledBox=function(t,e){if(Bi.assertIsValidBox(t,e),!Ri(t.label))throw new Error(e+" - expected property label ("+t.label+") to be a number");},Object.defineProperty(e.prototype,"label",{get:function get(){return this._label;},enumerable:!0,configurable:!0}),e;}(Bi),eo=function(){function t(t,e){if("string"!=typeof t)throw new Error("LabeledFaceDescriptors - constructor expected label to be a string");if(!Array.isArray(e)||e.some(function(t){return !(t instanceof Float32Array);}))throw new Error("LabeledFaceDescriptors - constructor expected descriptors to be an array of Float32Array");this._label=t,this._descriptors=e;}return Object.defineProperty(t.prototype,"label",{get:function get(){return this._label;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"descriptors",{get:function get(){return this._descriptors;},enumerable:!0,configurable:!0}),t.prototype.toJSON=function(){return {label:this.label,descriptors:this.descriptors.map(function(t){return Array.from(t);})};},t.fromJSON=function(e){var n=e.descriptors.map(function(t){return new Float32Array(t);});return new t(e.label,n);},t;}(),no=function(t){function e(e,n,r,i){var o=t.call(this,e,n)||this;return o._score=r,o._classScore=i,o;}return Object(xi.c)(e,t),e.assertIsValidPredictedBox=function(t,e){if(to.assertIsValidLabeledBox(t,e),!Mi(t.score)||!Mi(t.classScore))throw new Error(e+" - expected properties score ("+t.score+") and ("+t.classScore+") to be a number between [0, 1]");},Object.defineProperty(e.prototype,"score",{get:function get(){return this._score;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"classScore",{get:function get(){return this._classScore;},enumerable:!0,configurable:!0}),e;}(to);function ro(t){return t.detection instanceof zi;}function io(t,e){var n={detection:e};return Object.assign({},t,n);}function oo(){var t=window.fetch||function(){throw new Error("fetch - missing fetch implementation for browser environment");};return {Canvas:HTMLCanvasElement,CanvasRenderingContext2D:CanvasRenderingContext2D,Image:HTMLImageElement,ImageData:ImageData,Video:HTMLVideoElement,createCanvasElement:function createCanvasElement(){return document.createElement("canvas");},createImageElement:function createImageElement(){return document.createElement("img");},fetch:t,readFile:function readFile(){throw new Error("readFile - filesystem not available for browser environment");}};}var ao=n(131),so=n(178);function uo(){return "object"==(typeof window==="undefined"?"undefined":_typeof$1(window))&&"undefined"!=typeof document&&"undefined"!=typeof HTMLImageElement&&"undefined"!=typeof HTMLCanvasElement&&"undefined"!=typeof HTMLVideoElement&&"undefined"!=typeof ImageData&&"undefined"!=typeof CanvasRenderingContext2D;}var co,lo=n(177);function fo(t){co=t;}function ho(){uo()&&fo(oo()),Object(lo.a)()&&fo(Object(so.a)());}var po,mo={getEnv:function getEnv(){if(!co)throw new Error("getEnv - environment is not defined, check isNodejs() and isBrowser()");return co;},setEnv:fo,initialize:ho,createBrowserEnv:oo,createFileSystem:ao.a,createNodejsEnv:so.a,monkeyPatch:function monkeyPatch(t){if(co||ho(),!co)throw new Error("monkeyPatch - environment is not defined, check isNodejs() and isBrowser()");var e=t.Canvas,n=void 0===e?co.Canvas:e,r=t.Image,i=void 0===r?co.Image:r;co.Canvas=n,co.Image=i,co.createCanvasElement=t.createCanvasElement||function(){return new n();},co.createImageElement=t.createImageElement||function(){return new i();},co.ImageData=t.ImageData||co.ImageData,co.Video=t.Video||co.Video,co.fetch=t.fetch||co.fetch,co.readFile=t.readFile||co.readFile;},isBrowser:uo,isNodejs:lo.a};function go(t){return mo.isNodejs()||"string"!=typeof t?t:document.getElementById(t);}function vo(t){var e=mo.getEnv(),n=e.Canvas;if(t instanceof e.CanvasRenderingContext2D)return t;var r=go(t);if(!(r instanceof n))throw new Error("resolveContext2d - expected canvas to be of instance of Canvas");var i=r.getContext("2d");if(!i)throw new Error("resolveContext2d - canvas 2d context is null");return i;}ho(),function(t){t.TOP_LEFT="TOP_LEFT",t.TOP_RIGHT="TOP_RIGHT",t.BOTTOM_LEFT="BOTTOM_LEFT",t.BOTTOM_RIGHT="BOTTOM_RIGHT";}(po||(po={}));var yo=function(){return function(t){void 0===t&&(t={});var e=t.anchorPosition,n=t.backgroundColor,r=t.fontColor,i=t.fontSize,o=t.fontStyle,a=t.padding;this.anchorPosition=e||po.TOP_LEFT,this.backgroundColor=n||"rgba(0, 0, 0, 0.5)",this.fontColor=r||"rgba(255, 255, 255, 1)",this.fontSize=i||14,this.fontStyle=o||"Georgia",this.padding=a||4;};}(),bo=function(){function t(e,n,r){void 0===r&&(r={}),this.text="string"==typeof e?[e]:e instanceof t?e.text:e,this.anchor=n,this.options=new yo(r);}return t.prototype.measureWidth=function(t){var e=this.options.padding;return this.text.map(function(e){return t.measureText(e).width;}).reduce(function(t,e){return t<e?e:t;},0)+2*e;},t.prototype.measureHeight=function(){var t=this.options,e=t.fontSize,n=t.padding;return this.text.length*e+2*n;},t.prototype.getUpperLeft=function(t,e){var n=this.options.anchorPosition,r=n===po.BOTTOM_RIGHT||n===po.TOP_RIGHT,i=n===po.BOTTOM_LEFT||n===po.BOTTOM_RIGHT,o=this.measureWidth(t),a=this.measureHeight(),s=r?this.anchor.x-o:this.anchor.x,u=i?this.anchor.y-a:this.anchor.y;if(e){var c=e.width,l=e.height;return {x:Math.max(Math.min(s,c-o),0),y:Math.max(Math.min(u,l-a),0)};}return {x:s,y:u};},t.prototype.draw=function(t){var e=go(t),n=vo(e),r=this.options,i=r.backgroundColor,o=r.fontColor,a=r.fontSize,s=r.fontStyle,u=r.padding;n.font=a+"px "+s;var c=this.measureWidth(n),l=this.measureHeight();n.fillStyle=i;var f=this.getUpperLeft(n,e);n.fillRect(f.x,f.y,c,l),n.fillStyle=o,this.text.forEach(function(t,e){var r=u+f.x,i=u+f.y+(e+1)*a;n.fillText(t,r,i);});},t;}(),xo=function(){return function(t){void 0===t&&(t={});var e=t.boxColor,n=t.lineWidth,r=t.label,i=t.drawLabelOptions;this.boxColor=e||"rgba(0, 0, 255, 1)",this.lineWidth=n||2,this.label=r;var o={anchorPosition:po.BOTTOM_LEFT,backgroundColor:this.boxColor};this.drawLabelOptions=new yo(Object.assign({},o,i));};}(),wo=function(){function t(t,e){void 0===e&&(e={}),this.box=new Bi(t),this.options=new xo(e);}return t.prototype.draw=function(t){var e=vo(t),n=this.options,r=n.boxColor,i=n.lineWidth,o=this.box,a=o.x,s=o.y,u=o.width,c=o.height;e.strokeStyle=r,e.lineWidth=i,e.strokeRect(a,s,u,c);var l=this.options.label;l&&new bo([l],{x:a-i/2,y:s},this.options.drawLabelOptions).draw(t);},t;}();function ko(t,e){(Array.isArray(e)?e:[e]).forEach(function(e){var n=e instanceof zi?e.score:ro(e)?e.detection.score:void 0,r=e instanceof zi?e.box:ro(e)?e.detection.box:new Bi(e),i=n?""+Di(n):void 0;new wo(r,{label:i}).draw(t);});}function Eo(t){var e=mo.getEnv(),n=e.Image,r=e.Video;return t instanceof n&&t.complete||t instanceof r&&t.readyState>=3;}function Co(t){return new Promise(function(e,n){if(t instanceof mo.getEnv().Canvas||Eo(t))return e();function r(t){t.currentTarget&&(t.currentTarget.removeEventListener("load",r),t.currentTarget.removeEventListener("error",i),e(t));}function i(t){t.currentTarget&&(t.currentTarget.removeEventListener("load",r),t.currentTarget.removeEventListener("error",i),n(t));}t.addEventListener("load",r),t.addEventListener("error",i);});}function Ao(t){return new Promise(function(e,n){if(!(t instanceof Blob))return n("bufferToImage - expected buf to be of type: Blob");var r=new FileReader();r.onload=function(){if("string"!=typeof r.result)return n("bufferToImage - expected reader.result to be a string, in onload");var t=mo.getEnv().createImageElement();t.onload=function(){return e(t);},t.onerror=n,t.src=r.result;},r.onerror=n,r.readAsDataURL(t);});}function Oo(t){var e=mo.getEnv(),n=e.Image,r=e.Video;return t instanceof n?new wi(t.naturalWidth,t.naturalHeight):t instanceof r?new wi(t.videoWidth,t.videoHeight):new wi(t.width,t.height);}function _o(t){var e=t.width,n=t.height,r=(0, mo.getEnv().createCanvasElement)();return r.width=e,r.height=n,r;}function So(t,e){var n=mo.getEnv().ImageData;if(!(t instanceof n||Eo(t)))throw new Error("createCanvasFromMedia - media has not finished loading yet");var r=e||Oo(t),i=r.width,o=r.height,a=_o({width:i,height:o});return t instanceof n?vo(a).putImageData(t,0,0):vo(a).drawImage(t,0,0,i,o),a;}function Do(t,e){return Object(xi.b)(this,void 0,void 0,function(){var n,r,i,o,a,s;return Object(xi.d)(this,function(u){switch(u.label){case 0:return n=e||mo.getEnv().createCanvasElement(),r=t.shape.slice(Oi(t)?1:0),i=r[0],o=r[1],a=r[2],s=yi.tidy(function(){return t.as3D(i,o,a).toInt();}),[4,yi.browser.toPixels(s,n)];case 1:return u.sent(),s.dispose(),[2,n];}});});}function Fo(t){var e=mo.getEnv(),n=e.Image,r=e.Canvas,i=e.Video;return t instanceof n||t instanceof r||t instanceof i;}function To(t,e,n){void 0===n&&(n=!1);var r=mo.getEnv(),i=r.Image,o=r.Canvas;if(!(t instanceof i||t instanceof o))throw new Error("imageToSquare - expected arg0 to be HTMLImageElement | HTMLCanvasElement");var a=Oo(t),s=e/Math.max(a.height,a.width),u=s*a.width,c=s*a.height,l=_o({width:e,height:e}),f=t instanceof o?t:So(t),h=Math.abs(u-c)/2,d=n&&u<c?h:0,p=n&&c<u?h:0;return vo(l).drawImage(f,d,p,u,c),l;}var No=function(){function t(t,e){var n=this;if(void 0===e&&(e=!1),this._imageTensors=[],this._canvases=[],this._treatAsBatchInput=!1,this._inputDimensions=[],!Array.isArray(t))throw new Error("NetInput.constructor - expected inputs to be an Array of TResolvedNetInput or to be instanceof tf.Tensor4D, instead have "+t);this._treatAsBatchInput=e,this._batchSize=t.length,t.forEach(function(t,e){if(Ai(t))return n._imageTensors[e]=t,void(n._inputDimensions[e]=t.shape);if(Oi(t)){var r=t.shape[0];if(1!==r)throw new Error("NetInput - tf.Tensor4D with batchSize "+r+" passed, but not supported in input array");return n._imageTensors[e]=t,void(n._inputDimensions[e]=t.shape.slice(1));}var i=t instanceof mo.getEnv().Canvas?t:So(t);n._canvases[e]=i,n._inputDimensions[e]=[i.height,i.width,3];});}return Object.defineProperty(t.prototype,"imageTensors",{get:function get(){return this._imageTensors;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"canvases",{get:function get(){return this._canvases;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isBatchInput",{get:function get(){return this.batchSize>1||this._treatAsBatchInput;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"batchSize",{get:function get(){return this._batchSize;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"inputDimensions",{get:function get(){return this._inputDimensions;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"inputSize",{get:function get(){return this._inputSize;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"reshapedInputDimensions",{get:function get(){var t=this;return Ii(this.batchSize,0,1).map(function(e,n){return t.getReshapedInputDimensions(n);});},enumerable:!0,configurable:!0}),t.prototype.getInput=function(t){return this.canvases[t]||this.imageTensors[t];},t.prototype.getInputDimensions=function(t){return this._inputDimensions[t];},t.prototype.getInputHeight=function(t){return this._inputDimensions[t][0];},t.prototype.getInputWidth=function(t){return this._inputDimensions[t][1];},t.prototype.getReshapedInputDimensions=function(t){if("number"!=typeof this.inputSize)throw new Error("getReshapedInputDimensions - inputSize not set, toBatchTensor has not been called yet");return Ti({width:this.getInputWidth(t),height:this.getInputHeight(t)},this.inputSize);},t.prototype.toBatchTensor=function(t,e){var n=this;return void 0===e&&(e=!0),this._inputSize=t,yi.tidy(function(){var r=Ii(n.batchSize,0,1).map(function(r){var i=n.getInput(r);if(i instanceof yi.Tensor){var o=Oi(i)?i:i.expandDims();return (o=$i(o,e)).shape[1]===t&&o.shape[2]===t||(o=yi.image.resizeBilinear(o,[t,t])),o.as3D(t,t,3);}if(i instanceof mo.getEnv().Canvas)return yi.browser.fromPixels(To(i,t,e));throw new Error("toBatchTensor - at batchIdx "+r+", expected input to be instanceof tf.Tensor or instanceof HTMLCanvasElement, instead have "+i);});return yi.stack(r.map(function(t){return t.toFloat();})).as4D(n.batchSize,t,t,3);});},t;}();function Io(t){return Object(xi.b)(this,void 0,void 0,function(){var e,n,r;return Object(xi.d)(this,function(i){switch(i.label){case 0:if(t instanceof No)return [2,t];if(!(e=Array.isArray(t)?t:[t]).length)throw new Error("toNetInput - empty array passed as input");return n=function n(e){return Array.isArray(t)?" at input index "+e+":":"";},(r=e.map(go)).forEach(function(t,r){if(!Fo(t)&&!Ai(t)&&!Oi(t)){if("string"==typeof e[r])throw new Error("toNetInput -"+n(r)+" string passed, but could not resolve HTMLElement for element id "+e[r]);throw new Error("toNetInput -"+n(r)+" expected media to be of type HTMLImageElement | HTMLVideoElement | HTMLCanvasElement | tf.Tensor3D, or to be an element id");}if(Oi(t)){var i=t.shape[0];if(1!==i)throw new Error("toNetInput -"+n(r)+" tf.Tensor4D with batchSize "+i+" passed, but not supported in input array");}}),[4,Promise.all(r.map(function(t){return Fo(t)&&Co(t);}))];case 1:return i.sent(),[2,new No(r,Array.isArray(t))];}});});}function Ro(t,e){return Object(xi.b)(this,void 0,void 0,function(){var n,r,i,o,a,s;return Object(xi.d)(this,function(u){switch(u.label){case 0:return n=mo.getEnv().Canvas,r=t,t instanceof n?[3,5]:[4,Io(t)];case 1:if((i=u.sent()).batchSize>1)throw new Error("extractFaces - batchSize > 1 not supported");return (o=i.getInput(0))instanceof n?(a=o,[3,4]):[3,2];case 2:return [4,Do(o)];case 3:a=u.sent(),u.label=4;case 4:r=a,u.label=5;case 5:return s=vo(r),[2,e.map(function(t){return t instanceof zi?t.forSize(r.width,r.height).box.floor():t;}).map(function(t){return t.clipAtImageBorders(r.width,r.height);}).map(function(t){var e=t.x,n=t.y,r=t.width,i=t.height,o=_o({width:r,height:i});return vo(o).putImageData(s.getImageData(e,n,r,i),0,0),o;})];}});});}function Mo(t,e){return Object(xi.b)(this,void 0,void 0,function(){return Object(xi.d)(this,function(n){if(!Ai(t)&&!Oi(t))throw new Error("extractFaceTensors - expected image tensor to be 3D or 4D");if(Oi(t)&&t.shape[0]>1)throw new Error("extractFaceTensors - batchSize > 1 not supported");return [2,yi.tidy(function(){var n=t.shape.slice(Oi(t)?1:0),r=n[0],i=n[1],o=n[2];return e.map(function(t){return t instanceof zi?t.forSize(i,r).box:t;}).map(function(t){return t.clipAtImageBorders(i,r);}).map(function(e){var n=e.x,a=e.y,s=e.width,u=e.height;return yi.slice3d(t.as3D(r,i,o),[a,n,0],[u,s,o]);});})];});});}function jo(t,e){return Object(xi.b)(this,void 0,void 0,function(){var n;return Object(xi.d)(this,function(r){switch(r.label){case 0:return [4,(0, mo.getEnv().fetch)(t,e)];case 1:if(!((n=r.sent()).status<400))throw new Error("failed to fetch: ("+n.status+") "+n.statusText+", from url: "+n.url);return [2,n];}});});}function Bo(t){return Object(xi.b)(this,void 0,void 0,function(){var e,n;return Object(xi.d)(this,function(r){switch(r.label){case 0:return [4,jo(t)];case 1:return [4,(e=r.sent()).blob()];case 2:if(!(n=r.sent()).type.startsWith("image/"))throw new Error("fetchImage - expected blob type to be of type image/*, instead have: "+n.type+", for url: "+e.url);return [2,Ao(n)];}});});}function Po(t){return Object(xi.b)(this,void 0,void 0,function(){return Object(xi.d)(this,function(e){switch(e.label){case 0:return [4,jo(t)];case 1:return [2,e.sent().json()];}});});}function Lo(t){return Object(xi.b)(this,void 0,void 0,function(){var e;return Object(xi.d)(this,function(n){switch(n.label){case 0:return e=Float32Array.bind,[4,jo(t)];case 1:return [4,n.sent().arrayBuffer()];case 2:return [2,new(e.apply(Float32Array,[void 0,n.sent()]))()];}});});}function zo(t,e){var n=e+"-weights_manifest.json";if(!t)return {modelBaseUri:"",manifestUri:n};if("/"===t)return {modelBaseUri:"/",manifestUri:"/"+n};var r=t.startsWith("http://")?"http://":t.startsWith("https://")?"https://":"",i=(t=t.replace(r,"")).split("/").filter(function(t){return t;}),o=t.endsWith(".json")?i[i.length-1]:n,a=r+(t.endsWith(".json")?i.slice(0,i.length-1):i).join("/");return {modelBaseUri:a=t.startsWith("/")?"/"+a:a,manifestUri:"/"===a?"/"+o:a+"/"+o};}function Uo(t,e){return Object(xi.b)(this,void 0,void 0,function(){var n,r,i,o;return Object(xi.d)(this,function(a){switch(a.label){case 0:return n=zo(t,e),r=n.manifestUri,i=n.modelBaseUri,[4,Po(r)];case 1:return o=a.sent(),[2,yi.io.loadWeights(o,i)];}});});}function Wo(t,e,n){void 0===n&&(n=!1);var r=n?Oo(e):e,i=r.width,o=r.height;return t.width=i,t.height=o,{width:i,height:o};}var Vo=function(){function t(t){this._name=t,this._params=void 0,this._paramMappings=[];}return Object.defineProperty(t.prototype,"params",{get:function get(){return this._params;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"paramMappings",{get:function get(){return this._paramMappings;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isLoaded",{get:function get(){return !!this.params;},enumerable:!0,configurable:!0}),t.prototype.getParamFromPath=function(t){var e=this.traversePropertyPath(t);return e.obj[e.objProp];},t.prototype.reassignParamFromPath=function(t,e){var n=this.traversePropertyPath(t),r=n.obj,i=n.objProp;r[i].dispose(),r[i]=e;},t.prototype.getParamList=function(){var t=this;return this._paramMappings.map(function(e){var n=e.paramPath;return {path:n,tensor:t.getParamFromPath(n)};});},t.prototype.getTrainableParams=function(){return this.getParamList().filter(function(t){return t.tensor instanceof yi.Variable;});},t.prototype.getFrozenParams=function(){return this.getParamList().filter(function(t){return !(t.tensor instanceof yi.Variable);});},t.prototype.variable=function(){var t=this;this.getFrozenParams().forEach(function(e){var n=e.path,r=e.tensor;t.reassignParamFromPath(n,r.variable());});},t.prototype.freeze=function(){var t=this;this.getTrainableParams().forEach(function(e){var n=e.path,r=e.tensor,i=yi.tensor(r.dataSync());r.dispose(),t.reassignParamFromPath(n,i);});},t.prototype.dispose=function(t){void 0===t&&(t=!0),this.getParamList().forEach(function(e){if(t&&e.tensor.isDisposed)throw new Error("param tensor has already been disposed for path "+e.path);e.tensor.dispose();}),this._params=void 0;},t.prototype.serializeParams=function(){return new Float32Array(this.getParamList().map(function(t){var e=t.tensor;return Array.from(e.dataSync());}).reduce(function(t,e){return t.concat(e);}));},t.prototype.load=function(t){return Object(xi.b)(this,void 0,void 0,function(){return Object(xi.d)(this,function(e){switch(e.label){case 0:return t instanceof Float32Array?(this.extractWeights(t),[2]):[4,this.loadFromUri(t)];case 1:return e.sent(),[2];}});});},t.prototype.loadFromUri=function(t){return Object(xi.b)(this,void 0,void 0,function(){var e;return Object(xi.d)(this,function(n){switch(n.label){case 0:if(t&&"string"!=typeof t)throw new Error(this._name+".loadFromUri - expected model uri");return [4,Uo(t,this.getDefaultModelName())];case 1:return e=n.sent(),this.loadFromWeightMap(e),[2];}});});},t.prototype.loadFromDisk=function(t){return Object(xi.b)(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,c,l;return Object(xi.d)(this,function(f){switch(f.label){case 0:if(t&&"string"!=typeof t)throw new Error(this._name+".loadFromDisk - expected model file path");return e=mo.getEnv().readFile,n=zo(t,this.getDefaultModelName()),r=n.manifestUri,i=n.modelBaseUri,o=function o(t){return Promise.all(t.map(function(t){return e(t).then(function(t){return t.buffer;});}));},a=yi.io.weightsLoaderFactory(o),c=(u=JSON).parse,[4,e(r)];case 1:return s=c.apply(u,[f.sent().toString()]),[4,a(s,i)];case 2:return l=f.sent(),this.loadFromWeightMap(l),[2];}});});},t.prototype.loadFromWeightMap=function(t){var e=this.extractParamsFromWeigthMap(t),n=e.paramMappings,r=e.params;this._paramMappings=n,this._params=r;},t.prototype.extractWeights=function(t){var e=this.extractParams(t),n=e.paramMappings,r=e.params;this._paramMappings=n,this._params=r;},t.prototype.traversePropertyPath=function(t){if(!this.params)throw new Error("traversePropertyPath - model has no loaded params");var e=t.split("/").reduce(function(e,n){if(!e.nextObj.hasOwnProperty(n))throw new Error("traversePropertyPath - object does not have property "+n+", for path "+t);return {obj:e.nextObj,objProp:n,nextObj:e.nextObj[n]};},{nextObj:this.params}),n=e.obj,r=e.objProp;if(!(n&&r&&n[r]instanceof yi.Tensor))throw new Error("traversePropertyPath - parameter is not a tensor, for path "+t);return {obj:n,objProp:r};},t;}();function qo(t,e,n){return yi.tidy(function(){var r=yi.separableConv2d(t,e.depthwise_filter,e.pointwise_filter,n,"same");return r=yi.add(r,e.bias);});}function $o(t,e,n){return void 0===n&&(n=!1),yi.tidy(function(){var r=yi.relu(n?yi.add(yi.conv2d(t,e.conv0.filters,[2,2],"same"),e.conv0.bias):qo(t,e.conv0,[2,2])),i=qo(r,e.conv1,[1,1]),o=qo(yi.relu(yi.add(r,i)),e.conv2,[1,1]);return yi.relu(yi.add(r,yi.add(i,o)));});}function Ho(t,e,n,r){return void 0===n&&(n=!1),void 0===r&&(r=!0),yi.tidy(function(){var i=yi.relu(n?yi.add(yi.conv2d(t,e.conv0.filters,r?[2,2]:[1,1],"same"),e.conv0.bias):qo(t,e.conv0,r?[2,2]:[1,1])),o=qo(i,e.conv1,[1,1]),a=qo(yi.relu(yi.add(i,o)),e.conv2,[1,1]),s=qo(yi.relu(yi.add(i,yi.add(o,a))),e.conv3,[1,1]);return yi.relu(yi.add(i,yi.add(o,yi.add(a,s))));});}function Go(t,e,n,r){return void 0===n&&(n="same"),void 0===r&&(r=!1),yi.tidy(function(){var i=yi.add(yi.conv2d(t,e.filters,[1,1],n),e.bias);return r?yi.relu(i):i;});}function Ko(t,e){Object.keys(t).forEach(function(n){e.some(function(t){return t.originalPath===n;})||t[n].dispose();});}function Xo(t,e){return function(n,r,i,o){var a=yi.tensor4d(t(n*r*i*i),[i,i,n,r]),s=yi.tensor1d(t(r));return e.push({paramPath:o+"/filters"},{paramPath:o+"/bias"}),{filters:a,bias:s};};}function Yo(t,e){return function(n,r,i){var o=yi.tensor2d(t(n*r),[n,r]),a=yi.tensor1d(t(r));return e.push({paramPath:i+"/weights"},{paramPath:i+"/bias"}),{weights:o,bias:a};};}var Jo=function(){return function(t,e,n){this.depthwise_filter=t,this.pointwise_filter=e,this.bias=n;};}();function Qo(t,e){return function(n,r,i){var o=yi.tensor4d(t(9*n),[3,3,n,1]),a=yi.tensor4d(t(n*r),[1,1,n,r]),s=yi.tensor1d(t(r));return e.push({paramPath:i+"/depthwise_filter"},{paramPath:i+"/pointwise_filter"},{paramPath:i+"/bias"}),new Jo(o,a,s);};}function Zo(t){return function(e){var n=t(e+"/depthwise_filter",4),r=t(e+"/pointwise_filter",4),i=t(e+"/bias",1);return new Jo(n,r,i);};}function ta(t,e){return function(n,r,i){var o=t[n];if(!ki(o,r))throw new Error("expected weightMap["+n+"] to be a Tensor"+r+"D, instead have "+o);return e.push({originalPath:n,paramPath:i||n}),o;};}function ea(t){var e=t;return {extractWeights:function extractWeights(t){var n=e.slice(0,t);return e=e.slice(t),n;},getRemainingWeights:function getRemainingWeights(){return e;}};}function na(t,e){var n=Xo(t,e),r=Qo(t,e);function i(t,e,i,o){return void 0===o&&(o=!1),{conv0:o?n(t,e,3,i+"/conv0"):r(t,e,i+"/conv0"),conv1:r(e,e,i+"/conv1"),conv2:r(e,e,i+"/conv2")};}return {extractDenseBlock3Params:i,extractDenseBlock4Params:function extractDenseBlock4Params(t,e,n,o){void 0===o&&(o=!1);var a=i(t,e,n,o);return {conv0:a.conv0,conv1:a.conv1,conv2:a.conv2,conv3:r(e,e,n+"/conv3")};}};}function ra(t){return function(e){return {filters:t(e+"/filters",4),bias:t(e+"/bias",1)};};}function ia(t,e){var n=ta(t,e),r=ra(n),i=Zo(n);return {extractDenseBlock3Params:function extractDenseBlock3Params(t,e){return void 0===e&&(e=!1),{conv0:e?r(t+"/conv0"):i(t+"/conv0"),conv1:i(t+"/conv1"),conv2:i(t+"/conv2")};},extractDenseBlock4Params:function extractDenseBlock4Params(t,e){return void 0===e&&(e=!1),{conv0:e?r(t+"/conv0"):i(t+"/conv0"),conv1:i(t+"/conv1"),conv2:i(t+"/conv2"),conv3:i(t+"/conv3")};}};}var oa=function(t){function e(){return t.call(this,"FaceFeatureExtractor")||this;}return Object(xi.c)(e,t),e.prototype.forwardInput=function(t){var e=this.params;if(!e)throw new Error("FaceFeatureExtractor - load model before inference");return yi.tidy(function(){var n=Ho(qi(t.toBatchTensor(112,!0),[122.782,117.001,104.298]).div(yi.scalar(255)),e.dense0,!0);return n=Ho(n=Ho(n=Ho(n,e.dense1),e.dense2),e.dense3),n=yi.avgPool(n,[7,7],[2,2],"valid");});},e.prototype.forward=function(t){return Object(xi.b)(this,void 0,void 0,function(){var e;return Object(xi.d)(this,function(n){switch(n.label){case 0:return e=this.forwardInput,[4,Io(t)];case 1:return [2,e.apply(this,[n.sent()])];}});});},e.prototype.getDefaultModelName=function(){return "face_feature_extractor_model";},e.prototype.extractParamsFromWeigthMap=function(t){return function(t){var e=[],n=ia(t,e).extractDenseBlock4Params,r={dense0:n("dense0",!0),dense1:n("dense1"),dense2:n("dense2"),dense3:n("dense3")};return Ko(t,e),{params:r,paramMappings:e};}(t);},e.prototype.extractParams=function(t){return function(t){var e=[],n=ea(t),r=n.extractWeights,i=n.getRemainingWeights,o=na(r,e).extractDenseBlock4Params,a=o(3,32,"dense0",!0),s=o(32,64,"dense1"),u=o(64,128,"dense2"),c=o(128,256,"dense3");if(0!==i().length)throw new Error("weights remaing after extract: "+i().length);return {paramMappings:e,params:{dense0:a,dense1:s,dense2:u,dense3:c}};}(t);},e;}(Vo);function aa(t,e){return yi.tidy(function(){return yi.add(yi.matMul(t,e.weights),e.bias);});}function sa(t){var e={},n={};return Object.keys(t).forEach(function(r){(r.startsWith("fc")?n:e)[r]=t[r];}),{featureExtractorMap:e,classifierMap:n};}var ua=function(t){function e(e,n){var r=t.call(this,e)||this;return r._faceFeatureExtractor=n,r;}return Object(xi.c)(e,t),Object.defineProperty(e.prototype,"faceFeatureExtractor",{get:function get(){return this._faceFeatureExtractor;},enumerable:!0,configurable:!0}),e.prototype.runNet=function(t){var e=this,n=this.params;if(!n)throw new Error(this._name+" - load model before inference");return yi.tidy(function(){var r=t instanceof No?e.faceFeatureExtractor.forwardInput(t):t;return aa(r.as2D(r.shape[0],-1),n.fc);});},e.prototype.dispose=function(e){void 0===e&&(e=!0),this.faceFeatureExtractor.dispose(e),t.prototype.dispose.call(this,e);},e.prototype.loadClassifierParams=function(t){var e=this.extractClassifierParams(t),n=e.params,r=e.paramMappings;this._params=n,this._paramMappings=r;},e.prototype.extractClassifierParams=function(t){return function(t,e,n){var r=[],i=ea(t),o=i.extractWeights,a=i.getRemainingWeights,s=Yo(o,r)(e,n,"fc");if(0!==a().length)throw new Error("weights remaing after extract: "+a().length);return {paramMappings:r,params:{fc:s}};}(t,this.getClassifierChannelsIn(),this.getClassifierChannelsOut());},e.prototype.extractParamsFromWeigthMap=function(t){var e=sa(t),n=e.featureExtractorMap,r=e.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(n),function(t){var e=[],n=ta(t,e),r={fc:function(t){return {weights:n(t+"/weights",2),bias:n(t+"/bias",1)};}("fc")};return Ko(t,e),{params:r,paramMappings:e};}(r);},e.prototype.extractParams=function(t){var e=this.getClassifierChannelsIn(),n=this.getClassifierChannelsOut(),r=n*e+n,i=t.slice(0,t.length-r),o=t.slice(t.length-r);return this.faceFeatureExtractor.extractWeights(i),this.extractClassifierParams(o);},e;}(Vo),ca=["neutral","happy","sad","angry","fearful","disgusted","surprised"],la=function(){function t(t){var e=this;if(7!==t.length)throw new Error("FaceExpressions.constructor - expected probabilities.length to be 7, have: "+t.length);ca.forEach(function(n,r){e[n]=t[r];});}return t.prototype.asSortedArray=function(){var t=this;return ca.map(function(e){return {expression:e,probability:t[e]};}).sort(function(t,e){return e.probability-t.probability;});},t;}(),fa=function(t){function e(e){return void 0===e&&(e=new oa()),t.call(this,"FaceExpressionNet",e)||this;}return Object(xi.c)(e,t),e.prototype.forwardInput=function(t){var e=this;return yi.tidy(function(){return yi.softmax(e.runNet(t));});},e.prototype.forward=function(t){return Object(xi.b)(this,void 0,void 0,function(){var e;return Object(xi.d)(this,function(n){switch(n.label){case 0:return e=this.forwardInput,[4,Io(t)];case 1:return [2,e.apply(this,[n.sent()])];}});});},e.prototype.predictExpressions=function(t){return Object(xi.b)(this,void 0,void 0,function(){var e,n,r,i,o=this;return Object(xi.d)(this,function(a){switch(a.label){case 0:return [4,Io(t)];case 1:return e=a.sent(),[4,this.forwardInput(e)];case 2:return n=a.sent(),[4,Promise.all(yi.unstack(n).map(function(t){return Object(xi.b)(o,void 0,void 0,function(){var e;return Object(xi.d)(this,function(n){switch(n.label){case 0:return [4,t.data()];case 1:return e=n.sent(),t.dispose(),[2,e];}});});}))];case 3:return r=a.sent(),n.dispose(),i=r.map(function(t){return new la(t);}),[2,e.isBatchInput?i:i[0]];}});});},e.prototype.getDefaultModelName=function(){return "face_expression_model";},e.prototype.getClassifierChannelsIn=function(){return 256;},e.prototype.getClassifierChannelsOut=function(){return 7;},e;}(ua);function ha(t){return t.expressions instanceof la;}function da(t,e){var n={expressions:e};return Object.assign({},t,n);}function pa(t,e,n,r){void 0===n&&(n=.1),(Array.isArray(e)?e:[e]).forEach(function(e){var i=e instanceof la?e:ha(e)?e.expressions:void 0;if(!i)throw new Error("drawFaceExpressions - expected faceExpressions to be FaceExpressions | WithFaceExpressions<{}> or array thereof");var o=i.asSortedArray().filter(function(t){return t.probability>n;}),a=ro(e)?e.detection.box.bottomLeft:r||new ji(0,0);new bo(o.map(function(t){return t.expression+" ("+Di(t.probability)+")";}),a).draw(t);});}function ma(t){return ro(t)&&t.landmarks instanceof Yi&&t.unshiftedLandmarks instanceof Yi&&t.alignedRect instanceof zi;}function ga(t,e){var n=t.detection.box,r=e.shiftBy(n.x,n.y),i=r.align(),o=t.detection.imageDims,a={landmarks:r,unshiftedLandmarks:e,alignedRect:new zi(t.detection.score,i.rescale(o.reverse()),o)};return Object.assign({},t,a);}var va=function(){return function(t){void 0===t&&(t={});var e=t.drawLines,n=void 0===e||e,r=t.drawPoints,i=void 0===r||r,o=t.lineWidth,a=t.lineColor,s=t.pointSize,u=t.pointColor;this.drawLines=n,this.drawPoints=i,this.lineWidth=o||1,this.pointSize=s||2,this.lineColor=a||"rgba(0, 255, 255, 1)",this.pointColor=u||"rgba(255, 0, 255, 1)";};}(),ya=function(){function t(t,e){void 0===e&&(e={}),this.faceLandmarks=t,this.options=new va(e);}return t.prototype.draw=function(t){var e=vo(t),n=this.options,r=n.drawLines,i=n.drawPoints,o=n.lineWidth,a=n.lineColor,s=n.pointSize,u=n.pointColor;if(r&&this.faceLandmarks instanceof Qi&&(e.strokeStyle=a,e.lineWidth=o,bi(e,this.faceLandmarks.getJawOutline()),bi(e,this.faceLandmarks.getLeftEyeBrow()),bi(e,this.faceLandmarks.getRightEyeBrow()),bi(e,this.faceLandmarks.getNose()),bi(e,this.faceLandmarks.getLeftEye(),!0),bi(e,this.faceLandmarks.getRightEye(),!0),bi(e,this.faceLandmarks.getMouth(),!0)),i){e.strokeStyle=u,e.fillStyle=u;this.faceLandmarks.positions.forEach(function(t){e.beginPath(),e.arc(t.x,t.y,s,0,2*Math.PI),e.fill();});}},t;}();function ba(t,e){(Array.isArray(e)?e:[e]).forEach(function(e){var n=e instanceof Yi?e:ma(e)?e.landmarks:void 0;if(!n)throw new Error("drawFaceLandmarks - expected faceExpressions to be FaceLandmarks | WithFaceLandmarks<WithFaceDetection<{}>> or array thereof");new ya(n).draw(t);});}function xa(t,e){var n=[],r=ea(t),i=r.extractWeights,o=r.getRemainingWeights,a=function(t,e){var n=Xo(t,e),r=Qo(t,e);return {extractConvParams:n,extractSeparableConvParams:r,extractReductionBlockParams:function extractReductionBlockParams(t,e,i){return {separable_conv0:r(t,e,i+"/separable_conv0"),separable_conv1:r(e,e,i+"/separable_conv1"),expansion_conv:n(t,e,1,i+"/expansion_conv")};},extractMainBlockParams:function extractMainBlockParams(t,e){return {separable_conv0:r(t,t,e+"/separable_conv0"),separable_conv1:r(t,t,e+"/separable_conv1"),separable_conv2:r(t,t,e+"/separable_conv2")};}};}(i,n),s=a.extractConvParams,u=a.extractSeparableConvParams,c=a.extractReductionBlockParams,l=a.extractMainBlockParams,f={conv_in:s(3,32,3,"entry_flow/conv_in"),reduction_block_0:c(32,64,"entry_flow/reduction_block_0"),reduction_block_1:c(64,128,"entry_flow/reduction_block_1")},h={};Ii(e,0,1).forEach(function(t){h["main_block_"+t]=l(128,"middle_flow/main_block_"+t);});var d={reduction_block:c(128,256,"exit_flow/reduction_block"),separable_conv:u(256,512,"exit_flow/separable_conv")};if(0!==o().length)throw new Error("weights remaing after extract: "+o().length);return {paramMappings:n,params:{entry_flow:f,middle_flow:h,exit_flow:d}};}function wa(t,e){var n=[],r=function(t,e){var n=ta(t,e),r=ra(n),i=Zo(n);return {extractConvParams:r,extractSeparableConvParams:i,extractReductionBlockParams:function extractReductionBlockParams(t){return {separable_conv0:i(t+"/separable_conv0"),separable_conv1:i(t+"/separable_conv1"),expansion_conv:r(t+"/expansion_conv")};},extractMainBlockParams:function extractMainBlockParams(t){return {separable_conv0:i(t+"/separable_conv0"),separable_conv1:i(t+"/separable_conv1"),separable_conv2:i(t+"/separable_conv2")};}};}(t,n),i=r.extractConvParams,o=r.extractSeparableConvParams,a=r.extractReductionBlockParams,s=r.extractMainBlockParams,u={conv_in:i("entry_flow/conv_in"),reduction_block_0:a("entry_flow/reduction_block_0"),reduction_block_1:a("entry_flow/reduction_block_1")},c={};Ii(e,0,1).forEach(function(t){c["main_block_"+t]=s("middle_flow/main_block_"+t);});var l={reduction_block:a("exit_flow/reduction_block"),separable_conv:o("exit_flow/separable_conv")};return Ko(t,n),{params:{entry_flow:u,middle_flow:c,exit_flow:l},paramMappings:n};}function ka(t,e,n){return yi.add(yi.conv2d(t,e.filters,n,"same"),e.bias);}function Ea(t,e,n){void 0===n&&(n=!0);var r=n?yi.relu(t):t;return r=qo(r,e.separable_conv0,[1,1]),r=qo(yi.relu(r),e.separable_conv1,[1,1]),r=yi.maxPool(r,[3,3],[2,2],"same"),r=yi.add(r,ka(t,e.expansion_conv,[2,2]));}var Ca,Aa=function(t){function e(e){var n=t.call(this,"TinyXception")||this;return n._numMainBlocks=e,n;}return Object(xi.c)(e,t),e.prototype.forwardInput=function(t){var e=this,n=this.params;if(!n)throw new Error("TinyXception - load model before inference");return yi.tidy(function(){var r=qi(t.toBatchTensor(112,!0),[122.782,117.001,104.298]).div(yi.scalar(256)),i=yi.relu(ka(r,n.entry_flow.conv_in,[2,2]));return i=Ea(i=Ea(i,n.entry_flow.reduction_block_0,!1),n.entry_flow.reduction_block_1),Ii(e._numMainBlocks,0,1).forEach(function(t){i=function(t,e){var n=qo(yi.relu(t),e.separable_conv0,[1,1]);return n=qo(yi.relu(n),e.separable_conv1,[1,1]),n=qo(yi.relu(n),e.separable_conv2,[1,1]),n=yi.add(n,t);}(i,n.middle_flow["main_block_"+t]);}),i=Ea(i,n.exit_flow.reduction_block),i=yi.relu(qo(i,n.exit_flow.separable_conv,[1,1]));});},e.prototype.forward=function(t){return Object(xi.b)(this,void 0,void 0,function(){var e;return Object(xi.d)(this,function(n){switch(n.label){case 0:return e=this.forwardInput,[4,Io(t)];case 1:return [2,e.apply(this,[n.sent()])];}});});},e.prototype.getDefaultModelName=function(){return "tiny_xception_model";},e.prototype.extractParamsFromWeigthMap=function(t){return wa(t,this._numMainBlocks);},e.prototype.extractParams=function(t){return xa(t,this._numMainBlocks);},e;}(Vo);!function(t){t.FEMALE="female",t.MALE="male";}(Ca||(Ca={}));var Oa=function(t){function e(e){void 0===e&&(e=new Aa(2));var n=t.call(this,"AgeGenderNet")||this;return n._faceFeatureExtractor=e,n;}return Object(xi.c)(e,t),Object.defineProperty(e.prototype,"faceFeatureExtractor",{get:function get(){return this._faceFeatureExtractor;},enumerable:!0,configurable:!0}),e.prototype.runNet=function(t){var e=this,n=this.params;if(!n)throw new Error(this._name+" - load model before inference");return yi.tidy(function(){var r=t instanceof No?e.faceFeatureExtractor.forwardInput(t):t,i=yi.avgPool(r,[7,7],[2,2],"valid").as2D(r.shape[0],-1);return {age:aa(i,n.fc.age).as1D(),gender:aa(i,n.fc.gender)};});},e.prototype.forwardInput=function(t){var e=this;return yi.tidy(function(){var n=e.runNet(t),r=n.age,i=n.gender;return {age:r,gender:yi.softmax(i)};});},e.prototype.forward=function(t){return Object(xi.b)(this,void 0,void 0,function(){var e;return Object(xi.d)(this,function(n){switch(n.label){case 0:return e=this.forwardInput,[4,Io(t)];case 1:return [2,e.apply(this,[n.sent()])];}});});},e.prototype.predictAgeAndGender=function(t){return Object(xi.b)(this,void 0,void 0,function(){var e,n,r,i,o,a,s=this;return Object(xi.d)(this,function(u){switch(u.label){case 0:return [4,Io(t)];case 1:return e=u.sent(),[4,this.forwardInput(e)];case 2:return n=u.sent(),r=yi.unstack(n.age),i=yi.unstack(n.gender),o=r.map(function(t,e){return {ageTensor:t,genderTensor:i[e]};}),[4,Promise.all(o.map(function(t){var e=t.ageTensor,n=t.genderTensor;return Object(xi.b)(s,void 0,void 0,function(){var t,r,i,o,a;return Object(xi.d)(this,function(s){switch(s.label){case 0:return [4,e.data()];case 1:return t=s.sent()[0],[4,n.data()];case 2:return r=s.sent()[0],o=(i=r>.5)?Ca.MALE:Ca.FEMALE,a=i?r:1-r,e.dispose(),n.dispose(),[2,{age:t,gender:o,genderProbability:a}];}});});}))];case 3:return a=u.sent(),n.age.dispose(),n.gender.dispose(),[2,e.isBatchInput?a:a[0]];}});});},e.prototype.getDefaultModelName=function(){return "age_gender_model";},e.prototype.dispose=function(e){void 0===e&&(e=!0),this.faceFeatureExtractor.dispose(e),t.prototype.dispose.call(this,e);},e.prototype.loadClassifierParams=function(t){var e=this.extractClassifierParams(t),n=e.params,r=e.paramMappings;this._params=n,this._paramMappings=r;},e.prototype.extractClassifierParams=function(t){return function(t){var e=[],n=ea(t),r=n.extractWeights,i=n.getRemainingWeights,o=Yo(r,e),a=o(512,1,"fc/age"),s=o(512,2,"fc/gender");if(0!==i().length)throw new Error("weights remaing after extract: "+i().length);return {paramMappings:e,params:{fc:{age:a,gender:s}}};}(t);},e.prototype.extractParamsFromWeigthMap=function(t){var e=sa(t),n=e.featureExtractorMap,r=e.classifierMap;return this.faceFeatureExtractor.loadFromWeightMap(n),function(t){var e=[],n=ta(t,e);function r(t){return {weights:n(t+"/weights",2),bias:n(t+"/bias",1)};}var i={fc:{age:r("fc/age"),gender:r("fc/gender")}};return Ko(t,e),{params:i,paramMappings:e};}(r);},e.prototype.extractParams=function(t){var e=t.slice(0,t.length-1539),n=t.slice(t.length-1539);return this.faceFeatureExtractor.extractWeights(e),this.extractClassifierParams(n);},e;}(Vo),_a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e.prototype.postProcess=function(t,e,n){var r=n.map(function(t){var n=t.width,r=t.height,i=e/Math.max(r,n);return {width:n*i,height:r*i};}),i=r.length;return yi.tidy(function(){var n=function n(t,e){return yi.stack([yi.fill([68],t),yi.fill([68],e)],1).as2D(1,136).as1D();},o=function o(t,e){var n=r[t],i=n.width,o=n.height;return e(i,o)?Math.abs(i-o)/2:0;};return t.mul(yi.fill([i,136],e)).sub(yi.stack(Array.from(Array(i),function(t,e){return n(function(t){return o(t,function(t,e){return t<e;});}(e),function(t){return o(t,function(t,e){return e<t;});}(e));}))).div(yi.stack(Array.from(Array(i),function(t,e){return n(r[e].width,r[e].height);})));});},e.prototype.forwardInput=function(t){var e=this;return yi.tidy(function(){var n=e.runNet(t);return e.postProcess(n,t.inputSize,t.inputDimensions.map(function(t){return {height:t[0],width:t[1]};}));});},e.prototype.forward=function(t){return Object(xi.b)(this,void 0,void 0,function(){var e;return Object(xi.d)(this,function(n){switch(n.label){case 0:return e=this.forwardInput,[4,Io(t)];case 1:return [2,e.apply(this,[n.sent()])];}});});},e.prototype.detectLandmarks=function(t){return Object(xi.b)(this,void 0,void 0,function(){var e,n,r,i=this;return Object(xi.d)(this,function(o){switch(o.label){case 0:return [4,Io(t)];case 1:return e=o.sent(),n=yi.tidy(function(){return yi.unstack(i.forwardInput(e));}),[4,Promise.all(n.map(function(t,n){return Object(xi.b)(i,void 0,void 0,function(){var r,i,o,a,s;return Object(xi.d)(this,function(u){switch(u.label){case 0:return o=(i=Array).from,[4,t.data()];case 1:return r=o.apply(i,[u.sent()]),a=r.filter(function(t,e){return Si(e);}),s=r.filter(function(t,e){return !Si(e);}),[2,new Qi(Array(68).fill(0).map(function(t,e){return new ji(a[e],s[e]);}),{height:e.getInputHeight(n),width:e.getInputWidth(n)})];}});});}))];case 2:return r=o.sent(),n.forEach(function(t){return t.dispose();}),[2,e.isBatchInput?r:r[0]];}});});},e.prototype.getClassifierChannelsOut=function(){return 136;},e;}(ua),Sa=function(t){function e(e){return void 0===e&&(e=new oa()),t.call(this,"FaceLandmark68Net",e)||this;}return Object(xi.c)(e,t),e.prototype.getDefaultModelName=function(){return "face_landmark_68_model";},e.prototype.getClassifierChannelsIn=function(){return 256;},e;}(_a);var Da=function(t){function e(){return t.call(this,"TinyFaceFeatureExtractor")||this;}return Object(xi.c)(e,t),e.prototype.forwardInput=function(t){var e=this.params;if(!e)throw new Error("TinyFaceFeatureExtractor - load model before inference");return yi.tidy(function(){var n=$o(qi(t.toBatchTensor(112,!0),[122.782,117.001,104.298]).div(yi.scalar(255)),e.dense0,!0);return n=$o(n=$o(n,e.dense1),e.dense2),n=yi.avgPool(n,[14,14],[2,2],"valid");});},e.prototype.forward=function(t){return Object(xi.b)(this,void 0,void 0,function(){var e;return Object(xi.d)(this,function(n){switch(n.label){case 0:return e=this.forwardInput,[4,Io(t)];case 1:return [2,e.apply(this,[n.sent()])];}});});},e.prototype.getDefaultModelName=function(){return "face_feature_extractor_tiny_model";},e.prototype.extractParamsFromWeigthMap=function(t){return function(t){var e=[],n=ia(t,e).extractDenseBlock3Params,r={dense0:n("dense0",!0),dense1:n("dense1"),dense2:n("dense2")};return Ko(t,e),{params:r,paramMappings:e};}(t);},e.prototype.extractParams=function(t){return function(t){var e=[],n=ea(t),r=n.extractWeights,i=n.getRemainingWeights,o=na(r,e).extractDenseBlock3Params,a=o(3,32,"dense0",!0),s=o(32,64,"dense1"),u=o(64,128,"dense2");if(0!==i().length)throw new Error("weights remaing after extract: "+i().length);return {paramMappings:e,params:{dense0:a,dense1:s,dense2:u}};}(t);},e;}(Vo),Fa=function(t){function e(e){return void 0===e&&(e=new Da()),t.call(this,"FaceLandmark68TinyNet",e)||this;}return Object(xi.c)(e,t),e.prototype.getDefaultModelName=function(){return "face_landmark_68_tiny_model";},e.prototype.getClassifierChannelsIn=function(){return 128;},e;}(_a),Ta=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e;}(Sa);function Na(t,e,n,r,i){void 0===i&&(i="same");var o=e.conv,a=o.filters,s=o.bias,u=yi.conv2d(t,a,n,i);return u=function(t,e){return yi.add(yi.mul(t,e.weights),e.biases);}(u=yi.add(u,s),e.scale),r?yi.relu(u):u;}function Ia(t,e){return Na(t,e,[1,1],!1);}function Ra(t,e){return Na(t,e,[2,2],!0,"valid");}function Ma(t,e){function n(n,r,i,o){var a=function(e,n,r){var i=t(e),o=i.length/(n*r*r);if(_i(o))throw new Error("depth has to be an integer: "+o+", weights.length: "+i.length+", numFilters: "+n+", filterSize: "+r);return yi.tidy(function(){return yi.transpose(yi.tensor4d(i,[n,o,r,r]),[2,3,1,0]);});}(n,r,i),s=yi.tensor1d(t(r));return e.push({paramPath:o+"/filters"},{paramPath:o+"/bias"}),{filters:a,bias:s};}function r(r,i,o,a){return {conv:n(r,i,o,a+"/conv"),scale:function(n,r){var i=yi.tensor1d(t(n)),o=yi.tensor1d(t(n));return e.push({paramPath:r+"/weights"},{paramPath:r+"/biases"}),{weights:i,biases:o};}(i,a+"/scale")};}return {extractConvLayerParams:r,extractResidualLayerParams:function extractResidualLayerParams(t,e,n,i,o){return void 0===o&&(o=!1),{conv1:r((o?.5:1)*t,e,n,i+"/conv1"),conv2:r(t,e,n,i+"/conv2")};}};}function ja(t,e){var n=ta(t,e);function r(t){return {conv:{filters:n(t+"/conv/filters",4),bias:n(t+"/conv/bias",1)},scale:function(t){return {weights:n(t+"/scale/weights",1),biases:n(t+"/scale/biases",1)};}(t)};}return {extractConvLayerParams:r,extractResidualLayerParams:function extractResidualLayerParams(t){return {conv1:r(t+"/conv1"),conv2:r(t+"/conv2")};}};}function Ba(t,e){var n=function(t,e){return Na(t,e,[1,1],!0);}(t,e.conv1);return n=Ia(n,e.conv2),n=yi.add(n,t),n=yi.relu(n);}function Pa(t,e){var n=Ra(t,e.conv1);n=Ia(n,e.conv2);var r=yi.avgPool(t,2,2,"valid"),i=yi.zeros(r.shape),o=r.shape[3]!==n.shape[3];if(r.shape[1]!==n.shape[1]||r.shape[2]!==n.shape[2]){var a=Object(xi.e)(n.shape);a[1]=1;var s=yi.zeros(a);n=yi.concat([n,s],1);var u=Object(xi.e)(n.shape);u[2]=1;var c=yi.zeros(u);n=yi.concat([n,c],2);}return r=o?yi.concat([r,i],3):r,n=yi.add(r,n),n=yi.relu(n);}var La=function(t){function e(){return t.call(this,"FaceRecognitionNet")||this;}return Object(xi.c)(e,t),e.prototype.forwardInput=function(t){var e=this.params;if(!e)throw new Error("FaceRecognitionNet - load model before inference");return yi.tidy(function(){var n=Ra(qi(t.toBatchTensor(150,!0).toFloat(),[122.782,117.001,104.298]).div(yi.scalar(256)),e.conv32_down),r=(n=Pa(n=Ba(n=Ba(n=Pa(n=Ba(n=Ba(n=Pa(n=Ba(n=Ba(n=Ba(n=Pa(n=Ba(n=Ba(n=Ba(n=yi.maxPool(n,3,2,"valid"),e.conv32_1),e.conv32_2),e.conv32_3),e.conv64_down),e.conv64_1),e.conv64_2),e.conv64_3),e.conv128_down),e.conv128_1),e.conv128_2),e.conv256_down),e.conv256_1),e.conv256_2),e.conv256_down_out)).mean([1,2]);return yi.matMul(r,e.fc);});},e.prototype.forward=function(t){return Object(xi.b)(this,void 0,void 0,function(){var e;return Object(xi.d)(this,function(n){switch(n.label){case 0:return e=this.forwardInput,[4,Io(t)];case 1:return [2,e.apply(this,[n.sent()])];}});});},e.prototype.computeFaceDescriptor=function(t){return Object(xi.b)(this,void 0,void 0,function(){var e,n,r,i=this;return Object(xi.d)(this,function(o){switch(o.label){case 0:return [4,Io(t)];case 1:return e=o.sent(),n=yi.tidy(function(){return yi.unstack(i.forwardInput(e));}),[4,Promise.all(n.map(function(t){return t.data();}))];case 2:return r=o.sent(),n.forEach(function(t){return t.dispose();}),[2,e.isBatchInput?r:r[0]];}});});},e.prototype.getDefaultModelName=function(){return "face_recognition_model";},e.prototype.extractParamsFromWeigthMap=function(t){return function(t){var e=[],n=ja(t,e),r=n.extractConvLayerParams,i=n.extractResidualLayerParams,o=r("conv32_down"),a=i("conv32_1"),s=i("conv32_2"),u=i("conv32_3"),c=i("conv64_down"),l=i("conv64_1"),f=i("conv64_2"),h=i("conv64_3"),d=i("conv128_down"),p=i("conv128_1"),m=i("conv128_2"),g=i("conv256_down"),v=i("conv256_1"),y=i("conv256_2"),b=i("conv256_down_out"),x=t.fc;if(e.push({originalPath:"fc",paramPath:"fc"}),!Ci(x))throw new Error("expected weightMap[fc] to be a Tensor2D, instead have "+x);var w={conv32_down:o,conv32_1:a,conv32_2:s,conv32_3:u,conv64_down:c,conv64_1:l,conv64_2:f,conv64_3:h,conv128_down:d,conv128_1:p,conv128_2:m,conv256_down:g,conv256_1:v,conv256_2:y,conv256_down_out:b,fc:x};return Ko(t,e),{params:w,paramMappings:e};}(t);},e.prototype.extractParams=function(t){return function(t){var e=ea(t),n=e.extractWeights,r=e.getRemainingWeights,i=[],o=Ma(n,i),a=o.extractConvLayerParams,s=o.extractResidualLayerParams,u=a(4704,32,7,"conv32_down"),c=s(9216,32,3,"conv32_1"),l=s(9216,32,3,"conv32_2"),f=s(9216,32,3,"conv32_3"),h=s(36864,64,3,"conv64_down",!0),d=s(36864,64,3,"conv64_1"),p=s(36864,64,3,"conv64_2"),m=s(36864,64,3,"conv64_3"),g=s(147456,128,3,"conv128_down",!0),v=s(147456,128,3,"conv128_1"),y=s(147456,128,3,"conv128_2"),b=s(589824,256,3,"conv256_down",!0),x=s(589824,256,3,"conv256_1"),w=s(589824,256,3,"conv256_2"),k=s(589824,256,3,"conv256_down_out"),E=yi.tidy(function(){return yi.transpose(yi.tensor2d(n(32768),[128,256]),[1,0]);});if(i.push({paramPath:"fc"}),0!==r().length)throw new Error("weights remaing after extract: "+r().length);return {params:{conv32_down:u,conv32_1:c,conv32_2:l,conv32_3:f,conv64_down:h,conv64_1:d,conv64_2:p,conv64_3:m,conv128_down:g,conv128_1:v,conv128_2:y,conv256_down:b,conv256_1:x,conv256_2:w,conv256_down_out:k,fc:E},paramMappings:i};}(t);},e;}(Vo);function za(t){var e=new La();return e.extractWeights(t),e;}function Ua(t,e){var n={descriptor:e};return Object.assign({},t,n);}function Wa(t){return "number"==typeof t.age;}function Va(t,e){var n={age:e};return Object.assign({},t,n);}function qa(t){return (t.gender===Ca.MALE||t.gender===Ca.FEMALE)&&Mi(t.genderProbability);}function $a(t,e,n){var r={gender:e,genderProbability:n};return Object.assign({},t,r);}var Ha=function(){function t(t){var e=void 0===t?{}:t,n=e.minFaceSize,r=e.scaleFactor,i=e.maxNumScales,o=e.scoreThresholds,a=e.scaleSteps;if(this._name="MtcnnOptions",this._minFaceSize=n||20,this._scaleFactor=r||.709,this._maxNumScales=i||10,this._scoreThresholds=o||[.6,.7,.7],this._scaleSteps=a,"number"!=typeof this._minFaceSize||this._minFaceSize<0)throw new Error(this._name+" - expected minFaceSize to be a number > 0");if("number"!=typeof this._scaleFactor||this._scaleFactor<=0||this._scaleFactor>=1)throw new Error(this._name+" - expected scaleFactor to be a number between 0 and 1");if("number"!=typeof this._maxNumScales||this._maxNumScales<0)throw new Error(this._name+" - expected maxNumScales to be a number > 0");if(!Array.isArray(this._scoreThresholds)||3!==this._scoreThresholds.length||this._scoreThresholds.some(function(t){return "number"!=typeof t;}))throw new Error(this._name+" - expected scoreThresholds to be an array of numbers of length 3");if(this._scaleSteps&&(!Array.isArray(this._scaleSteps)||this._scaleSteps.some(function(t){return "number"!=typeof t;})))throw new Error(this._name+" - expected scaleSteps to be an array of numbers");}return Object.defineProperty(t.prototype,"minFaceSize",{get:function get(){return this._minFaceSize;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scaleFactor",{get:function get(){return this._scaleFactor;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxNumScales",{get:function get(){return this._maxNumScales;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scoreThresholds",{get:function get(){return this._scoreThresholds;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scaleSteps",{get:function get(){return this._scaleSteps;},enumerable:!0,configurable:!0}),t;}();function Ga(t,e){function n(n,r,i,o,a){var s=yi.tensor4d(t(n*r*i*i),[i,i,n,r]),u=yi.tensor1d(t(r));return e.push({paramPath:o+"/filters"},{paramPath:o+"/"+(a?"batch_norm_offset":"bias")}),{filters:s,bias:u};}function r(t,e,r,i){var o=n(t,e,r,i,!0);return {filters:o.filters,batch_norm_offset:o.bias};}function i(n,i,o){return {depthwise_conv:function(n,r){var i=yi.tensor4d(t(9*n),[3,3,n,1]),o=yi.tensor1d(t(n)),a=yi.tensor1d(t(n)),s=yi.tensor1d(t(n)),u=yi.tensor1d(t(n));return e.push({paramPath:r+"/filters"},{paramPath:r+"/batch_norm_scale"},{paramPath:r+"/batch_norm_offset"},{paramPath:r+"/batch_norm_mean"},{paramPath:r+"/batch_norm_variance"}),{filters:i,batch_norm_scale:o,batch_norm_offset:a,batch_norm_mean:s,batch_norm_variance:u};}(n,o+"/depthwise_conv"),pointwise_conv:r(n,i,1,o+"/pointwise_conv")};}return {extractMobilenetV1Params:function extractMobilenetV1Params(){return {conv_0:r(3,32,3,"mobilenetv1/conv_0"),conv_1:i(32,64,"mobilenetv1/conv_1"),conv_2:i(64,128,"mobilenetv1/conv_2"),conv_3:i(128,128,"mobilenetv1/conv_3"),conv_4:i(128,256,"mobilenetv1/conv_4"),conv_5:i(256,256,"mobilenetv1/conv_5"),conv_6:i(256,512,"mobilenetv1/conv_6"),conv_7:i(512,512,"mobilenetv1/conv_7"),conv_8:i(512,512,"mobilenetv1/conv_8"),conv_9:i(512,512,"mobilenetv1/conv_9"),conv_10:i(512,512,"mobilenetv1/conv_10"),conv_11:i(512,512,"mobilenetv1/conv_11"),conv_12:i(512,1024,"mobilenetv1/conv_12"),conv_13:i(1024,1024,"mobilenetv1/conv_13")};},extractPredictionLayerParams:function extractPredictionLayerParams(){return {conv_0:r(1024,256,1,"prediction_layer/conv_0"),conv_1:r(256,512,3,"prediction_layer/conv_1"),conv_2:r(512,128,1,"prediction_layer/conv_2"),conv_3:r(128,256,3,"prediction_layer/conv_3"),conv_4:r(256,128,1,"prediction_layer/conv_4"),conv_5:r(128,256,3,"prediction_layer/conv_5"),conv_6:r(256,64,1,"prediction_layer/conv_6"),conv_7:r(64,128,3,"prediction_layer/conv_7"),box_predictor_0:{box_encoding_predictor:n(512,12,1,"prediction_layer/box_predictor_0/box_encoding_predictor"),class_predictor:n(512,9,1,"prediction_layer/box_predictor_0/class_predictor")},box_predictor_1:{box_encoding_predictor:n(1024,24,1,"prediction_layer/box_predictor_1/box_encoding_predictor"),class_predictor:n(1024,18,1,"prediction_layer/box_predictor_1/class_predictor")},box_predictor_2:{box_encoding_predictor:n(512,24,1,"prediction_layer/box_predictor_2/box_encoding_predictor"),class_predictor:n(512,18,1,"prediction_layer/box_predictor_2/class_predictor")},box_predictor_3:{box_encoding_predictor:n(256,24,1,"prediction_layer/box_predictor_3/box_encoding_predictor"),class_predictor:n(256,18,1,"prediction_layer/box_predictor_3/class_predictor")},box_predictor_4:{box_encoding_predictor:n(256,24,1,"prediction_layer/box_predictor_4/box_encoding_predictor"),class_predictor:n(256,18,1,"prediction_layer/box_predictor_4/class_predictor")},box_predictor_5:{box_encoding_predictor:n(128,24,1,"prediction_layer/box_predictor_5/box_encoding_predictor"),class_predictor:n(128,18,1,"prediction_layer/box_predictor_5/class_predictor")}};}};}function Ka(t){var e=[],n=function(t,e){var n=ta(t,e);function r(t,e,r){return {filters:n(t+"/Conv2d_"+e+"_pointwise/weights",4,r+"/filters"),batch_norm_offset:n(t+"/Conv2d_"+e+"_pointwise/convolution_bn_offset",1,r+"/batch_norm_offset")};}function i(t){var e="mobilenetv1/conv_"+t,i="MobilenetV1/Conv2d_"+t+"_depthwise",o=e+"/depthwise_conv",a=e+"/pointwise_conv";return {depthwise_conv:{filters:n(i+"/depthwise_weights",4,o+"/filters"),batch_norm_scale:n(i+"/BatchNorm/gamma",1,o+"/batch_norm_scale"),batch_norm_offset:n(i+"/BatchNorm/beta",1,o+"/batch_norm_offset"),batch_norm_mean:n(i+"/BatchNorm/moving_mean",1,o+"/batch_norm_mean"),batch_norm_variance:n(i+"/BatchNorm/moving_variance",1,o+"/batch_norm_variance")},pointwise_conv:r("MobilenetV1",t,a)};}function o(t,e){return {filters:n(t+"/weights",4,e+"/filters"),bias:n(t+"/biases",1,e+"/bias")};}function a(t){return {box_encoding_predictor:o("Prediction/BoxPredictor_"+t+"/BoxEncodingPredictor","prediction_layer/box_predictor_"+t+"/box_encoding_predictor"),class_predictor:o("Prediction/BoxPredictor_"+t+"/ClassPredictor","prediction_layer/box_predictor_"+t+"/class_predictor")};}return {extractMobilenetV1Params:function extractMobilenetV1Params(){return {conv_0:r("MobilenetV1",0,"mobilenetv1/conv_0"),conv_1:i(1),conv_2:i(2),conv_3:i(3),conv_4:i(4),conv_5:i(5),conv_6:i(6),conv_7:i(7),conv_8:i(8),conv_9:i(9),conv_10:i(10),conv_11:i(11),conv_12:i(12),conv_13:i(13)};},extractPredictionLayerParams:function extractPredictionLayerParams(){return {conv_0:r("Prediction",0,"prediction_layer/conv_0"),conv_1:r("Prediction",1,"prediction_layer/conv_1"),conv_2:r("Prediction",2,"prediction_layer/conv_2"),conv_3:r("Prediction",3,"prediction_layer/conv_3"),conv_4:r("Prediction",4,"prediction_layer/conv_4"),conv_5:r("Prediction",5,"prediction_layer/conv_5"),conv_6:r("Prediction",6,"prediction_layer/conv_6"),conv_7:r("Prediction",7,"prediction_layer/conv_7"),box_predictor_0:a(0),box_predictor_1:a(1),box_predictor_2:a(2),box_predictor_3:a(3),box_predictor_4:a(4),box_predictor_5:a(5)};}};}(t,e),r=n.extractMobilenetV1Params,i=n.extractPredictionLayerParams,o=t["Output/extra_dim"];if(e.push({originalPath:"Output/extra_dim",paramPath:"output_layer/extra_dim"}),!Ai(o))throw new Error("expected weightMap['Output/extra_dim'] to be a Tensor3D, instead have "+o);var a={mobilenetv1:r(),prediction_layer:i(),output_layer:{extra_dim:o}};return Ko(t,e),{params:a,paramMappings:e};}function Xa(t,e,n){return yi.tidy(function(){var r=yi.conv2d(t,e.filters,n,"same");return r=yi.add(r,e.batch_norm_offset),yi.clipByValue(r,0,6);});}var Ya=.0010000000474974513;function Ja(t,e){return yi.tidy(function(){var n=null,r=Xa(t,e.conv_0,[2,2]);if([e.conv_1,e.conv_2,e.conv_3,e.conv_4,e.conv_5,e.conv_6,e.conv_7,e.conv_8,e.conv_9,e.conv_10,e.conv_11,e.conv_12,e.conv_13].forEach(function(t,e){var i=e+1,o=function(t){return [2,4,6,12].some(function(e){return e===t;})?[2,2]:[1,1];}(i);r=Xa(r=function(t,e,n){return yi.tidy(function(){var r=yi.depthwiseConv2d(t,e.filters,n,"same");return r=yi.batchNorm(r,e.batch_norm_mean,e.batch_norm_variance,e.batch_norm_offset,e.batch_norm_scale,Ya),yi.clipByValue(r,0,6);});}(r,t.depthwise_conv,o),t.pointwise_conv,[1,1]),11===i&&(n=r);}),null===n)throw new Error("mobileNetV1 - output of conv layer 11 is null");return {out:r,conv11:n};});}function Qa(t,e,n){var r=t.arraySync(),i=Math.min(r[e][0],r[e][2]),o=Math.min(r[e][1],r[e][3]),a=Math.max(r[e][0],r[e][2]),s=Math.max(r[e][1],r[e][3]),u=Math.min(r[n][0],r[n][2]),c=Math.min(r[n][1],r[n][3]),l=Math.max(r[n][0],r[n][2]),f=Math.max(r[n][1],r[n][3]),h=(a-i)*(s-o),d=(l-u)*(f-c);if(h<=0||d<=0)return 0;var p=Math.max(i,u),m=Math.max(o,c),g=Math.min(a,l),v=Math.min(s,f),y=Math.max(g-p,0)*Math.max(v-m,0);return y/(h+d-y);}function Za(t,e){var n=function(t){var e=yi.unstack(yi.transpose(t,[1,0])),n=[yi.sub(e[2],e[0]),yi.sub(e[3],e[1])];return {sizes:n,centers:[yi.add(e[0],yi.div(n[0],yi.scalar(2))),yi.add(e[1],yi.div(n[1],yi.scalar(2)))]};}(t),r=n.sizes,i=n.centers,o=yi.unstack(yi.transpose(e,[1,0])),a=yi.div(yi.mul(yi.exp(yi.div(o[2],yi.scalar(5))),r[0]),yi.scalar(2)),s=yi.add(yi.mul(yi.div(o[0],yi.scalar(10)),r[0]),i[0]),u=yi.div(yi.mul(yi.exp(yi.div(o[3],yi.scalar(5))),r[1]),yi.scalar(2)),c=yi.add(yi.mul(yi.div(o[1],yi.scalar(10)),r[1]),i[1]);return yi.transpose(yi.stack([yi.sub(s,a),yi.sub(c,u),yi.add(s,a),yi.add(c,u)]),[1,0]);}function ts(t,e){return yi.tidy(function(){var n=t.shape[0];return {boxPredictionEncoding:yi.reshape(Go(t,e.box_encoding_predictor),[n,-1,1,4]),classPrediction:yi.reshape(Go(t,e.class_predictor),[n,-1,3])};});}var es=function(){function t(t){var e=void 0===t?{}:t,n=e.minConfidence,r=e.maxResults;if(this._name="SsdMobilenetv1Options",this._minConfidence=n||.5,this._maxResults=r||100,"number"!=typeof this._minConfidence||this._minConfidence<=0||this._minConfidence>=1)throw new Error(this._name+" - expected minConfidence to be a number between 0 and 1");if("number"!=typeof this._maxResults)throw new Error(this._name+" - expected maxResults to be a number");}return Object.defineProperty(t.prototype,"minConfidence",{get:function get(){return this._minConfidence;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxResults",{get:function get(){return this._maxResults;},enumerable:!0,configurable:!0}),t;}(),ns=function(t){function e(){return t.call(this,"SsdMobilenetv1")||this;}return Object(xi.c)(e,t),e.prototype.forwardInput=function(t){var e=this.params;if(!e)throw new Error("SsdMobilenetv1 - load model before inference");return yi.tidy(function(){var n=t.toBatchTensor(512,!1).toFloat(),r=Ja(yi.sub(yi.mul(n,yi.scalar(.007843137718737125)),yi.scalar(1)),e.mobilenetv1),i=function(t,e,n){return yi.tidy(function(){var r=Xa(Xa(t,n.conv_0,[1,1]),n.conv_1,[2,2]),i=Xa(Xa(r,n.conv_2,[1,1]),n.conv_3,[2,2]),o=Xa(Xa(i,n.conv_4,[1,1]),n.conv_5,[2,2]),a=Xa(Xa(o,n.conv_6,[1,1]),n.conv_7,[2,2]),s=ts(e,n.box_predictor_0),u=ts(t,n.box_predictor_1),c=ts(r,n.box_predictor_2),l=ts(i,n.box_predictor_3),f=ts(o,n.box_predictor_4),h=ts(a,n.box_predictor_5);return {boxPredictions:yi.concat([s.boxPredictionEncoding,u.boxPredictionEncoding,c.boxPredictionEncoding,l.boxPredictionEncoding,f.boxPredictionEncoding,h.boxPredictionEncoding],1),classPredictions:yi.concat([s.classPrediction,u.classPrediction,c.classPrediction,l.classPrediction,f.classPrediction,h.classPrediction],1)};});}(r.out,r.conv11,e.prediction_layer);return function(t,e,n){return yi.tidy(function(){var r=t.shape[0],i=Za(yi.reshape(yi.tile(n.extra_dim,[r,1,1]),[-1,4]),yi.reshape(t,[-1,4]));i=yi.reshape(i,[r,i.shape[0]/r,4]);var o=yi.sigmoid(yi.slice(e,[0,0,1],[-1,-1,-1])),a=yi.slice(o,[0,0,0],[-1,-1,1]);return a=yi.reshape(a,[r,a.shape[1]]),{boxes:yi.unstack(i),scores:yi.unstack(a)};});}(i.boxPredictions,i.classPredictions,e.output_layer);});},e.prototype.forward=function(t){return Object(xi.b)(this,void 0,void 0,function(){var e;return Object(xi.d)(this,function(n){switch(n.label){case 0:return e=this.forwardInput,[4,Io(t)];case 1:return [2,e.apply(this,[n.sent()])];}});});},e.prototype.locateFaces=function(t,e){return void 0===e&&(e={}),Object(xi.b)(this,void 0,void 0,function(){var n,r,i,o,a,s,u,c,l,f,h,d,p,m,g,v,y,b,x,w;return Object(xi.d)(this,function(k){switch(k.label){case 0:return n=new es(e),r=n.maxResults,i=n.minConfidence,[4,Io(t)];case 1:for(o=k.sent(),a=this.forwardInput(o),s=a.boxes,u=a.scores,c=s[0],l=u[0],f=1;f<s.length;f++){s[f].dispose(),u[f].dispose();}return p=(d=Array).from,[4,l.data()];case 2:return h=p.apply(d,[k.sent()]),m=function(t,e,n,r,i){var o=t.shape[0],a=Math.min(n,o),s=function s(t){return t<=r?1:0;},u=[];return e.map(function(t,e){return {score:t,boxIndex:e};}).filter(function(t){return t.score>i;}).sort(function(t,e){return e.score-t.score;}).forEach(function(e){if(!(u.length>=a)){for(var n=e.score,r=u.length-1;r>=0;--r){var o=Qa(t,e.boxIndex,u[r]);if(0!==o&&(e.score*=s(o),e.score<=i))break;}n===e.score&&u.push(e.boxIndex);}}),u;}(c,h,r,.5,i),g=o.getReshapedInputDimensions(0),v=o.inputSize,y=v/g.width,b=v/g.height,x=c.arraySync(),w=m.map(function(t){var e=[Math.max(0,x[t][0]),Math.min(1,x[t][2])].map(function(t){return t*b;}),n=e[0],r=e[1],i=[Math.max(0,x[t][1]),Math.min(1,x[t][3])].map(function(t){return t*y;}),a=i[0],s=i[1];return new zi(h[t],new Xi(a,n,s-a,r-n),{height:o.getInputHeight(0),width:o.getInputWidth(0)});}),c.dispose(),l.dispose(),[2,w];}});});},e.prototype.getDefaultModelName=function(){return "ssd_mobilenetv1_model";},e.prototype.extractParamsFromWeigthMap=function(t){return Ka(t);},e.prototype.extractParams=function(t){return function(t){var e=[],n=ea(t),r=n.extractWeights,i=n.getRemainingWeights,o=Ga(r,e),a=o.extractMobilenetV1Params,s=o.extractPredictionLayerParams,u=a(),c=s(),l={extra_dim:yi.tensor3d(r(20472),[1,5118,4])};if(e.push({paramPath:"output_layer/extra_dim"}),0!==i().length)throw new Error("weights remaing after extract: "+i().length);return {params:{mobilenetv1:u,prediction_layer:c,output_layer:l},paramMappings:e};}(t);},e;}(Vo);function rs(t){var e=new ns();return e.extractWeights(t),e;}function is(t){return rs(t);}var os,as=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e;}(ns),ss=.4,us=[new ji(.738768,.874946),new ji(2.42204,2.65704),new ji(4.30971,7.04493),new ji(10.246,4.59428),new ji(12.6868,11.8741)],cs=[new ji(1.603231,2.094468),new ji(6.041143,7.080126),new ji(2.882459,3.518061),new ji(4.266906,5.178857),new ji(9.041765,10.66308)],ls=[117.001,114.697,97.404],fs=function fs(t){return "number"==typeof t;};function hs(t){if(!t)throw new Error("invalid config: "+t);if("boolean"!=typeof t.withSeparableConvs)throw new Error("config.withSeparableConvs has to be a boolean, have: "+t.withSeparableConvs);if(!fs(t.iouThreshold)||t.iouThreshold<0||t.iouThreshold>1)throw new Error("config.iouThreshold has to be a number between [0, 1], have: "+t.iouThreshold);if(!Array.isArray(t.classes)||!t.classes.length||!t.classes.every(function(t){return "string"==typeof t;}))throw new Error("config.classes has to be an array class names: string[], have: "+JSON.stringify(t.classes));if(!Array.isArray(t.anchors)||!t.anchors.length||!t.anchors.map(function(t){return t||{};}).every(function(t){return fs(t.x)&&fs(t.y);}))throw new Error("config.anchors has to be an array of { x: number, y: number }, have: "+JSON.stringify(t.anchors));if(t.meanRgb&&(!Array.isArray(t.meanRgb)||3!==t.meanRgb.length||!t.meanRgb.every(fs)))throw new Error("config.meanRgb has to be an array of shape [number, number, number], have: "+JSON.stringify(t.meanRgb));}function ds(t){return yi.tidy(function(){var e=yi.mul(t,yi.scalar(.10000000149011612));return yi.add(yi.relu(yi.sub(t,e)),e);});}function ps(t,e){return yi.tidy(function(){var n=yi.pad(t,[[0,0],[1,1],[1,1],[0,0]]);return n=yi.conv2d(n,e.conv.filters,[1,1],"valid"),n=yi.sub(n,e.bn.sub),n=yi.mul(n,e.bn.truediv),ds(n=yi.add(n,e.conv.bias));});}function ms(t,e){return yi.tidy(function(){var n=yi.pad(t,[[0,0],[1,1],[1,1],[0,0]]);return n=yi.separableConv2d(n,e.depthwise_filter,e.pointwise_filter,[1,1],"valid"),ds(n=yi.add(n,e.bias));});}function gs(t,e){var n=Xo(t,e);var r=Qo(t,e);return {extractConvParams:n,extractConvWithBatchNormParams:function extractConvWithBatchNormParams(r,i,o){return {conv:n(r,i,3,o+"/conv"),bn:function(n,r){var i=yi.tensor1d(t(n)),o=yi.tensor1d(t(n));return e.push({paramPath:r+"/sub"},{paramPath:r+"/truediv"}),{sub:i,truediv:o};}(i,o+"/bn")};},extractSeparableConvParams:r};}function vs(t,e){var n=ta(t,e);function r(t){return {filters:n(t+"/filters",4),bias:n(t+"/bias",1)};}return {extractConvParams:r,extractConvWithBatchNormParams:function extractConvWithBatchNormParams(t){return {conv:r(t+"/conv"),bn:function(t){return {sub:n(t+"/sub",1),truediv:n(t+"/truediv",1)};}(t+"/bn")};},extractSeparableConvParams:Zo(n)};}!function(t){t[t.XS=224]="XS",t[t.SM=320]="SM",t[t.MD=416]="MD",t[t.LG=608]="LG";}(os||(os={}));var ys=function(){function t(t){var e=void 0===t?{}:t,n=e.inputSize,r=e.scoreThreshold;if(this._name="TinyYolov2Options",this._inputSize=n||416,this._scoreThreshold=r||.5,"number"!=typeof this._inputSize||this._inputSize%32!=0)throw new Error(this._name+" - expected inputSize to be a number divisible by 32");if("number"!=typeof this._scoreThreshold||this._scoreThreshold<=0||this._scoreThreshold>=1)throw new Error(this._name+" - expected scoreThreshold to be a number between 0 and 1");}return Object.defineProperty(t.prototype,"inputSize",{get:function get(){return this._inputSize;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scoreThreshold",{get:function get(){return this._scoreThreshold;},enumerable:!0,configurable:!0}),t;}(),bs=function(t){function e(e){var n=t.call(this,"TinyYolov2")||this;return hs(e),n._config=e,n;}return Object(xi.c)(e,t),Object.defineProperty(e.prototype,"config",{get:function get(){return this._config;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"withClassScores",{get:function get(){return this.config.withClassScores||this.config.classes.length>1;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"boxEncodingSize",{get:function get(){return 5+(this.withClassScores?this.config.classes.length:0);},enumerable:!0,configurable:!0}),e.prototype.runTinyYolov2=function(t,e){var n=ps(t,e.conv0);return n=ps(n=yi.maxPool(n,[2,2],[2,2],"same"),e.conv1),n=ps(n=yi.maxPool(n,[2,2],[2,2],"same"),e.conv2),n=ps(n=yi.maxPool(n,[2,2],[2,2],"same"),e.conv3),n=ps(n=yi.maxPool(n,[2,2],[2,2],"same"),e.conv4),n=ps(n=yi.maxPool(n,[2,2],[2,2],"same"),e.conv5),Go(n=ps(n=ps(n=yi.maxPool(n,[2,2],[1,1],"same"),e.conv6),e.conv7),e.conv8,"valid",!1);},e.prototype.runMobilenet=function(t,e){var n=this.config.isFirstLayerConv2d?ds(Go(t,e.conv0,"valid",!1)):ms(t,e.conv0);return n=ms(n=yi.maxPool(n,[2,2],[2,2],"same"),e.conv1),n=ms(n=yi.maxPool(n,[2,2],[2,2],"same"),e.conv2),n=ms(n=yi.maxPool(n,[2,2],[2,2],"same"),e.conv3),n=ms(n=yi.maxPool(n,[2,2],[2,2],"same"),e.conv4),n=ms(n=yi.maxPool(n,[2,2],[2,2],"same"),e.conv5),n=yi.maxPool(n,[2,2],[1,1],"same"),n=e.conv6?ms(n,e.conv6):n,Go(n=e.conv7?ms(n,e.conv7):n,e.conv8,"valid",!1);},e.prototype.forwardInput=function(t,e){var n=this,r=this.params;if(!r)throw new Error("TinyYolov2 - load model before inference");return yi.tidy(function(){var i=t.toBatchTensor(e,!1).toFloat();return i=(i=n.config.meanRgb?qi(i,n.config.meanRgb):i).div(yi.scalar(256)),n.config.withSeparableConvs?n.runMobilenet(i,r):n.runTinyYolov2(i,r);});},e.prototype.forward=function(t,e){return Object(xi.b)(this,void 0,void 0,function(){var n;return Object(xi.d)(this,function(r){switch(r.label){case 0:return n=this.forwardInput,[4,Io(t)];case 1:return [4,n.apply(this,[r.sent(),e])];case 2:return [2,r.sent()];}});});},e.prototype.detect=function(t,e){return void 0===e&&(e={}),Object(xi.b)(this,void 0,void 0,function(){var n,r,i,o,a,s,u,c,l,f,h,d,p,m=this;return Object(xi.d)(this,function(g){switch(g.label){case 0:return n=new ys(e),r=n.inputSize,i=n.scoreThreshold,[4,Io(t)];case 1:return o=g.sent(),[4,this.forwardInput(o,r)];case 2:return a=g.sent(),s=yi.tidy(function(){return yi.unstack(a)[0].expandDims();}),u={width:o.getInputWidth(0),height:o.getInputHeight(0)},[4,this.extractBoxes(s,o.getReshapedInputDimensions(0),i)];case 3:return c=g.sent(),a.dispose(),s.dispose(),l=c.map(function(t){return t.box;}),f=c.map(function(t){return t.score;}),h=c.map(function(t){return t.classScore;}),d=c.map(function(t){return m.config.classes[t.label];}),p=Vi(l.map(function(t){return t.rescale(r);}),f,this.config.iouThreshold,!0),[2,p.map(function(t){return new Li(f[t],h[t],d[t],l[t],u);})];}});});},e.prototype.getDefaultModelName=function(){return "";},e.prototype.extractParamsFromWeigthMap=function(t){return function(t,e){var n,r=[],i=vs(t,r),o=i.extractConvParams,a=i.extractConvWithBatchNormParams,s=i.extractSeparableConvParams;if(e.withSeparableConvs){var u=e.filterSizes&&e.filterSizes.length||9;n={conv0:e.isFirstLayerConv2d?o("conv0"):s("conv0"),conv1:s("conv1"),conv2:s("conv2"),conv3:s("conv3"),conv4:s("conv4"),conv5:s("conv5"),conv6:u>7?s("conv6"):void 0,conv7:u>8?s("conv7"):void 0,conv8:o("conv8")};}else n={conv0:a("conv0"),conv1:a("conv1"),conv2:a("conv2"),conv3:a("conv3"),conv4:a("conv4"),conv5:a("conv5"),conv6:a("conv6"),conv7:a("conv7"),conv8:o("conv8")};return Ko(t,r),{params:n,paramMappings:r};}(t,this.config);},e.prototype.extractParams=function(t){var n=this.config.filterSizes||e.DEFAULT_FILTER_SIZES,r=n?n.length:void 0;if(7!==r&&8!==r&&9!==r)throw new Error("TinyYolov2 - expected 7 | 8 | 9 convolutional filters, but found "+r+" filterSizes in config");return function(t,e,n,r){var i,o=ea(t),a=o.extractWeights,s=o.getRemainingWeights,u=[],c=gs(a,u),l=c.extractConvParams,f=c.extractConvWithBatchNormParams,h=c.extractSeparableConvParams;if(e.withSeparableConvs){var d=r[0],p=r[1],m=r[2],g=r[3],v=r[4],y=r[5],b=r[6],x=r[7],w=r[8];i={conv0:e.isFirstLayerConv2d?l(d,p,3,"conv0"):h(d,p,"conv0"),conv1:h(p,m,"conv1"),conv2:h(m,g,"conv2"),conv3:h(g,v,"conv3"),conv4:h(v,y,"conv4"),conv5:h(y,b,"conv5"),conv6:x?h(b,x,"conv6"):void 0,conv7:w?h(x,w,"conv7"):void 0,conv8:l(w||x||b,5*n,1,"conv8")};}else d=r[0],p=r[1],m=r[2],g=r[3],v=r[4],y=r[5],b=r[6],x=r[7],w=r[8],i={conv0:f(d,p,"conv0"),conv1:f(p,m,"conv1"),conv2:f(m,g,"conv2"),conv3:f(g,v,"conv3"),conv4:f(v,y,"conv4"),conv5:f(y,b,"conv5"),conv6:f(b,x,"conv6"),conv7:f(x,w,"conv7"),conv8:l(w,5*n,1,"conv8")};if(0!==s().length)throw new Error("weights remaing after extract: "+s().length);return {params:i,paramMappings:u};}(t,this.config,this.boxEncodingSize,n);},e.prototype.extractBoxes=function(t,e,n){return Object(xi.b)(this,void 0,void 0,function(){var r,i,o,a,s,u,c,l,f,h,d,p,m,g,v,y,b,x,w,k,E,C,A,O,_,S,D,F,T,N=this;return Object(xi.d)(this,function(I){switch(I.label){case 0:return r=e.width,i=e.height,o=Math.max(r,i),a=o/r,s=o/i,u=t.shape[1],c=this.config.anchors.length,l=yi.tidy(function(){var e=t.reshape([u,u,c,N.boxEncodingSize]);return [e.slice([0,0,0,0],[u,u,c,4]),e.slice([0,0,0,4],[u,u,c,1]),N.withClassScores?yi.softmax(e.slice([0,0,0,5],[u,u,c,N.config.classes.length]),3):yi.scalar(0)];}),f=l[0],h=l[1],d=l[2],p=[],[4,h.array()];case 1:return m=I.sent(),[4,f.array()];case 2:g=I.sent(),v=0,I.label=3;case 3:if(!(v<u))return [3,12];y=0,I.label=4;case 4:if(!(y<u))return [3,11];b=0,I.label=5;case 5:return b<c?(x=Gi(m[v][y][b][0]),!n||x>n?(w=(y+Gi(g[v][y][b][0]))/u*a,k=(v+Gi(g[v][y][b][1]))/u*s,E=Math.exp(g[v][y][b][2])*this.config.anchors[b].x/u*a,C=Math.exp(g[v][y][b][3])*this.config.anchors[b].y/u*s,A=w-E/2,O=k-C/2,_={row:v,col:y,anchor:b},this.withClassScores?[4,this.extractPredictedClass(d,_)]:[3,7]):[3,9]):[3,10];case 6:return T=I.sent(),[3,8];case 7:T={classScore:1,label:0},I.label=8;case 8:D=(S=T).classScore,F=S.label,p.push(Object(xi.a)({box:new Pi(A,O,A+E,O+C),score:x,classScore:x*D,label:F},_)),I.label=9;case 9:return b++,[3,5];case 10:return y++,[3,4];case 11:return v++,[3,3];case 12:return f.dispose(),h.dispose(),d.dispose(),[2,p];}});});},e.prototype.extractPredictedClass=function(t,e){return Object(xi.b)(this,void 0,void 0,function(){var n,r,i,o;return Object(xi.d)(this,function(a){switch(a.label){case 0:return n=e.row,r=e.col,i=e.anchor,[4,t.array()];case 1:return o=a.sent(),[2,Array(this.config.classes.length).fill(0).map(function(t,e){return o[n][r][i][e];}).map(function(t,e){return {classScore:t,label:e};}).reduce(function(t,e){return t.classScore>e.classScore?t:e;})];}});});},e.DEFAULT_FILTER_SIZES=[3,16,32,64,128,256,512,1024,1024],e;}(Vo),xs=function(t){function e(e){void 0===e&&(e=!0);var n=Object.assign({},{withSeparableConvs:e,iouThreshold:ss,classes:["face"]},e?{anchors:cs,meanRgb:ls}:{anchors:us,withClassScores:!0});return t.call(this,n)||this;}return Object(xi.c)(e,t),Object.defineProperty(e.prototype,"withSeparableConvs",{get:function get(){return this.config.withSeparableConvs;},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"anchors",{get:function get(){return this.config.anchors;},enumerable:!0,configurable:!0}),e.prototype.locateFaces=function(t,e){return Object(xi.b)(this,void 0,void 0,function(){return Object(xi.d)(this,function(n){switch(n.label){case 0:return [4,this.detect(t,e)];case 1:return [2,n.sent().map(function(t){return new zi(t.score,t.relativeBox,{width:t.imageWidth,height:t.imageHeight});})];}});});},e.prototype.getDefaultModelName=function(){return this.withSeparableConvs?"tiny_yolov2_separable_conv_model":"tiny_yolov2_model";},e.prototype.extractParamsFromWeigthMap=function(e){return t.prototype.extractParamsFromWeigthMap.call(this,e);},e;}(bs);function ws(t,e){void 0===e&&(e=!0);var n=new xs(e);return n.extractWeights(t),n;}var ks=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._name="TinyFaceDetectorOptions",e;}return Object(xi.c)(e,t),e;}(ys),Es=function(){function t(){}return t.prototype.then=function(t){return Object(xi.b)(this,void 0,void 0,function(){var e;return Object(xi.d)(this,function(n){switch(n.label){case 0:return e=t,[4,this.run()];case 1:return [2,e.apply(void 0,[n.sent()])];}});});},t.prototype.run=function(){return Object(xi.b)(this,void 0,void 0,function(){return Object(xi.d)(this,function(t){throw new Error("ComposableTask - run is not implemented");});});},t;}();function Cs(t,e,n,r,i){return void 0===i&&(i=function i(t){return t.alignedRect;}),Object(xi.b)(this,void 0,void 0,function(){var o,a,s,u,c;return Object(xi.d)(this,function(l){switch(l.label){case 0:return o=t.map(function(t){return ma(t)?i(t):t.detection;}),(s=r)?[3,5]:e instanceof yi.Tensor?[4,Mo(e,o)]:[3,2];case 1:return u=l.sent(),[3,4];case 2:return [4,Ro(e,o)];case 3:u=l.sent(),l.label=4;case 4:s=u,l.label=5;case 5:return [4,n(a=s)];case 6:return c=l.sent(),a.forEach(function(t){return t instanceof yi.Tensor&&t.dispose();}),[2,c];}});});}function As(t,e,n,r,i){return Object(xi.b)(this,void 0,void 0,function(){var o=this;return Object(xi.d)(this,function(a){return [2,Cs([t],e,function(t){return Object(xi.b)(o,void 0,void 0,function(){return Object(xi.d)(this,function(e){return [2,n(t[0])];});});},r,i)];});});}var Os=2,_s=12;function Ss(t){var e=ea(t),n=e.extractWeights,r=e.getRemainingWeights,i=[],o=function(t,e){var n=Xo(t,e),r=Yo(t,e);function i(n,r){var i=yi.tensor1d(t(n));return e.push({paramPath:r}),i;}function o(t,e,r){return void 0===r&&(r=!1),{conv1:n(t[0],t[1],3,e+"/conv1"),prelu1_alpha:i(t[1],e+"/prelu1_alpha"),conv2:n(t[1],t[2],3,e+"/conv2"),prelu2_alpha:i(t[2],e+"/prelu2_alpha"),conv3:n(t[2],t[3],r?2:3,e+"/conv3"),prelu3_alpha:i(t[3],e+"/prelu3_alpha")};}return {extractPNetParams:function extractPNetParams(){var t=o([3,10,16,32],"pnet"),e=n(32,2,1,"pnet/conv4_1"),r=n(32,4,1,"pnet/conv4_2");return Object(xi.a)(Object(xi.a)({},t),{conv4_1:e,conv4_2:r});},extractRNetParams:function extractRNetParams(){var t=o([3,28,48,64],"rnet",!0),e=r(576,128,"rnet/fc1"),n=i(128,"rnet/prelu4_alpha"),a=r(128,2,"rnet/fc2_1"),s=r(128,4,"rnet/fc2_2");return Object(xi.a)(Object(xi.a)({},t),{fc1:e,prelu4_alpha:n,fc2_1:a,fc2_2:s});},extractONetParams:function extractONetParams(){var t=o([3,32,64,64],"onet"),e=n(64,128,2,"onet/conv4"),a=i(128,"onet/prelu4_alpha"),s=r(1152,256,"onet/fc1"),u=i(256,"onet/prelu5_alpha"),c=r(256,2,"onet/fc2_1"),l=r(256,4,"onet/fc2_2"),f=r(256,10,"onet/fc2_3");return Object(xi.a)(Object(xi.a)({},t),{conv4:e,prelu4_alpha:a,fc1:s,prelu5_alpha:u,fc2_1:c,fc2_2:l,fc2_3:f});}};}(n,i),a=o.extractPNetParams,s=o.extractRNetParams,u=o.extractONetParams,c=a(),l=s(),f=u();if(0!==r().length)throw new Error("weights remaing after extract: "+r().length);return {params:{pnet:c,rnet:l,onet:f},paramMappings:i};}function Ds(t){var e=[],n=function(t,e){var n=ta(t,e);function r(t){return {filters:n(t+"/weights",4,t+"/filters"),bias:n(t+"/bias",1)};}function i(t){return {weights:n(t+"/weights",2),bias:n(t+"/bias",1)};}function o(t){return n(t,1);}function a(t){return {conv1:r(t+"/conv1"),prelu1_alpha:o(t+"/prelu1_alpha"),conv2:r(t+"/conv2"),prelu2_alpha:o(t+"/prelu2_alpha"),conv3:r(t+"/conv3"),prelu3_alpha:o(t+"/prelu3_alpha")};}return {extractPNetParams:function extractPNetParams(){var t=a("pnet"),e=r("pnet/conv4_1"),n=r("pnet/conv4_2");return Object(xi.a)(Object(xi.a)({},t),{conv4_1:e,conv4_2:n});},extractRNetParams:function extractRNetParams(){var t=a("rnet"),e=i("rnet/fc1"),n=o("rnet/prelu4_alpha"),r=i("rnet/fc2_1"),s=i("rnet/fc2_2");return Object(xi.a)(Object(xi.a)({},t),{fc1:e,prelu4_alpha:n,fc2_1:r,fc2_2:s});},extractONetParams:function extractONetParams(){var t=a("onet"),e=r("onet/conv4"),n=o("onet/prelu4_alpha"),s=i("onet/fc1"),u=o("onet/prelu5_alpha"),c=i("onet/fc2_1"),l=i("onet/fc2_2"),f=i("onet/fc2_3");return Object(xi.a)(Object(xi.a)({},t),{conv4:e,prelu4_alpha:n,fc1:s,prelu5_alpha:u,fc2_1:c,fc2_2:l,fc2_3:f});}};}(t,e),r=n.extractPNetParams,i=n.extractRNetParams,o=n.extractONetParams,a=r(),s=i(),u=o();return Ko(t,e),{params:{pnet:a,rnet:s,onet:u},paramMappings:e};}function Fs(t,e){var n=e[0],r=e[1];return {height:Math.floor(n*t),width:Math.floor(r*t)};}var Ts=function(t){function e(e,n,r,i){return t.call(this,{left:e,top:n,right:r,bottom:i},!0)||this;}return Object(xi.c)(e,t),e;}(Bi);function Ns(t){return yi.tidy(function(){return yi.mul(yi.sub(t,yi.scalar(127.5)),yi.scalar(.0078125));});}function Is(t,e){return yi.tidy(function(){return yi.add(yi.relu(t),yi.mul(e,yi.neg(yi.relu(yi.neg(t)))));});}function Rs(t,e,n){return void 0===n&&(n=!1),yi.tidy(function(){var r=Go(t,e.conv1,"valid");return r=Is(r,e.prelu1_alpha),r=Is(r=Go(r=yi.maxPool(r,n?[2,2]:[3,3],[2,2],"same"),e.conv2,"valid"),e.prelu2_alpha),r=Is(r=Go(r=n?r:yi.maxPool(r,[3,3],[2,2],"valid"),e.conv3,"valid"),e.prelu3_alpha);});}function Ms(t,e,n,r,i){i.stage1=[];var o=e.map(function(e){return yi.tidy(function(){var n={scale:e},i=function(t,e){return yi.tidy(function(){var n=Fs(e,t.shape.slice(1)),r=n.height,i=n.width,o=Ns(yi.image.resizeBilinear(t,[r,i]));return yi.transpose(o,[0,2,1,3]);});}(t,e),o=Date.now(),a=function(t,e){return yi.tidy(function(){var n=Rs(t,e,!0),r=Go(n,e.conv4_1,"valid"),i=yi.expandDims(yi.max(r,3),3);return {prob:yi.softmax(yi.sub(r,i),3),regions:Go(n,e.conv4_2,"valid")};});}(i,r),s=a.prob,u=a.regions;return n.pnet=Date.now()-o,{scoresTensor:yi.unstack(yi.unstack(s,3)[1])[0],regionsTensor:yi.unstack(u)[0],scale:e,statsForScale:n};});}).map(function(t){var e=t.scoresTensor,r=t.regionsTensor,o=t.scale,a=t.statsForScale,s=function(t,e,n,r){for(var i=[],o=t.arraySync(),a=0;a<t.shape[0];a++){for(var s=0;s<t.shape[1];s++){o[a][s]>=r&&i.push(new ji(s,a));}}return i.map(function(t){var r=new Pi(Math.round((t.y*Os+1)/n),Math.round((t.x*Os+1)/n),Math.round((t.y*Os+_s)/n),Math.round((t.x*Os+_s)/n)),i=o[t.y][t.x],a=e.arraySync();return {cell:r,score:i,region:new Ts(a[t.y][t.x][0],a[t.y][t.x][1],a[t.y][t.x][2],a[t.y][t.x][3])};});}(e,r,o,n);if(e.dispose(),r.dispose(),!s.length)return i.stage1.push(a),[];var u=Date.now(),c=Vi(s.map(function(t){return t.cell;}),s.map(function(t){return t.score;}),.5);return a.nms=Date.now()-u,a.numBoxes=c.length,i.stage1.push(a),c.map(function(t){return s[t];});}).reduce(function(t,e){return t.concat(e);},[]),a=[],s=[];if(o.length>0){var u=Date.now(),c=Vi(o.map(function(t){return t.cell;}),o.map(function(t){return t.score;}),.7);i.stage1_nms=Date.now()-u,s=c.map(function(t){return o[t].score;}),a=c.map(function(t){return o[t];}).map(function(t){var e=t.cell,n=t.region;return new Pi(e.left+n.left*e.width,e.top+n.top*e.height,e.right+n.right*e.width,e.bottom+n.bottom*e.height).toSquare().round();});}return {boxes:a,scores:s};}function js(t,e,n){var r=n.width,i=n.height;return Object(xi.b)(this,void 0,void 0,function(){var n,o,a,s=this;return Object(xi.d)(this,function(u){switch(u.label){case 0:return n=vo(t),[4,Promise.all(e.map(function(e){return Object(xi.b)(s,void 0,void 0,function(){var r,i,o,a,s,u,c,l;return Object(xi.d)(this,function(f){return r=e.padAtBorders(t.height,t.width),i=r.y,o=r.ey,a=r.x,s=r.ex,u=a-1,c=i-1,l=n.getImageData(u,c,s-u,o-c),[2,mo.isNodejs()?So(l):createImageBitmap(l)];});});}))];case 1:return o=u.sent(),a=[],o.forEach(function(t){var e=vo(_o({width:r,height:i}));e.drawImage(t,0,0,r,i);for(var n=e.getImageData(0,0,r,i).data,o=[],s=0;s<n.length;s+=4){o.push(n[s+2]),o.push(n[s+1]),o.push(n[s]);}a.push(o);}),[2,a.map(function(t){return yi.tidy(function(){return Ns(yi.transpose(yi.tensor4d(t,[1,r,i,3]),[0,2,1,3]).toFloat());});})];}});});}function Bs(t,e,n,r,i){return Object(xi.b)(this,void 0,void 0,function(){var o,a,s,u,c,l,f,h,d,p,m,g,v,y;return Object(xi.d)(this,function(b){switch(b.label){case 0:return o=Date.now(),[4,js(t,e,{width:24,height:24})];case 1:return a=b.sent(),i.stage2_extractImagePatches=Date.now()-o,o=Date.now(),s=a.map(function(t){var e=function(t,e){return yi.tidy(function(){var n=Rs(t,e),r=Is(aa(yi.reshape(n,[n.shape[0],e.fc1.weights.shape[0]]),e.fc1),e.prelu4_alpha),i=aa(r,e.fc2_1),o=yi.expandDims(yi.max(i,1),1),a=yi.softmax(yi.sub(i,o),1),s=aa(r,e.fc2_2);return {scores:yi.unstack(a,1)[1],regions:s};});}(t,r);return t.dispose(),e;}),i.stage2_rnet=Date.now()-o,u=s.length>1?yi.concat(s.map(function(t){return t.scores;})):s[0].scores,f=(l=Array).from,[4,u.data()];case 2:return c=f.apply(l,[b.sent()]),u.dispose(),h=c.map(function(t,e){return {score:t,idx:e};}).filter(function(t){return t.score>n;}).map(function(t){return t.idx;}),d=h.map(function(t){return e[t];}),p=h.map(function(t){return c[t];}),m=[],g=[],d.length>0&&(o=Date.now(),v=Vi(d,p,.7),i.stage2_nms=Date.now()-o,y=v.map(function(t){var e=s[h[t]].regions.arraySync();return new Ts(e[0][0],e[0][1],e[0][2],e[0][3]);}),g=v.map(function(t){return p[t];}),m=v.map(function(t,e){return d[t].calibrate(y[e]);})),s.forEach(function(t){t.regions.dispose(),t.scores.dispose();}),[2,{boxes:m,scores:g}];}});});}function Ps(t,e,n,r,i){return Object(xi.b)(this,void 0,void 0,function(){var o,a,s,u,c,l,f,h,d,p,m,g,v,y,b;return Object(xi.d)(this,function(x){switch(x.label){case 0:return o=Date.now(),[4,js(t,e,{width:48,height:48})];case 1:return a=x.sent(),i.stage3_extractImagePatches=Date.now()-o,o=Date.now(),s=a.map(function(t){var e=function(t,e){return yi.tidy(function(){var n=Rs(t,e);n=Is(n=Go(n=yi.maxPool(n,[2,2],[2,2],"same"),e.conv4,"valid"),e.prelu4_alpha);var r=Is(aa(yi.reshape(n,[n.shape[0],e.fc1.weights.shape[0]]),e.fc1),e.prelu5_alpha),i=aa(r,e.fc2_1),o=yi.expandDims(yi.max(i,1),1),a=yi.softmax(yi.sub(i,o),1),s=aa(r,e.fc2_2),u=aa(r,e.fc2_3);return {scores:yi.unstack(a,1)[1],regions:s,points:u};});}(t,r);return t.dispose(),e;}),i.stage3_onet=Date.now()-o,u=s.length>1?yi.concat(s.map(function(t){return t.scores;})):s[0].scores,f=(l=Array).from,[4,u.data()];case 2:return c=f.apply(l,[x.sent()]),u.dispose(),h=c.map(function(t,e){return {score:t,idx:e};}).filter(function(t){return t.score>n;}).map(function(t){return t.idx;}),d=h.map(function(t){var e=s[t].regions.arraySync();return new Ts(e[0][0],e[0][1],e[0][2],e[0][3]);}),p=h.map(function(t,n){return e[t].calibrate(d[n]);}),m=h.map(function(t){return c[t];}),g=[],v=[],y=[],p.length>0&&(o=Date.now(),b=Vi(p,m,.7,!1),i.stage3_nms=Date.now()-o,g=b.map(function(t){return p[t];}),v=b.map(function(t){return m[t];}),y=b.map(function(t,e){return Array(5).fill(0).map(function(n,r){var i=s[t].points.arraySync();return new ji(i[0][r]*(g[e].width+1)+g[e].left,i[0][r+5]*(g[e].height+1)+g[e].top);});})),s.forEach(function(t){t.regions.dispose(),t.scores.dispose(),t.points.dispose();}),[2,{boxes:g,scores:v,points:y}];}});});}var Ls=function(t){function e(){return t.call(this,"Mtcnn")||this;}return Object(xi.c)(e,t),e.prototype.load=function(e){return Object(xi.b)(this,void 0,void 0,function(){return Object(xi.d)(this,function(n){return console.warn("mtcnn is deprecated and will be removed soon"),[2,t.prototype.load.call(this,e)];});});},e.prototype.loadFromDisk=function(e){return Object(xi.b)(this,void 0,void 0,function(){return Object(xi.d)(this,function(n){return console.warn("mtcnn is deprecated and will be removed soon"),[2,t.prototype.loadFromDisk.call(this,e)];});});},e.prototype.forwardInput=function(t,e){return void 0===e&&(e={}),Object(xi.b)(this,void 0,void 0,function(){var n,r,i,o,a,s,u,c,l,f,h,d,p,m,g,v,y,b,x,w,k;return Object(xi.d)(this,function(E){switch(E.label){case 0:if(!(n=this.params))throw new Error("Mtcnn - load model before inference");if(!(r=t.canvases[0]))throw new Error("Mtcnn - inputCanvas is not defined, note that passing tensors into Mtcnn.forwardInput is not supported yet.");return i={},o=Date.now(),a=yi.tidy(function(){return function(t){return yi.tidy(function(){return yi.stack(yi.unstack(t,3).reverse(),3);});}(yi.expandDims(yi.browser.fromPixels(r)).toFloat());}),s=function s(t){return a.dispose(),i.total=Date.now()-o,t;},u=a.shape.slice(1),c=u[0],l=u[1],f=new Ha(e),h=f.minFaceSize,d=f.scaleFactor,p=f.maxNumScales,m=f.scoreThresholds,g=f.scaleSteps,v=(g||function(t,e,n){for(var r=n[0],i=n[1],o=_s/t,a=[],s=Math.min(r,i)*o,u=0;s>=12;){a.push(o*Math.pow(e,u)),s*=e,u+=1;}return a;}(h,d,[c,l])).filter(function(t){var e=Fs(t,[c,l]);return Math.min(e.width,e.height)>_s;}).slice(0,p),i.scales=v,i.pyramid=v.map(function(t){return Fs(t,[c,l]);}),y=Date.now(),[4,Ms(a,v,m[0],n.pnet,i)];case 1:return b=E.sent(),i.total_stage1=Date.now()-y,b.boxes.length?(i.stage2_numInputBoxes=b.boxes.length,y=Date.now(),[4,Bs(r,b.boxes,m[1],n.rnet,i)]):[2,s({results:[],stats:i})];case 2:return x=E.sent(),i.total_stage2=Date.now()-y,x.boxes.length?(i.stage3_numInputBoxes=x.boxes.length,y=Date.now(),[4,Ps(r,x.boxes,m[2],n.onet,i)]):[2,s({results:[],stats:i})];case 3:return w=E.sent(),i.total_stage3=Date.now()-y,k=w.boxes.map(function(t,e){return ga(io({},new zi(w.scores[e],new Xi(t.left/l,t.top/c,t.width/l,t.height/c),{height:c,width:l})),new Ji(w.points[e].map(function(e){return e.sub(new ji(t.left,t.top)).div(new ji(t.width,t.height));}),{width:t.width,height:t.height}));}),[2,s({results:k,stats:i})];}});});},e.prototype.forward=function(t,e){return void 0===e&&(e={}),Object(xi.b)(this,void 0,void 0,function(){var n;return Object(xi.d)(this,function(r){switch(r.label){case 0:return n=this.forwardInput,[4,Io(t)];case 1:return [4,n.apply(this,[r.sent(),e])];case 2:return [2,r.sent().results];}});});},e.prototype.forwardWithStats=function(t,e){return void 0===e&&(e={}),Object(xi.b)(this,void 0,void 0,function(){var n;return Object(xi.d)(this,function(r){switch(r.label){case 0:return n=this.forwardInput,[4,Io(t)];case 1:return [2,n.apply(this,[r.sent(),e])];}});});},e.prototype.getDefaultModelName=function(){return "mtcnn_model";},e.prototype.extractParamsFromWeigthMap=function(t){return Ds(t);},e.prototype.extractParams=function(t){return Ss(t);},e;}(Vo),zs=.4,Us=[new ji(1.603231,2.094468),new ji(6.041143,7.080126),new ji(2.882459,3.518061),new ji(4.266906,5.178857),new ji(9.041765,10.66308)],Ws=[117.001,114.697,97.404],Vs=function(t){function e(){var e={withSeparableConvs:!0,iouThreshold:zs,classes:["face"],anchors:Us,meanRgb:Ws,isFirstLayerConv2d:!0,filterSizes:[3,16,32,64,128,256,512]};return t.call(this,e)||this;}return Object(xi.c)(e,t),Object.defineProperty(e.prototype,"anchors",{get:function get(){return this.config.anchors;},enumerable:!0,configurable:!0}),e.prototype.locateFaces=function(t,e){return Object(xi.b)(this,void 0,void 0,function(){return Object(xi.d)(this,function(n){switch(n.label){case 0:return [4,this.detect(t,e)];case 1:return [2,n.sent().map(function(t){return new zi(t.score,t.relativeBox,{width:t.imageWidth,height:t.imageHeight});})];}});});},e.prototype.getDefaultModelName=function(){return "tiny_face_detector_model";},e.prototype.extractParamsFromWeigthMap=function(e){return t.prototype.extractParamsFromWeigthMap.call(this,e);},e;}(bs),qs={ssdMobilenetv1:new ns(),tinyFaceDetector:new Vs(),tinyYolov2:new xs(),mtcnn:new Ls(),faceLandmark68Net:new Sa(),faceLandmark68TinyNet:new Fa(),faceRecognitionNet:new La(),faceExpressionNet:new fa(),ageGenderNet:new Oa()},$s=function $s(t,e){return qs.ssdMobilenetv1.locateFaces(t,e);},Hs=function Hs(t,e){return qs.tinyFaceDetector.locateFaces(t,e);},Gs=function Gs(t,e){return qs.tinyYolov2.locateFaces(t,e);},Ks=function Ks(t,e){return qs.mtcnn.forward(t,e);},Xs=function Xs(t){return qs.faceLandmark68Net.detectLandmarks(t);},Ys=function Ys(t){return qs.faceLandmark68TinyNet.detectLandmarks(t);},Js=function Js(t){return qs.faceRecognitionNet.computeFaceDescriptor(t);},Qs=function Qs(t){return qs.faceExpressionNet.predictExpressions(t);},Zs=function Zs(t){return qs.ageGenderNet.predictAgeAndGender(t);},tu=function tu(t){return qs.ssdMobilenetv1.load(t);},eu=function eu(t){return qs.tinyFaceDetector.load(t);},nu=function nu(t){return qs.mtcnn.load(t);},ru=function ru(t){return qs.tinyYolov2.load(t);},iu=function iu(t){return qs.faceLandmark68Net.load(t);},ou=function ou(t){return qs.faceLandmark68TinyNet.load(t);},au=function au(t){return qs.faceRecognitionNet.load(t);},su=function su(t){return qs.faceExpressionNet.load(t);},uu=function uu(t){return qs.ageGenderNet.load(t);},cu=tu,lu=$s,fu=Xs,hu=function(t){function e(e,n,r){var i=t.call(this)||this;return i.parentTask=e,i.input=n,i.extractedFaces=r,i;}return Object(xi.c)(e,t),e;}(Es),du=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e.prototype.run=function(){return Object(xi.b)(this,void 0,void 0,function(){var t,e,n=this;return Object(xi.d)(this,function(r){switch(r.label){case 0:return [4,this.parentTask];case 1:return [4,Cs(t=r.sent(),this.input,function(t){return Object(xi.b)(n,void 0,void 0,function(){return Object(xi.d)(this,function(e){switch(e.label){case 0:return [4,Promise.all(t.map(function(t){return qs.faceExpressionNet.predictExpressions(t);}))];case 1:return [2,e.sent()];}});});},this.extractedFaces)];case 2:return e=r.sent(),[2,t.map(function(t,n){return da(t,e[n]);})];}});});},e.prototype.withAgeAndGender=function(){return new yu(this,this.input);},e;}(hu),pu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e.prototype.run=function(){return Object(xi.b)(this,void 0,void 0,function(){var t,e;return Object(xi.d)(this,function(n){switch(n.label){case 0:return [4,this.parentTask];case 1:return (t=n.sent())?[4,As(t,this.input,function(t){return qs.faceExpressionNet.predictExpressions(t);},this.extractedFaces)]:[2];case 2:return e=n.sent(),[2,da(t,e)];}});});},e.prototype.withAgeAndGender=function(){return new bu(this,this.input);},e;}(hu),mu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e.prototype.withAgeAndGender=function(){return new xu(this,this.input);},e.prototype.withFaceDescriptors=function(){return new Eu(this,this.input);},e;}(du),gu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e.prototype.withAgeAndGender=function(){return new wu(this,this.input);},e.prototype.withFaceDescriptor=function(){return new Cu(this,this.input);},e;}(pu),vu=function(t){function e(e,n,r){var i=t.call(this)||this;return i.parentTask=e,i.input=n,i.extractedFaces=r,i;}return Object(xi.c)(e,t),e;}(Es),yu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e.prototype.run=function(){return Object(xi.b)(this,void 0,void 0,function(){var t,e,n=this;return Object(xi.d)(this,function(r){switch(r.label){case 0:return [4,this.parentTask];case 1:return [4,Cs(t=r.sent(),this.input,function(t){return Object(xi.b)(n,void 0,void 0,function(){return Object(xi.d)(this,function(e){switch(e.label){case 0:return [4,Promise.all(t.map(function(t){return qs.ageGenderNet.predictAgeAndGender(t);}))];case 1:return [2,e.sent()];}});});},this.extractedFaces)];case 2:return e=r.sent(),[2,t.map(function(t,n){var r=e[n],i=r.age;return Va($a(t,r.gender,r.genderProbability),i);})];}});});},e.prototype.withFaceExpressions=function(){return new du(this,this.input);},e;}(vu),bu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e.prototype.run=function(){return Object(xi.b)(this,void 0,void 0,function(){var t,e,n,r,i;return Object(xi.d)(this,function(o){switch(o.label){case 0:return [4,this.parentTask];case 1:return (t=o.sent())?[4,As(t,this.input,function(t){return qs.ageGenderNet.predictAgeAndGender(t);},this.extractedFaces)]:[2];case 2:return e=o.sent(),n=e.age,r=e.gender,i=e.genderProbability,[2,Va($a(t,r,i),n)];}});});},e.prototype.withFaceExpressions=function(){return new pu(this,this.input);},e;}(vu),xu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e.prototype.withFaceExpressions=function(){return new mu(this,this.input);},e.prototype.withFaceDescriptors=function(){return new Eu(this,this.input);},e;}(yu),wu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e.prototype.withFaceExpressions=function(){return new gu(this,this.input);},e.prototype.withFaceDescriptor=function(){return new Cu(this,this.input);},e;}(bu),ku=function(t){function e(e,n){var r=t.call(this)||this;return r.parentTask=e,r.input=n,r;}return Object(xi.c)(e,t),e;}(Es),Eu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e.prototype.run=function(){return Object(xi.b)(this,void 0,void 0,function(){var t;return Object(xi.d)(this,function(e){switch(e.label){case 0:return [4,this.parentTask];case 1:return [4,Cs(t=e.sent(),this.input,function(t){return Promise.all(t.map(function(t){return qs.faceRecognitionNet.computeFaceDescriptor(t);}));},null,function(t){return t.landmarks.align(null,{useDlibAlignment:!0});})];case 2:return [2,e.sent().map(function(e,n){return Ua(t[n],e);})];}});});},e.prototype.withFaceExpressions=function(){return new mu(this,this.input);},e.prototype.withAgeAndGender=function(){return new xu(this,this.input);},e;}(ku),Cu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e.prototype.run=function(){return Object(xi.b)(this,void 0,void 0,function(){var t,e;return Object(xi.d)(this,function(n){switch(n.label){case 0:return [4,this.parentTask];case 1:return (t=n.sent())?[4,As(t,this.input,function(t){return qs.faceRecognitionNet.computeFaceDescriptor(t);},null,function(t){return t.landmarks.align(null,{useDlibAlignment:!0});})]:[2];case 2:return e=n.sent(),[2,Ua(t,e)];}});});},e.prototype.withFaceExpressions=function(){return new gu(this,this.input);},e.prototype.withAgeAndGender=function(){return new wu(this,this.input);},e;}(ku),Au=function(t){function e(e,n,r){var i=t.call(this)||this;return i.parentTask=e,i.input=n,i.useTinyLandmarkNet=r,i;}return Object(xi.c)(e,t),Object.defineProperty(e.prototype,"landmarkNet",{get:function get(){return this.useTinyLandmarkNet?qs.faceLandmark68TinyNet:qs.faceLandmark68Net;},enumerable:!0,configurable:!0}),e;}(Es),Ou=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e.prototype.run=function(){return Object(xi.b)(this,void 0,void 0,function(){var t,e,n,r,i,o=this;return Object(xi.d)(this,function(a){switch(a.label){case 0:return [4,this.parentTask];case 1:return t=a.sent(),e=t.map(function(t){return t.detection;}),this.input instanceof yi.Tensor?[4,Mo(this.input,e)]:[3,3];case 2:return r=a.sent(),[3,5];case 3:return [4,Ro(this.input,e)];case 4:r=a.sent(),a.label=5;case 5:return n=r,[4,Promise.all(n.map(function(t){return o.landmarkNet.detectLandmarks(t);}))];case 6:return i=a.sent(),n.forEach(function(t){return t instanceof yi.Tensor&&t.dispose();}),[2,t.map(function(t,e){return ga(t,i[e]);})];}});});},e.prototype.withFaceExpressions=function(){return new mu(this,this.input);},e.prototype.withAgeAndGender=function(){return new xu(this,this.input);},e.prototype.withFaceDescriptors=function(){return new Eu(this,this.input);},e;}(Au),_u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e.prototype.run=function(){return Object(xi.b)(this,void 0,void 0,function(){var t,e,n,r,i;return Object(xi.d)(this,function(o){switch(o.label){case 0:return [4,this.parentTask];case 1:return (t=o.sent())?(e=t.detection,this.input instanceof yi.Tensor?[4,Mo(this.input,[e])]:[3,3]):[2];case 2:return r=o.sent(),[3,5];case 3:return [4,Ro(this.input,[e])];case 4:r=o.sent(),o.label=5;case 5:return n=r,[4,this.landmarkNet.detectLandmarks(n[0])];case 6:return i=o.sent(),n.forEach(function(t){return t instanceof yi.Tensor&&t.dispose();}),[2,ga(t,i)];}});});},e.prototype.withFaceExpressions=function(){return new gu(this,this.input);},e.prototype.withAgeAndGender=function(){return new wu(this,this.input);},e.prototype.withFaceDescriptor=function(){return new Cu(this,this.input);},e;}(Au),Su=function(t){function e(e,n){void 0===n&&(n=new es());var r=t.call(this)||this;return r.input=e,r.options=n,r;}return Object(xi.c)(e,t),e;}(Es),Du=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e.prototype.run=function(){return Object(xi.b)(this,void 0,void 0,function(){var t,e,n,r;return Object(xi.d)(this,function(i){switch(i.label){case 0:return e=(t=this).input,(n=t.options)instanceof Ha?[4,qs.mtcnn.forward(e,n)]:[3,2];case 1:return [2,i.sent().map(function(t){return t.detection;})];case 2:if(!(r=n instanceof ks?function(t){return qs.tinyFaceDetector.locateFaces(t,n);}:n instanceof es?function(t){return qs.ssdMobilenetv1.locateFaces(t,n);}:n instanceof ys?function(t){return qs.tinyYolov2.locateFaces(t,n);}:null))throw new Error("detectFaces - expected options to be instance of TinyFaceDetectorOptions | SsdMobilenetv1Options | MtcnnOptions | TinyYolov2Options");return [2,r(e)];}});});},e.prototype.runAndExtendWithFaceDetections=function(){var t=this;return new Promise(function(e){return Object(xi.b)(t,void 0,void 0,function(){var t;return Object(xi.d)(this,function(n){switch(n.label){case 0:return [4,this.run()];case 1:return t=n.sent(),[2,e(t.map(function(t){return io({},t);}))];}});});});},e.prototype.withFaceLandmarks=function(t){return void 0===t&&(t=!1),new Ou(this.runAndExtendWithFaceDetections(),this.input,t);},e.prototype.withFaceExpressions=function(){return new du(this.runAndExtendWithFaceDetections(),this.input);},e.prototype.withAgeAndGender=function(){return new yu(this.runAndExtendWithFaceDetections(),this.input);},e;}(Su),Fu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this;}return Object(xi.c)(e,t),e.prototype.run=function(){return Object(xi.b)(this,void 0,void 0,function(){var t,e;return Object(xi.d)(this,function(n){switch(n.label){case 0:return [4,new Du(this.input,this.options)];case 1:return t=n.sent(),e=t[0],t.forEach(function(t){t.score>e.score&&(e=t);}),[2,e];}});});},e.prototype.runAndExtendWithFaceDetection=function(){var t=this;return new Promise(function(e){return Object(xi.b)(t,void 0,void 0,function(){var t;return Object(xi.d)(this,function(n){switch(n.label){case 0:return [4,this.run()];case 1:return t=n.sent(),[2,e(t?io({},t):void 0)];}});});});},e.prototype.withFaceLandmarks=function(t){return void 0===t&&(t=!1),new _u(this.runAndExtendWithFaceDetection(),this.input,t);},e.prototype.withFaceExpressions=function(){return new pu(this.runAndExtendWithFaceDetection(),this.input);},e.prototype.withAgeAndGender=function(){return new bu(this.runAndExtendWithFaceDetection(),this.input);},e;}(Su);function Tu(t,e){return void 0===e&&(e=new es()),new Fu(t,e);}function Nu(t,e){return void 0===e&&(e=new es()),new Du(t,e);}function Iu(t,e){return Object(xi.b)(this,void 0,void 0,function(){return Object(xi.d)(this,function(n){switch(n.label){case 0:return console.warn("allFacesSsdMobilenetv1 is deprecated and will be removed soon, use the high level api instead"),[4,Nu(t,new es(e?{minConfidence:e}:{})).withFaceLandmarks().withFaceDescriptors()];case 1:return [2,n.sent()];}});});}function Ru(t,e){return void 0===e&&(e={}),Object(xi.b)(this,void 0,void 0,function(){return Object(xi.d)(this,function(n){switch(n.label){case 0:return console.warn("allFacesTinyYolov2 is deprecated and will be removed soon, use the high level api instead"),[4,Nu(t,new ys(e)).withFaceLandmarks().withFaceDescriptors()];case 1:return [2,n.sent()];}});});}function Mu(t,e){return void 0===e&&(e={}),Object(xi.b)(this,void 0,void 0,function(){return Object(xi.d)(this,function(n){switch(n.label){case 0:return console.warn("allFacesMtcnn is deprecated and will be removed soon, use the high level api instead"),[4,Nu(t,new Ha(e)).withFaceLandmarks().withFaceDescriptors()];case 1:return [2,n.sent()];}});});}var ju=Iu;function Bu(t,e){if(t.length!==e.length)throw new Error("euclideanDistance: arr1.length !== arr2.length");var n=Array.from(t),r=Array.from(e);return Math.sqrt(n.map(function(t,e){return t-r[e];}).reduce(function(t,e){return t+Math.pow(e,2);},0));}var Pu=function(){function t(t,e){void 0===e&&(e=.6),this._distanceThreshold=e;var n=Array.isArray(t)?t:[t];if(!n.length)throw new Error("FaceRecognizer.constructor - expected atleast one input");var r=1,i=function i(){return "person "+r++;};this._labeledDescriptors=n.map(function(t){if(t instanceof eo)return t;if(t instanceof Float32Array)return new eo(i(),[t]);if(t.descriptor&&t.descriptor instanceof Float32Array)return new eo(i(),[t.descriptor]);throw new Error("FaceRecognizer.constructor - expected inputs to be of type LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array | Array<LabeledFaceDescriptors | WithFaceDescriptor<any> | Float32Array>");});}return Object.defineProperty(t.prototype,"labeledDescriptors",{get:function get(){return this._labeledDescriptors;},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"distanceThreshold",{get:function get(){return this._distanceThreshold;},enumerable:!0,configurable:!0}),t.prototype.computeMeanDistance=function(t,e){return e.map(function(e){return Bu(e,t);}).reduce(function(t,e){return t+e;},0)/(e.length||1);},t.prototype.matchDescriptor=function(t){var e=this;return this.labeledDescriptors.map(function(n){var r=n.descriptors,i=n.label;return new Zi(i,e.computeMeanDistance(t,r));}).reduce(function(t,e){return t.distance<e.distance?t:e;});},t.prototype.findBestMatch=function(t){var e=this.matchDescriptor(t);return e.distance<this.distanceThreshold?e:new Zi("unknown",e.distance);},t.prototype.toJSON=function(){return {distanceThreshold:this.distanceThreshold,labeledDescriptors:this.labeledDescriptors.map(function(t){return t.toJSON();})};},t.fromJSON=function(e){return new t(e.labeledDescriptors.map(function(t){return eo.fromJSON(t);}),e.distanceThreshold);},t;}();function Lu(t){var e=new Ls();return e.extractWeights(t),e;}function zu(t){var e=new Vs();return e.extractWeights(t),e;}function Uu(t,e){var n=new wi(e.width,e.height),r=n.width,i=n.height;if(r<=0||i<=0)throw new Error("resizeResults - invalid dimensions: "+JSON.stringify({width:r,height:i}));if(Array.isArray(t))return t.map(function(t){return Uu(t,{width:r,height:i});});if(ma(t)){var o=t.detection.forSize(r,i),a=t.unshiftedLandmarks.forSize(o.box.width,o.box.height);return ga(io(t,o),a);}return ro(t)?io(t,t.detection.forSize(r,i)):t instanceof Yi||t instanceof zi?t.forSize(r,i):t;}var Wu={withLandmarks:!0,withDescriptors:!0,minConfidence:.5,withTinyNet:!0,MODEL_URLS:{Mobilenetv1Model:"https://raw.githubusercontent.com/ml5js/ml5-data-and-models/main/models/faceapi/ssd_mobilenetv1_model-weights_manifest.json",TinyFaceDetectorModel:"https://raw.githubusercontent.com/ml5js/ml5-data-and-models/main/models/faceapi/tiny_face_detector_model-weights_manifest.json",FaceLandmarkModel:"https://raw.githubusercontent.com/ml5js/ml5-data-and-models/main/models/faceapi/face_landmark_68_model-weights_manifest.json",FaceLandmark68TinyNet:"https://raw.githubusercontent.com/ml5js/ml5-data-and-models/main/models/faceapi/face_landmark_68_tiny_model-weights_manifest.json",FaceRecognitionModel:"https://raw.githubusercontent.com/ml5js/ml5-data-and-models/main/models/faceapi/face_recognition_model-weights_manifest.json"}},Vu=function(){function t(e,n,r){b()(this,t),this.video=e,this.model=null,this.modelReady=!1,this.detectorOptions=null,this.config={minConfidence:this.checkUndefined(n.minConfidence,Wu.minConfidence),withLandmarks:this.checkUndefined(n.withLandmarks,Wu.withLandmarks),withDescriptors:this.checkUndefined(n.withDescriptors,Wu.withDescriptors),withTinyNet:this.checkUndefined(n.withTinyNet,Wu.withTinyNet),MODEL_URLS:{Mobilenetv1Model:this.checkUndefined(n.Mobilenetv1Model,Wu.MODEL_URLS.Mobilenetv1Model),TinyFaceDetectorModel:this.checkUndefined(n.TinyFaceDetectorModel,Wu.MODEL_URLS.TinyFaceDetectorModel),FaceLandmarkModel:this.checkUndefined(n.FaceLandmarkModel,Wu.MODEL_URLS.FaceLandmarkModel),FaceLandmark68TinyNet:this.checkUndefined(n.FaceLandmark68TinyNet,Wu.MODEL_URLS.FaceLandmark68TinyNet),FaceRecognitionModel:this.checkUndefined(n.FaceRecognitionModel,Wu.MODEL_URLS.FaceRecognitionModel)}},this.ready=C(this.loadModel(),r);}return w()(t,[{key:"loadModel",value:function(){var t=v()(E.a.mark(function t(){var e,n,r,i,o,a,s,u=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(e=["Mobilenetv1Model","TinyFaceDetectorModel","FaceLandmarkModel","FaceLandmark68TinyNet","FaceRecognitionModel"],Object.keys(this.config.MODEL_URLS).forEach(function(t){e.includes(t)&&(u.config.MODEL_URLS[t]=Ce.getModelPath(u.config.MODEL_URLS[t]));}),n=this.config.MODEL_URLS,r=n.Mobilenetv1Model,i=n.TinyFaceDetectorModel,o=n.FaceLandmarkModel,a=n.FaceRecognitionModel,s=n.FaceLandmark68TinyNet,this.model=l,!0===this.config.withTinyNet?this.detectorOptions=new ks({minConfidence:this.minConfidence,inputSize:512}):this.detectorOptions=new es({minConfidence:this.minConfidence}),!0!==this.config.withTinyNet){t.next=12;break;}return t.next=8,this.model.loadFaceLandmarkTinyModel(s);case 8:return t.next=10,this.model.loadTinyFaceDetectorModel(i);case 10:t.next=16;break;case 12:return t.next=14,this.model.loadFaceLandmarkModel(o);case 14:return t.next=16,this.model.loadSsdMobilenetv1Model(r);case 16:return t.next=18,this.model.loadFaceRecognitionModel(a);case 18:return this.modelReady=!0,t.abrupt("return",this);case 20:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"detect",value:function(){var t=v()(E.a.mark(function t(e,n,r){var i,o,a;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(i=this.video,a=this.config,"function"!=typeof e){t.next=7;break;}i=this.video,o=e,t.next=21;break;case 7:if(!(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData)){t.next=11;break;}i=e,t.next=21;break;case 11:if("object"!==S()(e)||!(e.elt instanceof HTMLImageElement||e.elt instanceof HTMLCanvasElement||e.elt instanceof HTMLVideoElement||e.elt instanceof ImageData)){t.next=15;break;}i=e.elt,t.next=21;break;case 15:if(!("object"===S()(e)&&e.canvas instanceof HTMLCanvasElement)){t.next=19;break;}i=e.canvas,t.next=21;break;case 19:if(this.video instanceof HTMLVideoElement){t.next=21;break;}throw new Error("No input image provided. If you want to classify a video, pass the video element in the constructor. ");case 21:return "object"===S()(n)?a=n:"function"==typeof n&&(o=n),"function"==typeof r&&(o=r),t.abrupt("return",C(this.detectInternal(i,a),o));case 24:case"end":return t.stop();}}},t,this);}));return function(e,n,r){return t.apply(this,arguments);};}()},{key:"detectInternal",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i,o,a,s=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.ready;case 2:return t.next=4,p.nextFrame();case 4:if(!this.video||0!==this.video.readyState){t.next=7;break;}return t.next=7,new Promise(function(t){s.video.onloadeddata=function(){return t();};});case 7:if(this.config=this.setReturnOptions(n),r=this.config,i=r.withLandmarks,o=r.withDescriptors,!i){t.next=21;break;}if(!o){t.next=16;break;}return t.next=13,this.model.detectAllFaces(e,this.detectorOptions).withFaceLandmarks(this.config.withTinyNet).withFaceDescriptors();case 13:a=t.sent,t.next=19;break;case 16:return t.next=18,this.model.detectAllFaces(e,this.detectorOptions).withFaceLandmarks(this.config.withTinyNet);case 18:a=t.sent;case 19:t.next=30;break;case 21:if(i){t.next=27;break;}return t.next=24,this.model.detectAllFaces(e);case 24:a=t.sent,t.next=30;break;case 27:return t.next=29,this.model.detectAllFaces(e,this.detectorOptions).withFaceLandmarks(this.config.withTinyNet).withFaceDescriptors();case 29:a=t.sent;case 30:return a=this.resizeResults(a,e.width,e.height),a=this.landmarkParts(a),t.abrupt("return",a);case 33:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"detectSingle",value:function(){var t=v()(E.a.mark(function t(e,n,r){var i,o,a;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(i=this.video,a=this.config,"function"!=typeof e){t.next=7;break;}i=this.video,o=e,t.next=21;break;case 7:if(!(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData)){t.next=11;break;}i=e,t.next=21;break;case 11:if("object"!==S()(e)||!(e.elt instanceof HTMLImageElement||e.elt instanceof HTMLCanvasElement||e.elt instanceof HTMLVideoElement||e.elt instanceof ImageData)){t.next=15;break;}i=e.elt,t.next=21;break;case 15:if(!("object"===S()(e)&&e.canvas instanceof HTMLCanvasElement)){t.next=19;break;}i=e.canvas,t.next=21;break;case 19:if(this.video instanceof HTMLVideoElement){t.next=21;break;}throw new Error("No input image provided. If you want to classify a video, pass the video element in the constructor. ");case 21:return "object"===S()(n)?a=n:"function"==typeof n&&(o=n),"function"==typeof r&&(o=r),t.abrupt("return",C(this.detectSingleInternal(i,a),o));case 24:case"end":return t.stop();}}},t,this);}));return function(e,n,r){return t.apply(this,arguments);};}()},{key:"detectSingleInternal",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i,o,a,s=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.ready;case 2:return t.next=4,p.nextFrame();case 4:if(!this.video||0!==this.video.readyState){t.next=7;break;}return t.next=7,new Promise(function(t){s.video.onloadeddata=function(){return t();};});case 7:if(this.config=this.setReturnOptions(n),r=this.config,i=r.withLandmarks,o=r.withDescriptors,!i){t.next=21;break;}if(!o){t.next=16;break;}return t.next=13,this.model.detectSingleFace(e,this.detectorOptions).withFaceLandmarks(this.config.withTinyNet).withFaceDescriptor();case 13:a=t.sent,t.next=19;break;case 16:return t.next=18,this.model.detectSingleFace(e,this.detectorOptions).withFaceLandmarks(this.config.withTinyNet);case 18:a=t.sent;case 19:t.next=30;break;case 21:if(i){t.next=27;break;}return t.next=24,this.model.detectSingleFace(e);case 24:a=t.sent,t.next=30;break;case 27:return t.next=29,this.model.detectSingleFace(e,this.detectorOptions).withFaceLandmarks(this.config.withTinyNet).withFaceDescriptor();case 29:a=t.sent;case 30:return a=this.resizeResults(a,e.width,e.height),a=this.landmarkParts(a),t.abrupt("return",a);case 33:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"checkUndefined",value:function value(t,e){return void 0!==t?t:e;}},{key:"setReturnOptions",value:function value(t){var e=this,n=Object.assign({},this.config);return ["withLandmarks","withDescriptors"].forEach(function(r){void 0!==t[r]?e.config[r]=t[r]:n[r]=e.config[r];}),n;}},{key:"resizeResults",value:function value(t,e,n){if(void 0===e||void 0===n)throw new Error("width and height must be defined");return this.model.resizeResults(t,{width:e,height:n});}},{key:"landmarkParts",value:function value(t){var e;if(!0===Array.isArray(t))e=t.map(function(t){var e=Object.assign({},t);if(e.landmarks){var n=e.landmarks;e.parts={mouth:n.getMouth(),nose:n.getNose(),leftEye:n.getLeftEye(),leftEyeBrow:n.getLeftEyeBrow(),rightEye:n.getRightEye(),rightEyeBrow:n.getRightEyeBrow(),jawOutline:n.getJawOutline()};}else e.parts={mouth:[],nose:[],leftEye:[],leftEyeBrow:[],rightEye:[],rightEyeBrow:[],jawOutline:[]};return e;});else if((e=Object.assign({},t)).landmarks){var n=t.landmarks;e.parts={mouth:n.getMouth(),nose:n.getNose(),leftEye:n.getLeftEye(),leftEyeBrow:n.getLeftEyeBrow(),rightEye:n.getRightEye(),rightEyeBrow:n.getRightEyeBrow()};}else e.parts={mouth:[],nose:[],leftEye:[],leftEyeBrow:[],rightEye:[],rightEyeBrow:[]};return e;}}]),t;}(),qu=function qu(t,e,n){var r,i={},o=n;t instanceof HTMLVideoElement?r=t:"object"===S()(t)&&t.elt instanceof HTMLVideoElement?r=t.elt:"object"===S()(t)?i=t:"function"==typeof t&&(o=t),"object"===S()(e)?(i=e,console.log(i)):"function"==typeof e&&(o=e);var a=new Vu(r,i,o);return o?a:a.ready;},$u={k:3,maxIter:5,threshold:.5};function Hu(t){return Gu.apply(this,arguments);}function Gu(){return (Gu=v()(E.a.mark(function t(e){var n,r;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return n=p.data.csv(e),t.next=3,n.toArray();case 3:return r=t.sent,t.abrupt("return",r);case 5:case"end":return t.stop();}}},t);}))).apply(this,arguments);}function Ku(t){return Xu.apply(this,arguments);}function Xu(){return (Xu=v()(E.a.mark(function t(e){var n,r;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if("string"!=typeof e){t.next=6;break;}return t.next=3,Hu(e);case 3:n=t.sent,t.next=7;break;case 6:n=e;case 7:return r=n.map(function(t){return Object.values(t);}),t.abrupt("return",r);case 9:case"end":return t.stop();}}},t);}))).apply(this,arguments);}var Yu=function(){function t(e,n,r){b()(this,t),this.config={k:n.k||$u.k,maxIter:n.maxIter||$u.maxIter,threshold:n.threshold||$u.threshold},this.ready=C(this.load(e),r);}return w()(t,[{key:"load",value:function(){var t=v()(E.a.mark(function t(e){var n=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,Ku(e);case 2:return this.dataset=t.sent,p.tidy(function(){n.dataTensor=p.tensor2d(n.dataset),n.dataset.forEach(function(t){var e=p.tensor1d(Object.values(t));t.tensor=e;}),n.centroids=p.tensor2d(ri(n.dataset,n.config.k,!1)),n.fit();}),t.abrupt("return",this);case 5:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"fit",value:function value(){this.getClosestCentroids(),this.recenterCentroids();for(var e=t.getEuclidianDistance(this.centroids,this.centroidsOld),n=0;e>this.config.threshold&&n<this.config.maxIter;){this.getClosestCentroids(),this.recenterCentroids(),e=t.getEuclidianDistance(this.centroids,this.centroidsOld),n+=1;}}},{key:"getClosestCentroids",value:function value(){var t=this;this.dataset.forEach(function(e){var n=t.closestCentroid(e.tensor);e.centroid=n;});}},{key:"closestCentroid",value:function value(t){var e=this;return p.tidy(function(){return e.centroids.squaredDifference(t).sum(1).sqrt().argMin().arraySync();});}},{key:"classify",value:function value(t){var e=this;return p.tidy(function(){var n=p.tensor1d(Object.values(t));return e.closestCentroid(n);});}},{key:"recenterCentroids",value:function value(){var t=this,e=p.tidy(function(){return t.centroidsOld=t.centroids,p.stack(t.centroids.unstack().map(function(e,n){var r=t.dataset.filter(function(t){return t.centroid===n;}).map(function(t){return t.tensor;});return 0===r.length?e:1===r.length?r[0]:p.tidy(function(){return p.stack(r).mean(0);});}));});this.centroids=e;}}],[{key:"getEuclidianDistance",value:function value(t,e){return p.tidy(function(){return p.squaredDifference(t,e).sum().sqrt().dataSync();})[0];}}]),t;}(),Ju=function Ju(t,e,n){return new Yu(t,e,n);};function Qu(t){return Zu.apply(this,arguments);}function Zu(){return (Zu=v()(E.a.mark(function t(e){var n,r;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return n=p.data.csv(e),t.next=3,n.toArray();case 3:return r=t.sent,t.abrupt("return",r);case 5:case"end":return t.stop();}}},t);}))).apply(this,arguments);}function tc(t){return ec.apply(this,arguments);}function ec(){return (ec=v()(E.a.mark(function t(e){var n,r;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if("string"!=typeof e){t.next=6;break;}return t.next=3,Qu(e);case 3:n=t.sent,t.next=7;break;case 6:n=e;case 7:return r=n.map(function(t){return Object.values(t);}),t.abrupt("return",r);case 9:case"end":return t.stop();}}},t);}))).apply(this,arguments);}var nc={eps:50,minPts:3},rc=function(){function t(e,n,r){b()(this,t),this.config={eps:n.eps||nc.eps,minPts:n.minPts||nc.minPts},this.lastClusterId=0,this.status=[],this.ready=C(this.load(e),r);}return w()(t,[{key:"load",value:function(){var t=v()(E.a.mark(function t(e){var n=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,tc(e);case 2:return this.dataset=t.sent,p.tidy(function(){n.dataTensor=p.tensor2d(n.dataset),n.dataset.forEach(function(t){var e=p.tensor1d(Object.values(t));t.tensor=e;}),n.fit();}),t.abrupt("return",this);case 5:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"fit",value:function value(){var t=this;this.dataset.forEach(function(e,n){if(void 0===e.status){e.status=0;var r=t.getNeighboursIndices(e);r.length<t.config.minPts?e.status=0:(t.incrementClusterId(),t.extend(n,r));}});}},{key:"extend",value:function value(t,e){var n=this;this.dataset[t].clusterid=this.getClusterId(),this.dataset[t].status=this.dataset[t].clusterid,e.forEach(function(e){if(void 0===n.dataset[e].status){n.dataset[e].status=0;var r=n.getNeighboursIndices(n.dataset[e]);r.length>=n.config.minPts&&n.extend(e,r);}n.dataset[e].status<1&&(n.dataset[e].status=n.dataset[t].clusterid,n.dataset[e].clusterid=n.dataset[t].clusterid);});}},{key:"getClusterId",value:function value(){return this.lastClusterId;}},{key:"incrementClusterId",value:function value(){this.lastClusterId+=1;}},{key:"getNeighboursIndices",value:function value(t){var e=this;try{return p.tidy(function(){var n=p.squaredDifference(t.tensor,e.dataTensor).sum(1).sqrt().topk(e.dataTensor.shape[0],!0),r=n.values,i=n.indices;return p.stack([r.asType("float32"),i.asType("float32")],1).arraySync().filter(function(t){return t[0]<=e.config.eps;}).reduce(function(t,e){return t.push(e[1]),t;},[]);})||[];}catch(t){console.log("error ".concat(t));}return [];}}]),t;}(),ic=function ic(t,e,n){return new rc(t,e,n);},oc={hosoda:"https://raw.githubusercontent.com/leemengtaiwan/tfjs-models/master/cartoongan/tfjs_json_models/hosoda/model.json",miyazaki:"https://raw.githubusercontent.com/Derek-Wds/training_CartoonGAN/master/tfModels/Miyazaki/model.json"},ac=function(){function t(e,n){b()(this,t),this.config={modelUrl:e.modelUrl?e.modelUrl:oc.miyazaki,returnTensors:!!e.returnTensors&&e.returnTensors},this.model={},this.ready=!1,this.ready=C(this.loadModel(this.config.modelUrl),n);}return w()(t,[{key:"loadModel",value:function(){var t=v()(E.a.mark(function t(e){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,p.loadGraphModel(e);case 2:return this.model=t.sent,t.abrupt("return",this);case 4:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"generate",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(i=n,!ct(e)){t.next=5;break;}r=e,t.next=19;break;case 5:if("object"!==S()(e)||!ct(e.elt)){t.next=9;break;}r=e.elt,t.next=19;break;case 9:if("object"!==S()(e)||!ct(e.canvas)){t.next=13;break;}r=e.canvas,t.next=19;break;case 13:if("function"!=typeof e){t.next=18;break;}r=this.video,i=e,t.next=19;break;case 18:throw new Error("Detection subject not supported");case 19:return t.abrupt("return",C(this.generateInternal(r),i));case 20:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"generateInternal",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i,o;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,this.ready;case 2:return t.next=4,p.nextFrame();case 4:if(256===(n=p.browser.fromPixels(e).resizeBilinear([256,256])).shape[0]&&256===n.shape[1]){t.next=9;break;}throw new Error("Input size should be ".concat(256,"*").concat(256," but ").concat(n.shape," is found"));case 9:if(3===n.shape[2]){t.next=11;break;}throw new Error("Input color channel number should be 3 but ".concat(n.shape[2]," is found"));case 11:if(n=n.sub(127.5).div(127.5).reshape([1,256,256,3]),r=p.ones([256,256,1]).tile([1,1,1]).mul(255),i=(i=(i=this.model.predict(n)).add(1).mul(127.5).reshape([256,256,3]).floor()).concat(r,2),o=this.resultFinalize(i),!this.config.returnTensors){t.next=19;break;}return t.abrupt("return",o);case 19:return n.dispose(),i.dispose(),t.abrupt("return",o);case 22:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()},{key:"resultFinalize",value:function(){var t=v()(E.a.mark(function t(e){var n,r,i,o;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return n=e,t.next=3,e.data();case 3:return r=t.sent,t.next=6,rt.rawToBlob(r,e.shape[0],e.shape[1]);case 6:return i=t.sent,t.next=9,rt.blobToP5Image(i);case 9:if(o=t.sent,!this.config.returnTensors){t.next=12;break;}return t.abrupt("return",{tensor:n,raw:r,blob:i,image:o});case 12:return t.abrupt("return",{raw:r,blob:i,image:o});case 13:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()}]),t;}(),sc=function sc(t,e){var n="object"===S()(t)?t:{},r="function"==typeof t?t:e;return "string"==typeof t&&(n.modelUrl=t),new ac(n,r);};/**
    * @license
    * Copyright 2021 Google LLC. All Rights Reserved.
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    * http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    * =============================================================================
    */function uc(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e);})).then(a,s);}u((r=r.apply(t,e||[])).next());});}function cc(t,e){var n,r,i,o,a={label:0,sent:function sent(){if(1&i[0])throw i[1];return i[1];},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this;}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;){try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue;}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break;}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break;}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break;}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(t,a);}catch(t){o=[6,t],r=0;}finally{n=i=0;}}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:!0};}([o,s]);};}}var lc=function lc(t){for(var e=[],n=0,r=t;n<r.length;n++){var i=r[n];e.push(i);}return e;},fc=function fc(){this.parent=null,this.children={},this.end=!1,this.word=[[],0,0];},hc=function(){function t(){this.root=new fc();}return t.prototype.insert=function(t,e,n){for(var r=this.root,i=lc(t),o=0;o<i.length;o++){r.children[i[o]]||(r.children[i[o]]=new fc(),r.children[i[o]].parent=r,r.children[i[o]].word[0]=r.word[0].concat(i[o])),r=r.children[i[o]],o===i.length-1&&(r.end=!0,r.word[1]=e,r.word[2]=n);}},t.prototype.commonPrefixSearch=function(t){for(var e=[],n=this.root.children[t[0]],r=0;r<t.length&&n;r++){n.end&&e.push(n.word),n=n.children[t[r+1]];}return e.length||e.push([[t[0]],0,0]),e;},t;}(),dc="▁";var pc=6,mc=function(){function t(t,e){void 0===e&&(e=pc),this.vocabulary=t,this.reservedSymbolsCount=e,this.trie=new hc();for(var n=this.reservedSymbolsCount;n<this.vocabulary.length;n++){this.trie.insert(this.vocabulary[n][0],this.vocabulary[n][1],n);}}return t.prototype.encode=function(t){var e=[],n=[],r=[];t=function(t){var e=t.normalize("NFKC");return e.length>0?dc+e.replace(/ /g,dc):e;}(t);for(var i=lc(t),o=0;o<=i.length;o++){e.push({}),n.push(0),r.push(0);}for(o=0;o<i.length;o++){for(var a=this.trie.commonPrefixSearch(i.slice(o)),s=0;s<a.length;s++){var u=a[s],c={key:u[0],score:u[1],index:u[2]};null==e[o+(l=u[0].length)][o]&&(e[o+l][o]=[]),e[o+l][o].push(c);}}for(var l=0;l<=i.length;l++){for(var f in e[l]){var h=e[l][f];for(s=0;s<h.length;s++){var d=h[s],p=d.score+r[l-d.key.length];(0===r[l]||p>=r[l])&&(r[l]=p,n[l]=h[s].index);}}}for(var m=[],g=n.length-1;g>0;){m.push(n[g]),g-=this.vocabulary[n[g]][0].length;}var v=[],y=!1;for(o=0;o<m.length;o++){var b=m[o];y&&0===b||v.push(b),y=0===b;}return v.reverse();},t;}();function gc(t){return uc(this,void 0,void 0,function(){var e;return cc(this,function(n){switch(n.label){case 0:return [4,vc(t)];case 1:return e=n.sent(),[2,new mc(e)];}});});}function vc(t){return uc(this,void 0,void 0,function(){return cc(this,function(e){switch(e.label){case 0:return [4,N.util.fetch(t)];case 1:return [2,e.sent().json()];}});});}function bc(t){return uc(this,void 0,void 0,function(){var e;return cc(this,function(n){switch(n.label){case 0:return [4,(e=new xc()).load(t)];case 1:return n.sent(),[2,e];}});});}var xc=function(){function t(){}return t.prototype.loadModel=function(t){return uc(this,void 0,void 0,function(){return cc(this,function(e){return [2,t?Object(T.loadGraphModel)(t):Object(T.loadGraphModel)("https://tfhub.dev/tensorflow/tfjs-model/universal-sentence-encoder-lite/1/default/1",{fromTFHub:!0})];});});},t.prototype.load=function(t){return void 0===t&&(t={}),uc(this,void 0,void 0,function(){var e,n,r;return cc(this,function(i){switch(i.label){case 0:return [4,Promise.all([this.loadModel(t.modelUrl),vc(t.vocabUrl||"https://storage.googleapis.com/tfjs-models/savedmodel/universal_sentence_encoder/vocab.json")])];case 1:return e=i.sent(),n=e[0],r=e[1],this.model=n,this.tokenizer=new mc(r),[2];}});});},t.prototype.embed=function(t){return uc(this,void 0,void 0,function(){var e,n,r,i,o,a,s,u,c=this;return cc(this,function(l){switch(l.label){case 0:for("string"==typeof t&&(t=[t]),e=t.map(function(t){return c.tokenizer.encode(t);}),n=e.map(function(t,e){return t.map(function(t,n){return [e,n];});}),r=[],i=0;i<n.length;i++){r=r.concat(n[i]);}return o=Object(N.tensor2d)(r,[r.length,2],"int32"),a=Object(N.tensor1d)(N.util.flatten(e),"int32"),s={indices:o,values:a},[4,this.model.executeAsync(s)];case 1:return u=l.sent(),o.dispose(),a.dispose(),[2,u];}});});},t;}(),wc={withTokenizer:!1},kc=function(){function t(e,n){b()(this,t),this.model=null,this.tokenizer=null,this.config={withTokenizer:e.withTokenizer||wc.withTokenizer},C(this.loadModel(),n);}return w()(t,[{key:"loadModel",value:function(){var t=v()(E.a.mark(function t(){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(!0!==this.config.withTokenizer){t.next=4;break;}return t.next=3,gc();case 3:this.tokenizer=t.sent;case 4:return t.next=6,bc();case 6:return this.model=t.sent,t.abrupt("return",this);case 8:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"predict",value:function value(t,e){return C(this.predictInternal(t),e);}},{key:"predictInternal",value:function(){var t=v()(E.a.mark(function t(e){var n,r;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.model.embed(e);case 3:return n=t.sent,t.next=6,n.array();case 6:return r=t.sent,n.dispose(),t.abrupt("return",r);case 11:return t.prev=11,t.t0=t.catch(0),console.error(t.t0),t.abrupt("return",t.t0);case 15:case"end":return t.stop();}}},t,this,[[0,11]]);}));return function(e){return t.apply(this,arguments);};}()},{key:"encode",value:function value(t,e){return C(this.encodeInternal(t),e);}},{key:"encodeInternal",value:function(){var t=v()(E.a.mark(function t(e){return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(!0!==this.config.withTokenizer){t.next=2;break;}return t.abrupt("return",this.tokenizer.encode(e));case 2:return console.error('withTokenizer must be set to true - please pass "withTokenizer:true" as an option in the constructor'),t.abrupt("return",!1);case 4:case"end":return t.stop();}}},t,this);}));return function(e){return t.apply(this,arguments);};}()}]),t;}(),Ec=function Ec(t,e){var n="object"===S()(t)?t:{};return new kc(n,"function"==typeof t?t:e);};/**
    * @license
    * Copyright 2020 Google LLC. All Rights Reserved.
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    * http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    * =============================================================================
    */var Cc=function Cc(t){t.startEndTensor.dispose(),t.startPoint.dispose(),t.endPoint.dispose();},Ac=function Ac(t){return {startEndTensor:t,startPoint:Object(N.slice)(t,[0,0],[-1,2]),endPoint:Object(N.slice)(t,[0,2],[-1,2])};},Oc=function Oc(t,e){var n=Object(N.mul)(t.startPoint,e),r=Object(N.mul)(t.endPoint,e),i=Object(N.concat2d)([n,r],1);return Ac(i);},_c={strides:[8,16],anchors:[2,6]},Sc=6;function Dc(t,e){var n,r,i;if(t.topLeft instanceof N.Tensor&&t.bottomRight instanceof N.Tensor){var _Object=Object(N.tidy)(function(){return [Object(N.concat)([Object(N.sub)(e-1,t.topLeft.slice(0,1)),t.topLeft.slice(1,1)]),Object(N.concat)([Object(N.sub)(e-1,t.bottomRight.slice(0,1)),t.bottomRight.slice(1,1)])];}),_Object2=_slicedToArray(_Object,2),_o99=_Object2[0],_a80=_Object2[1];n=_o99,r=_a80,null!=t.landmarks&&(i=Object(N.tidy)(function(){var n=Object(N.sub)(Object(N.tensor1d)([e-1,0]),t.landmarks),r=Object(N.tensor1d)([1,-1]);return Object(N.mul)(n,r);}));}else {var _t$topLeft=_slicedToArray(t.topLeft,2),_o100=_t$topLeft[0],_a81=_t$topLeft[1],_t$bottomRight=_slicedToArray(t.bottomRight,2),_s69=_t$bottomRight[0],_u39=_t$bottomRight[1];n=[e-1-_o100,_a81],r=[e-1-_s69,_u39],null!=t.landmarks&&(i=t.landmarks.map(function(t){return [e-1-t[0],t[1]];}));}var o={topLeft:n,bottomRight:r};return null!=i&&(o.landmarks=i),null!=t.probability&&(o.probability=t.probability instanceof N.Tensor?t.probability.clone():t.probability),o;}function Fc(t,e){return Object(N.tidy)(function(){var n;return n=t.hasOwnProperty("box")?t.box:t,Oc(n,e).startEndTensor.squeeze();});}var Tc=/*#__PURE__*/function(){function Tc(t,e,n,r,i,o){_classCallCheck(this,Tc);this.blazeFaceModel=t,this.width=e,this.height=n,this.maxFaces=r,this.anchorsData=function(t,e,n){var r=[];for(var _i187=0;_i187<n.strides.length;_i187++){var _o101=n.strides[_i187],_a82=Math.floor((e+_o101-1)/_o101),_s70=Math.floor((t+_o101-1)/_o101),_u40=n.anchors[_i187];for(var _t303=0;_t303<_a82;_t303++){var _e303=_o101*(_t303+.5);for(var _t304=0;_t304<_s70;_t304++){var _n237=_o101*(_t304+.5);for(var _t305=0;_t305<_u40;_t305++){r.push([_n237,_e303]);}}}}return r;}(e,n,_c),this.anchors=Object(N.tensor2d)(this.anchorsData),this.inputSizeData=[e,n],this.inputSize=Object(N.tensor1d)([e,n]),this.iouThreshold=i,this.scoreThreshold=o;}_createClass(Tc,[{key:"getBoundingBoxes",value:function(){var _getBoundingBoxes=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee36(t,e){var _this74=this;var n,_Object3,_Object4,r,i,o,a,s,u,c,l,f,h,d,_loop13,_t306,_args41=arguments;return regeneratorRuntime.wrap(function _callee36$(_context41){while(1){switch(_context41.prev=_context41.next){case 0:n=_args41.length>2&&_args41[2]!==undefined?_args41[2]:!0;_Object3=Object(N.tidy)(function(){var e=t.resizeBilinear([_this74.width,_this74.height]),n=Object(N.mul)(Object(N.sub)(e.div(255),.5),2),r=_this74.blazeFaceModel.predict(n).squeeze(),i=function(t,e,n){var r=Object(N.slice)(t,[0,1],[-1,2]),i=Object(N.add)(r,e),o=Object(N.slice)(t,[0,3],[-1,2]),a=Object(N.div)(o,n),s=Object(N.div)(i,n),u=Object(N.div)(a,2),c=Object(N.sub)(s,u),l=Object(N.add)(s,u),f=Object(N.mul)(c,n),h=Object(N.mul)(l,n);return Object(N.concat2d)([f,h],1);}(r,_this74.anchors,_this74.inputSize),o=Object(N.slice)(r,[0,0],[-1,1]);return [r,i,Object(N.sigmoid)(o).squeeze()];}),_Object4=_slicedToArray(_Object3,3),r=_Object4[0],i=_Object4[1],o=_Object4[2],a=console.warn;console.warn=function(){};s=N.image.nonMaxSuppression(i,o,this.maxFaces,this.iouThreshold,this.scoreThreshold);console.warn=a;_context41.next=7;return s.array();case 7:u=_context41.sent;s.dispose();c=u.map(function(t){return Object(N.slice)(i,[t,0],[1,-1]);});_context41.t0=e;if(_context41.t0){_context41.next=15;break;}_context41.next=14;return Promise.all(c.map(/*#__PURE__*/function(){var _ref129=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee35(t){var e;return regeneratorRuntime.wrap(function _callee35$(_context40){while(1){switch(_context40.prev=_context40.next){case 0:_context40.next=2;return t.array();case 2:e=_context40.sent;return _context40.abrupt("return",(t.dispose(),e));case 4:case"end":return _context40.stop();}}},_callee35);}));return function(_x40){return _ref129.apply(this,arguments);};}()));case 14:c=_context41.sent;case 15:l=t.shape[1],f=t.shape[2];h=e?Object(N.div)([f,l],this.inputSize):[f/this.inputSizeData[0],l/this.inputSizeData[1]];d=[];_loop13=function _loop13(_t306){var i=c[_t306],a=Object(N.tidy)(function(){var a=Ac(i instanceof N.Tensor?i:Object(N.tensor2d)(i));if(!n)return a;var s=u[_t306];var c;return c=e?_this74.anchors.slice([s,0],[1,2]):_this74.anchorsData[s],{box:a,landmarks:Object(N.slice)(r,[s,Sc-1],[1,-1]).squeeze().reshape([Sc,-1]),probability:Object(N.slice)(o,[s],[1]),anchor:c};});d.push(a);};for(_t306=0;_t306<c.length;_t306++){_loop13(_t306);}return _context41.abrupt("return",(i.dispose(),o.dispose(),r.dispose(),{boxes:d,scaleFactor:h}));case 21:case"end":return _context41.stop();}}},_callee36,this);}));function getBoundingBoxes(_x38,_x39){return _getBoundingBoxes.apply(this,arguments);}return getBoundingBoxes;}()},{key:"estimateFaces",value:function(){var _estimateFaces=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee39(t){var e,n,r,_ref130,_ref131,i,o,_yield$this$getBoundi,a,s,_args44=arguments;return regeneratorRuntime.wrap(function _callee39$(_context44){while(1){switch(_context44.prev=_context44.next){case 0:e=_args44.length>1&&_args44[1]!==undefined?_args44[1]:!1;n=_args44.length>2&&_args44[2]!==undefined?_args44[2]:!1;r=_args44.length>3&&_args44[3]!==undefined?_args44[3]:!0;_ref130=function(t){return t instanceof N.Tensor?[t.shape[0],t.shape[1]]:[t.height,t.width];}(t);_ref131=_slicedToArray(_ref130,2);i=_ref131[1];o=Object(N.tidy)(function(){return t instanceof N.Tensor||(t=N.browser.fromPixels(t)),t.toFloat().expandDims(0);});_context44.next=9;return this.getBoundingBoxes(o,e,r);case 9:_yield$this$getBoundi=_context44.sent;a=_yield$this$getBoundi.boxes;s=_yield$this$getBoundi.scaleFactor;return _context44.abrupt("return",(o.dispose(),e?a.map(function(t){var e=Fc(t,s);var o={topLeft:e.slice([0],[2]),bottomRight:e.slice([2],[2])};if(r){var _e304=t.landmarks,_n238=t.probability,_r219=t.anchor,_i188=_e304.add(_r219).mul(s);o.landmarks=_i188,o.probability=_n238;}return n&&(o=Dc(o,i)),o;}):Promise.all(a.map(/*#__PURE__*/function(){var _ref132=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee38(t){var e,o,_yield$Promise$all,_yield$Promise$all2,_n239,_r220,_i189,_a83,_s71,_u41,_c29,_l19,_t307;return regeneratorRuntime.wrap(function _callee38$(_context43){while(1){switch(_context43.prev=_context43.next){case 0:e=Fc(t,s);if(!r){_context43.next=17;break;}_context43.next=4;return Promise.all([t.landmarks,e,t.probability].map(/*#__PURE__*/function(){var _ref133=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee37(t){return regeneratorRuntime.wrap(function _callee37$(_context42){while(1){switch(_context42.prev=_context42.next){case 0:return _context42.abrupt("return",t.array());case 1:case"end":return _context42.stop();}}},_callee37);}));return function(_x43){return _ref133.apply(this,arguments);};}()));case 4:_yield$Promise$all=_context43.sent;_yield$Promise$all2=_slicedToArray(_yield$Promise$all,3);_n239=_yield$Promise$all2[0];_r220=_yield$Promise$all2[1];_i189=_yield$Promise$all2[2];_a83=t.anchor;_s71=_slicedToArray(s,2);_u41=_s71[0];_c29=_s71[1];_l19=_n239.map(function(t){return [(t[0]+_a83[0])*_u41,(t[1]+_a83[1])*_c29];});o={topLeft:_r220.slice(0,2),bottomRight:_r220.slice(2),landmarks:_l19,probability:_i189},Cc(t.box),t.landmarks.dispose(),t.probability.dispose();_context43.next=21;break;case 17:_context43.next=19;return e.array();case 19:_t307=_context43.sent;o={topLeft:_t307.slice(0,2),bottomRight:_t307.slice(2)};case 21:return _context43.abrupt("return",(e.dispose(),n&&(o=Dc(o,i)),o));case 22:case"end":return _context43.stop();}}},_callee38);}));return function(_x42){return _ref132.apply(this,arguments);};}()))));case 13:case"end":return _context44.stop();}}},_callee39,this);}));function estimateFaces(_x41){return _estimateFaces.apply(this,arguments);}return estimateFaces;}()}]);return Tc;}();var Nc="https://tfhub.dev/tensorflow/tfjs-model/blazeface/1/default/1";var Ic={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],lipsUpperOuter:[61,185,40,39,37,0,267,269,270,409,291],lipsLowerOuter:[146,91,181,84,17,314,405,321,375,291],lipsUpperInner:[78,191,80,81,82,13,312,311,310,415,308],lipsLowerInner:[78,95,88,178,87,14,317,402,318,324,308],rightEyeUpper0:[246,161,160,159,158,157,173],rightEyeLower0:[33,7,163,144,145,153,154,155,133],rightEyeUpper1:[247,30,29,27,28,56,190],rightEyeLower1:[130,25,110,24,23,22,26,112,243],rightEyeUpper2:[113,225,224,223,222,221,189],rightEyeLower2:[226,31,228,229,230,231,232,233,244],rightEyeLower3:[143,111,117,118,119,120,121,128,245],rightEyebrowUpper:[156,70,63,105,66,107,55,193],rightEyebrowLower:[35,124,46,53,52,65],leftEyeUpper0:[466,388,387,386,385,384,398],leftEyeLower0:[263,249,390,373,374,380,381,382,362],leftEyeUpper1:[467,260,259,257,258,286,414],leftEyeLower1:[359,255,339,254,253,252,256,341,463],leftEyeUpper2:[342,445,444,443,442,441,413],leftEyeLower2:[446,261,448,449,450,451,452,453,464],leftEyeLower3:[372,340,346,347,348,349,350,357,465],leftEyebrowUpper:[383,300,293,334,296,336,285,417],leftEyebrowLower:[265,353,276,283,282,295],midwayBetweenEyes:[168],noseTip:[1],noseBottom:[2],noseRightCorner:[98],noseLeftCorner:[327],rightCheek:[205],leftCheek:[425]};function Rc(t){null!=t&&null!=t.startPoint&&(t.startEndTensor.dispose(),t.startPoint.dispose(),t.endPoint.dispose());}function Mc(t,e,n){return {startEndTensor:t,startPoint:null!=e?e:Object(N.slice)(t,[0,0],[-1,2]),endPoint:null!=n?n:Object(N.slice)(t,[0,2],[-1,2])};}function jc(t){return Object(N.tidy)(function(){var e=Object(N.sub)(t.endPoint,t.startPoint);return Object(N.abs)(e);});}function Bc(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1.5;return Object(N.tidy)(function(){var n=function(t){return Object(N.tidy)(function(){var e=Object(N.div)(Object(N.sub)(t.endPoint,t.startPoint),2);return Object(N.add)(t.startPoint,e);});}(t),r=jc(t),i=Object(N.mul)(Object(N.div)(r,2),e),o=Object(N.sub)(n,i),a=Object(N.add)(n,i);return Mc(Object(N.concat2d)([o,a],1),o,a);});}var Pc=468,Lc=.25;var zc=/*#__PURE__*/function(){function zc(t,e,n,r,i,o){_classCallCheck(this,zc);this.regionsOfInterest=[],this.runsWithoutFaceDetector=0,this.boundingBoxDetector=t,this.meshDetector=e,this.meshWidth=n,this.meshHeight=r,this.maxContinuousChecks=i,this.maxFaces=o;}_createClass(zc,[{key:"predict",value:function(){var _predict=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee40(t){var _this75=this;var _e305,_n240,_yield$this$boundingB,_r221,_i190,o;return regeneratorRuntime.wrap(function _callee40$(_context45){while(1){switch(_context45.prev=_context45.next){case 0:if(!this.shouldUpdateRegionsOfInterest()){_context45.next=14;break;}_e305=!0;_n240=!1;_context45.next=5;return this.boundingBoxDetector.getBoundingBoxes(t,_e305,_n240);case 5:_yield$this$boundingB=_context45.sent;_r221=_yield$this$boundingB.boxes;_i190=_yield$this$boundingB.scaleFactor;if(!(0===_r221.length)){_context45.next=10;break;}return _context45.abrupt("return",(_i190.dispose(),this.clearAllRegionsOfInterest(),null));case 10:o=_r221.map(function(t){return Bc(function(t,e){var n=Object(N.mul)(t.startPoint,e),r=Object(N.mul)(t.endPoint,e);return Mc(Object(N.concat2d)([n,r],1));}(t,_i190));});_r221.forEach(Rc),this.updateRegionsOfInterest(o),this.runsWithoutFaceDetector=0;_context45.next=15;break;case 14:this.runsWithoutFaceDetector++;case 15:return _context45.abrupt("return",Object(N.tidy)(function(){return _this75.regionsOfInterest.map(function(e,n){var r=function(t,e,n){var r=e.shape[1],i=e.shape[2],o=t.startEndTensor;return Object(N.tidy)(function(){var t=Object(N.concat2d)([o.slice([0,1],[-1,1]),o.slice([0,0],[-1,1]),o.slice([0,3],[-1,1]),o.slice([0,2],[-1,1])],0),a=Object(N.div)(t.transpose(),[r,i,r,i]);return N.image.cropAndResize(e,a,[0],n);});}(e,t,[_this75.meshHeight,_this75.meshWidth]).div(255),_this75$meshDetector$=_this75.meshDetector.predict(r),_this75$meshDetector$2=_slicedToArray(_this75$meshDetector$,3),i=_this75$meshDetector$2[1],o=_this75$meshDetector$2[2],a=Object(N.reshape)(o,[-1,3]),s=Object(N.div)(jc(e),[_this75.meshWidth,_this75.meshHeight]),u=Object(N.mul)(a,s.concat(Object(N.tensor2d)([1],[1,1]),1)).add(e.startPoint.concat(Object(N.tensor2d)([0],[1,1]),1)),c=_this75.calculateLandmarksBoundingBox(u);return Rc(_this75.regionsOfInterest[n]),_this75.regionsOfInterest[n]=c,{coords:a,scaledCoords:u,box:c,flag:i.squeeze()};});}));case 16:case"end":return _context45.stop();}}},_callee40,this);}));function predict(_x44){return _predict.apply(this,arguments);}return predict;}()},{key:"updateRegionsOfInterest",value:function updateRegionsOfInterest(t){for(var _e306=0;_e306<t.length;_e306++){var _n241=t[_e306],_r222=this.regionsOfInterest[_e306];var _i191=0;if(_r222&&_r222.startPoint){var _n241$startEndTensor$=_slicedToArray(_n241.startEndTensor.arraySync()[0],4),_t308=_n241$startEndTensor$[0],_e307=_n241$startEndTensor$[1],o=_n241$startEndTensor$[2],_a84=_n241$startEndTensor$[3],_r222$startEndTensor$=_slicedToArray(_r222.startEndTensor.arraySync()[0],4),_s72=_r222$startEndTensor$[0],_u42=_r222$startEndTensor$[1],_c30=_r222$startEndTensor$[2],_l20=_r222$startEndTensor$[3],_f19=Math.max(_t308,_s72),h=Math.max(_e307,_u42),_d9=(Math.min(o,_c30)-_f19)*(Math.min(_a84,_l20)-h);_i191=_d9/((o-_t308)*(_a84-_e307)+(_c30-_s72)*(_l20-_e307)-_d9);}_i191>Lc?Rc(_n241):(this.regionsOfInterest[_e306]=_n241,Rc(_r222));}for(var _e308=t.length;_e308<this.regionsOfInterest.length;_e308++){Rc(this.regionsOfInterest[_e308]);}this.regionsOfInterest=this.regionsOfInterest.slice(0,t.length);}},{key:"clearRegionOfInterest",value:function clearRegionOfInterest(t){null!=this.regionsOfInterest[t]&&(Rc(this.regionsOfInterest[t]),this.regionsOfInterest=[].concat(_toConsumableArray(this.regionsOfInterest.slice(0,t)),_toConsumableArray(this.regionsOfInterest.slice(t+1))));}},{key:"clearAllRegionsOfInterest",value:function clearAllRegionsOfInterest(){for(var _t309=0;_t309<this.regionsOfInterest.length;_t309++){Rc(this.regionsOfInterest[_t309]);}this.regionsOfInterest=[];}},{key:"shouldUpdateRegionsOfInterest",value:function shouldUpdateRegionsOfInterest(){var t=this.regionsOfInterest.length,e=0===t;return 1===this.maxFaces||e?e:t!==this.maxFaces&&this.runsWithoutFaceDetector>=this.maxContinuousChecks;}},{key:"calculateLandmarksBoundingBox",value:function calculateLandmarksBoundingBox(t){var e=t.slice([0,0],[Pc,1]),n=t.slice([0,1],[Pc,1]);return Bc(Mc(Object(N.stack)([e.min(),n.min(),e.max(),n.max()]).expandDims(0)));}}]);return zc;}();var Uc=[[.499976992607117,.652534008026123],[.500025987625122,.547487020492554],[.499974012374878,.602371990680695],[.482113003730774,.471979022026062],[.500150978565216,.527155995368958],[.499909996986389,.498252987861633],[.499523013830185,.40106201171875],[.289712011814117,.380764007568359],[.499954998493195,.312398016452789],[.499987006187439,.269918978214264],[.500023007392883,.107050001621246],[.500023007392883,.666234016418457],[.5000159740448,.679224014282227],[.500023007392883,.692348003387451],[.499976992607117,.695277988910675],[.499976992607117,.70593398809433],[.499976992607117,.719385027885437],[.499976992607117,.737019002437592],[.499967992305756,.781370997428894],[.499816000461578,.562981009483337],[.473773002624512,.573909997940063],[.104906998574734,.254140973091125],[.365929991006851,.409575998783112],[.338757991790771,.41302502155304],[.311120003461838,.409460008144379],[.274657994508743,.389131009578705],[.393361985683441,.403706014156342],[.345234006643295,.344011008739471],[.370094001293182,.346076011657715],[.319321990013123,.347265005111694],[.297903001308441,.353591024875641],[.24779200553894,.410809993743896],[.396889001131058,.842755019664764],[.280097991228104,.375599980354309],[.106310002505779,.399955987930298],[.2099249958992,.391353011131287],[.355807989835739,.534406006336212],[.471751004457474,.65040397644043],[.474155008792877,.680191993713379],[.439785003662109,.657229006290436],[.414617002010345,.66654098033905],[.450374007225037,.680860996246338],[.428770989179611,.682690978050232],[.374971002340317,.727805018424988],[.486716985702515,.547628998756409],[.485300987958908,.527395009994507],[.257764995098114,.314490020275116],[.401223003864288,.455172002315521],[.429818987846375,.548614978790283],[.421351999044418,.533740997314453],[.276895999908447,.532056987285614],[.483370006084442,.499586999416351],[.33721199631691,.282882988452911],[.296391993761063,.293242990970612],[.169294998049736,.193813979625702],[.447580009698868,.302609980106354],[.392390012741089,.353887975215912],[.354490011930466,.696784019470215],[.067304998636246,.730105042457581],[.442739009857178,.572826027870178],[.457098007202148,.584792017936707],[.381974011659622,.694710969924927],[.392388999462128,.694203019142151],[.277076005935669,.271932005882263],[.422551989555359,.563233017921448],[.385919004678726,.281364023685455],[.383103013038635,.255840003490448],[.331431001424789,.119714021682739],[.229923993349075,.232002973556519],[.364500999450684,.189113974571228],[.229622006416321,.299540996551514],[.173287004232407,.278747975826263],[.472878992557526,.666198015213013],[.446828007698059,.668527007102966],[.422762006521225,.673889994621277],[.445307999849319,.580065965652466],[.388103008270264,.693961024284363],[.403039008378983,.706539988517761],[.403629004955292,.693953037261963],[.460041999816895,.557139039039612],[.431158006191254,.692366003990173],[.452181994915009,.692366003990173],[.475387006998062,.692366003990173],[.465828001499176,.779190003871918],[.472328990697861,.736225962638855],[.473087012767792,.717857003211975],[.473122000694275,.704625964164734],[.473033010959625,.695277988910675],[.427942007780075,.695277988910675],[.426479011774063,.703539967536926],[.423162013292313,.711845993995667],[.4183090031147,.720062971115112],[.390094995498657,.639572978019714],[.013953999616206,.560034036636353],[.499913990497589,.58014702796936],[.413199990987778,.69539999961853],[.409626007080078,.701822996139526],[.468080013990402,.601534962654114],[.422728985548019,.585985004901886],[.463079988956451,.593783974647522],[.37211999297142,.47341400384903],[.334562003612518,.496073007583618],[.411671012639999,.546965003013611],[.242175996303558,.14767599105835],[.290776997804642,.201445996761322],[.327338010072708,.256527006626129],[.399509996175766,.748921036720276],[.441727995872498,.261676013469696],[.429764986038208,.187834024429321],[.412198007106781,.108901023864746],[.288955003023148,.398952007293701],[.218936994671822,.435410976409912],[.41278201341629,.398970007896423],[.257135003805161,.355440020561218],[.427684992551804,.437960982322693],[.448339998722076,.536936044692993],[.178560003638268,.45755398273468],[.247308000922203,.457193970680237],[.286267012357712,.467674970626831],[.332827985286713,.460712015628815],[.368755996227264,.447206974029541],[.398963987827301,.432654976844788],[.476410001516342,.405806005001068],[.189241006970406,.523923993110657],[.228962004184723,.348950982093811],[.490725994110107,.562400996685028],[.404670000076294,.485132992267609],[.019469000399113,.401564002037048],[.426243007183075,.420431017875671],[.396993011236191,.548797011375427],[.266469985246658,.376977026462555],[.439121007919312,.51895797252655],[.032313998788595,.644356966018677],[.419054001569748,.387154996395111],[.462783008813858,.505746960639954],[.238978996872902,.779744982719421],[.198220998048782,.831938028335571],[.107550002634525,.540755033493042],[.183610007166862,.740257024765015],[.134409993886948,.333683013916016],[.385764002799988,.883153975009918],[.490967005491257,.579378008842468],[.382384985685349,.508572995662689],[.174399003386497,.397670984268188],[.318785011768341,.39623498916626],[.343364000320435,.400596976280212],[.396100014448166,.710216999053955],[.187885001301765,.588537991046906],[.430987000465393,.944064974784851],[.318993002176285,.898285031318665],[.266247987747192,.869701027870178],[.500023007392883,.190576016902924],[.499976992607117,.954452991485596],[.366169989109039,.398822009563446],[.393207013607025,.39553701877594],[.410373002290726,.391080021858215],[.194993004202843,.342101991176605],[.388664990663528,.362284004688263],[.365961998701096,.355970978736877],[.343364000320435,.355356991291046],[.318785011768341,.35834002494812],[.301414996385574,.363156020641327],[.058132998645306,.319076001644135],[.301414996385574,.387449026107788],[.499987989664078,.618434011936188],[.415838003158569,.624195992946625],[.445681989192963,.566076993942261],[.465844005346298,.620640993118286],[.49992299079895,.351523995399475],[.288718998432159,.819945991039276],[.335278987884521,.852819979190826],[.440512001514435,.902418971061707],[.128294005990028,.791940987110138],[.408771991729736,.373893976211548],[.455606997013092,.451801002025604],[.499877005815506,.908990025520325],[.375436991453171,.924192011356354],[.11421000212431,.615022003650665],[.448662012815475,.695277988910675],[.4480200111866,.704632043838501],[.447111994028091,.715808033943176],[.444831997156143,.730794012546539],[.430011987686157,.766808986663818],[.406787008047104,.685672998428345],[.400738000869751,.681069016456604],[.392399996519089,.677703022956848],[.367855995893478,.663918972015381],[.247923001646996,.601333022117615],[.452769994735718,.420849978923798],[.43639200925827,.359887003898621],[.416164010763168,.368713974952698],[.413385987281799,.692366003990173],[.228018000721931,.683571994304657],[.468268007040024,.352671027183533],[.411361992359161,.804327011108398],[.499989002943039,.469825029373169],[.479153990745544,.442654013633728],[.499974012374878,.439637005329132],[.432112008333206,.493588984012604],[.499886006116867,.866917014122009],[.49991300702095,.821729004383087],[.456548988819122,.819200992584229],[.344549000263214,.745438992977142],[.37890899181366,.574010014533997],[.374292999505997,.780184984207153],[.319687992334366,.570737957954407],[.357154995203018,.604269981384277],[.295284003019333,.621580958366394],[.447750002145767,.862477004528046],[.410986006259918,.508723020553589],[.31395098567009,.775308012962341],[.354128003120422,.812552988529205],[.324548006057739,.703992962837219],[.189096003770828,.646299958229065],[.279776990413666,.71465802192688],[.1338230073452,.682700991630554],[.336768001317978,.644733011722565],[.429883986711502,.466521978378296],[.455527991056442,.548622965812683],[.437114000320435,.558896005153656],[.467287987470627,.529924988746643],[.414712011814117,.335219979286194],[.37704598903656,.322777986526489],[.344107985496521,.320150971412659],[.312875986099243,.32233202457428],[.283526003360748,.333190023899078],[.241245999932289,.382785975933075],[.102986000478268,.468762993812561],[.267612010240555,.424560010433197],[.297879010438919,.433175981044769],[.333433985710144,.433878004550934],[.366427004337311,.426115989685059],[.396012008190155,.416696012020111],[.420121014118195,.41022801399231],[.007561000064015,.480777025222778],[.432949006557465,.569517970085144],[.458638995885849,.479089021682739],[.473466008901596,.545744001865387],[.476087987422943,.563830018043518],[.468472003936768,.555056989192963],[.433990985155106,.582361996173859],[.483518004417419,.562983989715576],[.482482999563217,.57784903049469],[.42645001411438,.389798998832703],[.438998997211456,.39649498462677],[.450067013502121,.400434017181396],[.289712011814117,.368252992630005],[.276670008897781,.363372981548309],[.517862021923065,.471948027610779],[.710287988185883,.380764007568359],[.526226997375488,.573909997940063],[.895093023777008,.254140973091125],[.634069979190826,.409575998783112],[.661242008209229,.41302502155304],[.688880026340485,.409460008144379],[.725341975688934,.389131009578705],[.606630027294159,.40370500087738],[.654766023159027,.344011008739471],[.629905998706818,.346076011657715],[.680678009986877,.347265005111694],[.702096998691559,.353591024875641],[.75221198797226,.410804986953735],[.602918028831482,.842862963676453],[.719901978969574,.375599980354309],[.893692970275879,.399959981441498],[.790081977844238,.391354024410248],[.643998026847839,.534487962722778],[.528249025344849,.65040397644043],[.525849997997284,.680191040039062],[.560214996337891,.657229006290436],[.585384011268616,.66654098033905],[.549625992774963,.680860996246338],[.57122802734375,.682691991329193],[.624852001667023,.72809898853302],[.513050019741058,.547281980514526],[.51509702205658,.527251958847046],[.742246985435486,.314507007598877],[.598631024360657,.454979002475739],[.570338010787964,.548575043678284],[.578631997108459,.533622980117798],[.723087012767792,.532054007053375],[.516445994377136,.499638974666595],[.662801027297974,.282917976379395],[.70362401008606,.293271005153656],[.830704987049103,.193813979625702],[.552385985851288,.302568018436432],[.607609987258911,.353887975215912],[.645429015159607,.696707010269165],[.932694971561432,.730105042457581],[.557260990142822,.572826027870178],[.542901992797852,.584792017936707],[.6180260181427,.694710969924927],[.607590973377228,.694203019142151],[.722943007946014,.271963000297546],[.577413976192474,.563166975975037],[.614082992076874,.281386971473694],[.616907000541687,.255886018276215],[.668509006500244,.119913995265961],[.770092010498047,.232020974159241],[.635536015033722,.189248979091644],[.77039098739624,.299556016921997],[.826722025871277,.278755009174347],[.527121007442474,.666198015213013],[.553171992301941,.668527007102966],[.577238023281097,.673889994621277],[.554691970348358,.580065965652466],[.611896991729736,.693961024284363],[.59696102142334,.706539988517761],[.596370995044708,.693953037261963],[.539958000183105,.557139039039612],[.568841993808746,.692366003990173],[.547818005084991,.692366003990173],[.52461302280426,.692366003990173],[.534089982509613,.779141008853912],[.527670979499817,.736225962638855],[.526912987232208,.717857003211975],[.526877999305725,.704625964164734],[.526966989040375,.695277988910675],[.572058022022247,.695277988910675],[.573521018028259,.703539967536926],[.57683801651001,.711845993995667],[.581691026687622,.720062971115112],[.609944999217987,.639909982681274],[.986046016216278,.560034036636353],[.5867999792099,.69539999961853],[.590372025966644,.701822996139526],[.531915009021759,.601536989212036],[.577268004417419,.585934996604919],[.536915004253387,.593786001205444],[.627542972564697,.473352015018463],[.665585994720459,.495950996875763],[.588353991508484,.546862006187439],[.757824003696442,.14767599105835],[.709249973297119,.201507985591888],[.672684013843536,.256581008434296],[.600408971309662,.74900496006012],[.55826598405838,.261672019958496],[.570303976535797,.187870979309082],[.588165998458862,.109044015407562],[.711045026779175,.398952007293701],[.781069993972778,.435405015945435],[.587247014045715,.398931980133057],[.742869973182678,.355445981025696],[.572156012058258,.437651991844177],[.55186802148819,.536570012569427],[.821442008018494,.457556009292603],[.752701997756958,.457181990146637],[.71375697851181,.467626988887787],[.66711300611496,.460672974586487],[.631101012229919,.447153985500336],[.6008620262146,.432473003864288],[.523481011390686,.405627012252808],[.810747981071472,.523926019668579],[.771045982837677,.348959028720856],[.509127020835876,.562718033790588],[.595292985439301,.485023975372314],[.980530977249146,.401564002037048],[.573499977588654,.420000016689301],[.602994978427887,.548687994480133],[.733529984951019,.376977026462555],[.560611009597778,.519016981124878],[.967685997486115,.644356966018677],[.580985009670258,.387160003185272],[.537728011608124,.505385041236877],[.760966002941132,.779752969741821],[.801778972148895,.831938028335571],[.892440974712372,.54076099395752],[.816350996494293,.740260004997253],[.865594983100891,.333687007427216],[.614073991775513,.883246004581451],[.508952975273132,.579437971115112],[.617941975593567,.508316040039062],[.825608015060425,.397674977779388],[.681214988231659,.39623498916626],[.656635999679565,.400596976280212],[.603900015354156,.710216999053955],[.81208598613739,.588539004325867],[.56801301240921,.944564998149872],[.681007981300354,.898285031318665],[.733752012252808,.869701027870178],[.633830010890961,.398822009563446],[.606792986392975,.39553701877594],[.589659988880157,.391062021255493],[.805015981197357,.342108011245728],[.611334979534149,.362284004688263],[.634037971496582,.355970978736877],[.656635999679565,.355356991291046],[.681214988231659,.35834002494812],[.698584973812103,.363156020641327],[.941866993904114,.319076001644135],[.698584973812103,.387449026107788],[.584177017211914,.624107003211975],[.554318010807037,.566076993942261],[.534153997898102,.62064003944397],[.711217999458313,.819975018501282],[.664629995822906,.852871000766754],[.559099972248077,.902631998062134],[.871706008911133,.791940987110138],[.591234028339386,.373893976211548],[.544341027736664,.451583981513977],[.624562978744507,.924192011356354],[.88577002286911,.615028977394104],[.551338016986847,.695277988910675],[.551980018615723,.704632043838501],[.552887976169586,.715808033943176],[.555167973041534,.730794012546539],[.569944024085999,.767035007476807],[.593203008174896,.685675978660583],[.599261999130249,.681069016456604],[.607599973678589,.677703022956848],[.631937980651855,.663500010967255],[.752032995223999,.601315021514893],[.547226011753082,.420395016670227],[.563543975353241,.359827995300293],[.583841025829315,.368713974952698],[.586614012718201,.692366003990173],[.771915018558502,.683578014373779],[.531597018241882,.352482974529266],[.588370978832245,.804440975189209],[.52079701423645,.442565023899078],[.567984998226166,.493479013442993],[.543282985687256,.819254994392395],[.655317008495331,.745514988899231],[.621008992195129,.574018001556396],[.625559985637665,.78031200170517],[.680198013782501,.570719003677368],[.64276397228241,.604337990283966],[.704662978649139,.621529996395111],[.552012026309967,.862591981887817],[.589071989059448,.508637011051178],[.685944974422455,.775357007980347],[.645735025405884,.812640011310577],[.675342977046967,.703978002071381],[.810858011245728,.646304965019226],[.72012197971344,.714666962623596],[.866151988506317,.682704985141754],[.663187026977539,.644596993923187],[.570082008838654,.466325998306274],[.544561982154846,.548375964164734],[.562758982181549,.558784961700439],[.531987011432648,.530140042304993],[.585271000862122,.335177004337311],[.622952997684479,.32277899980545],[.655896008014679,.320163011550903],[.687132000923157,.322345972061157],[.716481983661652,.333200991153717],[.758756995201111,.382786989212036],[.897013008594513,.468769013881683],[.732392013072968,.424547016620636],[.70211398601532,.433162987232208],[.66652500629425,.433866024017334],[.633504986763,.426087975502014],[.603875994682312,.416586995124817],[.579657971858978,.409945011138916],[.992439985275269,.480777025222778],[.567192018032074,.569419980049133],[.54136598110199,.478899002075195],[.526564002037048,.546118021011353],[.523913025856018,.563830018043518],[.531529009342194,.555056989192963],[.566035985946655,.582329034805298],[.51631098985672,.563053965568542],[.5174720287323,.577877044677734],[.573594987392426,.389806985855103],[.560697972774506,.395331978797913],[.549755990505219,.399751007556915],[.710287988185883,.368252992630005],[.723330020904541,.363372981548309]],Wc="https://tfhub.dev/mediapipe/tfjs-model/facemesh/1/default/1",Vc=192,qc=192;function $c(){return _$c.apply(this,arguments);}function _$c(){_$c=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee49(){var _ref140,_ref140$maxContinuous,t,_ref140$detectionConf,e,_ref140$maxFaces,n,_ref140$iouThreshold,r,_ref140$scoreThreshol,i,_yield$Promise$all3,_yield$Promise$all4,o,a,_args54=arguments;return regeneratorRuntime.wrap(function _callee49$(_context54){while(1){switch(_context54.prev=_context54.next){case 0:_ref140=_args54.length>0&&_args54[0]!==undefined?_args54[0]:{},_ref140$maxContinuous=_ref140.maxContinuousChecks,t=_ref140$maxContinuous===void 0?5:_ref140$maxContinuous,_ref140$detectionConf=_ref140.detectionConfidence,e=_ref140$detectionConf===void 0?.9:_ref140$detectionConf,_ref140$maxFaces=_ref140.maxFaces,n=_ref140$maxFaces===void 0?10:_ref140$maxFaces,_ref140$iouThreshold=_ref140.iouThreshold,r=_ref140$iouThreshold===void 0?.3:_ref140$iouThreshold,_ref140$scoreThreshol=_ref140.scoreThreshold,i=_ref140$scoreThreshol===void 0?.75:_ref140$scoreThreshol;_context54.next=3;return Promise.all([function(){var _ref141=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee47(t,e,n){return regeneratorRuntime.wrap(function _callee47$(_context52){while(1){switch(_context52.prev=_context52.next){case 0:return _context52.abrupt("return",_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee46(){var _ref143,_ref143$maxFaces,t,_ref143$inputWidth,e,_ref143$inputHeight,n,_ref143$iouThreshold,r,_ref143$scoreThreshol,i,o,_args51=arguments;return regeneratorRuntime.wrap(function _callee46$(_context51){while(1){switch(_context51.prev=_context51.next){case 0:_ref143=_args51.length>0&&_args51[0]!==undefined?_args51[0]:{},_ref143$maxFaces=_ref143.maxFaces,t=_ref143$maxFaces===void 0?10:_ref143$maxFaces,_ref143$inputWidth=_ref143.inputWidth,e=_ref143$inputWidth===void 0?128:_ref143$inputWidth,_ref143$inputHeight=_ref143.inputHeight,n=_ref143$inputHeight===void 0?128:_ref143$inputHeight,_ref143$iouThreshold=_ref143.iouThreshold,r=_ref143$iouThreshold===void 0?.3:_ref143$iouThreshold,_ref143$scoreThreshol=_ref143.scoreThreshold,i=_ref143$scoreThreshol===void 0?.75:_ref143$scoreThreshol;_context51.next=3;return Object(T.loadGraphModel)(Nc,{fromTFHub:!0});case 3:o=_context51.sent;return _context51.abrupt("return",new Tc(o,e,n,t,r,i));case 5:case"end":return _context51.stop();}}},_callee46);}))({maxFaces:t,iouThreshold:e,scoreThreshold:n}));case 1:case"end":return _context52.stop();}}},_callee47);}));return function(_x52,_x53,_x54){return _ref141.apply(this,arguments);};}()(n,r,i),_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee48(){return regeneratorRuntime.wrap(function _callee48$(_context53){while(1){switch(_context53.prev=_context53.next){case 0:return _context53.abrupt("return",Object(T.loadGraphModel)(Wc,{fromTFHub:!0}));case 1:case"end":return _context53.stop();}}},_callee48);}))()]);case 3:_yield$Promise$all3=_context54.sent;_yield$Promise$all4=_slicedToArray(_yield$Promise$all3,2);o=_yield$Promise$all4[0];a=_yield$Promise$all4[1];return _context54.abrupt("return",new Gc(o,a,t,e,n));case 8:case"end":return _context54.stop();}}},_callee49);}));return _$c.apply(this,arguments);}function Hc(t,e){if(t.mesh instanceof N.Tensor){var _Object5=Object(N.tidy)(function(){var n=Object(N.tensor1d)([e-1,0,0]),r=Object(N.tensor1d)([1,-1,1]);return Object(N.tidy)(function(){return [Object(N.concat)([Object(N.sub)(e-1,t.boundingBox.topLeft.slice(0,1)),t.boundingBox.topLeft.slice(1,1)]),Object(N.concat)([Object(N.sub)(e-1,t.boundingBox.bottomRight.slice(0,1)),t.boundingBox.bottomRight.slice(1,1)]),Object(N.sub)(n,t.mesh).mul(r),Object(N.sub)(n,t.scaledMesh).mul(r)];});}),_Object6=_slicedToArray(_Object5,4),_n242=_Object6[0],_r223=_Object6[1],_i192=_Object6[2],o=_Object6[3];return Object.assign({},t,{boundingBox:{topLeft:_n242,bottomRight:_r223},mesh:_i192,scaledMesh:o});}return Object.assign({},t,{boundingBox:{topLeft:[e-1-t.boundingBox.topLeft[0],t.boundingBox.topLeft[1]],bottomRight:[e-1-t.boundingBox.bottomRight[0],t.boundingBox.bottomRight[1]]},mesh:t.mesh.map(function(t){var n=t.slice(0);return n[0]=e-1-t[0],n;}),scaledMesh:t.scaledMesh.map(function(t){var n=t.slice(0);return n[0]=e-1-t[0],n;})});}var Gc=/*#__PURE__*/function(){function Gc(t,e,n,r,i){_classCallCheck(this,Gc);this.pipeline=new zc(t,e,Vc,qc,n,i),this.detectionConfidence=r;}_createClass(Gc,[{key:"estimateFaces",value:function(){var _estimateFaces2=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee43(t){var _this76=this;var e,n,_ref134,_ref135,r,i,o,a,_args48=arguments;return regeneratorRuntime.wrap(function _callee43$(_context48){while(1){switch(_context48.prev=_context48.next){case 0:e=_args48.length>1&&_args48[1]!==undefined?_args48[1]:!1;n=_args48.length>2&&_args48[2]!==undefined?_args48[2]:!1;_ref134=function(t){return t instanceof N.Tensor?[t.shape[0],t.shape[1]]:[t.height,t.width];}(t),_ref135=_slicedToArray(_ref134,2),r=_ref135[1],i=Object(N.tidy)(function(){return t instanceof N.Tensor||(t=N.browser.fromPixels(t)),t.toFloat().expandDims(0);}),o=Object(N.env)().get("WEBGL_PACK_DEPTHWISECONV");Object(N.env)().set("WEBGL_PACK_DEPTHWISECONV",!0);_context48.next=6;return this.pipeline.predict(i);case 6:a=_context48.sent;return _context48.abrupt("return",(Object(N.env)().set("WEBGL_PACK_DEPTHWISECONV",o),i.dispose(),null!=a&&a.length>0?Promise.all(a.map(/*#__PURE__*/function(){var _ref136=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee42(t,i){var o,a,s,u,c,l,f,_t310,_l$slice,_l$slice2,h,d,p,m,g,v,_t311;return regeneratorRuntime.wrap(function _callee42$(_context47){while(1){switch(_context47.prev=_context47.next){case 0:o=t.coords,a=t.scaledCoords,s=t.box,u=t.flag;c=[u];e||(c=c.concat([o,a,s.startPoint,s.endPoint]));_context47.next=5;return Promise.all(c.map(/*#__PURE__*/function(){var _ref137=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee41(t){return regeneratorRuntime.wrap(function _callee41$(_context46){while(1){switch(_context46.prev=_context46.next){case 0:return _context46.abrupt("return",t.array());case 1:case"end":return _context46.stop();}}},_callee41);}));return function(_x48){return _ref137.apply(this,arguments);};}()));case 5:l=_context47.sent;f=l[0];if(!(u.dispose(),f<_this76.detectionConfidence&&_this76.pipeline.clearRegionOfInterest(i),e)){_context47.next=10;break;}_t310={faceInViewConfidence:f,mesh:o,scaledMesh:a,boundingBox:{topLeft:s.startPoint.squeeze(),bottomRight:s.endPoint.squeeze()}};return _context47.abrupt("return",n?Hc(_t310,r):_t310);case 10:_l$slice=l.slice(1),_l$slice2=_slicedToArray(_l$slice,4),h=_l$slice2[0],d=_l$slice2[1],p=_l$slice2[2],m=_l$slice2[3];a.dispose(),o.dispose();g={faceInViewConfidence:f,boundingBox:{topLeft:p,bottomRight:m},mesh:h,scaledMesh:d};n&&(g=Hc(g,r));v={};for(_t311 in Ic){v[_t311]=Ic[_t311].map(function(t){return g.scaledMesh[t];});}return _context47.abrupt("return",(g.annotations=v,g));case 17:case"end":return _context47.stop();}}},_callee42);}));return function(_x46,_x47){return _ref136.apply(this,arguments);};}())):[]));case 8:case"end":return _context48.stop();}}},_callee43,this);}));function estimateFaces(_x45){return _estimateFaces2.apply(this,arguments);}return estimateFaces;}()}],[{key:"getAnnotations",value:function getAnnotations(){return Ic;}},{key:"getUVCoords",value:function getUVCoords(){return Uc;}}]);return Gc;}();function Kc(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0;}catch(t){return !1;}}();return function(){var n,r=we()(t);if(e){var i=we()(this).constructor;n=Reflect.construct(r,arguments,i);}else n=r.apply(this,arguments);return be()(this,n);};}var Xc=function(t){ve()(n,t);var e=Kc(n);function n(t,r,i){var o;return b()(this,n),(o=e.call(this)).video=t,o.model=null,o.modelReady=!1,o.config=r,o.ready=C(o.loadModel(),i),o;}return w()(n,[{key:"loadModel",value:function(){var t=v()(E.a.mark(function t(){var e=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,$c(this.config);case 2:if(this.model=t.sent,this.modelReady=!0,!this.video||0!==this.video.readyState){t.next=7;break;}return t.next=7,new Promise(function(t){e.video.onloadeddata=function(){t();};});case 7:return this.video&&this.predict(),t.abrupt("return",this);case 9:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"predict",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i,o,a,s=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(r=this.getInput(e)){t.next=3;break;}throw new Error("No input image found.");case 3:return i=this.config.flipHorizontal,t.next=6,this.model.estimateFaces(r,i);case 6:if(o=t.sent,a=o,this.emit("predict",a),this.emit("face",a),!this.video){t.next=12;break;}return t.abrupt("return",p.nextFrame().then(function(){return s.predict();}));case 12:return "function"==typeof n&&n(a),t.abrupt("return",a);case 14:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"getInput",value:function value(t){return t instanceof HTMLImageElement||t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof ImageData?t:"object"===S()(t)&&(t.elt instanceof HTMLImageElement||t.elt instanceof HTMLVideoElement||t.elt instanceof ImageData)?t.elt:"object"===S()(t)&&t.canvas instanceof HTMLCanvasElement?t.canvas:this.video;}}]),n;}(qe.EventEmitter),Yc=function Yc(t,e,n){var r,i={},o=n;t instanceof HTMLVideoElement?r=t:"object"===S()(t)&&t.elt instanceof HTMLVideoElement?r=t.elt:"object"===S()(t)?i=t:"function"==typeof t&&(o=t),"object"===S()(e)?i=e:"function"==typeof e&&(o=e);var a=new Xc(r,i,o);return o?a:a.ready;};/**
    * @license
    * Copyright 2020 Google LLC. All Rights Reserved.
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    * http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    * =============================================================================
    */function Jc(t){return [Math.abs(t.endPoint[0]-t.startPoint[0]),Math.abs(t.endPoint[1]-t.startPoint[1])];}function Qc(t){return [t.startPoint[0]+(t.endPoint[0]-t.startPoint[0])/2,t.startPoint[1]+(t.endPoint[1]-t.startPoint[1])/2];}function Zc(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1.5;var n=Qc(t),r=Jc(t),i=[e*r[0]/2,e*r[1]/2];return {startPoint:[n[0]-i[0],n[1]-i[1]],endPoint:[n[0]+i[0],n[1]+i[1]],palmLandmarks:t.palmLandmarks};}function tl(t){var e=Qc(t),n=Jc(t),r=Math.max.apply(Math,_toConsumableArray(n))/2;return {startPoint:[e[0]-r,e[1]-r],endPoint:[e[0]+r,e[1]+r],palmLandmarks:t.palmLandmarks};}function el(t,e){var n=[t.endPoint[0]-t.startPoint[0],t.endPoint[1]-t.startPoint[1]],r=[n[0]*e[0],n[1]*e[1]];return {startPoint:[t.startPoint[0]+r[0],t.startPoint[1]+r[1]],endPoint:[t.endPoint[0]+r[0],t.endPoint[1]+r[1]],palmLandmarks:t.palmLandmarks};}var nl=/*#__PURE__*/function(){function nl(t,e,n,r,i,o){_classCallCheck(this,nl);this.model=t,this.width=e,this.height=n,this.iouThreshold=i,this.scoreThreshold=o,this.anchors=r.map(function(t){return [t.x_center,t.y_center];}),this.anchorsTensor=Object(N.tensor2d)(this.anchors),this.inputSizeTensor=Object(N.tensor1d)([e,n]),this.doubleInputSizeTensor=Object(N.tensor1d)([2*e,2*n]);}_createClass(nl,[{key:"normalizeBoxes",value:function normalizeBoxes(t){var _this77=this;return Object(N.tidy)(function(){var e=Object(N.slice)(t,[0,0],[-1,2]),n=Object(N.slice)(t,[0,2],[-1,2]),r=Object(N.add)(Object(N.div)(e,_this77.inputSizeTensor),_this77.anchorsTensor),i=Object(N.div)(n,_this77.doubleInputSizeTensor),o=Object(N.mul)(Object(N.sub)(r,i),_this77.inputSizeTensor),a=Object(N.mul)(Object(N.add)(r,i),_this77.inputSizeTensor);return Object(N.concat2d)([o,a],1);});}},{key:"normalizeLandmarks",value:function normalizeLandmarks(t,e){var _this78=this;return Object(N.tidy)(function(){var n=Object(N.add)(Object(N.div)(t.reshape([-1,7,2]),_this78.inputSizeTensor),_this78.anchors[e]);return Object(N.mul)(n,_this78.inputSizeTensor);});}},{key:"getBoundingBoxes",value:function getBoundingBoxes(t){var _this79=this;return Object(N.tidy)(function(){var e=Object(N.mul)(Object(N.sub)(t,.5),2),n=Object(N.env)().get("WEBGL_PACK_DEPTHWISECONV");Object(N.env)().set("WEBGL_PACK_DEPTHWISECONV",!0);var r=_this79.model.predict(e).squeeze();Object(N.env)().set("WEBGL_PACK_DEPTHWISECONV",n);var i=Object(N.sigmoid)(Object(N.slice)(r,[0,0],[-1,1])).squeeze(),o=Object(N.slice)(r,[0,1],[-1,4]),a=_this79.normalizeBoxes(o),s=console.warn;console.warn=function(){};var u=N.image.nonMaxSuppression(a,i,1,_this79.iouThreshold,_this79.scoreThreshold).arraySync();if(console.warn=s,0===u.length)return null;var c=u[0],l=Object(N.slice)(a,[c,0],[1,-1]),f=Object(N.slice)(r,[c,5],[1,14]);return {boxes:l,palmLandmarks:_this79.normalizeLandmarks(f,c).reshape([-1,2])};});}},{key:"estimateHandBounds",value:function estimateHandBounds(t){var _this80=this;var e=t.shape[1],n=t.shape[2],r=Object(N.tidy)(function(){return t.resizeBilinear([_this80.width,_this80.height]).div(255);}),i=this.getBoundingBoxes(r);if(null===i)return r.dispose(),null;var o=i.boxes.arraySync(),a=o[0].slice(0,2),s=o[0].slice(2,4),u=i.palmLandmarks.arraySync();return r.dispose(),i.boxes.dispose(),i.palmLandmarks.dispose(),function(t,e){return {startPoint:[t.startPoint[0]*e[0],t.startPoint[1]*e[1]],endPoint:[t.endPoint[0]*e[0],t.endPoint[1]*e[1]],palmLandmarks:t.palmLandmarks.map(function(t){return [t[0]*e[0],t[1]*e[1]];})};}({startPoint:a,endPoint:s,palmLandmarks:u},[n/this.width,e/this.height]);}}]);return nl;}();var rl={thumb:[1,2,3,4],indexFinger:[5,6,7,8],middleFinger:[9,10,11,12],ringFinger:[13,14,15,16],pinky:[17,18,19,20],palmBase:[0]};function il(t,e){return function(t){return t-2*Math.PI*Math.floor((t+Math.PI)/(2*Math.PI));}(Math.PI/2-Math.atan2(-(e[1]-t[1]),e[0]-t[0]));}var ol=function ol(t,e){return [[1,0,t],[0,1,e],[0,0,1]];};function al(t,e){var n=0;for(var _r224=0;_r224<t.length;_r224++){n+=t[_r224]*e[_r224];}return n;}function sl(t,e){var n=[];for(var _r225=0;_r225<t.length;_r225++){n.push(t[_r225][e]);}return n;}function ul(t,e){var n=[],r=t.length;for(var _i193=0;_i193<r;_i193++){n.push([]);for(var o=0;o<r;o++){n[_i193].push(al(t[_i193],sl(e,o)));}}return n;}function cl(t,e){var n=Math.cos(t),r=Math.sin(t),i=[[n,-r,0],[r,n,0],[0,0,1]];return ul(ul(ol(e[0],e[1]),i),ol(-e[0],-e[1]));}function ll(t,e){return [al(t,e[0]),al(t,e[1])];}var fl=.8,hl=[0,-.4],dl=3,pl=[0,-.1],ml=1.65,gl=[0,5,9,13,17,1,2],vl=0,yl=2;var bl=/*#__PURE__*/function(){function bl(t,e,n,r,i,o){_classCallCheck(this,bl);this.regionsOfInterest=[],this.runsWithoutHandDetector=0,this.boundingBoxDetector=t,this.meshDetector=e,this.maxContinuousChecks=i,this.detectionConfidence=o,this.meshWidth=n,this.meshHeight=r,this.maxHandsNumber=1;}_createClass(bl,[{key:"getBoxForPalmLandmarks",value:function getBoxForPalmLandmarks(t,e){var n=t.map(function(t){return ll([].concat(_toConsumableArray(t),[1]),e);});return Zc(tl(el(this.calculateLandmarksBoundingBox(n),hl)),dl);}},{key:"getBoxForHandLandmarks",value:function getBoxForHandLandmarks(t){var e=Zc(tl(el(this.calculateLandmarksBoundingBox(t),pl)),ml),n=[];for(var _e309=0;_e309<gl.length;_e309++){n.push(t[gl[_e309]].slice(0,2));}return e.palmLandmarks=n,e;}},{key:"transformRawCoords",value:function transformRawCoords(t,e,n,r){var _this81=this;var i=Jc(e),o=[i[0]/this.meshWidth,i[1]/this.meshHeight],a=t.map(function(t){return [o[0]*(t[0]-_this81.meshWidth/2),o[1]*(t[1]-_this81.meshHeight/2),t[2]];}),s=cl(n,[0,0]),u=a.map(function(t){return [].concat(_toConsumableArray(ll(t,s)),[t[2]]);}),c=function(t){var e=[[t[0][0],t[1][0]],[t[0][1],t[1][1]]],n=[t[0][2],t[1][2]],r=[-al(e[0],n),-al(e[1],n)];return [e[0].concat(r[0]),e[1].concat(r[1]),[0,0,1]];}(r),l=[].concat(_toConsumableArray(Qc(e)),[1]),f=[al(l,c[0]),al(l,c[1])];return u.map(function(t){return [t[0]+f[0],t[1]+f[1],t[2]];});}},{key:"estimateHand",value:function(){var _estimateHand=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee44(t){var e,_e310,n,r,i,o,a,s,u,c,l,f,h,_this$meshDetector$pr,_this$meshDetector$pr2,d,p,m,g,v,y,b;return regeneratorRuntime.wrap(function _callee44$(_context49){while(1){switch(_context49.prev=_context49.next){case 0:e=this.shouldUpdateRegionsOfInterest();if(!(!0===e)){_context49.next=8;break;}_e310=this.boundingBoxDetector.estimateHandBounds(t);if(!(null===_e310)){_context49.next=5;break;}return _context49.abrupt("return",(t.dispose(),this.regionsOfInterest=[],null));case 5:this.updateRegionsOfInterest(_e310,!0),this.runsWithoutHandDetector=0;_context49.next=9;break;case 8:this.runsWithoutHandDetector++;case 9:n=this.regionsOfInterest[0],r=il(n.palmLandmarks[vl],n.palmLandmarks[yl]),i=Qc(n),o=[i[0]/t.shape[2],i[1]/t.shape[1]];s=Object(N.getBackend)();if(!("webgl"===s)){_context49.next=15;break;}a=function(t,e,n,r){var i=t.shape,o=i[1],a=i[2],s=Math.sin(e),u=Math.cos(e),c=Math.floor(a*("number"==typeof r?r:r[0])),l=Math.floor(o*("number"==typeof r?r:r[1]));var h={variableNames:["Image"],outputShape:i,userCode:"\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int x = coords[2];\n        int y = coords[1];\n        int coordX = int(float(x - ".concat(c,") * ").concat(u," -\n          float(y - ").concat(l,") * ").concat(s,");\n        int coordY = int(float(x - ").concat(c,") * ").concat(s," +\n          float(y - ").concat(l,") * ").concat(u,");\n        coordX = int(coordX + ").concat(c,");\n        coordY = int(coordY + ").concat(l,");\n\n        ").concat("number"==typeof n?"float outputValue = ".concat(n.toFixed(2),";"):"\n      vec3 fill = vec3(".concat(n.join(","),");\n      float outputValue = fill[coords[3]];"),"\n\n        if(coordX > 0 && coordX < ").concat(a," && coordY > 0 && coordY < ").concat(o,") {\n          outputValue = getImage(coords[0], coordY, coordX, coords[3]);\n        }\n\n      setOutput(outputValue);\n    }")};return Object(N.backend)().compileAndRun(h,[t]);}(t,r,0,o);_context49.next=18;break;case 15:if(!("cpu"!==s)){_context49.next=17;break;}throw new Error("Handpose is not yet supported by the ".concat(s," ")+"backend - rotation kernel is not defined.");case 17:a=function(t,e,n,r){var i=Object(N.backend)(),o=Object(N.buffer)(t.shape,t.dtype),_t$shape=_slicedToArray(t.shape,4),a=_t$shape[0],s=_t$shape[1],u=_t$shape[2],c=_t$shape[3],l=u*("number"==typeof r?r:r[0]),f=s*("number"==typeof r?r:r[1]),h=Math.sin(-e),d=Math.cos(-e),p=i.readSync(t.dataId);for(var _t312=0;_t312<a;_t312++){for(var _e311=0;_e311<s;_e311++){for(var _r226=0;_r226<u;_r226++){for(var _i194=0;_i194<c;_i194++){var _m7=[a,_e311,_r226,_i194],_g7=_m7[2],_v6=_m7[1];var _y6=(_g7-l)*d-(_v6-f)*h,_b4=(_g7-l)*h+(_v6-f)*d;_y6=Math.round(_y6+l),_b4=Math.round(_b4+f);var _x50=n;"number"!=typeof n&&(_x50=3===_i194?255:n[_i194]),_y6>=0&&_y6<u&&_b4>=0&&_b4<s&&(_x50=p[_t312*u*s*c+_b4*(u*c)+_y6*c+_i194]);var _w5=_t312*u*s*c+_e311*(u*c)+_r226*c+_i194;o.values[_w5]=_x50;}}}}return o.toTensor();}(t,r,0,o);case 18:u=cl(-r,i);l=function(t,e,n){var r=e.shape[1],i=e.shape[2],o=[[t.startPoint[1]/r,t.startPoint[0]/i,t.endPoint[1]/r,t.endPoint[0]/i]];return N.image.cropAndResize(e,o,[0],n);}(c=!0===e?this.getBoxForPalmLandmarks(n.palmLandmarks,u):n,a,[this.meshWidth,this.meshHeight]),f=l.div(255);l.dispose(),a.dispose();h=Object(N.env)().get("WEBGL_PACK_DEPTHWISECONV");Object(N.env)().set("WEBGL_PACK_DEPTHWISECONV",!0);_this$meshDetector$pr=this.meshDetector.predict(f),_this$meshDetector$pr2=_slicedToArray(_this$meshDetector$pr,2),d=_this$meshDetector$pr2[0],p=_this$meshDetector$pr2[1];Object(N.env)().set("WEBGL_PACK_DEPTHWISECONV",h),f.dispose();m=d.dataSync()[0];if(!(d.dispose(),m<this.detectionConfidence)){_context49.next=28;break;}return _context49.abrupt("return",(p.dispose(),this.regionsOfInterest=[],null));case 28:g=Object(N.reshape)(p,[-1,3]),v=g.arraySync();p.dispose(),g.dispose();y=this.transformRawCoords(v,c,r,u),b=this.getBoxForHandLandmarks(y);return _context49.abrupt("return",(this.updateRegionsOfInterest(b,!1),{landmarks:y,handInViewConfidence:m,boundingBox:{topLeft:b.startPoint,bottomRight:b.endPoint}}));case 32:case"end":return _context49.stop();}}},_callee44,this);}));function estimateHand(_x49){return _estimateHand.apply(this,arguments);}return estimateHand;}()},{key:"calculateLandmarksBoundingBox",value:function calculateLandmarksBoundingBox(t){var e=t.map(function(t){return t[0];}),n=t.map(function(t){return t[1];});return {startPoint:[Math.min.apply(Math,_toConsumableArray(e)),Math.min.apply(Math,_toConsumableArray(n))],endPoint:[Math.max.apply(Math,_toConsumableArray(e)),Math.max.apply(Math,_toConsumableArray(n))]};}},{key:"updateRegionsOfInterest",value:function updateRegionsOfInterest(t,e){if(e)this.regionsOfInterest=[t];else {var _e312=this.regionsOfInterest[0];var _n243=0;if(null!=_e312&&null!=_e312.startPoint){var _t$startPoint=_slicedToArray(t.startPoint,2),_r227=_t$startPoint[0],_i195=_t$startPoint[1],_t$endPoint=_slicedToArray(t.endPoint,2),o=_t$endPoint[0],a=_t$endPoint[1],_e312$startPoint=_slicedToArray(_e312.startPoint,2),_s73=_e312$startPoint[0],_u43=_e312$startPoint[1],_e312$endPoint=_slicedToArray(_e312.endPoint,2),c=_e312$endPoint[0],_l21=_e312$endPoint[1],_f20=Math.max(_r227,_s73),h=Math.max(_i195,_u43),_d10=(Math.min(o,c)-_f20)*(Math.min(a,_l21)-h);_n243=_d10/((o-_r227)*(a-_i195)+(c-_s73)*(_l21-_i195)-_d10);}this.regionsOfInterest[0]=_n243>fl?_e312:t;}}},{key:"shouldUpdateRegionsOfInterest",value:function shouldUpdateRegionsOfInterest(){return this.regionsOfInterest.length!==this.maxHandsNumber||this.runsWithoutHandDetector>=this.maxContinuousChecks;}}]);return bl;}();var xl=256,wl=256;function kl(){return _kl.apply(this,arguments);}function _kl(){_kl=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee53(){var _ref145,_ref145$maxContinuous,t,_ref145$detectionConf,e,_ref145$iouThreshold,n,_ref145$scoreThreshol,r,_yield$Promise$all5,_yield$Promise$all6,i,o,a,s,u,_args58=arguments;return regeneratorRuntime.wrap(function _callee53$(_context58){while(1){switch(_context58.prev=_context58.next){case 0:_ref145=_args58.length>0&&_args58[0]!==undefined?_args58[0]:{},_ref145$maxContinuous=_ref145.maxContinuousChecks,t=_ref145$maxContinuous===void 0?1/0:_ref145$maxContinuous,_ref145$detectionConf=_ref145.detectionConfidence,e=_ref145$detectionConf===void 0?.8:_ref145$detectionConf,_ref145$iouThreshold=_ref145.iouThreshold,n=_ref145$iouThreshold===void 0?.3:_ref145$iouThreshold,_ref145$scoreThreshol=_ref145.scoreThreshold,r=_ref145$scoreThreshol===void 0?.5:_ref145$scoreThreshol;_context58.next=3;return Promise.all([_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee50(){return regeneratorRuntime.wrap(function _callee50$(_context55){while(1){switch(_context55.prev=_context55.next){case 0:return _context55.abrupt("return",N.util.fetch("https://tfhub.dev/mediapipe/tfjs-model/handskeleton/1/default/1/anchors.json?tfjs-format=file").then(function(t){return t.json();}));case 1:case"end":return _context55.stop();}}},_callee50);}))(),_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee51(){return regeneratorRuntime.wrap(function _callee51$(_context56){while(1){switch(_context56.prev=_context56.next){case 0:return _context56.abrupt("return",Object(T.loadGraphModel)("https://tfhub.dev/mediapipe/tfjs-model/handdetector/1/default/1",{fromTFHub:!0}));case 1:case"end":return _context56.stop();}}},_callee51);}))(),_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee52(){return regeneratorRuntime.wrap(function _callee52$(_context57){while(1){switch(_context57.prev=_context57.next){case 0:return _context57.abrupt("return",Object(T.loadGraphModel)("https://tfhub.dev/mediapipe/tfjs-model/handskeleton/1/default/1",{fromTFHub:!0}));case 1:case"end":return _context57.stop();}}},_callee52);}))()]);case 3:_yield$Promise$all5=_context58.sent;_yield$Promise$all6=_slicedToArray(_yield$Promise$all5,3);i=_yield$Promise$all6[0];o=_yield$Promise$all6[1];a=_yield$Promise$all6[2];s=new nl(o,xl,wl,i,n,r);u=new bl(s,a,xl,wl,t,e);return _context58.abrupt("return",new El(u));case 11:case"end":return _context58.stop();}}},_callee53);}));return _kl.apply(this,arguments);}var El=/*#__PURE__*/function(){function El(t){_classCallCheck(this,El);this.pipeline=t;}_createClass(El,[{key:"estimateHands",value:function(){var _estimateHands=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee45(t){var e,_ref138,_ref139,n,r,i,o,a,_i196,_Object$keys2,_t313,_args50=arguments;return regeneratorRuntime.wrap(function _callee45$(_context50){while(1){switch(_context50.prev=_context50.next){case 0:e=_args50.length>1&&_args50[1]!==undefined?_args50[1]:!1;_ref138=function(t){return t instanceof N.Tensor?[t.shape[0],t.shape[1]]:[t.height,t.width];}(t);_ref139=_slicedToArray(_ref138,2);n=_ref139[1];r=Object(N.tidy)(function(){return t instanceof N.Tensor||(t=N.browser.fromPixels(t)),t.toFloat().expandDims(0);});_context50.next=7;return this.pipeline.estimateHand(r);case 7:i=_context50.sent;if(!(r.dispose(),null===i)){_context50.next=10;break;}return _context50.abrupt("return",[]);case 10:o=i;!0===e&&(o=function(t,e){var n=t.handInViewConfidence,r=t.landmarks,i=t.boundingBox;return {handInViewConfidence:n,landmarks:r.map(function(t){return [e-1-t[0],t[1],t[2]];}),boundingBox:{topLeft:[e-1-i.topLeft[0],i.topLeft[1]],bottomRight:[e-1-i.bottomRight[0],i.bottomRight[1]]}};}(i,n));a={};for(_i196=0,_Object$keys2=Object.keys(rl);_i196<_Object$keys2.length;_i196++){_t313=_Object$keys2[_i196];a[_t313]=rl[_t313].map(function(t){return o.landmarks[t];});}return _context50.abrupt("return",[{handInViewConfidence:o.handInViewConfidence,boundingBox:o.boundingBox,landmarks:o.landmarks,annotations:a}]);case 15:case"end":return _context50.stop();}}},_callee45,this);}));function estimateHands(_x51){return _estimateHands.apply(this,arguments);}return estimateHands;}()}],[{key:"getAnnotations",value:function getAnnotations(){return rl;}}]);return El;}();function Cl(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0;}catch(t){return !1;}}();return function(){var n,r=we()(t);if(e){var i=we()(this).constructor;n=Reflect.construct(r,arguments,i);}else n=r.apply(this,arguments);return be()(this,n);};}var Al=function(t){ve()(n,t);var e=Cl(n);function n(t,r,i){var o;return b()(this,n),(o=e.call(this)).video=t,o.model=null,o.modelReady=!1,o.config=r,o.ready=C(o.loadModel(),i),o;}return w()(n,[{key:"loadModel",value:function(){var t=v()(E.a.mark(function t(){var e=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return t.next=2,kl(this.config);case 2:if(this.model=t.sent,this.modelReady=!0,!this.video||0!==this.video.readyState){t.next=7;break;}return t.next=7,new Promise(function(t){e.video.onloadeddata=function(){t();};});case 7:return this.video&&this.predict(),t.abrupt("return",this);case 9:case"end":return t.stop();}}},t,this);}));return function(){return t.apply(this,arguments);};}()},{key:"predict",value:function(){var t=v()(E.a.mark(function t(e,n){var r,i,o,a,s=this;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:if(r=this.getInput(e)){t.next=3;break;}throw new Error("No input image found.");case 3:return i=this.config.flipHorizontal,t.next=6,this.model.estimateHands(r,i);case 6:if(o=t.sent,a=o,this.emit("predict",a),this.emit("hand",a),!this.video){t.next=12;break;}return t.abrupt("return",p.nextFrame().then(function(){return s.predict();}));case 12:return "function"==typeof n&&n(a),t.abrupt("return",a);case 14:case"end":return t.stop();}}},t,this);}));return function(e,n){return t.apply(this,arguments);};}()},{key:"getInput",value:function value(t){return t instanceof HTMLImageElement||t instanceof HTMLVideoElement||t instanceof HTMLCanvasElement||t instanceof ImageData?t:"object"===S()(t)&&(t.elt instanceof HTMLImageElement||t.elt instanceof HTMLVideoElement||t.elt instanceof ImageData)?t.elt:"object"===S()(t)&&t.canvas instanceof HTMLCanvasElement?t.canvas:this.video;}}]),n;}(qe.EventEmitter),Ol=function Ol(t,e,n){var r,i={},o=n;t instanceof HTMLVideoElement?r=t:"object"===S()(t)&&t.elt instanceof HTMLVideoElement?r=t.elt:"object"===S()(t)?i=t:"function"==typeof t&&(o=t),"object"===S()(e)?i=e:"function"==typeof e&&(o=e);var a=new Al(r,i,o);return o?a:a.ready;},_l=function _l(){console.log("\n🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈\n🌟 Thank you for using ml5.js v".concat(_r.a," 🌟\n\nPlease read our community statement to ensure \nthat the use of this software reflects the values \nof the ml5.js community:\n↳ https://ml5js.org/about\n\nReporting: \n↳ https://github.com/ml5js/ml5-library/issues\n↳ Email: info@ml5js.org \n🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈🌈"));},Sl=function(){var t=v()(E.a.mark(function t(){var e;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:return (e=new Image()).crossOrigin="",e.src="https://cdn.jsdelivr.net/gh/ml5js/ml5-library@main/assets/bird.jpg",t.next=5,new Promise(function(t){e.onload=t;});case 5:return t.abrupt("return",e);case 6:case"end":return t.stop();}}},t);}));return function(){return t.apply(this,arguments);};}(),Dl=function(){var t=v()(E.a.mark(function t(){var e,n,r;return E.a.wrap(function(t){for(;;){switch(t.prev=t.next){case 0:for(e=new Uint8ClampedArray(2e4),n=0;n<e.length;n+=4){e[n+0]=0,e[n+1]=190,e[n+2]=0,e[n+3]=255;}return r=new ImageData(e,200),t.abrupt("return",r);case 4:case"end":return t.stop();}}},t);}));return function(){return t.apply(this,arguments);};}();function Fl(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable;})),n.push.apply(n,r);}return n;}function Tl(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Fl(Object(n),!0).forEach(function(e){d()(t,e,n[e]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Fl(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e));});}return t;}var Nl={charRNN:cr,CVAE:kr,cartoon:sc,DCGAN:Cr,featureExtractor:pe,imageClassifier:pt,kmeans:Ju,dbscan:ic,soundClassifier:Qt,pitchDetection:O,pix2pix:hr,poseNet:Jn,sketchRNN:vr,styleTransfer:rr,word2vec:me,YOLO:je,CocoSsd:ze,objectDetector:Ve,uNet:xr,sentiment:Fr,bodyPix:ti,faceApi:qu,universalSentenceEncoder:Ec,facemesh:Yc,handpose:Ol};_l();e.default=Object.assign({p5Utils:rt},function(t){if("undefined"==typeof window)return t;if(void 0===window.p5)return t;if(void 0===window.p5.prototype)return t;if(void 0===window.p5.prototype.registerPreloadMethod)return t;var e=t;return Object.keys(t).forEach(function(n){var r=t[n];e[n]=function(){for(var e=null,n=arguments.length,i=new Array(n),o=0;o<n;o++){i[o]=arguments[o];}var a=i.length;return "function"==typeof i[a-1]&&(e=i[a-1],a-=1),r.apply(t,[].concat(Or()(i.slice(0,a)),[function(){try{e&&e();}catch(t){console.error(t);}return window._decrementPreload?window._decrementPreload():null;}]));},window.p5.prototype.registerPreloadMethod("".concat(n),t);}),t;}(Nl),Tl(Tl({KNNClassifier:oe,communityStatement:_l},a),{},{tf:p,tfvis:m,version:_r.a,neuralNetwork:vi,testingUtils:f}));},function(t,e){},function(t,e){},function(t,e){},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");},t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e){t.exports=function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t);},t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e,n){var r=n(186);t.exports=function(t){if(Array.isArray(t))return r(t);},t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e,n){function r(t){return new Uint8Array(atob(t).split("").map(function(t){return t.charCodeAt(0);}));}Object.defineProperty(e,"__esModule",{value:!0}),e.stringToUint8array=r,e.stringToArray=function(t){var e=r(t);return new Int16Array(e.buffer);};var i=!1,o=0;function a(){if(i)return i=!1,o;var t=2*Math.random()-1,e=2*Math.random()-1,n=t*t+e*e;if(0===n||n>1)return a();var r=Math.sqrt(-2*Math.log(n)/n);return o=e*r,i=!0,t*r;}function s(t,e){return Math.random()*(e-t)+t;}function u(t,e){return t+a()*e;}function c(t,e){void 0===e&&(e=2);var n=e;function r(t,e){return [t[0]-e[0],t[1]-e[1]];}function i(t,e){return t[0]*e[0]+t[1]*e[1];}function o(t){return t[0]*t[0]+t[1]*t[1];}function a(t,e){return o(r(t,e));}var s,u,c,l,f=t.length,h=[],d=n*n,p=[],m=[];for(p[0]=t[0],s=u=1,l=0;s<f;s++){a(t[s],t[l])<d||(p[u++]=t[s],l=s);}for(l<f-1&&(p[u++]=t[f-1]),m[0]=m[u-1]=1,function t(e,n,s,u,c){if(!(u<=s+1)){for(var l,f,h,d,p=s,m=0,g=e*e,v=[n[s],n[u]],y=r(v[1],v[0]),b=o(y),x=s+1;x<u;x++){(h=i(r(n[x],v[0]),y))<=0?d=a(n[x],v[0]):b<=h?d=a(n[x],v[1]):(f=h/b,l=[v[0][0]+f*y[0],v[0][1]+f*y[1]],d=a(n[x],l)),d<=m||(p=x,m=d);}m>g&&(c[p]=1,t(e,n,s,p,c),t(e,n,p,u,c));}}(n,p,0,u-1,m),s=c=0;s<u;s++){m[s]&&(h[c++]=p[s]);}return h;}e.gaussRandom=a,e.randf=s,e.randi=function(t,e){return Math.floor(Math.random()*(e-t)+t);},e.randn=u,e.birandn=function(t,e,n,r,i){var o=u(0,1),a=u(0,1);return [Math.sqrt(1-i*i)*n*o+i*n*a+t,r*a+e];},e.sampleSoftmax=function(t){var e,n=s(0,1),r=t.length,i=0;for(e=0;e<r;e++){if((i+=t[e])>=n)return e;}return console.log("error sampling pi index"),-1;},e.simplifyLine=c,e.simplifyLines=function(t,e){var n=[],r=2;e&&(r=e);for(var i=0;i<t.length;i++){n.push(c(t[i],r));}return n;},e.linesToStrokes=function(t){var e,n,r,i,o,a,s,u,c,l,f=0,h=0,d=[];for(s=0;s<t.length;s++){if((c=t[s].length)>1)for(u=0;u<c;u++){e=(l=t[s][u])[0],n=l[1],u===c-1?(a=1,o=0):(a=0,o=1),r=e-f,i=n-h,f=e,h=n,d.push([r,i,o,a,0]);}}return d.push([0,0,0,0,1]),d.slice(1);},e.lineToStroke=function(t,e){var n,r,i,o,a,s,u,c,l,f,h,d=[];if(l=e[0],f=e[1],(i=t.length)>1)for(h=0;h<i;h++){u=(o=t[h])[0],c=o[1],h===i-1?(r=1,n=0):(r=0,n=1),a=u-l,s=c-f,l=u,f=c,d.push([a,s,n,r,0]);}return d;};},function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});},i=this&&this.__generator||function(t,e){var n,r,i,o,a={label:0,sent:function sent(){if(1&i[0])throw i[1];return i[1];},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this;}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;){try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue;}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break;}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break;}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break;}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(t,a);}catch(t){o=[6,t],r=0;}finally{n=i=0;}}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:!0};}([o,s]);};}};Object.defineProperty(e,"__esModule",{value:!0});var o=n(0),a=n(255),s=function(){function t(t){this.NMIXTURE=20,this.checkpointURL=t,this.initialized=!1;}return t.prototype.isInitialized=function(){return this.initialized;},t.prototype.instantiateFromJSON=function(t,e,n){var r;this.forgetBias=o.scalar(1),this.info=t,this.setPixelFactor(2),this.weightDims=e,this.numUnits=this.weightDims[0][0];this.weights=[];for(var i=0;i<n.length;i++){for(var s=(r=new Float32Array(a.stringToArray(n[i]))).length,u=0;u<s;u++){r[u]=10*r[u]/32767;}this.weights.push(r);}this.outputKernel=o.tensor2d(this.weights[0],[this.weightDims[0][0],this.weightDims[0][1]]),this.outputBias=o.tensor1d(this.weights[1]);var c=o.tensor2d(this.weights[2],[this.weightDims[2][0],this.weightDims[2][1]]),l=o.tensor2d(this.weights[3],[this.weightDims[3][0],this.weightDims[3][1]]);this.lstmKernel=o.concat2d([c,l],0),this.lstmBias=o.tensor1d(this.weights[4]),this.rawVars=[this.outputKernel,this.outputBias,this.lstmKernel,this.lstmBias];},t.prototype.initialize=function(){return r(this,void 0,void 0,function(){var t;return i(this,function(e){switch(e.label){case 0:return this.dispose(),[4,fetch(this.checkpointURL).then(function(t){return t.json();})];case 1:return t=e.sent(),this.instantiateFromJSON(t[0],t[1],t[2]),this.initialized=!0,console.log("Initialized SketchRNN."),[2];}});});},t.prototype.dispose=function(){if(this.rawVars){for(var t=0;t<this.rawVars.length;t++){this.rawVars[t].dispose();}this.rawVars=void 0;}this.forgetBias&&(this.forgetBias.dispose(),this.forgetBias=void 0),this.initialized=!1;},t.prototype.setPixelFactor=function(t){this.pixelFactor=t,this.scaleFactor=this.info.scale_factor/this.pixelFactor;},t.prototype.update=function(t,e){var n=this,r=o.tidy(function(){var r=n.numUnits,i=n.scaleFactor,a=[t[0]/i,t[1]/i,t[2],t[3],t[4]],s=o.tensor2d(a,[1,5]),u=o.tensor2d(e.c,[1,r]),c=o.tensor2d(e.h,[1,r]),l=o.basicLSTMCell(n.forgetBias,n.lstmKernel,n.lstmBias,s,u,c);return o.concat(l,1);}),i=r.dataSync();r.dispose();var a=i.slice(0,this.numUnits),s=i.slice(this.numUnits,2*this.numUnits);return {c:new Float32Array(a),h:new Float32Array(s)};},t.prototype.updateStrokes=function(t,e,n){var r=this,i=o.tidy(function(){var i,a,s,u,c,l=r.numUnits,f=r.scaleFactor,h=t.length;n&&(h=n),s=o.tensor2d(e.c,[1,l]),u=o.tensor2d(e.h,[1,l]);for(var d=0;d<h;d++){i=[t[d][0]/f,t[d][1]/f,t[d][2],t[d][3],t[d][4]],a=o.tensor2d(i,[1,5]),s=(c=o.basicLSTMCell(r.forgetBias,r.lstmKernel,r.lstmBias,a,s,u))[0],u=c[1];}return o.concat(c,1);}),a=i.dataSync();i.dispose();var s=a.slice(0,this.numUnits),u=a.slice(this.numUnits,2*this.numUnits);return {c:new Float32Array(s),h:new Float32Array(u)};},t.prototype.getPDF=function(t,e,n){var r=this;void 0===e&&(e=.65);var i=e,a=.5+.5*i;n&&(a=n);var s=this.NMIXTURE,u=o.tidy(function(){var e=r.numUnits,n=o.tensor2d(t.h,[1,e]),u=o.scalar(Math.sqrt(i)),c=o.scalar(a),l=o.add(o.matMul(n,r.outputKernel),r.outputBias).squeeze(),f=o.split(l,[3,6*s]),h=f[0],d=f[1],p=o.split(d,6),m=p[0],g=p[1],v=p[2],y=p[3],b=p[4],x=p[5],w=o.softmax(h.div(c)),k=[o.softmax(m.div(c)),g,v,o.exp(y).mul(u),o.exp(b).mul(u),o.tanh(x),w];return o.concat(k);}),c=u.dataSync();return u.dispose(),{pi:new Float32Array(c.slice(0,s)),muX:new Float32Array(c.slice(1*s,2*s)),muY:new Float32Array(c.slice(2*s,3*s)),sigmaX:new Float32Array(c.slice(3*s,4*s)),sigmaY:new Float32Array(c.slice(4*s,15*s)),corr:new Float32Array(c.slice(5*s,6*s)),pen:new Float32Array(c.slice(6*s,6*s+3))};},t.prototype.zeroState=function(){return {c:new Float32Array(this.numUnits),h:new Float32Array(this.numUnits)};},t.prototype.copyState=function(t){return {c:new Float32Array(t.c),h:new Float32Array(t.h)};},t.prototype.zeroInput=function(){return [0,0,1,0,0];},t.prototype.sample=function(t){var e=a.sampleSoftmax(t.pi),n=t.muX[e],r=t.muY[e],i=t.sigmaX[e],o=t.sigmaY[e],s=t.corr[e],u=[0,0,0];u[a.sampleSoftmax(t.pen)]=1;var c=a.birandn(n,r,i,o,s);return [c[0]*this.scaleFactor,c[1]*this.scaleFactor,u[0],u[1],u[2]];},t.prototype.simplifyLine=function(t,e){return a.simplifyLine(t,e);},t.prototype.simplifyLines=function(t,e){return a.simplifyLines(t,e);},t.prototype.linesToStroke=function(t){return a.linesToStrokes(t);},t.prototype.lineToStroke=function(t,e){return a.lineToStroke(t,e);},t;}();e.SketchRNN=s;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0});var r=n(256);e.SketchRNN=r.SketchRNN;},function(t,e){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t;},t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e){function n(e,r){return t.exports=n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t;},t.exports.__esModule=!0,t.exports.default=t.exports,n(e,r);}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");},t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e){t.exports=function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o=[],a=!0,s=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(o.push(r.value),!e||o.length!==e);a=!0){;}}catch(t){s=!0,i=t;}finally{try{a||null==n.return||n.return();}finally{if(s)throw i;}}return o;}},t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e){t.exports=function(t){if(Array.isArray(t))return t;},t.exports.__esModule=!0,t.exports.default=t.exports;},function(t,e,n){t.exports=function(t){return "object"==_typeof$1(t)&&!0===t.isAxiosError;};},function(t,e,n){t.exports=function(t){return function(e){return t.apply(null,e);};};},function(t,e,n){var r=n(188);function i(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(t){e=t;});var n=this;t(function(t){n.reason||(n.reason=new r(t),e(n.reason));});}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason;},i.source=function(){var t;return {token:new i(function(e){t=e;}),cancel:t};},t.exports=i;},function(t){t.exports={name:"axios",version:"0.21.4",description:"Promise based HTTP client for the browser and node.js",main:"index.js",scripts:{test:"grunt test",start:"node ./sandbox/server.js",build:"NODE_ENV=production grunt build",preversion:"npm test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",postversion:"git push && git push --tags",examples:"node ./examples/server.js",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",fix:"eslint --fix lib/**/*.js"},repository:{type:"git",url:"https://github.com/axios/axios.git"},keywords:["xhr","http","ajax","promise","node"],author:"Matt Zabriskie",license:"MIT",bugs:{url:"https://github.com/axios/axios/issues"},homepage:"https://axios-http.com",devDependencies:{coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},browser:{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},jsdelivr:"dist/axios.min.js",unpkg:"dist/axios.min.js",typings:"./index.d.ts",dependencies:{"follow-redirects":"^1.14.0"},bundlesize:[{path:"./dist/axios.min.js",threshold:"5kB"}],_resolved:"https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",_integrity:"sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",_from:"axios@0.21.4"};},function(t,e,n){var r=n(266),i={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){i[t]=function(n){return _typeof$1(n)===t||"a"+(e<1?"n ":" ")+t;};});var o={},a=r.version.split(".");function s(t,e){for(var n=e?e.split("."):a,r=t.split("."),i=0;i<3;i++){if(n[i]>r[i])return !0;if(n[i]<r[i])return !1;}return !1;}i.transitional=function(t,e,n){var i=e&&s(e);function a(t,e){return "[Axios v"+r.version+"] Transitional option '"+t+"'"+e+(n?". "+n:"");}return function(n,r,s){if(!1===t)throw new Error(a(r," has been removed in "+e));return i&&!o[r]&&(o[r]=!0,console.warn(a(r," has been deprecated since v"+e+" and will be removed in the near future"))),!t||t(n,r,s);};},t.exports={isOlderVersion:s,assertOptions:function assertOptions(t,e,n){if("object"!=_typeof$1(t))throw new TypeError("options must be an object");for(var r=Object.keys(t),i=r.length;i-->0;){var o=r[i],a=e[o];if(a){var s=t[o],u=void 0===s||a(s,o,t);if(!0!==u)throw new TypeError("option "+o+" must be "+u);}else if(!0!==n)throw Error("Unknown option "+o);}},validators:i};},function(t,e,n){var r=n(36);t.exports=r.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function i(t){var r=t;return e&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname};}return t=i(window.location.href),function(e){var n=r.isString(e)?i(e):e;return n.protocol===t.protocol&&n.host===t.host;};}():function(){return !0;};},function(t,e,n){var r=n(36),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];t.exports=function(t){var e,n,o,a={};return t?(r.forEach(t.split("\n"),function(t){if(o=t.indexOf(":"),e=r.trim(t.substr(0,o)).toLowerCase(),n=r.trim(t.substr(o+1)),e){if(a[e]&&i.indexOf(e)>=0)return;a[e]="set-cookie"===e?(a[e]?a[e]:[]).concat([n]):a[e]?a[e]+", "+n:n;}}),a):a;};},function(t,e,n){t.exports=function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t;};},function(t,e,n){t.exports=function(t){return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t);};},function(t,e,n){var r=n(271),i=n(270);t.exports=function(t,e){return t&&!r(e)?i(t,e):e;};},function(t,e,n){var r=n(36);t.exports=r.isStandardBrowserEnv()?{write:function write(t,e,n,i,o,a){var s=[];s.push(t+"="+encodeURIComponent(e)),r.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),r.isString(i)&&s.push("path="+i),r.isString(o)&&s.push("domain="+o),!0===a&&s.push("secure"),document.cookie=s.join("; ");},read:function read(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null;},remove:function remove(t){this.write(t,"",Date.now()-864e5);}}:{write:function write(){},read:function read(){return null;},remove:function remove(){}};},function(t,e,n){var r=n(191);t.exports=function(t,e,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?e(r("Request failed with status code "+n.status,n.config,null,n.request,n)):t(n);};},function(t,e,n){var r=n(36);t.exports=function(t,e){r.forEach(t,function(n,r){r!==e&&r.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[r]);});};},function(t,e,n){var r=n(36),i=n(136);t.exports=function(t,e,n){var o=this||i;return r.forEach(n,function(n){t=n.call(o,t,e);}),t;};},function(t,e,n){var r=n(36),i=n(276),o=n(190),a=n(136);function s(t){t.cancelToken&&t.cancelToken.throwIfRequested();}t.exports=function(t){return s(t),t.headers=t.headers||{},t.data=i.call(t,t.data,t.headers,t.transformRequest),t.headers=r.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),r.forEach(["delete","get","head","post","put","patch","common"],function(e){delete t.headers[e];}),(t.adapter||a.adapter)(t).then(function(e){return s(t),e.data=i.call(t,e.data,e.headers,t.transformResponse),e;},function(e){return o(e)||(s(t),e&&e.response&&(e.response.data=i.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e);});};},function(t,e,n){var r=n(36);function i(){this.handlers=[];}i.prototype.use=function(t,e,n){return this.handlers.push({fulfilled:t,rejected:e,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1;},i.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null);},i.prototype.forEach=function(t){r.forEach(this.handlers,function(e){null!==e&&t(e);});},t.exports=i;},function(t,e,n){var r=n(36),i=n(194),o=n(278),a=n(277),s=n(189),u=n(267),c=u.validators;function l(t){this.defaults=t,this.interceptors={request:new o(),response:new o()};}l.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=s(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=t.transitional;void 0!==e&&u.assertOptions(e,{silentJSONParsing:c.transitional(c.boolean,"1.0.0"),forcedJSONParsing:c.transitional(c.boolean,"1.0.0"),clarifyTimeoutError:c.transitional(c.boolean,"1.0.0")},!1);var n=[],r=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(r=r&&e.synchronous,n.unshift(e.fulfilled,e.rejected));});var i,o=[];if(this.interceptors.response.forEach(function(t){o.push(t.fulfilled,t.rejected);}),!r){var l=[a,void 0];for(Array.prototype.unshift.apply(l,n),l=l.concat(o),i=Promise.resolve(t);l.length;){i=i.then(l.shift(),l.shift());}return i;}for(var f=t;n.length;){var h=n.shift(),d=n.shift();try{f=h(f);}catch(t){d(t);break;}}try{i=a(f);}catch(t){return Promise.reject(t);}for(;o.length;){i=i.then(o.shift(),o.shift());}return i;},l.prototype.getUri=function(t){return t=s(this.defaults,t),i(t.url,t.params,t.paramsSerializer).replace(/^\?/,"");},r.forEach(["delete","get","head","options"],function(t){l.prototype[t]=function(e,n){return this.request(s(n||{},{method:t,url:e,data:(n||{}).data}));};}),r.forEach(["post","put","patch"],function(t){l.prototype[t]=function(e,n,r){return this.request(s(r||{},{method:t,url:e,data:n}));};}),t.exports=l;},function(t,e,n){var r=n(36),i=n(195),o=n(279),a=n(189);function s(t){var e=new o(t),n=i(o.prototype.request,e);return r.extend(n,o.prototype,e),r.extend(n,e),n;}var u=s(n(136));u.Axios=o,u.create=function(t){return s(a(u.defaults,t));},u.Cancel=n(188),u.CancelToken=n(265),u.isCancel=n(190),u.all=function(t){return Promise.all(t);},u.spread=n(264),u.isAxiosError=n(263),t.exports=u,t.exports.default=u;},function(t,e,n){var r=function(t){var e,n=Object.prototype,r=n.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e];}try{u({},"");}catch(t){u=function u(t,e,n){return t[e]=n;};}function c(t,e,n,r){var i=e&&e.prototype instanceof g?e:g,o=Object.create(i.prototype),a=new S(r||[]);return o._invoke=function(t,e,n){var r=f;return function(i,o){if(r===d)throw new Error("Generator is already running");if(r===p){if("throw"===i)throw o;return F();}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var s=A(a,n);if(s){if(s===m)continue;return s;}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===f)throw r=p,n.arg;n.dispatchException(n.arg);}else "return"===n.method&&n.abrupt("return",n.arg);r=d;var u=l(t,e,n);if("normal"===u.type){if(r=n.done?p:h,u.arg===m)continue;return {value:u.arg,done:n.done};}"throw"===u.type&&(r=p,n.method="throw",n.arg=u.arg);}};}(t,n,a),o;}function l(t,e,n){try{return {type:"normal",arg:t.call(e,n)};}catch(t){return {type:"throw",arg:t};}}t.wrap=c;var f="suspendedStart",h="suspendedYield",d="executing",p="completed",m={};function g(){}function v(){}function y(){}var b={};u(b,o,function(){return this;});var x=Object.getPrototypeOf,w=x&&x(x(D([])));w&&w!==n&&r.call(w,o)&&(b=w);var k=y.prototype=g.prototype=Object.create(b);function E(t){["next","throw","return"].forEach(function(e){u(t,e,function(t){return this._invoke(e,t);});});}function C(t,e){var n;this._invoke=function(i,o){function a(){return new e(function(n,a){!function n(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==_typeof$1(f)&&r.call(f,"__await")?e.resolve(f.__await).then(function(t){n("next",t,a,s);},function(t){n("throw",t,a,s);}):e.resolve(f).then(function(t){c.value=t,a(c);},function(t){return n("throw",t,a,s);});}s(u.arg);}(i,o,n,a);});}return n=n?n.then(a,a):a();};}function A(t,n){var r=t.iterator[n.method];if(r===e){if(n.delegate=null,"throw"===n.method){if(t.iterator.return&&(n.method="return",n.arg=e,A(t,n),"throw"===n.method))return m;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method");}return m;}var i=l(r,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,m;var o=i.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,m):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m);}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e);}function _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e;}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0);}function D(t){if(t){var n=t[o];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function n(){for(;++i<t.length;){if(r.call(t,i))return n.value=t[i],n.done=!1,n;}return n.value=e,n.done=!0,n;};return a.next=a;}}return {next:F};}function F(){return {value:e,done:!0};}return v.prototype=y,u(k,"constructor",y),u(y,"constructor",v),v.displayName=u(y,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return !!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name));},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,u(t,s,"GeneratorFunction")),t.prototype=Object.create(k),t;},t.awrap=function(t){return {__await:t};},E(C.prototype),u(C.prototype,a,function(){return this;}),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(c(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then(function(t){return t.done?t.value:a.next();});},E(k),u(k,s,"Generator"),u(k,o,function(){return this;}),u(k,"toString",function(){return "[object Generator]";}),t.keys=function(t){var e=[];for(var n in t){e.push(n);}return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n;}return n.done=!0,n;};},t.values=D,S.prototype={constructor:S,reset:function reset(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(_),!t)for(var n in this){"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e);}},stop:function stop(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval;},dispatchException:function dispatchException(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i;}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc);}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);}else {if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc);}}}},abrupt:function abrupt(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break;}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(a);},complete:function complete(t,e){if("throw"===t.type)throw t.arg;return "break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m;},finish:function finish(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),_(n),m;}},catch:function _catch(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;_(n);}return i;}}throw new Error("illegal catch attempt");},delegateYield:function delegateYield(t,n,r){return this.delegate={iterator:D(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),m;}},t;}(t.exports);try{regeneratorRuntime=r;}catch(t){"object"==(typeof globalThis==="undefined"?"undefined":_typeof$1(globalThis))?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r);}},function(t,e,n){/** @license See the LICENSE file. */Object.defineProperty(e,"__esModule",{value:!0});e.version="1.5.1";},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});};Object.defineProperty(e,"__esModule",{value:!0});var i=n(137),o=n(46),a=n(110);e.valuesDistribution=function(t,e){return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee54(){var n,r,s;return regeneratorRuntime.wrap(function _callee54$(_context59){while(1){switch(_context59.prev=_context59.next){case 0:n=o.getDrawArea(t);_context59.next=3;return a.tensorStats(e);case 3:r=_context59.sent;_context59.next=6;return e.data();case 6:s=_context59.sent;i.histogram(n,s,{height:150,stats:r});case 8:case"end":return _context59.stop();}}},_callee54);}));};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});};Object.defineProperty(e,"__esModule",{value:!0});var i=n(46),o=n(109);e.perClassAccuracy=function(t,e,n){return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee55(){var r,a,_t314,_r228,_i197;return regeneratorRuntime.wrap(function _callee55$(_context60){while(1){switch(_context60.prev=_context60.next){case 0:r=i.getDrawArea(t),a=[];for(_t314=0;_t314<e.length;_t314++){_r228=n?n[_t314]:_t314.toString(),_i197=e[_t314];a.push([_r228,_i197.accuracy,_i197.count]);}return _context60.abrupt("return",o.table(r,{headers:["Class","Accuracy","# Samples"],values:a}));case 3:case"end":return _context60.stop();}}},_callee55);}));};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});};Object.defineProperty(e,"__esModule",{value:!0});var i=n(137),o=n(46),a=n(109),s=n(64),u=n(110);function c(t){var e;if(Array.isArray(t.outputShape[0])){e="[".concat(t.outputShape.map(function(t){return l(t);}).join(", "),"]");}else e=l(t.outputShape);return {name:t.name,trainable:t.trainable,parameters:t.countParams(),outputShape:e};}function l(t){var e=t.slice();return 0===e.length?"Scalar":(null===e[0]&&(e[0]="batch"),"[".concat(e.join(","),"]"));}e.modelSummary=function(t,e){return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee56(){var n,r;return regeneratorRuntime.wrap(function _callee56$(_context61){while(1){switch(_context61.prev=_context61.next){case 0:n=o.getDrawArea(t),r=function(t){return {layers:t.layers.map(c)};}(e).layers.map(function(t){return [t.name,t.outputShape,t.parameters,t.trainable];});a.table(n,{headers:["Layer Name","Output Shape","# Of Params","Trainable"],values:r});case 2:case"end":return _context61.stop();}}},_callee56);}));},e.layer=function(t,e){return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee59(){var _this82=this;var n,c,f,h,d,p;return regeneratorRuntime.wrap(function _callee59$(_context64){while(1){switch(_context64.prev=_context64.next){case 0:n=o.getDrawArea(t);_context64.next=3;return function(t){return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee57(){var e,n,r,i,o;return regeneratorRuntime.wrap(function _callee57$(_context62){while(1){switch(_context62.prev=_context62.next){case 0:e=t.getWeights();n=t.weights;r=e.map(u.tensorStats);_context62.next=5;return Promise.all(r);case 5:i=_context62.sent;o=e.map(function(t){return t.shape;});return _context62.abrupt("return",e.map(function(t,e){return {name:n[e].name,stats:i[e],shape:l(o[e]),weight:t};}));case 8:case"end":return _context62.stop();}}},_callee57);}));}(e);case 3:c=_context64.sent;f=s.subSurface(n,"layer-weights-info");h=c.map(function(t){return [t.name,t.shape,t.stats.min,t.stats.max,t.weight.size,t.stats.numZeros,t.stats.numNans,t.stats.numInfs];});a.table(f,{headers:["Weight Name","Shape","Min","Max","# Params","# Zeros","# NaNs","# Infinity"],values:h});d=s.subSurface(n,"select-layer"),p=s.subSurface(n,"param-distribution");!function(t,e,n){var r="<div><button>Show Values Distribution for:</button>".concat("\n    <select>\n      ".concat(t.map(function(t){return "<option value=".concat(t,">").concat(t,"</option>");}),"\n    </select>\n  "),"</div>");e.innerHTML=r;var i=e.querySelector("button"),o=e.querySelector("select");i.addEventListener("click",function(){n(o.selectedOptions[0].label);});}(c.map(function(t){return t.name;}),d,function(t){return r(_this82,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee58(){var e;return regeneratorRuntime.wrap(function _callee58$(_context63){while(1){switch(_context63.prev=_context63.next){case 0:_context63.next=2;return c.filter(function(e){return e.name===t;})[0].weight.data();case 2:e=_context63.sent;i.histogram(p,e,{height:150,width:460,stats:!1});case 4:case"end":return _context63.stop();}}},_callee58);}));});case 9:case"end":return _context64.stop();}}},_callee59);}));};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});};Object.defineProperty(e,"__esModule",{value:!0});var i=n(196),o=n(46),a=n(64);function s(t,e,n){var s=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee60(){var r,l,_iterator237,_step237,_t316,_r229,_i199,_r230,f,h,d,_i198,_f21,_t315,_e313,_n244,_o102,_s74;return regeneratorRuntime.wrap(function _callee60$(_context65){while(1){switch(_context65.prev=_context65.next){case 0:r=o.getDrawArea(t),l={};_iterator237=_createForOfIteratorHelper(n);try{for(_iterator237.s();!(_step237=_iterator237.n()).done;){_t316=_step237.value;if(/val_/.test(_t316)){_r229=_t316.replace("val_","");u(l,_r229);_i199=c(e,_t316,n.indexOf(_t316));l[_r229].series.push(_t316),l[_r229].values.push(_i199);}else {_r230=c(e,_t316,n.indexOf(_t316));u(l,_t316),l[_t316].series.push(_t316),l[_t316].values.push(_r230);}}}catch(err){_iterator237.e(err);}finally{_iterator237.f();}f=Object.keys(l),h=Object.assign({},{xLabel:"Iteration",yLabel:"Value"},s),d=[];for(_i198=0,_f21=f;_i198<_f21.length;_i198++){_t315=_f21[_i198];_e313=a.subSurface(r,_t315),_n244=l[_t315].series,_o102=l[_t315].values;_n244.every(function(t){return Boolean(t.match("acc"));})&&(h.zoomToFitAccuracy?h.zoomToFit=!0:(h.yAxisDomain=[0,1],delete h.zoomToFit));_s74=i.linechart(_e313,{values:_o102,series:_n244},h);d.push(_s74);}_context65.next=7;return Promise.all(d);case 7:case"end":return _context65.stop();}}},_callee60);}));}function u(t,e){null==t[e]&&(t[e]={series:[],values:[]});}function c(t,e,n){if(Array.isArray(t)){var _r231=Array.isArray(t[0])?t[n]:t,_i200=[];for(var _t317=0;_t317<_r231.length;_t317++){var _n245=_r231[_t317];_i200.push({x:_t317,y:_n245[e]});}return _i200;}return t.history[e].map(function(t,e){return {x:e,y:t};});}function l(t,e,n){return null==t[e]&&(t[e]={}),null==t[e][n]&&(t[e][n]=[]),t[e][n];}e.history=s,e.fitCallbacks=function(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var i={},u=n.callbacks||["onEpochEnd","onBatchEnd"],c=o.getDrawArea(t),f=Object.assign({},n);delete f.callbacks;var h={};return u.forEach(function(t){h[t]=function(t){var _this83=this;return function(n,u){return r(_this83,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee61(){var n,r,_iterator238,_step238,_o103,_e314;return regeneratorRuntime.wrap(function _callee61$(_context66){while(1){switch(_context66.prev=_context66.next){case 0:/batch/i.test(t)?f.xLabel="Batch":/epoch/i.test(t)&&(f.xLabel="Epoch");n=[],r=[];_iterator238=_createForOfIteratorHelper(e);try{for(_iterator238.s();!(_step238=_iterator238.n()).done;){_o103=_step238.value;if(null!=u[_o103]){r.push(_o103);_e314=l(i,t,_o103);_e314.push(_defineProperty({},_o103,u[_o103])),n.push(_e314);}}}catch(err){_iterator238.e(err);}finally{_iterator238.f();}s(a.subSurface(c,t,{title:t}),n,r,f);_context66.next=7;return o.nextFrame();case 7:case"end":return _context66.stop();}}},_callee61);}));};}(t);}),h;};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t};};Object.defineProperty(e,"__esModule",{value:!0});var o=i(n(88)),a=n(64),s=n(111),u=n(46);e.scatterplot=function(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee62(){var r,i,l,f,h,d;return regeneratorRuntime.wrap(function _callee62$(_context67){while(1){switch(_context67.prev=_context67.next){case 0:r=e.values;i=null==e.series?[]:e.series,l=[];(r=Array.isArray(r[0])?r:[r]).forEach(function(t,e){var n=null!=i[e]?i[e]:"Series ".concat(e+1),r=t.map(function(t){return Object.assign({},t,{series:n});});l.push.apply(l,_toConsumableArray(r));}),null!=n.seriesColors&&s.assert(n.seriesColors.length===r.length,"Must have an equal number of series colors as there are data series");f=u.getDrawArea(t),h=Object.assign({},c,n),d={width:h.width||a.getDefaultWidth(f),height:h.height||a.getDefaultHeight(f),padding:0,autosize:{type:"fit",contains:"padding",resize:!0},config:{axis:{labelFontSize:h.fontSize,titleFontSize:h.fontSize},text:{fontSize:h.fontSize},legend:{labelFontSize:h.fontSize,titleFontSize:h.fontSize}},data:{values:l},mark:{type:"point",clip:!0,tooltip:{content:"data"}},encoding:{x:{field:"x",type:h.xType,title:h.xLabel,scale:h.zoomToFit?{zero:!1}:null!=h.xAxisDomain?{domain:h.xAxisDomain}:void 0},y:{field:"y",type:h.yType,title:h.yLabel,scale:h.zoomToFit?{zero:!1}:null!=h.yAxisDomain?{domain:h.yAxisDomain}:void 0},color:{field:"series",type:"nominal",scale:{range:h.seriesColors}},shape:{field:"series",type:"nominal"}}};_context67.next=6;return o.default(f,d,{actions:!1,mode:"vega-lite",defaultStyle:!1});case 6:return _context67.abrupt("return",Promise.resolve());case 7:case"end":return _context67.stop();}}},_callee62);}));};var c={xLabel:"x",yLabel:"y",xType:"quantitative",yType:"quantitative",zoomToFit:!1,fontSize:11};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});},i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t){Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);}return e.default=t,e;},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t};};Object.defineProperty(e,"__esModule",{value:!0});var a=i(n(0)),s=o(n(88)),u=n(64),c=n(111),l=n(46);function f(t,e,n){var r=t instanceof a.Tensor?t.shape:[t.length,t[0].length];0===n?c.assert(r[0]===e.length,"Length of xTickLabels (".concat(e.length,") must match number of rows")+" (".concat(r[0],")")):1===n&&c.assert(r[1]===e.length,"Length of yTickLabels (".concat(e.length,") must match number of columns (").concat(r[1],")"));}e.heatmap=function(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee64(){var i,o,d,p,m,g,_t318,_d$shape,_e315,_n246,_r232,_e316,_i201,_o104,_a85,_t319,_e317,_n247,_r233,_i202,_o105,v,y,b,x,_t320;return regeneratorRuntime.wrap(function _callee64$(_context69){while(1){switch(_context69.prev=_context69.next){case 0:i=Object.assign({},h,n),o=l.getDrawArea(t);d=e.values;_context69.t0=i.rowMajor;if(!_context69.t0){_context69.next=7;break;}_context69.next=6;return function(t){return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee63(){var e,n,r,i;return regeneratorRuntime.wrap(function _callee63$(_context68){while(1){switch(_context68.prev=_context68.next){case 0:t instanceof a.Tensor?(e=t.shape,n=t.transpose()):(e=[t.length,t[0].length],n=a.tidy(function(){return a.tensor2d(t).transpose();})),c.assert(2===n.rank,"Input to renderHeatmap must be a 2d array or Tensor2d");_context68.next=3;return n.array();case 3:r=_context68.sent;n.dispose();i=[r.length,r[0].length];return _context68.abrupt("return",(c.assert(e[0]===i[1]&&e[1]===i[0],"Unexpected transposed shape. Original ".concat(e," : Transposed ").concat(i)),r));case 7:case"end":return _context68.stop();}}},_callee63);}));}(e.values);case 6:d=_context69.sent;case 7:p=e.xTickLabels,m=e.yTickLabels;null!=p&&f(d,p,0),null!=m&&f(d,m,1);g=[];if(!(d instanceof a.Tensor)){_context69.next=21;break;}c.assert(2===d.rank,"Input to renderHeatmap must be a 2d array or Tensor2d");_context69.next=14;return d.data();case 14:_t318=_context69.sent;_d$shape=_slicedToArray(d.shape,2);_e315=_d$shape[0];_n246=_d$shape[1];for(_r232=0;_r232<_e315;_r232++){_e316=p?"".concat(p[_r232],"@tfidx@").concat(_r232):_r232;for(_i201=0;_i201<_n246;_i201++){_o104=m?"".concat(m[_i201],"@tfidx@").concat(_i201):_i201,_a85=_t318[_r232*_n246+_i201];g.push({x:_e316,y:_o104,value:_a85});}}_context69.next=23;break;case 21:_t319=d;for(_e317=0;_e317<_t319.length;_e317++){_n247=p?"".concat(p[_e317],"@tfidx@").concat(_e317):_e317;for(_r233=0;_r233<_t319[_e317].length;_r233++){_i202=m?"".concat(m[_r233],"@tfidx@").concat(_r233):_r233,_o105=_t319[_e317][_r233];g.push({x:_n247,y:_i202,value:_o105});}}case 23:v={actions:!1,mode:"vega-lite",defaultStyle:!1},y={width:i.width||u.getDefaultWidth(o),height:i.height||u.getDefaultHeight(o),padding:0,autosize:{type:"fit",contains:"padding",resize:!0},config:{axis:{labelFontSize:i.fontSize,titleFontSize:i.fontSize},text:{fontSize:i.fontSize},legend:{labelFontSize:i.fontSize,titleFontSize:i.fontSize},scale:{bandPaddingInner:0,bandPaddingOuter:0}},data:{values:g},mark:{type:"rect",tooltip:!0},encoding:{x:{field:"x",type:i.xType,title:i.xLabel,sort:!1},y:{field:"y",type:i.yType,title:i.yLabel,sort:!1},fill:{field:"value",type:"quantitative"}}},b=new RegExp("@tfidx@\\d+$");_context69.t1=(p&&(y.encoding.x.axis={labelExpr:"replace(datum.value, regexp(/@tfidx@\\d+$/), '')"}),m&&(y.encoding.y.axis={labelExpr:"replace(datum.value, regexp(/@tfidx@\\d+$/), '')"}),(p||m)&&(v.tooltip={sanitize:function sanitize(t){return String(t).replace(b,"");}}),i.colorMap);_context69.next=_context69.t1==="blues"?27:_context69.t1==="greyscale"?29:_context69.t1==="viridis"?31:31;break;case 27:x=["#f7fbff","#4292c6"];return _context69.abrupt("break",32);case 29:x=["#000000","#ffffff"];return _context69.abrupt("break",32);case 31:x="viridis";case 32:if("viridis"!==x&&(y.encoding.fill.scale={range:x}),i.domain){_t320=y.encoding.fill;null!=_t320.scale?_t320.scale=Object.assign({},_t320.scale,{domain:i.domain}):_t320.scale={domain:i.domain};}_context69.next=35;return s.default(o,y,v);case 35:case"end":return _context69.stop();}}},_callee64);}));};var h={xLabel:null,yLabel:null,xType:"ordinal",yType:"ordinal",colorMap:"viridis",fontSize:12,domain:null,rowMajor:!1};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t};};Object.defineProperty(e,"__esModule",{value:!0});var o=i(n(88)),a=n(64),s=n(46);e.confusionMatrix=function(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee65(){var r,i,c,l,f,h,d,_t321,_e318,_n248,_i203,_o106,_iterator239,_step239,_t322,p,m;return regeneratorRuntime.wrap(function _callee65$(_context70){while(1){switch(_context70.prev=_context70.next){case 0:r=Object.assign({},u,n),i=s.getDrawArea(t),c=[],l=e.values,f=e.tickLabels||[],h=0===f.length;d=!0;for(_t321=0;_t321<l.length;_t321++){_e318=h?"Class ".concat(_t321):f[_t321];h&&f.push(_e318);for(_n248=0;_n248<l[_t321].length;_n248++){_i203=h?"Class ".concat(_n248):f[_n248],_o106=l[_t321][_n248];_t321!==_n248||r.shadeDiagonal?(c.push({label:_e318,prediction:_i203,count:_o106,scaleCount:_o106}),0!==_o106&&(d=!1)):c.push({label:_e318,prediction:_i203,count:_o106,noFill:!0});}}if(!r.shadeDiagonal&&d){_iterator239=_createForOfIteratorHelper(c);try{for(_iterator239.s();!(_step239=_iterator239.n()).done;){_t322=_step239.value;!0===_t322.noFill&&(_t322.noFill=!1,_t322.scaleCount=_t322.count);}}catch(err){_iterator239.e(err);}finally{_iterator239.f();}}p={width:r.width||a.getDefaultWidth(i),height:r.height||a.getDefaultHeight(i),padding:0,autosize:{type:"fit",contains:"padding",resize:!0},config:{axis:{labelFontSize:r.fontSize,titleFontSize:r.fontSize},text:{fontSize:r.fontSize},legend:{labelFontSize:r.fontSize,titleFontSize:r.fontSize}},data:{values:c},encoding:{x:{field:"prediction",type:"ordinal",title:r.xLabel||"prediction",scale:{domain:f}},y:{field:"label",type:"ordinal",title:r.yLabel||"label",scale:{domain:f}}},layer:[{transform:[{filter:"datum.noFill != true"}],mark:{type:"rect"},encoding:{color:{field:"scaleCount",type:"quantitative",scale:{range:r.colorMap}},tooltip:[{field:"label",type:"nominal"},{field:"prediction",type:"nominal"},{field:"count",type:"quantitative"}]}}]};!1===r.shadeDiagonal&&p.layer.push({transform:[{filter:"datum.noFill == true"}],mark:{type:"rect",fill:"white"},encoding:{tooltip:[{field:"label",type:"nominal"},{field:"prediction",type:"nominal"},{field:"count",type:"quantitative"}]}}),r.showTextOverlay&&p.layer.push({mark:{type:"text",baseline:"middle"},encoding:{text:{field:"count",type:"nominal"}}});m="string"==typeof r.colorMap?{scheme:r.colorMap}:r.colorMap;p.layer[0].encoding.color.scale.range=m;_context70.next=10;return o.default(i,p,{actions:!1,mode:"vega-lite",defaultStyle:!1});case 10:case"end":return _context70.stop();}}},_callee65);}));};var u={xLabel:null,yLabel:null,xType:"nominal",yType:"nominal",shadeDiagonal:!0,fontSize:12,showTextOverlay:!0,height:400,colorMap:["#f7fbff","#4292c6"]};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(138),i=n(102);e.Tabs=/*#__PURE__*/function(_r$Component){_inherits(_class4,_r$Component);var _super54=_createSuper(_class4);function _class4(){_classCallCheck(this,_class4);return _super54.apply(this,arguments);}_createClass(_class4,[{key:"render",value:function render(){var _this$props=this.props,t=_this$props.tabNames,e=_this$props.activeTab,n=_this$props.handleClick,a=t.length>0?t.map(function(t){return r.h(o,{key:t,id:t,handleClick:n,isActive:t===e},t);}):null,s=i.css({overflowX:"scroll",overflowY:"hidden",whiteSpace:"nowrap",borderBottomStyle:"solid",borderBottomWidth:"1px",borderColor:"#eee",paddingBottom:"1rem",marginTop:"1rem"});return r.h("div",{className:"".concat(s," visor-tabs")},a);}}]);return _class4;}(r.Component);var o=/*#__PURE__*/function(_r$Component2){_inherits(o,_r$Component2);var _super55=_createSuper(o);function o(){_classCallCheck(this,o);return _super55.apply(this,arguments);}_createClass(o,[{key:"render",value:function render(){var _this$props2=this.props,t=_this$props2.children,e=_this$props2.isActive,n=_this$props2.handleClick,_o107=_this$props2.id,a=i.css({borderBottomColor:e?"#357EDD":"#AAAAAA",borderBottomWidth:"1px",borderBottomStyle:"solid",cursor:"pointer",":hover":{color:"#357EDD"},display:"inline-block",marginRight:"1rem",padding:".5rem",fontSize:"1rem",fontWeight:"bold"});return r.h("a",{className:"".concat(a," tf-tab"),"data-isactive":e,onClick:function onClick(){return n(_o107);}},t);}}]);return o;}(r.Component);},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(138),i=n(102);var o=/*#__PURE__*/function(_r$Component3){_inherits(o,_r$Component3);var _super56=_createSuper(o);function o(){_classCallCheck(this,o);return _super56.apply(this,arguments);}_createClass(o,[{key:"componentDidMount",value:function componentDidMount(){var _this$props3=this.props,t=_this$props3.name,e=_this$props3.tab;this.props.registerSurface(t,e,this);}},{key:"componentDidUpdate",value:function componentDidUpdate(){return !1;}},{key:"render",value:function render(){var _this84=this;var _this$props4=this.props,t=_this$props4.name,e=_this$props4.visible,n=_this$props4.styles,a=Object.assign({},o.defaultStyles,n),s=a.width,u=a.height;var c=a.maxHeight,l=a.maxWidth;c=u===o.defaultStyles.height?c:u,l=s===o.defaultStyles.width?l:s;var f=i.css({display:e?"block":"none",backgroundColor:"white",marginTop:"10px",marginBottom:"10px",boxShadow:"0 0 6px -3px #777",padding:"10px !important",height:u,width:s,maxHeight:c,maxWidth:l,overflow:"auto"}),h=i.css({backgroundColor:"white",boxSizing:"border-box",borderBottom:"1px solid #357EDD",lineHeight:"2em",marginBottom:"20px",fontWeight:"600",textAlign:"center"}),d=i.css({boxSizing:"border-box"});return r.h("div",{className:"".concat(f," tf-surface"),ref:function ref(t){return _this84.container=t;},"data-visible":e},r.h("div",{className:"".concat(h," tf-label"),ref:function ref(t){return _this84.label=t;}},t),r.h("div",{className:"".concat(d," tf-draw-area"),ref:function ref(t){return _this84.drawArea=t;}}));}}]);return o;}(r.Component);o.defaultStyles={maxWidth:"550px",maxHeight:"580px",height:"auto",width:"auto"},e.SurfaceComponent=o;},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(138),i=n(102),o=n(291),a=n(290);var s=/*#__PURE__*/function(_r$Component4){_inherits(s,_r$Component4);var _super57=_createSuper(s);function s(t){var _this85;_classCallCheck(this,s);_this85=_super57.call(this,t),_this85.surfaces=new Map();var e=null==t.startOpen||t.startOpen;_this85.state={isOpen:e,isFullscreen:!1,activeTab:null,tabs:new Set()},_this85.keyHandler=_this85.keyHandler.bind(_assertThisInitialized(_this85));return _this85;}_createClass(s,[{key:"close",value:function close(){this.setState({isOpen:!1});}},{key:"open",value:function open(){this.setState({isOpen:!0});}},{key:"toggle",value:function toggle(){this.setState({isOpen:!this.state.isOpen});}},{key:"toggleFullScreen",value:function toggleFullScreen(){this.setState({isFullscreen:!this.state.isFullscreen});}},{key:"isOpen",value:function isOpen(){return this.state.isOpen;}},{key:"isFullscreen",value:function isFullscreen(){return this.state.isFullscreen;}},{key:"getSurface",value:function getSurface(t,e){var n=this.surfaceId(t,e);var r;if(!this.surfaces.has(n))throw Error("Surface not found with id: ".concat(n));return {container:(r=this.surfaces.get(n)).container,label:r.label,drawArea:r.drawArea};}},{key:"bindKeys",value:function bindKeys(){document.addEventListener("keydown",this.keyHandler,!1);}},{key:"unbindKeys",value:function unbindKeys(){document.removeEventListener("keydown",this.keyHandler);}},{key:"surfaceId",value:function surfaceId(t,e){return t+e;}},{key:"setTabs",value:function setTabs(t){var e=t.map(function(t){return t.tab;}),n=this.state.tabs;var r;var _iterator240=_createForOfIteratorHelper(e),_step240;try{for(_iterator240.s();!(_step240=_iterator240.n()).done;){var _t323=_step240.value;n.has(_t323)||(n.add(_t323),r=_t323);}}catch(err){_iterator240.e(err);}finally{_iterator240.f();}null!=r&&this.setState({tabs:n,activeTab:r});}},{key:"getTabs",value:function getTabs(){return this.state.tabs;}},{key:"registerSurface",value:function registerSurface(t,e,n){var r=this.surfaceId(t,e);this.surfaces.set(r,n);}},{key:"keyHandler",value:function keyHandler(t){192===t.keyCode&&(t.shiftKey?this.toggleFullScreen():this.toggle());}},{key:"setActiveTab",value:function setActiveTab(t){this.setState({activeTab:t});}},{key:"componentDidMount",value:function componentDidMount(){this.bindKeys();}},{key:"componentWillMount",value:function componentWillMount(){this.setTabs(this.props.surfaceList);}},{key:"componentWillReceiveProps",value:function componentWillReceiveProps(t){this.setTabs(t.surfaceList);}},{key:"render",value:function render(){var _this86=this;var _this$state=this.state,t=_this$state.isOpen,e=_this$state.isFullscreen,n=_this$state.activeTab,_s75=this.props.surfaceList,c=Array.from(this.getTabs().values()),l=e?"90vw":"550px",f=i.css({width:l,height:"100%",backgroundColor:"#fafafa",boxSizing:"border-box",padding:"10px",position:"fixed",top:"0px",transition:"right 0.5s cubic-bezier(0.645, 0.045, 0.355, 1), width 0.5s cubic-bezier(0.645, 0.045, 0.355, 1)",boxShadow:"0 2px 5px rgba(0, 0, 0, 0.12), 0 2px 5px rgba(0, 0, 0, 0.24)",overflow:"auto",fontFamily:"sans-serif",fontSize:"14px",zIndex:1e3}),h=i.css({right:"0"}),d=i.css({right:"calc(-".concat(l," - 10px)")}),p=t?h:d,m=i.css({});return r.h("div",{className:"".concat(f," ").concat(p," visor"),"data-isopen":t,"data-isfullscreen":e},r.h(u,{fullScreenHandler:this.toggleFullScreen.bind(this),closeHandler:this.close.bind(this),isFullScreen:e}),r.h(a.Tabs,{tabNames:c,activeTab:n,handleClick:this.setActiveTab.bind(this)}),r.h("div",{className:"".concat(m," visor-surfaces")},_s75.map(function(t){return r.h(o.SurfaceComponent,{key:t.name+t.tab,name:t.name,tab:t.tab,styles:t.styles,registerSurface:_this86.registerSurface.bind(_this86),visible:n===t.tab});})));}}],[{key:"render",value:function render(t,e,n){return r.render(r.h(s,Object.assign({},n)),t,e);}}]);return s;}(r.Component);function u(t){var e=t.isFullScreen,n=t.fullScreenHandler,o=t.closeHandler,a=i.css({display:"flex",backgroundColor:"white",border:"1px solid white",padding:"6px",paddingTop:"10px",marginBottom:"10px",borderRadius:"6px",marginTop:"-16px"}),s=i.css({fontSize:".875rem",borderRadius:".25rem",paddingLeft:"1rem",paddingRight:"1rem",paddingTop:".5rem",paddingBottom:".5rem",textDecoration:"none",transition:"color .15s ease-in",color:"#111"}),u=i.css({marginLeft:"auto"});return r.h("div",{className:"".concat(a," visor-controls")},r.h("button",{className:"".concat(s),onClick:n},e?"Minimize":"Maximize"),r.h("button",{className:"".concat(s," ").concat(u),onClick:o},"Hide"));}e.VisorComponent=s;},function(t,e,n){function r(t,e){return t.charCodeAt(e++)+(t.charCodeAt(e++)<<8)+(t.charCodeAt(e++)<<16)+(t.charCodeAt(e)<<24);}function i(t,e){return t.charCodeAt(e++)+(t.charCodeAt(e++)<<8);}function o(t,e){return (65535&(t|=0))*(e|=0)+(((t>>>16)*e&65535)<<16)|0;}Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){var n=1540483477,a=e^t.length,s=t.length,u=0;for(;s>=4;){var c=r(t,u);c=o(c,n),c=o(c^=c>>>24,n),a=o(a,n),a^=c,u+=4,s-=4;}switch(s){case 3:a^=i(t,u),a=o(a^=t.charCodeAt(u+2)<<16,n);break;case 2:a=o(a^=i(t,u),n);break;case 1:a=o(a^=t.charCodeAt(u),n);}return a=o(a^=a>>>13,n),(a^=a>>>15)>>>0;};},function(t,e,n){n.r(e);var r=/[A-Z]/g,i=/^ms-/,o={};function a(t){return "-"+t.toLowerCase();}e.default=function(t){if(o.hasOwnProperty(t))return o[t];var e=t.replace(r,a);return o[t]=i.test(e)?"-"+e:e;};},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){return (0, r.default)(t);};var r=function(t){return t&&t.__esModule?t:{default:t};}(n(294));t.exports=e.default;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,n,a){if("string"==typeof e&&s.hasOwnProperty(t)){var c=function(t,e){if((0, i.default)(t))return t;for(var n=t.split(/,(?![^()]*(?:\([^()]*\))?\))/g),o=0,a=n.length;o<a;++o){var s=n[o],c=[s];for(var l in e){var f=(0, r.default)(l);if(s.indexOf(f)>-1&&"order"!==f)for(var h=e[l],d=0,p=h.length;d<p;++d){c.unshift(s.replace(f,u[h[d]]+f));}}n[o]=c.join(",");}return n.join(",");}(e,a),l=c.split(/,(?![^()]*(?:\([^()]*\))?\))/g).filter(function(t){return !/-moz-|-ms-/.test(t);}).join(",");if(t.indexOf("Webkit")>-1)return l;var f=c.split(/,(?![^()]*(?:\([^()]*\))?\))/g).filter(function(t){return !/-webkit-|-ms-/.test(t);}).join(",");return t.indexOf("Moz")>-1?f:(n["Webkit"+(0, o.default)(t)]=l,n["Moz"+(0, o.default)(t)]=f,c);}};var r=a(n(295)),i=a(n(101)),o=a(n(199));function a(t){return t&&t.__esModule?t:{default:t};}var s={transition:!0,transitionProperty:!0,WebkitTransition:!0,WebkitTransitionProperty:!0,MozTransition:!0,MozTransitionProperty:!0},u={Webkit:"-webkit-",Moz:"-moz-",ms:"-ms-"};t.exports=e.default;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){if(i.hasOwnProperty(t)&&o.hasOwnProperty(e))return r.map(function(t){return t+e;});};var r=["-webkit-","-moz-",""],i={maxHeight:!0,maxWidth:!0,width:!0,height:!0,columnWidth:!0,minWidth:!0,minHeight:!0},o={"min-content":!0,"max-content":!0,"fill-available":!0,"fit-content":!0,"contain-floats":!0};t.exports=e.default;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){if("position"===t&&"sticky"===e)return ["-webkit-sticky","sticky"];},t.exports=e.default;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){if("string"==typeof e&&!(0, r.default)(e)&&e.indexOf("image-set(")>-1)return i.map(function(t){return e.replace(/image-set\(/g,t+"image-set(");});};var r=function(t){return t&&t.__esModule?t:{default:t};}(n(101));var i=["-webkit-",""];t.exports=e.default;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){if("string"==typeof e&&!(0, r.default)(e)&&o.test(e))return i.map(function(t){return t+e;});};var r=function(t){return t&&t.__esModule?t:{default:t};}(n(101));var i=["-webkit-","-moz-",""],o=/linear-gradient|radial-gradient|repeating-linear-gradient|repeating-radial-gradient/;t.exports=e.default;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,n){"flexDirection"===t&&"string"==typeof e&&(e.indexOf("column")>-1?n.WebkitBoxOrient="vertical":n.WebkitBoxOrient="horizontal",e.indexOf("reverse")>-1?n.WebkitBoxDirection="reverse":n.WebkitBoxDirection="normal");i.hasOwnProperty(t)&&(n[i[t]]=r[e]||e);};var r={"space-around":"justify","space-between":"justify","flex-start":"start","flex-end":"end","wrap-reverse":"multiple",wrap:"multiple"},i={alignItems:"WebkitBoxAlign",justifyContent:"WebkitBoxPack",flexWrap:"WebkitBoxLines"};t.exports=e.default;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){if("display"===t&&r.hasOwnProperty(e))return r[e];};var r={flex:["-webkit-box","-moz-box","-ms-flexbox","-webkit-flex","flex"],"inline-flex":["-webkit-inline-box","-moz-inline-box","-ms-inline-flexbox","-webkit-inline-flex","inline-flex"]};t.exports=e.default;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){if("string"==typeof e&&!(0, r.default)(e)&&e.indexOf("filter(")>-1)return i.map(function(t){return e.replace(/filter\(/g,t+"filter(");});};var r=function(t){return t&&t.__esModule?t:{default:t};}(n(101));var i=["-webkit-",""];t.exports=e.default;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){if("string"==typeof e&&!(0, r.default)(e)&&e.indexOf("cross-fade(")>-1)return i.map(function(t){return e.replace(/cross-fade\(/g,t+"cross-fade(");});};var r=function(t){return t&&t.__esModule?t:{default:t};}(n(101));var i=["-webkit-",""];t.exports=e.default;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){if("cursor"===t&&i.hasOwnProperty(e))return r.map(function(t){return t+e;});};var r=["-webkit-","-moz-",""],i={"zoom-in":!0,"zoom-out":!0,grab:!0,grabbing:!0};t.exports=e.default;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,n,r,i){for(var o=0,a=t.length;o<a;++o){var s=t[o](e,n,r,i);if(s)return s;}},t.exports=e.default;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,n){if(t.hasOwnProperty(e))for(var i=t[e],o=0,a=i.length;o<a;++o){n[i[o]+(0, r.default)(e)]=n[e];}};var r=function(t){return t&&t.__esModule?t:{default:t};}(n(199));t.exports=e.default;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0});var r=["Webkit"],i=["Moz"],o=["ms"],a=["Webkit","Moz"],s=["Webkit","ms"],u=["Webkit","Moz","ms"];e.default={plugins:[],prefixMap:{appearance:a,userSelect:u,textEmphasisPosition:r,textEmphasis:r,textEmphasisStyle:r,textEmphasisColor:r,boxDecorationBreak:r,clipPath:r,maskImage:r,maskMode:r,maskRepeat:r,maskPosition:r,maskClip:r,maskOrigin:r,maskSize:r,maskComposite:r,mask:r,maskBorderSource:r,maskBorderMode:r,maskBorderSlice:r,maskBorderWidth:r,maskBorderOutset:r,maskBorderRepeat:r,maskBorder:r,maskType:r,textDecorationStyle:r,textDecorationSkip:r,textDecorationLine:r,textDecorationColor:r,filter:r,fontFeatureSettings:r,breakAfter:u,breakBefore:u,breakInside:u,columnCount:a,columnFill:a,columnGap:a,columnRule:a,columnRuleColor:a,columnRuleStyle:a,columnRuleWidth:a,columns:a,columnSpan:a,columnWidth:a,writingMode:s,flex:r,flexBasis:r,flexDirection:r,flexGrow:r,flexFlow:r,flexShrink:r,flexWrap:r,alignContent:r,alignItems:r,alignSelf:r,justifyContent:r,order:r,transform:r,transformOrigin:r,transformOriginX:r,transformOriginY:r,backfaceVisibility:r,perspective:r,perspectiveOrigin:r,transformStyle:r,transformOriginZ:r,animation:r,animationDelay:r,animationDirection:r,animationFillMode:r,animationDuration:r,animationIterationCount:r,animationName:r,animationPlayState:r,animationTimingFunction:r,backdropFilter:r,fontKerning:r,scrollSnapType:s,scrollSnapPointsX:s,scrollSnapPointsY:s,scrollSnapDestination:s,scrollSnapCoordinate:s,shapeImageThreshold:r,shapeImageMargin:r,shapeImageOutside:r,hyphens:u,flowInto:s,flowFrom:s,regionFragment:s,textAlignLast:i,tabSize:i,wrapFlow:o,wrapThrough:o,wrapMargin:o,gridTemplateColumns:o,gridTemplateRows:o,gridTemplateAreas:o,gridTemplate:o,gridAutoColumns:o,gridAutoRows:o,gridAutoFlow:o,grid:o,gridRowStart:o,gridColumnStart:o,gridRowEnd:o,gridRow:o,gridColumn:o,gridColumnEnd:o,gridColumnGap:o,gridRowGap:o,gridArea:o,gridGap:o,textSizeAdjust:s,borderImage:r,borderImageOutset:r,borderImageRepeat:r,borderImageSlice:r,borderImageSource:r,borderImageWidth:r,transitionDelay:r,transitionDuration:r,transitionProperty:r,transitionTimingFunction:r}},t.exports=e.default;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){for(var e in t){var n=t[e],r=(0, o.default)(v,e,n,t,y);r&&(t[e]=r),(0, i.default)(y,e,t);}return t;};var r=g(n(308)),i=g(n(307)),o=g(n(306)),a=g(n(305)),s=g(n(304)),u=g(n(303)),c=g(n(302)),l=g(n(301)),f=g(n(300)),h=g(n(299)),d=g(n(298)),p=g(n(297)),m=g(n(296));function g(t){return t&&t.__esModule?t:{default:t};}var v=[s.default,a.default,u.default,l.default,f.default,h.default,d.default,p.default,m.default,c.default],y=r.default.prefixMap;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0});var r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n){Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r]);}}return t;};e.PluginSet=u,e.fallbacks=function(t){if(Object.keys(t.style).map(function(e){return Array.isArray(t.style[e]);}).indexOf(!0)>=0){var e=t.style,n=Object.keys(e).reduce(function(t,n){return t[n]=Array.isArray(e[n])?e[n].join("; "+(0, o.processStyleName)(n)+": "):e[n],t;},{});return (0, i.default)({},t,{style:n});}return t;},e.contentWrap=function(t){if(t.style.content){var e=t.style.content;return c.indexOf(e)>=0?t:/^(attr|calc|counters?|url)\(/.test(e)?t:e.charAt(0)!==e.charAt(e.length-1)||'"'!==e.charAt(0)&&"'"!==e.charAt(0)?r({},t,{style:r({},t.style,{content:'"'+e+'"'})}):t;}return t;},e.prefixes=function(t){return (0, i.default)({},t,{style:(0, a.default)(r({},t.style))});};var i=s(n(139)),o=n(201),a=s(n(309));function s(t){return t&&t.__esModule?t:{default:t};}function u(t){this.fns=t||[];}(0, i.default)(u.prototype,{add:function add(){for(var t=this,e=arguments.length,n=Array(e),r=0;r<e;r++){n[r]=arguments[r];}n.forEach(function(e){t.fns.indexOf(e)>=0||(t.fns=[e].concat(t.fns));});},remove:function remove(t){this.fns=this.fns.filter(function(e){return e!==t;});},clear:function clear(){this.fns=[];},transform:function transform(t){return this.fns.reduce(function(t,e){return e(t);},t);}});var c=["normal","none","counter","open-quote","close-quote","no-open-quote","no-close-quote","initial","inherit"];},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==_typeof$1(Symbol.iterator)?function(t){return _typeof$1(t);}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":_typeof$1(t);};function i(t){if(function(t){return null===t||void 0===t||!1===t||"object"===(void 0===t?"undefined":r(t))&&0===Object.keys(t).length;}(t))return null;if("object"!==(void 0===t?"undefined":r(t)))return t;for(var e={},n=Object.keys(t),i=!1,a=0;a<n.length;a++){var s=t[n[a]],u=o(s);null!==u&&u===s||(i=!0),null!==u&&(e[n[a]]=u);}return 0===Object.keys(e).length?null:i?e:t;}function o(t){return Array.isArray(t)?function(t){var e=!1,n=[];return t.forEach(function(t){var r=o(t);null!==r&&r===t||(e=!0),null!==r&&n.push(r);}),0==n.length?null:e?n:t;}(t):i(t);}e.default=o;},function(t,e,n){t.exports=function(t){var e={};return function(n){return e.hasOwnProperty(n)||(e[n]=t.call(this,n)),e[n];};};},function(t,e,n){var r=/([A-Z])/g;t.exports=function(t){return t.replace(r,"-$1").toLowerCase();};},function(t,e,n){var r=n(313),i=/^ms-/;t.exports=function(t){return r(t).replace(i,"-ms-");};},function(t,e,n){function r(t){return function(){return t;};}var i=function i(){};i.thatReturns=r,i.thatReturnsFalse=r(!1),i.thatReturnsTrue=r(!0),i.thatReturnsNull=r(null),i.thatReturnsThis=function(){return this;},i.thatReturnsArgument=function(t){return t;},t.exports=i;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0});var r={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridRow:!0,gridRowStart:!0,gridRowEnd:!0,gridColumn:!0,gridColumnStart:!0,gridColumnEnd:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0};var i=["Webkit","ms","Moz","O"];Object.keys(r).forEach(function(t){i.forEach(function(e){r[function(t,e){return t+e.charAt(0).toUpperCase()+e.substring(1);}(e,t)]=r[t];});});var o={isUnitlessNumber:r,shorthandPropertyExpansions:{background:{backgroundAttachment:!0,backgroundColor:!0,backgroundImage:!0,backgroundPositionX:!0,backgroundPositionY:!0,backgroundRepeat:!0},backgroundPosition:{backgroundPositionX:!0,backgroundPositionY:!0},border:{borderWidth:!0,borderStyle:!0,borderColor:!0},borderBottom:{borderBottomWidth:!0,borderBottomStyle:!0,borderBottomColor:!0},borderLeft:{borderLeftWidth:!0,borderLeftStyle:!0,borderLeftColor:!0},borderRight:{borderRightWidth:!0,borderRightStyle:!0,borderRightColor:!0},borderTop:{borderTopWidth:!0,borderTopStyle:!0,borderTopColor:!0},font:{fontStyle:!0,fontVariant:!0,fontWeight:!0,fontSize:!0,lineHeight:!0,fontFamily:!0},outline:{outlineWidth:!0,outlineStyle:!0,outlineColor:!0}}};e.default=o;},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0});var r=i(n(316));i(n(200));function i(t){return t&&t.__esModule?t:{default:t};}var o=r.default.isUnitlessNumber;e.default=function(t,e,n){return null==e||"boolean"==typeof e||""===e?"":isNaN(e)||0===e||o.hasOwnProperty(t)&&o[t]?""+e:("string"==typeof e&&(e=e.trim()),e+"px");};},function(t,e,n){var r=/-(.)/g;t.exports=function(t){return t.replace(r,function(t,e){return e.toUpperCase();});};},function(t,e,n){var r=n(318),i=/^-ms-/;t.exports=function(t){return r(t.replace(i,"ms-"));};},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),e.StyleSheet=f;var r=function(t){return t&&t.__esModule?t:{default:t};}(n(139));function i(t){return t[t.length-1];}function o(t){if(t.sheet)return t.sheet;for(var e=0;e<document.styleSheets.length;e++){if(document.styleSheets[e].ownerNode===t)return document.styleSheets[e];}}var a="undefined"!=typeof window,u=!1,c=function(){if(a){var t=document.createElement("div");return t.innerHTML="\x3c!--[if lt IE 10]><i></i><![endif]--\x3e",1===t.getElementsByTagName("i").length;}}();function l(){var t=document.createElement("style");return t.type="text/css",t.setAttribute("data-glamor",""),t.appendChild(document.createTextNode("")),(document.head||document.getElementsByTagName("head")[0]).appendChild(t),t;}function f(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.speedy,n=void 0===e?!u:e,r=t.maxLength,i=void 0===r?a&&c?4e3:65e3:r;this.isSpeedy=n,this.sheet=void 0,this.tags=[],this.maxLength=i,this.ctr=0;}(0, r.default)(f.prototype,{getSheet:function getSheet(){return o(i(this.tags));},inject:function inject(){var t=this;if(this.injected)throw new Error("already injected stylesheet!");a?this.tags[0]=l():this.sheet={cssRules:[],insertRule:function insertRule(e){t.sheet.cssRules.push({cssText:e});}},this.injected=!0;},speedy:function speedy(t){if(0!==this.ctr)throw new Error("cannot change speedy mode after inserting any rule to sheet. Either call speedy("+t+") earlier in your app, or call flush() before speedy("+t+")");this.isSpeedy=!!t;},_insert:function _insert(t){try{var e=this.getSheet();e.insertRule(t,-1!==t.indexOf("@import")?0:e.cssRules.length);}catch(e){}},insert:function insert(t){if(a){if(this.isSpeedy&&this.getSheet().insertRule)this._insert(t);else if(-1!==t.indexOf("@import")){var e=i(this.tags);e.insertBefore(document.createTextNode(t),e.firstChild);}else i(this.tags).appendChild(document.createTextNode(t));}else this.sheet.insertRule(t,-1!==t.indexOf("@import")?0:this.sheet.cssRules.length);return this.ctr++,a&&this.ctr%this.maxLength==0&&this.tags.push(l()),this.ctr-1;},delete:function _delete(t){return this.replace(t,"");},flush:function flush(){a?(this.tags.forEach(function(t){return t.parentNode.removeChild(t);}),this.tags=[],this.sheet=null,this.ctr=0):this.sheet.cssRules=[],this.injected=!1;},rules:function rules(){if(!a)return this.sheet.cssRules;var t=[];return this.tags.forEach(function(e){return t.splice.apply(t,[t.length,0].concat(function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++){n[e]=t[e];}return n;}return Array.from(t);}(Array.from(o(e).cssRules))));}),t;}});},function(t,e,n){n.r(e),n.d(e,"default",function(){return u;});var r=n(null),i=n(87),o=n(null),a=n(null),s=n(null);function u(){var t=[],e=a.c;function n(n){if(null!=n&&!isNaN(n=+n))return e((Object(r.c)(t,n,1)-1)/(t.length-1));}return n.domain=function(e){if(!arguments.length)return t.slice();t=[];var _iterator241=_createForOfIteratorHelper(e),_step241;try{for(_iterator241.s();!(_step241=_iterator241.n()).done;){var _n249=_step241.value;null==_n249||isNaN(_n249=+_n249)||t.push(_n249);}}catch(err){_iterator241.e(err);}finally{_iterator241.f();}return t.sort(i.a),n;},n.interpolator=function(t){return arguments.length?(e=t,n):e;},n.range=function(){return t.map(function(n,r){return e(r/(t.length-1));});},n.quantiles=function(e){return Array.from({length:e+1},function(n,r){return Object(o.b)(t,r/e);});},n.copy=function(){return u(e).domain(t);},s.b.apply(n,arguments);}},function(t,e,n){n.r(e),n.d(e,"default",function(){return u;});var r=n(null),i=n(null),o=n(null),a=n(null);function s(t){return Math.sign(t)*t*t;}function u(){var t,e=Object(r.a)(),n=[0,1],c=!1;function l(n){var r=function(t){return Math.sign(t)*Math.sqrt(Math.abs(t));}(e(n));return isNaN(r)?t:c?Math.round(r):r;}return l.invert=function(t){return e.invert(s(t));},l.domain=function(t){return arguments.length?(e.domain(t),l):e.domain();},l.range=function(t){return arguments.length?(e.range((n=Array.from(t,a.a)).map(s)),l):n.slice();},l.rangeRound=function(t){return l.range(t).round(!0);},l.round=function(t){return arguments.length?(c=!!t,l):c;},l.clamp=function(t){return arguments.length?(e.clamp(t),l):e.clamp();},l.unknown=function(e){return arguments.length?(t=e,l):t;},l.copy=function(){return u(e.domain(),n).round(c).clamp(e.clamp()).unknown(t);},i.a.apply(l,arguments),Object(o.b)(l);}},function(t,e,n){var r=n(47),i=n(113),o=i.ANY,a=n(112),s=n(48),u=function u(t,e,n){if(t===e)return !0;if(1===t.length&&t[0].semver===o){if(1===e.length&&e[0].semver===o)return !0;t=n.includePrerelease?[new i(">=0.0.0-0")]:[new i(">=0.0.0")];}if(1===e.length&&e[0].semver===o){if(n.includePrerelease)return !0;e=[new i(">=0.0.0")];}var r=new Set();var u,f,h,d,p,m,g;var _iterator242=_createForOfIteratorHelper(t),_step242;try{for(_iterator242.s();!(_step242=_iterator242.n()).done;){var _e319=_step242.value;">"===_e319.operator||">="===_e319.operator?u=c(u,_e319,n):"<"===_e319.operator||"<="===_e319.operator?f=l(f,_e319,n):r.add(_e319.semver);}}catch(err){_iterator242.e(err);}finally{_iterator242.f();}if(r.size>1)return null;if(u&&f){if((h=s(u.semver,f.semver,n))>0)return null;if(0===h&&(">="!==u.operator||"<="!==f.operator))return null;}var _iterator243=_createForOfIteratorHelper(r),_step243;try{for(_iterator243.s();!(_step243=_iterator243.n()).done;){var _t324=_step243.value;if(u&&!a(_t324,String(u),n))return null;if(f&&!a(_t324,String(f),n))return null;var _iterator245=_createForOfIteratorHelper(e),_step245;try{for(_iterator245.s();!(_step245=_iterator245.n()).done;){var _r234=_step245.value;if(!a(_t324,String(_r234),n))return !1;}}catch(err){_iterator245.e(err);}finally{_iterator245.f();}return !0;}}catch(err){_iterator243.e(err);}finally{_iterator243.f();}var v=!(!f||n.includePrerelease||!f.semver.prerelease.length)&&f.semver,y=!(!u||n.includePrerelease||!u.semver.prerelease.length)&&u.semver;v&&1===v.prerelease.length&&"<"===f.operator&&0===v.prerelease[0]&&(v=!1);var _iterator244=_createForOfIteratorHelper(e),_step244;try{for(_iterator244.s();!(_step244=_iterator244.n()).done;){var _t325=_step244.value;if(g=g||">"===_t325.operator||">="===_t325.operator,m=m||"<"===_t325.operator||"<="===_t325.operator,u)if(y&&_t325.semver.prerelease&&_t325.semver.prerelease.length&&_t325.semver.major===y.major&&_t325.semver.minor===y.minor&&_t325.semver.patch===y.patch&&(y=!1),">"===_t325.operator||">="===_t325.operator){if((d=c(u,_t325,n))===_t325&&d!==u)return !1;}else if(">="===u.operator&&!a(u.semver,String(_t325),n))return !1;if(f)if(v&&_t325.semver.prerelease&&_t325.semver.prerelease.length&&_t325.semver.major===v.major&&_t325.semver.minor===v.minor&&_t325.semver.patch===v.patch&&(v=!1),"<"===_t325.operator||"<="===_t325.operator){if((p=l(f,_t325,n))===_t325&&p!==f)return !1;}else if("<="===f.operator&&!a(f.semver,String(_t325),n))return !1;if(!_t325.operator&&(f||u)&&0!==h)return !1;}}catch(err){_iterator244.e(err);}finally{_iterator244.f();}return !(u&&m&&!f&&0!==h)&&!(f&&g&&!u&&0!==h)&&!y&&!v;},c=function c(t,e,n){if(!t)return e;var r=s(t.semver,e.semver,n);return r>0?t:r<0?e:">"===e.operator&&">="===t.operator?e:t;},l=function l(t,e,n){if(!t)return e;var r=s(t.semver,e.semver,n);return r<0?t:r>0?e:"<"===e.operator&&"<="===t.operator?e:t;};t.exports=function(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};if(t===e)return !0;t=new r(t,n),e=new r(e,n);var i=!1;var _iterator246=_createForOfIteratorHelper(t.set),_step246;try{t:for(_iterator246.s();!(_step246=_iterator246.n()).done;){var _r235=_step246.value;var _iterator247=_createForOfIteratorHelper(e.set),_step247;try{for(_iterator247.s();!(_step247=_iterator247.n()).done;){var _t326=_step247.value;var _e320=u(_r235,_t326,n);if(i=i||null!==_e320,_e320)continue t;}}catch(err){_iterator247.e(err);}finally{_iterator247.f();}if(i)return !1;}}catch(err){_iterator246.e(err);}finally{_iterator246.f();}return !0;};},function(t,e,n){var r=n(112),i=n(48);t.exports=function(t,e,n){var o=[];var a=null,s=null;var u=t.sort(function(t,e){return i(t,e,n);});var _iterator248=_createForOfIteratorHelper(u),_step248;try{for(_iterator248.s();!(_step248=_iterator248.n()).done;){var _t328=_step248.value;r(_t328,e,n)?(s=_t328,a||(a=_t328)):(s&&o.push([a,s]),s=null,a=null);}}catch(err){_iterator248.e(err);}finally{_iterator248.f();}a&&o.push([a,null]);var c=[];for(var _i204=0,_o108=o;_i204<_o108.length;_i204++){var _o108$_i=_slicedToArray(_o108[_i204],2),_t327=_o108$_i[0],_e321=_o108$_i[1];_t327===_e321?c.push(_t327):_e321||_t327!==u[0]?_e321?_t327===u[0]?c.push("<=".concat(_e321)):c.push("".concat(_t327," - ").concat(_e321)):c.push(">=".concat(_t327)):c.push("*");}var l=c.join(" || "),f="string"==typeof e.raw?e.raw:String(e);return l.length<f.length?l:e;};},function(t,e,n){var r=n(47);t.exports=function(t,e,n){return t=new r(t,n),e=new r(e,n),t.intersects(e);};},function(t,e,n){var r=n(140);t.exports=function(t,e,n){return r(t,e,"<",n);};},function(t,e,n){var r=n(140);t.exports=function(t,e,n){return r(t,e,">",n);};},function(t,e,n){var r=n(47);t.exports=function(t,e){try{return new r(t,e).range||"*";}catch(t){return null;}};},function(t,e,n){var r=n(32),i=n(47),o=n(114);t.exports=function(t,e){t=new i(t,e);var n=new r("0.0.0");if(t.test(n))return n;if(n=new r("0.0.0-0"),t.test(n))return n;n=null;var _loop14=function _loop14(_e322){var i=null;t.set[_e322].forEach(function(t){var e=new r(t.semver.version);switch(t.operator){case">":0===e.prerelease.length?e.patch++:e.prerelease.push(0),e.raw=e.format();case"":case">=":i&&!o(e,i)||(i=e);break;case"<":case"<=":break;default:throw new Error("Unexpected operation: ".concat(t.operator));}}),!i||n&&!o(n,i)||(n=i);};for(var _e322=0;_e322<t.set.length;++_e322){_loop14(_e322);}return n&&t.test(n)?n:null;};},function(t,e,n){var r=n(32),i=n(47);t.exports=function(t,e,n){var o=null,a=null,s=null;try{s=new i(e,n);}catch(t){return null;}return t.forEach(function(t){s.test(t)&&(o&&1!==a.compare(t)||(a=new r(o=t,n)));}),o;};},function(t,e,n){var r=n(32),i=n(47);t.exports=function(t,e,n){var o=null,a=null,s=null;try{s=new i(e,n);}catch(t){return null;}return t.forEach(function(t){s.test(t)&&(o&&-1!==a.compare(t)||(a=new r(o=t,n)));}),o;};},function(t,e,n){var r=n(47);t.exports=function(t,e){return new r(t,e).set.map(function(t){return t.map(function(t){return t.value;}).join(" ").trim().split(" ");});};},function(t,e,n){t.exports=function(t){t.prototype[Symbol.iterator]=/*#__PURE__*/regeneratorRuntime.mark(function _callee66(){var _t329;return regeneratorRuntime.wrap(function _callee66$(_context71){while(1){switch(_context71.prev=_context71.next){case 0:_t329=this.head;case 1:if(!_t329){_context71.next=7;break;}_context71.next=4;return _t329.value;case 4:_t329=_t329.next;_context71.next=1;break;case 7:case"end":return _context71.stop();}}},_callee66,this);});};},function(t,e,n){function r(t){var e=this;if(e instanceof r||(e=new r()),e.tail=null,e.head=null,e.length=0,t&&"function"==typeof t.forEach)t.forEach(function(t){e.push(t);});else if(arguments.length>0)for(var n=0,i=arguments.length;n<i;n++){e.push(arguments[n]);}return e;}function i(t,e,n){var r=e===t.head?new s(n,null,e,t):new s(n,e,e.next,t);return null===r.next&&(t.tail=r),null===r.prev&&(t.head=r),t.length++,r;}function o(t,e){t.tail=new s(e,t.tail,null,t),t.head||(t.head=t.tail),t.length++;}function a(t,e){t.head=new s(e,null,t.head,t),t.tail||(t.tail=t.head),t.length++;}function s(t,e,n,r){if(!(this instanceof s))return new s(t,e,n,r);this.list=r,this.value=t,e?(e.next=this,this.prev=e):this.prev=null,n?(n.prev=this,this.next=n):this.next=null;}t.exports=r,r.Node=s,r.create=r,r.prototype.removeNode=function(t){if(t.list!==this)throw new Error("removing node which does not belong to this list");var e=t.next,n=t.prev;return e&&(e.prev=n),n&&(n.next=e),t===this.head&&(this.head=e),t===this.tail&&(this.tail=n),t.list.length--,t.next=null,t.prev=null,t.list=null,e;},r.prototype.unshiftNode=function(t){if(t!==this.head){t.list&&t.list.removeNode(t);var e=this.head;t.list=this,t.next=e,e&&(e.prev=t),this.head=t,this.tail||(this.tail=t),this.length++;}},r.prototype.pushNode=function(t){if(t!==this.tail){t.list&&t.list.removeNode(t);var e=this.tail;t.list=this,t.prev=e,e&&(e.next=t),this.tail=t,this.head||(this.head=t),this.length++;}},r.prototype.push=function(){for(var t=0,e=arguments.length;t<e;t++){o(this,arguments[t]);}return this.length;},r.prototype.unshift=function(){for(var t=0,e=arguments.length;t<e;t++){a(this,arguments[t]);}return this.length;},r.prototype.pop=function(){if(this.tail){var t=this.tail.value;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,t;}},r.prototype.shift=function(){if(this.head){var t=this.head.value;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,t;}},r.prototype.forEach=function(t,e){e=e||this;for(var n=this.head,r=0;null!==n;r++){t.call(e,n.value,r,this),n=n.next;}},r.prototype.forEachReverse=function(t,e){e=e||this;for(var n=this.tail,r=this.length-1;null!==n;r--){t.call(e,n.value,r,this),n=n.prev;}},r.prototype.get=function(t){for(var e=0,n=this.head;null!==n&&e<t;e++){n=n.next;}if(e===t&&null!==n)return n.value;},r.prototype.getReverse=function(t){for(var e=0,n=this.tail;null!==n&&e<t;e++){n=n.prev;}if(e===t&&null!==n)return n.value;},r.prototype.map=function(t,e){e=e||this;for(var n=new r(),i=this.head;null!==i;){n.push(t.call(e,i.value,this)),i=i.next;}return n;},r.prototype.mapReverse=function(t,e){e=e||this;for(var n=new r(),i=this.tail;null!==i;){n.push(t.call(e,i.value,this)),i=i.prev;}return n;},r.prototype.reduce=function(t,e){var n,r=this.head;if(arguments.length>1)n=e;else {if(!this.head)throw new TypeError("Reduce of empty list with no initial value");r=this.head.next,n=this.head.value;}for(var i=0;null!==r;i++){n=t(n,r.value,i),r=r.next;}return n;},r.prototype.reduceReverse=function(t,e){var n,r=this.tail;if(arguments.length>1)n=e;else {if(!this.tail)throw new TypeError("Reduce of empty list with no initial value");r=this.tail.prev,n=this.tail.value;}for(var i=this.length-1;null!==r;i--){n=t(n,r.value,i),r=r.prev;}return n;},r.prototype.toArray=function(){for(var t=new Array(this.length),e=0,n=this.head;null!==n;e++){t[e]=n.value,n=n.next;}return t;},r.prototype.toArrayReverse=function(){for(var t=new Array(this.length),e=0,n=this.tail;null!==n;e++){t[e]=n.value,n=n.prev;}return t;},r.prototype.slice=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var n=new r();if(e<t||e<0)return n;t<0&&(t=0),e>this.length&&(e=this.length);for(var i=0,o=this.head;null!==o&&i<t;i++){o=o.next;}for(;null!==o&&i<e;i++,o=o.next){n.push(o.value);}return n;},r.prototype.sliceReverse=function(t,e){(e=e||this.length)<0&&(e+=this.length),(t=t||0)<0&&(t+=this.length);var n=new r();if(e<t||e<0)return n;t<0&&(t=0),e>this.length&&(e=this.length);for(var i=this.length,o=this.tail;null!==o&&i>e;i--){o=o.prev;}for(;null!==o&&i>t;i--,o=o.prev){n.push(o.value);}return n;},r.prototype.splice=function(t,e){t>this.length&&(t=this.length-1),t<0&&(t=this.length+t);for(var r=0,o=this.head;null!==o&&r<t;r++){o=o.next;}var a=[];for(r=0;o&&r<e;r++){a.push(o.value),o=this.removeNode(o);}null===o&&(o=this.tail),o!==this.head&&o!==this.tail&&(o=o.prev);for(r=0;r<(arguments.length<=2?0:arguments.length-2);r++){o=i(this,o,r+2<2||arguments.length<=r+2?undefined:arguments[r+2]);}return a;},r.prototype.reverse=function(){for(var t=this.head,e=this.tail,n=t;null!==n;n=n.prev){var r=n.prev;n.prev=n.next,n.next=r;}return this.head=e,this.tail=t,this;};try{n(333)(r);}catch(t){}},function(t,e,n){var r=n(334),i=Symbol("max"),o=Symbol("length"),a=Symbol("lengthCalculator"),s=Symbol("allowStale"),u=Symbol("maxAge"),c=Symbol("dispose"),l=Symbol("noDisposeOnSet"),f=Symbol("lruList"),h=Symbol("cache"),d=Symbol("updateAgeOnGet"),p=function p(){return 1;};var m=function m(t,e,n){var r=t[h].get(e);if(r){var _e323=r.value;if(g(t,_e323)){if(y(t,r),!t[s])return;}else n&&(t[d]&&(r.value.now=Date.now()),t[f].unshiftNode(r));return _e323.value;}},g=function g(t,e){if(!e||!e.maxAge&&!t[u])return !1;var n=Date.now()-e.now;return e.maxAge?n>e.maxAge:t[u]&&n>t[u];},v=function v(t){if(t[o]>t[i])for(var _e324=t[f].tail;t[o]>t[i]&&null!==_e324;){var _n250=_e324.prev;y(t,_e324),_e324=_n250;}},y=function y(t,e){if(e){var _n251=e.value;t[c]&&t[c](_n251.key,_n251.value),t[o]-=_n251.length,t[h].delete(_n251.key),t[f].removeNode(e);}};var b=function b(t,e,n,r,i){_classCallCheck(this,b);this.key=t,this.value=e,this.length=n,this.now=r,this.maxAge=i||0;};var x=function x(t,e,n,r){var i=n.value;g(t,i)&&(y(t,n),t[s]||(i=void 0)),i&&e.call(r,i.value,i.key,t);};t.exports=/*#__PURE__*/function(){function _class5(t){_classCallCheck(this,_class5);if("number"==typeof t&&(t={max:t}),t||(t={}),t.max&&("number"!=typeof t.max||t.max<0))throw new TypeError("max must be a non-negative number");this[i]=t.max||1/0;var e=t.length||p;if(this[a]="function"!=typeof e?p:e,this[s]=t.stale||!1,t.maxAge&&"number"!=typeof t.maxAge)throw new TypeError("maxAge must be a number");this[u]=t.maxAge||0,this[c]=t.dispose,this[l]=t.noDisposeOnSet||!1,this[d]=t.updateAgeOnGet||!1,this.reset();}_createClass(_class5,[{key:"max",get:function get(){return this[i];},set:function set(t){if("number"!=typeof t||t<0)throw new TypeError("max must be a non-negative number");this[i]=t||1/0,v(this);}},{key:"allowStale",get:function get(){return this[s];},set:function set(t){this[s]=!!t;}},{key:"maxAge",get:function get(){return this[u];},set:function set(t){if("number"!=typeof t)throw new TypeError("maxAge must be a non-negative number");this[u]=t,v(this);}},{key:"lengthCalculator",get:function get(){return this[a];},set:function set(t){var _this87=this;"function"!=typeof t&&(t=p),t!==this[a]&&(this[a]=t,this[o]=0,this[f].forEach(function(t){t.length=_this87[a](t.value,t.key),_this87[o]+=t.length;})),v(this);}},{key:"length",get:function get(){return this[o];}},{key:"itemCount",get:function get(){return this[f].length;}},{key:"rforEach",value:function rforEach(t,e){e=e||this;for(var _n252=this[f].tail;null!==_n252;){var _r236=_n252.prev;x(this,t,_n252,e),_n252=_r236;}}},{key:"forEach",value:function forEach(t,e){e=e||this;for(var _n253=this[f].head;null!==_n253;){var _r237=_n253.next;x(this,t,_n253,e),_n253=_r237;}}},{key:"keys",value:function keys(){return this[f].toArray().map(function(t){return t.key;});}},{key:"values",value:function values(){return this[f].toArray().map(function(t){return t.value;});}},{key:"reset",value:function reset(){var _this88=this;this[c]&&this[f]&&this[f].length&&this[f].forEach(function(t){return _this88[c](t.key,t.value);}),this[h]=new Map(),this[f]=new r(),this[o]=0;}},{key:"dump",value:function dump(){var _this89=this;return this[f].map(function(t){return !g(_this89,t)&&{k:t.key,v:t.value,e:t.now+(t.maxAge||0)};}).toArray().filter(function(t){return t;});}},{key:"dumpLru",value:function dumpLru(){return this[f];}},{key:"set",value:function set(t,e,n){if((n=n||this[u])&&"number"!=typeof n)throw new TypeError("maxAge must be a number");var r=n?Date.now():0,s=this[a](e,t);if(this[h].has(t)){if(s>this[i])return y(this,this[h].get(t)),!1;var _a86=this[h].get(t).value;return this[c]&&(this[l]||this[c](t,_a86.value)),_a86.now=r,_a86.maxAge=n,_a86.value=e,this[o]+=s-_a86.length,_a86.length=s,this.get(t),v(this),!0;}var d=new b(t,e,s,r,n);return d.length>this[i]?(this[c]&&this[c](t,e),!1):(this[o]+=d.length,this[f].unshift(d),this[h].set(t,this[f].head),v(this),!0);}},{key:"has",value:function has(t){if(!this[h].has(t))return !1;var e=this[h].get(t).value;return !g(this,e);}},{key:"get",value:function get(t){return m(this,t,!0);}},{key:"peek",value:function peek(t){return m(this,t,!1);}},{key:"pop",value:function pop(){var t=this[f].tail;return t?(y(this,t),t.value):null;}},{key:"del",value:function del(t){y(this,this[h].get(t));}},{key:"load",value:function load(t){this.reset();var e=Date.now();for(var _n254=t.length-1;_n254>=0;_n254--){var _r238=t[_n254],_i205=_r238.e||0;if(0===_i205)this.set(_r238.k,_r238.v);else {var _t330=_i205-e;_t330>0&&this.set(_r238.k,_r238.v,_t330);}}}},{key:"prune",value:function prune(){var _this90=this;this[h].forEach(function(t,e){return m(_this90,e,!1);});}}]);return _class5;}();},function(t,e,n){var r=n(32),i=n(89),_n255=n(90),o=_n255.re,a=_n255.t;t.exports=function(t,e){if(t instanceof r)return t;if("number"==typeof t&&(t=String(t)),"string"!=typeof t)return null;var n=null;if((e=e||{}).rtl){var _e325;for(;(_e325=o[a.COERCERTL].exec(t))&&(!n||n.index+n[0].length!==t.length);){n&&_e325.index+_e325[0].length===n.index+n[0].length||(n=_e325),o[a.COERCERTL].lastIndex=_e325.index+_e325[1].length+_e325[2].length;}o[a.COERCERTL].lastIndex=-1;}else n=t.match(o[a.COERCE]);return null===n?null:i("".concat(n[2],".").concat(n[3]||"0",".").concat(n[4]||"0"),e);};},function(t,e,n){var r=n(144);t.exports=function(t,e){return t.sort(function(t,n){return r(n,t,e);});};},function(t,e,n){var r=n(144);t.exports=function(t,e){return t.sort(function(t,n){return r(t,n,e);});};},function(t,e,n){var r=n(48);t.exports=function(t,e){return r(t,e,!0);};},function(t,e,n){var r=n(48);t.exports=function(t,e,n){return r(e,t,n);};},function(t,e,n){var r=n(89);t.exports=function(t,e){var n=r(t,e);return n&&n.prerelease.length?n.prerelease:null;};},function(t,e,n){var r=n(32);t.exports=function(t,e){return new r(t,e).patch;};},function(t,e,n){var r=n(32);t.exports=function(t,e){return new r(t,e).minor;};},function(t,e,n){var r=n(32);t.exports=function(t,e){return new r(t,e).major;};},function(t,e,n){var r=n(89),i=n(145);t.exports=function(t,e){if(i(t,e))return null;{var _n256=r(t),_i206=r(e),o=_n256.prerelease.length||_i206.prerelease.length,a=o?"pre":"",s=o?"prerelease":"";for(var _t331 in _n256){if(("major"===_t331||"minor"===_t331||"patch"===_t331)&&_n256[_t331]!==_i206[_t331])return a+_t331;}return s;}};},function(t,e,n){var r=n(32);t.exports=function(t,e,n,i){"string"==typeof n&&(i=n,n=void 0);try{return new r(t,n).inc(e,i).version;}catch(t){return null;}};},function(t,e,n){var r=n(89);t.exports=function(t,e){var n=r(t.trim().replace(/^[=v]+/,""),e);return n?n.version:null;};},function(t,e,n){var r=n(89);t.exports=function(t,e){var n=r(t,e);return n?n.version:null;};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});},i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t};};Object.defineProperty(e,"__esModule",{value:!0});var o=i(n(88)),a=n(64),s=n(46);e.barchart=function(t,e){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};return r(this,void 0,void 0,/*#__PURE__*/regeneratorRuntime.mark(function _callee67(){var r,i,l,_t332,_e326,_n257,f,h,d,p,m,g,v,y,b;return regeneratorRuntime.wrap(function _callee67$(_context72){while(1){switch(_context72.prev=_context72.next){case 0:r=s.getDrawArea(t),i=e,l=Object.assign({},u,n);if(!c.has(r)){_context72.next=10;break;}_t332=c.get(r);if(!s.shallowEquals(l,_t332.lastOptions)){_context72.next=10;break;}_context72.next=6;return s.nextFrame();case 6:_e326=_t332.view,_n257=_e326.changeset().remove(function(){return !0;}).insert(i);_context72.next=9;return _e326.change("values",_n257).runAsync();case 9:return _context72.abrupt("return",void _context72.sent);case 10:f=l.xLabel,h=l.yLabel,d=l.xType,p=l.yType;m=null;null!=f&&(m={title:f});v=null;null!=h&&(v={title:h}),g=null!=l.color?Array.isArray(l.color)?{field:"index",type:"nominal",scale:{range:l.color}}:{value:l.color}:{value:"#4C78A0"};y={width:l.width||a.getDefaultWidth(r),height:l.height||a.getDefaultHeight(r),padding:0,autosize:{type:"fit",contains:"padding",resize:!0},config:{axis:{labelFontSize:l.fontSize,titleFontSize:l.fontSize},text:{fontSize:l.fontSize},legend:{labelFontSize:l.fontSize,titleFontSize:l.fontSize}},data:{values:i,name:"values"},mark:{type:"bar",tooltip:!0},encoding:{x:{field:"index",type:d,axis:m},y:{field:"value",type:p,axis:v},color:g}};_context72.next=18;return s.nextFrame();case 18:_context72.next=20;return o.default(r,y,{actions:!1,mode:"vega-lite",defaultStyle:!1});case 20:b=_context72.sent;c.set(r,{view:b.view,lastOptions:l});case 22:case"end":return _context72.stop();}}},_callee67);}));};var u={xLabel:"",yLabel:"",xType:"ordinal",yType:"quantitative",fontSize:11},c=new Map();},function(t,e,n){/**
 * @license
 * Copyright 2018 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(25),i=n(103),o=n(33),a=n(74);function s(t){i.env().getBool("DEPRECATION_WARNINGS_ENABLED")&&console.warn(t+" You can disable deprecation warnings with tf.disableDeprecationWarnings().");}e.enableProdMode=function(){i.env().set("PROD",!0);},e.enableDebugMode=function(){i.env().set("DEBUG",!0);},e.disableDeprecationWarnings=function(){i.env().set("DEPRECATION_WARNINGS_ENABLED",!1),console.warn("TensorFlow.js deprecation warnings have been disabled.");},e.deprecationWarn=s,o.setDeprecationWarningFn(s),e.disposeVariables=function(){r.ENGINE.disposeVariables();},e.engine=function(){return r.ENGINE;},e.memory=function(){return r.ENGINE.memory();},e.profile=function(t){return r.ENGINE.profile(t);},e.tidy=function(t,e){return r.ENGINE.tidy(t,e);},e.dispose=function(t){a.getTensorsInContainer(t).forEach(function(t){return t.dispose();});},e.keep=function(t){return r.ENGINE.keep(t);},e.time=function(t){return r.ENGINE.time(t);},e.setBackend=function(t){return r.ENGINE.setBackend(t);},e.ready=function(){return r.ENGINE.ready();},e.getBackend=function(){return r.ENGINE.backendName;},e.removeBackend=function(t){r.ENGINE.removeBackend(t);},e.findBackend=function(t){return r.ENGINE.findBackend(t);},e.findBackendFactory=function(t){return r.ENGINE.findBackendFactory(t);},e.registerBackend=function(t,e,n){return void 0===n&&(n=1),r.ENGINE.registerBackend(t,e,n);},e.backend=function(){return r.ENGINE.backend;},e.setPlatform=function(t,e){i.env().setPlatform(t,e);};},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0});/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=n(350);e.warnDeprecation=function(){r.deprecationWarn("tf.batchNormalization() is going away. Use tf.batchNorm() instead, and note the positional argument change of scale, offset, and varianceEpsilon");},e.xAs4D=function(t){return 0===t.rank||1===t.rank?t.as4D(1,1,1,t.size):2===t.rank?t.as4D(1,1,t.shape[0],t.shape[1]):3===t.rank?t.as4D(1,t.shape[0],t.shape[1],t.shape[2]):t;};},function(t,e,n){/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(25),i=n(29),o=n(21),a=n(351),s=n(28);function u(t,e,n,s,u,l){null==l&&(l=.001);var f,h,d=i.convertToTensor(t,"x","batchNorm"),p=i.convertToTensor(e,"mean","batchNorm"),m=i.convertToTensor(n,"variance","batchNorm");null!=u&&(f=i.convertToTensor(u,"scale","batchNorm")),null!=s&&(h=i.convertToTensor(s,"offset","batchNorm")),o.assert(p.rank===m.rank,function(){return "Batch normalization gradient requires mean and variance to have equal ranks.";}),o.assert(null==h||p.rank===h.rank,function(){return "Batch normalization gradient requires mean and offset to have equal ranks.";}),o.assert(null==f||p.rank===f.rank,function(){return "Batch normalization gradient requires mean and scale to have equal ranks.";});var g={x:d,scale:f,offset:h,mean:p,variance:m},v={varianceEpsilon:l};return r.ENGINE.runKernelFunc(function(t,e){var n=a.xAs4D(d),r=t.batchNormalization(n,c(p),c(m),l,c(f),c(h));return e([d,p,m,f]),r;},g,null,"FusedBatchNorm",v).reshape(d.shape);}function c(t){return null==t?null:0===t.rank?t.as1D():1===t.rank?t:2===t.rank?t.as4D(1,1,t.shape[0],t.shape[1]):3===t.rank?t.as4D(1,t.shape[0],t.shape[1],t.shape[2]):t;}e.batchNormalization=s.op({batchNormalization_:function batchNormalization_(t,e,n,r,i,o){return void 0===r&&(r=.001),a.warnDeprecation(),u(t,e,n,o,i,r);}}),e.batchNorm=s.op({batchNorm_:u});},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0});/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=n(352);n(33).Tensor.prototype.batchNorm=function(t,e,n,i,o){return r.batchNorm(this,t,e,n,i,o);};},function(t,e,n){/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(25),i=n(73),o=n(29),a=n(28);e.pad=a.op({pad_:function pad_(t,e,n){void 0===n&&(n=0);var a=o.convertToTensor(t,"x","pad");if(0===a.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");var s={paddings:e,constantValue:n},u={x:a};return r.ENGINE.runKernelFunc(function(t,r){return r([a]),t.pad(a,e,n);},u,null,i.PadV2,s);}});},function(t,e,n){/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(354);n(33).Tensor.prototype.pad=function(t,e){return r.pad(this,t,e);};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(25),i=n(29),o=n(21),a=n(28);e.transpose=a.op({transpose_:function transpose_(t,e){var n=i.convertToTensor(t,"x","transpose");if(null==e&&(e=n.shape.map(function(t,e){return e;}).reverse()),o.assert(n.rank===e.length,function(){return "Error in transpose: rank of input "+n.rank+" must match length of perm "+e+".";}),e.forEach(function(t){o.assert(t>=0&&t<n.rank,function(){return "All entries in 'perm' must be between 0 and "+(n.rank-1)+" but got "+e;});}),n.rank<=1)return n.clone();var a={perm:e};return r.ENGINE.runKernelFunc(function(t){return t.transpose(n,e);},{x:n},null,"Transpose",a);}});},function(t,e,n){/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(356);n(33).Tensor.prototype.transpose=function(t){return r.transpose(this,t);};},function(t,e,n){/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(25),i=n(73),o=n(29),a=n(28);e.oneHot=a.op({oneHot_:function oneHot_(t,e,n,a){if(void 0===n&&(n=1),void 0===a&&(a=0),e<2)throw new Error("Error in oneHot: depth must be >=2, but it is "+e);var s=o.convertToTensor(t,"indices","oneHot","int32"),u=s.shape.concat([e]),c={indices:s=s.flatten()},l={depth:e,onValue:n,offValue:a};return r.ENGINE.runKernelFunc(function(t,r){return r([s]),t.oneHot(s,e,n,a);},c,null,i.OneHot,l).reshape(u);}});},function(t,e,n){/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(358);n(33).Tensor.prototype.oneHot=function(t,e,n){return void 0===e&&(e=1),void 0===n&&(n=0),r.oneHot(this,t,e,n);};},function(t,e,n){/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(25),i=n(73),o=n(29),a=n(21),s=n(28);e.tile=s.op({tile_:function tile_(t,e){var n=o.convertToTensor(t,"x","tile",null);a.assert(n.rank===e.length,function(){return "Error in transpose: rank of input "+n.rank+" must match length of reps "+e+".";});var s=[n],u={x:n},c={reps:e};return r.ENGINE.runKernelFunc(function(t,r){var i=t.tile(n,e);return r([n]),i;},u,null,i.Tile,c,s);}});},function(t,e,n){/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(360);n(33).Tensor.prototype.tile=function(t){return r.tile(this,t);};},function(t,e,n){/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(25),i=n(73),o=n(74),a=n(29),s=n(147),u=n(28),c=n(91);e.squaredDifference=u.op({squaredDifference_:function squaredDifference_(t,e){var n,u=a.convertToTensor(t,"a","squaredDifference"),l=a.convertToTensor(e,"b","squaredDifference");n=o.makeTypesMatch(u,l),u=n[0],l=n[1],s.assertAndGetBroadcastShape(u.shape,l.shape);var f={a:u,b:l},h=[u,l];return r.ENGINE.runKernelFunc(function(t,e){var n=t.squaredDifference(u,l);return e([u,l]),n;},f,function(t,e){var n=e[0],r=e[1],i=c.scalar(2);return {a:function a(){return t.mul(n.sub(r).mul(i));},b:function b(){return t.mul(r.sub(n).mul(i));}};},i.SquaredDifference,{},h,[]);}});},function(t,e,n){/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(362);n(33).Tensor.prototype.squaredDifference=function(t){return r.squaredDifference(this,t);};},function(t,e,n){/**
 * @license
 * Copyright 2017 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(21);e.assertParamsConsistent=function(t,e){var n=t[0].length;t.forEach(function(t,e){r.assert(t.length===n,function(){return "Error in concat"+n+"D: rank of tensors["+e+"] must be the same as the rank of the rest ("+n+")";});}),r.assert(e>=0&&e<n,function(){return "Error in concat"+n+"D: axis must be between 0 and "+(n-1)+".";});var i=t[0];t.forEach(function(t,o){for(var a=0;a<n;a++){r.assert(a===e||t[a]===i[a],function(){return "Error in concat"+n+"D: Shape of tensors["+o+"] ("+t+") does not match the shape of the rest ("+i+") along the non-concatenated axis "+o+".";});}});},e.computeOutShape=function(t,e){for(var n=t[0].slice(),r=1;r<t.length;r++){n[e]+=t[r][e];}return n;};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(25),i=n(29),o=n(21),a=n(21),s=n(364),u=n(28),c=n(91);e.concat=u.op({concat_:function concat_(t,n){void 0===n&&(n=0),o.assert(t.length>=1,function(){return "Pass at least one tensor to concat";});var u=i.convertToTensorArray(t,"tensors","concat");"complex64"===u[0].dtype&&u.forEach(function(t){if("complex64"!==t.dtype)throw new Error("Cannot concatenate complex64 tensors with a tensor\n          with dtype "+t.dtype+". ");}),n=a.parseAxisParam(n,u[0].shape)[0];var l=s.computeOutShape(u.map(function(t){return t.shape;}),n);if(0===o.sizeFromShape(l))return c.tensor([],l);if(1===(u=u.filter(function(t){return t.size>0;})).length)return u[0];var f=u.map(function(t){return t.shape;});s.assertParamsConsistent(f,n);var h=u,d={axis:n};return r.ENGINE.runKernelFunc(function(t){return t.concat(u,n);},h,function(t){var r=f.map(function(t){return t[n];});return e.split(t,r,n).map(function(t){return function(){return t;};});},"Concat",d);}}),e.concat1d=u.op({concat1d_:function concat1d_(t){return e.concat(t,0);}}),e.concat2d=u.op({concat2d_:function concat2d_(t,n){return e.concat(t,n);}}),e.concat3d=u.op({concat3d_:function concat3d_(t,n){return e.concat(t,n);}}),e.concat4d=u.op({concat4d_:function concat4d_(t,n){return e.concat(t,n);}}),e.split=u.op({split_:function split_(t,n,s){void 0===s&&(s=0);var u,c=i.convertToTensor(t,"x","split");return s=a.parseAxisParam(s,c.shape)[0],"number"==typeof n?(o.assert(c.shape[s]%n==0,function(){return "Number of splits must evenly divide the axis.";}),u=new Array(n).fill(c.shape[s]/n)):(o.assert(c.shape[s]===n.reduce(function(t,e){return t+e;}),function(){return "The sum of sizes must match the size of the axis dimension.";}),u=n),r.ENGINE.runKernelFunc(function(t){return t.split(c,u,s);},{$x:c},function(t){return {$x:function $x(){return e.concat(t,s);}};});}});},function(t,e,n){/**
 * @license
 * Copyright 2017 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(21);function i(t,e){for(var n=0;n<t.length;++n){if(t[t.length-n-1]!==e-1-n)return !1;}return !0;}function o(t,e,n){for(var r=t.length+e.length,i=[],o=0,a=0,s=0;s<r;s++){-1===n.indexOf(s)?i.push(t[o++]):i.push(e[a++]);}return i;}e.axesAreInnerMostDims=i,e.combineLocations=o,e.computeOutAndReduceShapes=function(t,e){for(var n=[],r=t.length,i=0;i<r;i++){-1===e.indexOf(i)&&n.push(t[i]);}return [n,e.map(function(e){return t[e];})];},e.expandShapeToKeepDim=function(t,e){return o(t,e.map(function(t){return 1;}),e);},e.assertAxesAreInnerMostDims=function(t,e,n){r.assert(i(e,n),function(){return t+" supports only inner-most axes for now. Got axes "+e+" and rank-"+n+" input.";});},e.getAxesPermutation=function(t,e){if(i(t,e))return null;for(var n=[],r=0;r<e;++r){-1===t.indexOf(r)&&n.push(r);}return t.forEach(function(t){return n.push(t);}),n;},e.getUndoAxesPermutation=function(t){return t.map(function(t,e){return [e,t];}).sort(function(t,e){return t[1]-e[1];}).map(function(t){return t[0];});},e.getInnerMostAxes=function(t,e){for(var n=[],r=e-t;r<e;++r){n.push(r);}return n;};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});},i=this&&this.__generator||function(t,e){var n,r,i,o,a={label:0,sent:function sent(){if(1&i[0])throw i[1];return i[1];},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this;}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;){try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue;}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break;}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break;}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break;}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(t,a);}catch(t){o=[6,t],r=0;}finally{n=i=0;}}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:!0};}([o,s]);};}};Object.defineProperty(e,"__esModule",{value:!0});var o=n(25),a=n(33),s=n(29),u=n(21),c=n(366),l=n(365),f=n(28);e.buffer=function(t,e,n){return void 0===e&&(e="float32"),e=e||"float32",u.assertNonNegativeIntegerDimensions(t),new a.TensorBuffer(t,e,n);},e.print=function(t,e){void 0===e&&(e=!1),console.log(t.toString(e));},e.batchToSpaceND=f.op({batchToSpaceND_:function batchToSpaceND_(t,e,n){var r=s.convertToTensor(t,"x","batchToSpaceND"),i=e.reduce(function(t,e){return t*e;});return u.assert(r.rank>=1+e.length,function(){return "input rank is "+r.rank+" but should be > than blockShape.length "+e.length;}),u.assert(n.length===e.length,function(){return "crops.length is "+n.length+" but should be equal to blockShape.length  "+e.length;}),u.assert(r.shape[0]%i==0,function(){return "input tensor batch is "+r.shape[0]+" but is not divisible by the product of the elements of blockShape "+e.join(" * ")+" === "+i;}),o.ENGINE.runKernelFunc(function(t){return t.batchToSpaceND(r,e,n);},{$x:r},function(t){return {$x:function $x(){return t.spaceToBatchND(e,n);}};});}}),e.cast=f.op({cast_:function cast_(t,e){var n=s.convertToTensor(t,"x","cast");if(!u.isValidDtype(e))throw new Error("Failed to cast to unknown dtype "+e);if("string"===e&&"string"!==n.dtype||"string"!==e&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");var r={dtype:e};return o.ENGINE.runKernelFunc(function(t){return t.cast(n,e);},{x:n},function(t){return {x:function x(){return t.clone();}};},"Cast",r);}}),e.cumsum=f.op({cumsum_:function cumsum_(t,e,n,r){void 0===e&&(e=0),void 0===n&&(n=!1),void 0===r&&(r=!1);var i=s.convertToTensor(t,"x","cumsum");e|=0;var a=c.getAxesPermutation([e],i.rank),u=i;null!=a&&(u=i.transpose(a));var l=c.getInnerMostAxes(1,i.rank)[0],f=o.ENGINE.runKernelFunc(function(t){return t.cumsum(u,l,n,r);},{permutedX:u},function(t){return {permutedX:function permutedX(){return t.cumsum(e,n,!r);}};});return null!=a&&(f=f.transpose(a)),f;}}),e.depthToSpace=f.op({depthToSpace_:function depthToSpace_(t,e,n){void 0===n&&(n="NHWC");var r=s.convertToTensor(t,"x","depthToSpace"),i="NHWC"===n?r.shape[1]:r.shape[2],a="NHWC"===n?r.shape[2]:r.shape[3],c="NHWC"===n?r.shape[3]:r.shape[1];return u.assert(i*e>=0,function(){return "Negative dimension size caused by overflow when multiplying\n      "+i+" and "+e+"  for depthToSpace with input shape\n      "+r.shape;}),u.assert(a*e>=0,function(){return "Negative dimension size caused by overflow when multiplying\n      "+a+" and "+e+" for depthToSpace with input shape\n          "+r.shape;}),u.assert(c%(e*e)==0,function(){return "Dimension size must be evenly divisible by "+e*e+" but is "+c+" for depthToSpace with input shape "+r.shape;}),o.ENGINE.runKernelFunc(function(t){return t.depthToSpace(r,e,n);},{$x:r});}}),e.expandDims=f.op({expandDims_:function expandDims_(t,n){void 0===n&&(n=0);var r=s.convertToTensor(t,"x","expandDims",null);u.assert(n<=r.rank,function(){return "Axis must be <= rank of the tensor";});var i=r.shape.slice();return n<0&&(u.assert(-(r.rank+1)<=n,function(){return "Axis must be in the interval ["+-(r.rank+1)+", "+r.rank+"]";}),n=r.rank+n+1),i.splice(n,0,1),e.reshape(r,i);}}),e.reshape=f.op({reshape_:function reshape_(t,e){var n=s.convertToTensor(t,"x","reshape",null);e=u.inferFromImplicitShape(e,n.size),u.assert(n.size===u.sizeFromShape(e),function(){return "new shape and old shape must have the same number of elements.";});var r={shape:e};return o.ENGINE.runKernelFunc(function(t){return t.reshape(n,e);},{x:n},function(t){return {x:function x(){return t.reshape(n.shape);}};},"Reshape",r);}}),e.spaceToBatchND=f.op({spaceToBatchND_:function spaceToBatchND_(t,e,n){var r=s.convertToTensor(t,"x","spaceToBatchND");return u.assert(r.rank>=1+e.length,function(){return "input rank "+r.rank+" should be > than [blockShape] "+e.length;}),u.assert(n.length===e.length,function(){return "paddings.shape[0] "+n.length+" must be equal to [blockShape] "+e.length;}),u.assert(r.shape.reduce(function(t,r,i){return i>0&&i<=e.length?t&&(r+n[i-1][0]+n[i-1][1])%e[i-1]==0:t;},!0),function(){return "input spatial dimensions "+r.shape.slice(1)+" with paddings "+n.toString()+" must be divisible by blockShapes "+e.toString();}),o.ENGINE.runKernelFunc(function(t){return t.spaceToBatchND(r,e,n);},{$x:r},function(t){return {$x:function $x(){return t.batchToSpaceND(e,n);}};});}}),e.squeeze=f.op({squeeze_:function squeeze_(t,n){var r=s.convertToTensor(t,"x","squeeze");return e.reshape(r,u.squeezeShape(r.shape,n).newShape);}}),e.stack=f.op({stack_:function stack_(t,e){void 0===e&&(e=0);var n=s.convertToTensorArray(t,"tensors","stack");if(u.assert(n.length>=1,function(){return "Pass at least one tensor to tf.stack";}),1===n.length)return n[0].expandDims(e);var r=n[0].rank,i=n[0].shape,o=n[0].dtype;u.assert(e<=r,function(){return "Axis must be <= rank of the tensor";}),n.forEach(function(t){u.assertShapesMatch(i,t.shape,"All tensors passed to stack must have matching shapes");}),n.forEach(function(t){u.assert(o===t.dtype,function(){return "All tensors passed to stack must have matching dtypes";});});var a=n.map(function(t){return t.expandDims(e);});return l.concat(a,e);}}),e.unstack=f.op({unstack_:function unstack_(t,n){void 0===n&&(n=0),n=n||0;var r=s.convertToTensor(t,"x","unstack");u.assert(n>=-r.shape.length&&n<r.shape.length,function(){return "Axis = "+n+" is not in [-"+r.shape.length+", "+r.shape.length+")";}),n<0&&(n+=r.shape.length);var i={axis:n};return o.ENGINE.runKernelFunc(function(t){return t.unstack(r,n);},{x:r},function(t){return {x:function x(){return e.stack(t,n);}};},"Unpack",i);}}),e.setdiff1dAsync=function(t,e){return r(this,void 0,void 0,function(){var n,r,o,c,l,f,h,d,p,m;return i(this,function(i){switch(i.label){case 0:return n=s.convertToTensor(t,"x","setdiff1d"),r=s.convertToTensor(e,"y","setdiff1d"),u.assert(n.dtype===r.dtype,function(){return "x and y should have the same dtype, but got x ("+n.dtype+") and y ("+r.dtype+").";}),u.assert(1===n.rank,function(){return "x should be 1D tensor, but got x ("+n.shape+").";}),u.assert(1===r.rank,function(){return "y should be 1D tensor, but got y ("+r.shape+").";}),[4,n.data()];case 1:return o=i.sent(),[4,r.data()];case 2:for(c=i.sent(),l=new Set(c),f=0,p=0;p<o.length;p++){l.has(o[p])||f++;}for(h=new a.TensorBuffer([f],n.dtype),d=new a.TensorBuffer([f],"int32"),p=0,m=0;p<o.length;p++){l.has(o[p])||(h.values[m]=o[p],d.values[m]=p,m++);}return [2,[h.toTensor(),d.toTensor()]];}});});};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(367);e.whereImpl=function(t,e){for(var n=[],i=0;i<e.length;i++){e[i]&&n.push(i);}var o=r.buffer(t,"int32"),a=r.buffer([n.length,t.length],"int32");for(i=0;i<n.length;i++){var s=o.indexToLoc(n[i]),u=i*t.length;a.values.set(s,u);}return a.toTensor();};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t));}catch(t){o(t);}}function s(t){try{u(r.throw(t));}catch(t){o(t);}}function u(t){t.done?i(t.value):new n(function(e){e(t.value);}).then(a,s);}u((r=r.apply(t,e||[])).next());});},i=this&&this.__generator||function(t,e){var n,r,i,o,a={label:0,sent:function sent(){if(1&i[0])throw i[1];return i[1];},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this;}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;){try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue;}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break;}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break;}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break;}i[2]&&a.ops.pop(),a.trys.pop();continue;}o=e.call(t,a);}catch(t){o=[6,t],r=0;}finally{n=i=0;}}if(5&o[0])throw o[1];return {value:o[0]?o[1]:void 0,done:!0};}([o,s]);};}};Object.defineProperty(e,"__esModule",{value:!0});var o=n(368),a=n(25),s=n(29),u=n(21),c=n(147),l=n(28),f=n(91);e.logicalAnd=l.op({logicalAnd_:function logicalAnd_(t,e){var n=s.convertToTensor(t,"a","logicalAnd","bool"),r=s.convertToTensor(e,"b","logicalAnd","bool");return c.assertAndGetBroadcastShape(n.shape,r.shape),a.ENGINE.runKernelFunc(function(t){return t.logicalAnd(n,r);},{a:n,b:r},null,"LogicalAnd");}}),e.logicalNot=l.op({logicalNot_:function logicalNot_(t){var e=s.convertToTensor(t,"x","logicalNot","bool");return a.ENGINE.runKernelFunc(function(t){return t.logicalNot(e);},{$x:e});}}),e.logicalOr=l.op({logicalOr_:function logicalOr_(t,e){var n=s.convertToTensor(t,"a","logicalOr","bool"),r=s.convertToTensor(e,"b","logicalOr","bool");return c.assertAndGetBroadcastShape(n.shape,r.shape),a.ENGINE.runKernelFunc(function(t){return t.logicalOr(n,r);},{$a:n,$b:r});}}),e.logicalXor=l.op({logicalXor_:function logicalXor_(t,n){var r=s.convertToTensor(t,"a","logicalXor","bool"),i=s.convertToTensor(n,"b","logicalXor","bool");return c.assertAndGetBroadcastShape(r.shape,i.shape),e.logicalOr(t,n).logicalAnd(e.logicalAnd(t,n).logicalNot());}}),e.where=l.op({where_:function where_(t,e,n){var r=s.convertToTensor(e,"a","where"),i=s.convertToTensor(n,"b","where"),o=s.convertToTensor(t,"condition","where","bool");return u.assertShapesMatch(r.shape,i.shape,"Error in where: "),1===o.rank?u.assert(o.shape[0]===r.shape[0],function(){return "The first dimension of `a` must match the size of `condition`.";}):u.assertShapesMatch(o.shape,i.shape,"Error in where: "),a.ENGINE.runKernelFunc(function(t,e){var n=t.select(o,r,i);return e([o]),n;},{$condition:o,$a:r,$b:i},function(t,e){var n=e[0];return {$condition:function $condition(){return f.zerosLike(n).toFloat();},$a:function $a(){return t.mul(n.cast(t.dtype));},$b:function $b(){return t.mul(n.logicalNot().cast(t.dtype));}};});}}),e.whereAsync=function(t){return r(this,void 0,void 0,function(){var e,n,r;return i(this,function(i){switch(i.label){case 0:return [4,(e=s.convertToTensor(t,"condition","whereAsync","bool")).data()];case 1:return n=i.sent(),r=o.whereImpl(e.shape,n),t!==e&&e.dispose(),[2,r];}});});};},function(t,e,n){/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(74),i=n(29),o=n(205),a=n(369),s=n(28),u=n(91);e.divNoNan=s.op({divNoNan_:function divNoNan_(t,e){var n,s=i.convertToTensor(t,"a","div"),c=i.convertToTensor(e,"b","div");s=(n=r.makeTypesMatch(s,c))[0],c=n[1];var l=o.div(s,c),f=u.zerosLike(l),h=c.equal(f);return a.where(h,f,l);}});},function(t,e,n){/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(370);n(33).Tensor.prototype.divNoNan=function(t){return r.divNoNan(this,t);};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(25),i=n(29),o=n(21),a=n(28),s=n(91);e.abs=a.op({abs_:function abs_(t){var e=i.convertToTensor(t,"x","abs");return "complex64"===e.dtype?r.ENGINE.runKernelFunc(function(t){return t.complexAbs(e);},{$x:e}):r.ENGINE.runKernelFunc(function(t,n){var r=t.abs(e);return n([e]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return t.mul(n.toFloat().step(-1));}};},"Abs");}}),e.acos=a.op({acos_:function acos_(t){var e=i.convertToTensor(t,"x","acos");return r.ENGINE.runKernelFunc(function(t,n){var r=t.acos(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.divStrict(s.scalar(1).sub(n.toFloat().square()).sqrt()).neg();}};});}}),e.acosh=a.op({acosh_:function acosh_(t){var e=i.convertToTensor(t,"x","acosh");return r.ENGINE.runKernelFunc(function(t,n){var r=t.acosh(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.divStrict(n.toFloat().square().sub(1).sqrt());}};});}}),e.asin=a.op({asin_:function asin_(t){var e=i.convertToTensor(t,"x","asin");return r.ENGINE.runKernelFunc(function(t,n){var r=t.asin(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.divStrict(s.scalar(1).sub(n.toFloat().square()).sqrt());}};});}}),e.asinh=a.op({asinh_:function asinh_(t){var e=i.convertToTensor(t,"x","asinh");return r.ENGINE.runKernelFunc(function(t,n){var r=t.asinh(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.divStrict(s.scalar(1).add(n.toFloat().square()).sqrt());}};});}}),e.atan=a.op({atan_:function atan_(t){var e=i.convertToTensor(t,"x","atan");return r.ENGINE.runKernelFunc(function(t,n){var r=t.atan(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(n.toFloat().square().add(1));}};});}}),e.atanh=a.op({atanh_:function atanh_(t){var e=i.convertToTensor(t,"x","atanh");return r.ENGINE.runKernelFunc(function(t,n){var r=t.atanh(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(s.scalar(1).sub(n.toFloat().square()));}};});}}),e.ceil=a.op({ceil_:function ceil_(t){var e=i.convertToTensor(t,"x","ceil");return r.ENGINE.runKernelFunc(function(t){return t.ceil(e);},{$x:e},function(t){return {$x:function $x(){return s.zerosLike(t);}};});}}),e.clipByValue=a.op({clipByValue_:function clipByValue_(t,e,n){var a=i.convertToTensor(t,"x","clipByValue");o.assert(e<=n,function(){return "Error in clip: min ("+e+") must be less than or equal to max ("+n+").";});var u=[a],c={min:e,max:n};return r.ENGINE.runKernelFunc(function(t,r){var i=t.clip(a,e,n);return r([a]),i;},{x:a},function(t,r){var i=r[0];return {x:function x(){return t.where(i.greaterEqual(e).logicalAnd(i.lessEqual(n)),s.zerosLike(t));}};},"ClipByValue",c,u);}}),e.cos=a.op({cos_:function cos_(t){var e=i.convertToTensor(t,"x","cos"),n=[e];return r.ENGINE.runKernelFunc(function(t,n){var r=t.cos(e);return n([e]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return n.toFloat().sin().neg().mul(t);}};},"Cos",{},n);}}),e.cosh=a.op({cosh_:function cosh_(t){var e=i.convertToTensor(t,"x","cosh");return r.ENGINE.runKernelFunc(function(t,n){var r=t.cosh(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return n.toFloat().sinh().mulStrict(t);}};});}}),e.erf=a.op({erf_:function erf_(t){var e=i.convertToTensor(t,"x","erf");return o.assert("int32"===e.dtype||"float32"===e.dtype,function(){return "Input dtype must be `int32` or `float32`.";}),"int32"===e.dtype&&(e=e.toFloat()),r.ENGINE.runKernelFunc(function(t,n){var r=t.erf(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.mul(n.square().neg().exp().mul(2/Math.sqrt(Math.PI)));}};});}}),e.exp=a.op({exp_:function exp_(t){var e=i.convertToTensor(t,"x","exp");return r.ENGINE.runKernelFunc(function(t,n){var r=t.exp(e);return n([r]),r;},{x:e},function(t,e){return {x:function x(){return t.mulStrict(e[0]);}};},"Exp",{},[],[!0]);}}),e.expm1=a.op({expm1_:function expm1_(t){var e=i.convertToTensor(t,"x","expm1");return r.ENGINE.runKernelFunc(function(t,n){var r=t.expm1(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.mul(n.exp());}};});}}),e.floor=a.op({floor_:function floor_(t){var e=i.convertToTensor(t,"x","floor");return r.ENGINE.runKernelFunc(function(t){return t.floor(e);},{$x:e},function(t){return {$x:function $x(){return s.zerosLike(t);}};});}}),e.log=a.op({log_:function log_(t){var e=i.convertToTensor(t,"x","log"),n=[e];return r.ENGINE.runKernelFunc(function(t,n){var r=t.log(e);return n([e]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return t.div(n.toFloat());}};},"Log",{},n);}}),e.log1p=a.op({log1p_:function log1p_(t){var e=i.convertToTensor(t,"x","log1p");return r.ENGINE.runKernelFunc(function(t,n){var r=t.log1p(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(n.add(1));}};});}}),e.logSigmoid=a.op({logSigmoid_:function logSigmoid_(t){var e=i.convertToTensor(t,"x","logSigmoid");return r.ENGINE.runKernelFunc(function(t,n){var r=t.softplus(e.neg()).neg();return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.mul(n.neg().sigmoid());}};});}}),e.neg=a.op({neg_:function neg_(t){var e=i.convertToTensor(t,"x","neg"),n=[e];return r.ENGINE.runKernelFunc(function(t){return t.neg(e);},{x:e},function(t){return {x:function x(){return t.neg();}};},"Neg",{},n);}}),e.reciprocal=a.op({reciprocal_:function reciprocal_(t){var e=i.convertToTensor(t,"x","reciprocal");return r.ENGINE.runKernelFunc(function(t,n){var r=t.reciprocal(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(n.square().neg());}};});}}),e.round=a.op({round_:function round_(t){var e=i.convertToTensor(t,"x","round");return r.ENGINE.runKernelFunc(function(t){return t.round(e);},{$x:e},function(t){return {$x:function $x(){return s.zerosLike(t);}};});}}),e.rsqrt=a.op({rsqrt_:function rsqrt_(t){var e=i.convertToTensor(t,"x","rsqrt"),n=[e];return r.ENGINE.runKernelFunc(function(t,n){var r=t.rsqrt(e);return n([e]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return t.div(n.pow(1.5).mul(2)).neg();}};},"Rsqrt",{},n);}}),e.sigmoid=a.op({sigmoid_:function sigmoid_(t){var e=i.convertToTensor(t,"x","sigmoid");return r.ENGINE.runKernelFunc(function(t,n){var r=t.sigmoid(e);return n([r]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return t.mul(n.mul(s.scalar(1).sub(n)));}};},"Sigmoid");}}),e.sign=a.op({sign_:function sign_(t){var e=i.convertToTensor(t,"x","sign");return r.ENGINE.runKernelFunc(function(t){return t.sign(e);},{$x:e},function(t){return {$x:function $x(){return s.zerosLike(t);}};});}}),e.isNaN=a.op({isNaN_:function isNaN_(t){var e=i.convertToTensor(t,"x","isNaN");return r.ENGINE.runKernelFunc(function(t){return t.isNaN(e);},{$x:e},function(t){return {$x:function $x(){return s.zerosLike(t);}};});}}),e.isInf=a.op({isInf_:function isInf_(t){var e=i.convertToTensor(t,"x","isInf");return r.ENGINE.runKernelFunc(function(t){return t.isInf(e);},{$x:e},function(t){return {$x:function $x(){return s.zerosLike(t);}};});}}),e.isFinite=a.op({isFinite_:function isFinite_(t){var e=i.convertToTensor(t,"x","isFinite");return r.ENGINE.runKernelFunc(function(t){return t.isFinite(e);},{$x:e},function(t){return {$x:function $x(){return s.zerosLike(t);}};});}}),e.sin=a.op({sin_:function sin_(t){var e=i.convertToTensor(t,"x","sin"),n=[e];return r.ENGINE.runKernelFunc(function(t,n){var r=t.sin(e);return n([e]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return n.toFloat().cos().mul(t);}};},"Sin",{},n);}}),e.sinh=a.op({sinh_:function sinh_(t){var e=i.convertToTensor(t,"x","sinh");return r.ENGINE.runKernelFunc(function(t,n){var r=t.sinh(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return n.toFloat().cosh().mulStrict(t);}};});}}),e.softplus=a.op({softplus_:function softplus_(t){var e=i.convertToTensor(t,"x","softplus");return r.ENGINE.runKernelFunc(function(t,n){var r=t.softplus(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.mul(n.sigmoid());}};});}}),e.sqrt=a.op({sqrt_:function sqrt_(t){var e=i.convertToTensor(t,"x","sqrt");return r.ENGINE.runKernelFunc(function(t,n){var r=t.sqrt(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(n.toFloat().sqrt().mul(2));}};});}}),e.step=a.op({step_:function step_(t,e){void 0===e&&(e=0);var n=i.convertToTensor(t,"x","step");return r.ENGINE.runKernelFunc(function(t){return t.step(n,e);},{$x:n},function(t){return {$x:function $x(){return s.zerosLike(t);}};});}}),e.tan=a.op({tan_:function tan_(t){var e=i.convertToTensor(t,"x","tan");return r.ENGINE.runKernelFunc(function(t,n){var r=t.tan(e);return n([e]),r;},{$x:e},function(t,e){var n=e[0];return {$x:function $x(){return t.div(n.cos().square());}};});}}),e.tanh=a.op({tanh_:function tanh_(t){var e=i.convertToTensor(t,"x","tanh");return r.ENGINE.runKernelFunc(function(t,n){var r=t.tanh(e);return n([r]),r;},{x:e},function(t,e){var n=e[0];return {x:function x(){return s.scalar(1).sub(n.square()).mulStrict(t);}};},"Tanh",{},null,[!0]);}});},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0});/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=n(25),i=n(29),o=n(21),a=n(28);e.complex=a.op({complex_:function complex_(t,e){var n=i.convertToTensor(t,"real","complex"),a=i.convertToTensor(e,"imag","complex");return o.assertShapesMatch(n.shape,a.shape,"real and imag shapes, "+n.shape+" and "+a.shape+", must match in call to tf.complex()."),r.ENGINE.runKernelFunc(function(t){return t.complex(n,a);},{$real:n,$imag:a});}}),e.real=a.op({real_:function real_(t){var e=i.convertToTensor(t,"input","real");return r.ENGINE.runKernelFunc(function(t){return t.real(e);},{$input:e});}}),e.imag=a.op({imag_:function imag_(t){var e=i.convertToTensor(t,"input","imag");return r.ENGINE.runKernelFunc(function(t){return t.imag(e);},{$input:e});}});},function(t,e,n){/**
 * @license
 * Copyright 2018 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(25),i=n(74),o=n(29),a=n(21),s=n(206),u=n(147),c=n(28),l=n(91),f=n(372);e.addStrict=c.op({addStrict_:function addStrict_(t,e){var n=o.convertToTensor(t,"a","addStrict"),r=o.convertToTensor(e,"b","addStrict");return a.assertShapesMatch(n.shape,r.shape,"Error in addStrict: "),n.add(r);}}),e.atan2=c.op({atan2_:function atan2_(t,e){var n,a=o.convertToTensor(t,"a","atan2"),c=o.convertToTensor(e,"b","atan2");n=i.makeTypesMatch(a,c),a=n[0],c=n[1];var l=u.assertAndGetBroadcastShape(a.shape,c.shape);return r.ENGINE.runKernelFunc(function(t,e){var n=t.atan2(a,c);return e([a,c]),n;},{$a:a,$b:c},function(t,e){var n=e[0],r=e[1];return {$a:function $a(){var e=s.add(n.square(),r.square()),i=t.mul(r.div(e)),o=u.getReductionAxes(n.shape,l);return o.length>0&&(i=i.sum(o)),i.reshape(n.shape);},$b:function $b(){var e=s.add(n.square(),r.square()),i=f.neg(t.mul(n.div(e))),o=u.getReductionAxes(r.shape,l);return o.length>0&&(i=i.sum(o)),i.reshape(r.shape);}};});}}),e.divStrict=c.op({divStrict_:function divStrict_(t,e){var n=o.convertToTensor(t,"a","div"),r=o.convertToTensor(e,"b","div");return a.assertShapesMatch(n.shape,r.shape,"Error in divideStrict: "),n.div(r);}}),e.floorDiv=c.op({floorDiv_:function floorDiv_(t,e){var n,a=o.convertToTensor(t,"a","floorDiv"),s=o.convertToTensor(e,"b","floorDiv");n=i.makeTypesMatch(a,s),a=n[0],s=n[1];var c=u.assertAndGetBroadcastShape(a.shape,s.shape);return r.ENGINE.runKernelFunc(function(t,e){var n=t.floorDiv(a,s);return e([a,s]),n;},{a:a,b:s},function(t,e){var n=e[0],r=e[1];return {a:function a(){var e=t.div(r.toFloat()),i=u.getReductionAxes(n.shape,c);return i.length>0?e.sum(i).reshape(n.shape):e;},b:function b(){var e=t.mul(n.toFloat()),i=u.getReductionAxes(r.shape,c);i.length>0&&(e=e.sum(i).reshape(r.shape));var o=r.square();return e.div(o.toFloat()).neg();}};},"FloorDiv");}}),e.maximum=c.op({maximum_:function maximum_(t,e){var n,a=o.convertToTensor(t,"a","maximum"),s=o.convertToTensor(e,"b","maximum");return n=i.makeTypesMatch(a,s),a=n[0],s=n[1],"bool"===a.dtype&&(a=a.toInt(),s=s.toInt()),u.assertAndGetBroadcastShape(a.shape,s.shape),r.ENGINE.runKernelFunc(function(t,e){var n=t.maximum(a,s);return e([a,s]),n;},{a:a,b:s},function(t,e){var n=e[0],r=e[1];return {a:function a(){return t.mul(n.greaterEqual(r).toFloat());},b:function b(){return t.mul(n.less(r).toFloat());}};},"Maximum");}}),e.maximumStrict=c.op({maximumStrict_:function maximumStrict_(t,e){var n=o.convertToTensor(t,"a","maximumStrict"),r=o.convertToTensor(e,"b","maximumStrict");return a.assertShapesMatch(n.shape,r.shape,"Error in maximumStrict: "),n.maximum(r);}}),e.minimum=c.op({minimum_:function minimum_(t,e){var n,a=o.convertToTensor(t,"a","minimum"),s=o.convertToTensor(e,"b","minimum");return n=i.makeTypesMatch(a,s),a=n[0],s=n[1],"bool"===a.dtype&&(a=a.toInt(),s=s.toInt()),u.assertAndGetBroadcastShape(a.shape,s.shape),r.ENGINE.runKernelFunc(function(t,e){var n=t.minimum(a,s);return e([a,s]),n;},{a:a,b:s},function(t,e){var n=e[0],r=e[1];return {a:function a(){return t.mul(n.lessEqual(r).toFloat());},b:function b(){return t.mul(n.greater(r).toFloat());}};},"Minimum");}}),e.minimumStrict=c.op({minimumStrict_:function minimumStrict_(t,e){var n=o.convertToTensor(t,"a","minimumStrict"),r=o.convertToTensor(e,"b","minimumStrict");return a.assertShapesMatch(n.shape,r.shape,"Error in minimumStrict: "),n.minimum(r);}}),e.mod=c.op({mod_:function mod_(t,e){var n,a=o.convertToTensor(t,"a","mod"),s=o.convertToTensor(e,"b","mod");n=i.makeTypesMatch(a,s),a=n[0],s=n[1];var c=u.assertAndGetBroadcastShape(a.shape,s.shape);return r.ENGINE.runKernelFunc(function(t,e){var n=t.mod(a,s);return e([a,s]),n;},{$a:a,$b:s},function(t,e){var n=e[0],r=e[1];return {$a:function $a(){var e=u.getReductionAxes(n.shape,c);return e.length>0?t.sum(e).reshape(n.shape):t;},$b:function $b(){var e=t.mul(n.div(r).floor().neg()),i=u.getReductionAxes(r.shape,c);return i.length>0?e.sum(i).reshape(r.shape):e;}};});}}),e.modStrict=c.op({modStrict_:function modStrict_(t,e){var n=o.convertToTensor(t,"a","modStrict"),r=o.convertToTensor(e,"b","modStrict");return a.assertShapesMatch(n.shape,r.shape,"Error in modStrict: "),n.mod(r);}}),e.mul=c.op({mul_:function mul_(t,e){var n,a=o.convertToTensor(t,"a","mul"),s=o.convertToTensor(e,"b","mul");n=i.makeTypesMatch(a,s),a=n[0],s=n[1];var c=u.assertAndGetBroadcastShape(a.shape,s.shape);return r.ENGINE.runKernelFunc(function(t,e){var n=t.multiply(a,s);return e([a,s]),n;},{a:a,b:s},function(t,e){var n=e[0],r=e[1];return {a:function a(){var e=t.mul(r.toFloat()),i=u.getReductionAxes(n.shape,c);return i.length>0?e.sum(i).reshape(n.shape):e;},b:function b(){var e=t.mul(n.toFloat()),i=u.getReductionAxes(r.shape,c);return i.length>0?e.sum(i).reshape(r.shape):e;}};},"Mul");}}),e.mulStrict=c.op({mulStrict_:function mulStrict_(t,e){var n=o.convertToTensor(t,"a","mul"),r=o.convertToTensor(e,"b","mul");return a.assertShapesMatch(n.shape,r.shape,"Error in multiplyStrict: "),n.mul(r);}}),e.pow=c.op({pow_:function pow_(t,e){var n,a=o.convertToTensor(t,"base","pow"),s=o.convertToTensor(e,"exp","pow");n=i.makeTypesMatch(a,s),a=n[0],s=n[1];var c=u.assertAndGetBroadcastShape(a.shape,s.shape),f=[a,s];return r.ENGINE.runKernelFunc(function(t,e){var n=t.pow(a,s);return e([a,s,n]),n;},{a:a,b:s},function(t,e){var n=e[0],r=e[1],i=e[2];return {a:function a(){var e=r.toFloat(),i=t.mul(e.mul(n.pow(e.sub(l.scalar(1))))),o=u.getReductionAxes(n.shape,c);return o.length>0&&(i=i.sum(o)),i.reshape(n.shape);},b:function b(){var e=n.greater(0),o=n.log().where(e,l.zerosLike(n)),a=t.mul(i.mul(o)),s=u.getReductionAxes(r.shape,c);return s.length>0&&(a=a.sum(s)),a.reshape(r.shape);}};},"Pow",{},f,[!0]);}}),e.powStrict=c.op({powStrict_:function powStrict_(t,e){return a.assertShapesMatch(t.shape,e.shape,"Error in powStrict: "),t.pow(e);}}),e.squaredDifferenceStrict=c.op({squaredDifferenceStrict_:function squaredDifferenceStrict_(t,e){var n=o.convertToTensor(t,"a","squaredDifferenceStrict"),r=o.convertToTensor(e,"b","squaredDifferenceStrict");return a.assertShapesMatch(n.shape,r.shape,"Error in squaredDifferenceStrict: "),n.squaredDifference(r);}}),e.sub=c.op({sub_:function sub_(t,e){var n,_a87=o.convertToTensor(t,"a","sub"),s=o.convertToTensor(e,"b","sub");n=i.makeTypesMatch(_a87,s),_a87=n[0],s=n[1];var c=u.assertAndGetBroadcastShape(_a87.shape,s.shape);return r.ENGINE.runKernelFunc(function(t){return t.subtract(_a87,s);},{a:_a87,b:s},function(t){return {a:function a(){var e=t,n=u.getReductionAxes(_a87.shape,c);return n.length>0&&(e=e.sum(n)),e.reshape(_a87.shape);},b:function b(){var e=t,n=u.getReductionAxes(s.shape,c);return n.length>0&&(e=e.sum(n)),e.neg().reshape(s.shape);}};},"Sub");}}),e.subStrict=c.op({subStrict_:function subStrict_(t,e){var n=o.convertToTensor(t,"a","subStrict"),r=o.convertToTensor(e,"b","subStrict");return a.assertShapesMatch(n.shape,r.shape,"Error in subStrict: "),n.sub(r);}});},function(t,e,n){/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(205);n(33).Tensor.prototype.div=function(t){return r.div(this,t);};},function(t,e,n){/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(25),i=n(73),o=n(29),a=n(28);e.broadcastTo=a.op({broadcastTo_:function broadcastTo_(t,e){var n=o.convertToTensor(t,"broadcastTo","x"),a=n.shape;if(e.some(function(t){return !(t>0)||t%1!=0;}))throw new Error("broadcastTo(): Invalid broadcast shape ["+e+"].");if(e.length<n.rank)throw new Error("broadcastTo(): shape.length="+e.length+" < input.rank="+n.rank+".");if(e.length>n.rank){for(var s=n.shape.slice();s.length<e.length;){s.unshift(1);}n=n.reshape(s);}for(var u=n.shape,c=Array.from(e),l=e.length-1;l>=0;l--){if(u[l]===e[l])c[l]=1;else if(1!==n.shape[l])throw new Error("broadcastTo(): ["+a+"] cannot be broadcast to ["+e+"].");}var f=c.map(function(t,e){return t>1?e:-1;}).filter(function(t){return t>=0;});if(0===f.length)return n.clone();var h={x:n},d={shape:e,inputShape:u};return r.ENGINE.runKernelFunc(function(t){return t.tile(n,c);},h,function(t){return {x:function x(){return t.sum(f,!0);}};},i.BroadcastTo,d);}});},function(t,e,n){/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(376);n(33).Tensor.prototype.broadcastTo=function(t){return r.broadcastTo(this,t);};},function(t,e,n){/**
 * @license
 * Copyright 2017 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r,i,o,a;Object.defineProperty(e,"__esModule",{value:!0}),function(t){t.R0="R0",t.R1="R1",t.R2="R2",t.R3="R3",t.R4="R4",t.R5="R5",t.R6="R6";}(e.Rank||(e.Rank={})),function(t){t.float32="float32",t.int32="int32",t.bool="int32",t.complex64="complex64";}(r||(r={})),function(t){t.float32="float32",t.int32="int32",t.bool="bool",t.complex64="complex64";}(i||(i={})),function(t){t.float32="float32",t.int32="float32",t.bool="float32",t.complex64="complex64";}(o||(o={})),function(t){t.float32="complex64",t.int32="complex64",t.bool="complex64",t.complex64="complex64";}(a||(a={}));var s={float32:o,int32:r,bool:i,complex64:a};function u(t,e){if("string"===t||"string"===e){if("string"===t&&"string"===e)return "string";throw new Error("Can not upcast "+t+" with "+e);}return s[t][e];}e.upcastType=u,e.sumOutType=function(t){return u(t,"int32");};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(21),i=20,o=3,a=7;function s(t,e,n){var i;return i=Array.isArray(t)?parseFloat(t[0].toFixed(a))+" + "+parseFloat(t[1].toFixed(a))+"j":r.isString(t)?"'"+t+"'":"bool"===n?u(t):parseFloat(t.toFixed(a)).toString(),r.rightPad(i,e);}function u(t){return 0===t?"false":"true";}function c(t){for(var e=[],n=0;n<t.length;n+=2){e.push([t[n],t[n+1]]);}return e;}e.tensorToString=function(t,e,n,a){var l=r.computeStrides(e),f=function(t,e,n,i){var o=r.sizeFromShape(e),a=i[i.length-1],u=new Array(a).fill(0),l=e.length,f="complex64"===n?c(t):t;if(l>1)for(var h=0;h<o/a;h++){for(var d=h*a,p=0;p<a;p++){u[p]=Math.max(u[p],s(f[d+p],0,n).length);}}return u;}(t,e,n,l),h=e.length,d=function t(e,n,r,a,l,f){void 0===f&&(f=!0);var h="complex64"===r?2:1,d=n[0],p=n.length;if(0===p){if("complex64"===r){var m=c(e);return [s(m[0],0,r)];}return "bool"===r?[u(e[0])]:[e[0].toString()];}if(1===p){if(d>i){var g=o*h,v=Array.from(e.slice(0,g)),y=Array.from(e.slice((d-o)*h,d*h));return "complex64"===r&&(v=c(v),y=c(y)),["["+v.map(function(t,e){return s(t,l[e],r);}).join(", ")+", ..., "+y.map(function(t,e){return s(t,l[d-o+e],r);}).join(", ")+"]"];}var b="complex64"===r?c(e):Array.from(e);return ["["+b.map(function(t,e){return s(t,l[e],r);}).join(", ")+"]"];}var x=n.slice(1),w=a.slice(1),k=a[0]*h,E=[];if(d>i){for(var C=0;C<o;C++){var A=C*k,O=A+k;E.push.apply(E,t(e.slice(A,O),x,r,w,l,!1));}E.push("...");for(var C=d-o;C<d;C++){var A=C*k,O=A+k;E.push.apply(E,t(e.slice(A,O),x,r,w,l,C===d-1));}}else for(var C=0;C<d;C++){var A=C*k,O=A+k;E.push.apply(E,t(e.slice(A,O),x,r,w,l,C===d-1));}var _=2===p?",":"";E[0]="["+E[0]+_;for(var C=1;C<E.length-1;C++){E[C]=" "+E[C]+_;}for(var S=",\n",C=2;C<p;C++){S+="\n";}return E[E.length-1]=" "+E[E.length-1]+"]"+(f?"":S),E;}(t,e,n,l,f),p=["Tensor"];return a&&(p.push("  dtype: "+n),p.push("  rank: "+h),p.push("  shape: ["+e+"]"),p.push("  values:")),p.push(d.map(function(t){return "    "+t;}).join("\n")),p.join("\n");};},function(t,e,n){/**
 * @license
 * Copyright 2017 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(21);e.getFilteredNodesXToY=function(t,e,n){for(var r={},i={},o=0;o<e.length;o++){r[e[o].id]=!0;}for(o=0;o<t.length;o++){var a=(p=t[o]).inputs;for(var s in a){for(var u=a[s],c=!1,l=0;l<e.length;l++){if(r[u.id]){p.outputs.forEach(function(t){return r[t.id]=!0;}),c=!0,i[p.id]=!0;break;}}if(c)break;}}var f={};f[n.id]=!0;var h={};for(o=t.length-1;o>=0;o--){for(a=(p=t[o]).inputs,l=0;l<p.outputs.length;l++){if(f[p.outputs[l].id]){for(var s in a){f[a[s].id]=!0,h[p.id]=!0;}break;}}}var d=[];for(o=0;o<t.length;o++){var p;if(i[(p=t[o]).id]&&h[p.id]){var m={};for(var s in p.inputs){var g=p.inputs[s];r[g.id]&&(m[s]=g);}var v=Object.assign({},p);v.inputs=m,v.outputs=p.outputs,d.push(v);}}return d;},e.backpropagateGradients=function(t,e,n){for(var i=function i(_i207){var o=e[_i207],a=[];if(o.outputs.forEach(function(e){var n=t[e.id];null!=n?a.push(n):a.push(null);}),null==o.gradient)throw new Error("Cannot compute gradient: gradient function not found for "+o.kernelName+".");var s=o.gradient(a),u=function u(e){if(!(e in s))throw new Error("Cannot backprop through input "+e+". Available gradients found: "+Object.keys(s)+".");var i=n(function(){return s[e]();});if("float32"!==i.dtype)throw new Error("Error in gradient for op "+o.kernelName+". The gradient of input "+e+" must have 'float32' dtype, but has '"+i.dtype+"'");var a=o.inputs[e];if(!r.arraysEqual(i.shape,a.shape))throw new Error("Error in gradient for op "+o.kernelName+". The gradient of input '"+e+"' has shape '"+i.shape+"', which does not match the shape of the input '"+a.shape+"'");if(null==t[a.id])t[a.id]=i;else {var u=t[a.id];t[a.id]=u.add(i),u.dispose();}};for(var c in o.inputs){u(c);}},o=e.length-1;o>=0;o--){i(o);}};},function(t,e,n){/**
 * @license
 * Copyright 2018 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=n(21),i=function(){function t(t,e){this.backendTimer=t,this.logger=e,null==e&&(this.logger=new a());}return t.prototype.profileKernel=function(t,e,n){var r,i=this,a=this.backendTimer.time(function(){r=n();});return r.forEach(function(n){n.data().then(function(r){o(r,n.dtype,t),a.then(function(o){var a="";null!=o.getExtraProfileInfo&&(a=o.getExtraProfileInfo()),i.logger.logKernelProfile(t,n,r,o.kernelMs,e,a);});});}),r;},t;}();function o(t,e,n){if("float32"!==e)return !1;for(var r=0;r<t.length;r++){var i=t[r];if(isNaN(i)||!isFinite(i))return console.warn("Found "+i+" in the result of '"+n+"'"),!0;}return !1;}e.Profiler=i,e.checkComputationForErrors=o;var a=function(){function t(){}return t.prototype.logKernelProfile=function(t,e,n,i,o,a){var s="number"==typeof i?r.rightPad(i+"ms",9):i.error,u=r.rightPad(t,25),c=e.rank,l=e.size,f=r.rightPad(e.shape.toString(),14),h="";for(var d in o){var p=o[d].shape||e.shape,m=p.length;h+=d+": "+m+"D "+(m>0?p:"")+" ";}console.log("%c"+u+"\t%c"+s+"\t%c"+c+"D "+f+"\t%c"+l+"\t%c"+h+"\t%c"+a,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue");},t;}();e.Logger=a;},function(t,e,n){/**
 * @license
 * Copyright 2019 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */Object.defineProperty(e,"__esModule",{value:!0});var r=new Map(),i=new Map();function o(t,e){return e+"_"+t;}e.getKernel=function(t,e){var n=o(t,e);return r.get(n);},e.getGradient=function(t){return i.get(t);},e.getKernelsForBackend=function(t){for(var e=r.entries(),n=[];;){var i=e.next(),o=i.done,a=i.value;if(o)break;var s=a[0],u=a[1];s.split("_")[0]===t&&n.push(u);}return n;},e.registerKernel=function(t){var e=t.kernelName,n=t.backendName,i=o(e,n);if(r.has(i))throw new Error("The kernel '"+e+"' for backend '"+n+"' is already registered");r.set(i,t);},e.registerGradient=function(t){var e=t.kernelName;i.has(e)&&console.warn("Overriding the gradient for '"+e+"'"),i.set(e,t);},e.unregisterKernel=function(t,e){var n=o(t,e);if(!r.has(n))throw new Error("The kernel '"+t+"' for backend '"+e+"' is not registered");r.delete(n);},e.unregisterGradient=function(t){if(!i.has(t))throw new Error("The gradient '"+t+"' for backend is not registered");i.delete(t);};},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0});/**
 * @license
 * Copyright 2020 Google LLC. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */var r=n(206);n(33).Tensor.prototype.add=function(t){return r.add(this,t);};},function(t,e,n){Object.defineProperty(e,"__esModule",{value:!0}),/**
 * @license
 * Copyright 2020 Google Inc. All Rights Reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * =============================================================================
 */n(383),n(377),n(375),n(371),n(363),n(361),n(359),n(357),n(355),n(353);},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e){},function(t,e,n){(function(t,e){!function(t,n){if(!t.setImmediate){var r,i=1,o={},a=!1,s=t.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(t);u=u&&u.setTimeout?u:t,"[object process]"==={}.toString.call(t.process)?r=function r(t){e.nextTick(function(){l(t);});}:function(){if(t.postMessage&&!t.importScripts){var e=!0,n=t.onmessage;return t.onmessage=function(){e=!1;},t.postMessage("","*"),t.onmessage=n,e;}}()?function(){var e="setImmediate$"+Math.random()+"$",n=function n(_n258){_n258.source===t&&"string"==typeof _n258.data&&0===_n258.data.indexOf(e)&&l(+_n258.data.slice(e.length));};t.addEventListener?t.addEventListener("message",n,!1):t.attachEvent("onmessage",n),r=function r(n){t.postMessage(e+n,"*");};}():t.MessageChannel?function(){var t=new MessageChannel();t.port1.onmessage=function(t){l(t.data);},r=function r(e){t.port2.postMessage(e);};}():s&&"onreadystatechange"in s.createElement("script")?function(){var t=s.documentElement;r=function r(e){var n=s.createElement("script");n.onreadystatechange=function(){l(e),n.onreadystatechange=null,t.removeChild(n),n=null;},t.appendChild(n);};}():r=function r(t){setTimeout(l,0,t);},u.setImmediate=function(t){"function"!=typeof t&&(t=new Function(""+t));for(var e=new Array(arguments.length-1),n=0;n<e.length;n++){e[n]=arguments[n+1];}var a={callback:t,args:e};return o[i]=a,r(i),i++;},u.clearImmediate=c;}function c(t){delete o[t];}function l(t){if(a)setTimeout(l,0,t);else {var e=o[t];if(e){a=!0;try{!function(t){var e=t.callback,r=t.args;switch(r.length){case 0:e();break;case 1:e(r[0]);break;case 2:e(r[0],r[1]);break;case 3:e(r[0],r[1],r[2]);break;default:e.apply(n,r);}}(e);}finally{c(t),a=!1;}}}}}("undefined"==typeof self?void 0===t?this:t:self);}).call(this,n(59),n(75));},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return "[object Array]"==n.call(t);};},function(t,e){/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */e.read=function(t,e,n,r,i){var o,a,s=8*i-r-1,u=(1<<s)-1,c=u>>1,l=-7,f=n?i-1:0,h=n?-1:1,d=t[e+f];for(f+=h,o=d&(1<<-l)-1,d>>=-l,l+=s;l>0;o=256*o+t[e+f],f+=h,l-=8){}for(a=o&(1<<-l)-1,o>>=-l,l+=r;l>0;a=256*a+t[e+f],f+=h,l-=8){}if(0===o)o=1-c;else {if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,r),o-=c;}return (d?-1:1)*a*Math.pow(2,o-r);},e.write=function(t,e,n,r,i,o){var a,s,u,c=8*o-i-1,l=(1<<c)-1,f=l>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,p=r?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=l):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+f>=1?h/u:h*Math.pow(2,1-f))*u>=2&&(a++,u/=2),a+f>=l?(s=0,a=l):a+f>=1?(s=(e*u-1)*Math.pow(2,i),a+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),a=0));i>=8;t[n+d]=255&s,d+=p,s/=256,i-=8){}for(a=a<<i|s,c+=i;c>0;t[n+d]=255&a,d+=p,a/=256,c-=8){}t[n+d-p]|=128*m;};},function(t,e,n){e.byteLength=function(t){var e=c(t),n=e[0],r=e[1];return 3*(n+r)/4-r;},e.toByteArray=function(t){var e,n,r=c(t),a=r[0],s=r[1],u=new o(function(t,e,n){return 3*(e+n)/4-n;}(0,a,s)),l=0,f=s>0?a-4:a;for(n=0;n<f;n+=4){e=i[t.charCodeAt(n)]<<18|i[t.charCodeAt(n+1)]<<12|i[t.charCodeAt(n+2)]<<6|i[t.charCodeAt(n+3)],u[l++]=e>>16&255,u[l++]=e>>8&255,u[l++]=255&e;}2===s&&(e=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,u[l++]=255&e);1===s&&(e=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,u[l++]=e>>8&255,u[l++]=255&e);return u;},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=0,s=n-i;a<s;a+=16383){o.push(f(t,a,a+16383>s?s:a+16383));}1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return o.join("");};for(var r=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s<u;++s){r[s]=a[s],i[a.charCodeAt(s)]=s;}function c(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return -1===n&&(n=e),[n,n===e?0:4-n%4];}function l(t){return r[t>>18&63]+r[t>>12&63]+r[t>>6&63]+r[63&t];}function f(t,e,n){for(var r,i=[],o=e;o<n;o+=3){r=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(l(r));}return i.join("");}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63;},function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e);};},function(t,e){t.exports=function(t,e){return {enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e};};},function(t,e,n){var r=n(149);t.exports=function(t,e){if(!r(t))return t;var n,i;if(e&&"function"==typeof(n=t.toString)&&!r(i=n.call(t)))return i;if("function"==typeof(n=t.valueOf)&&!r(i=n.call(t)))return i;if(!e&&"function"==typeof(n=t.toString)&&!r(i=n.call(t)))return i;throw TypeError("Can't convert object to primitive value");};},function(t,e,n){var r=n(149),i=n(150).document,o=r(i)&&r(i.createElement);t.exports=function(t){return o?i.createElement(t):{};};},function(t,e,n){t.exports=!n(148)&&!n(208)(function(){return 7!=Object.defineProperty(n(398)("div"),"a",{get:function get(){return 7;}}).a;});},function(t,e,n){var r=n(149);t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t;};},function(t,e,n){var r=n(400),i=n(399),o=n(397),a=Object.defineProperty;e.f=n(148)?Object.defineProperty:function(t,e,n){if(r(t),e=o(e,!0),r(n),i)try{return a(t,e,n);}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return "value"in n&&(t[e]=n.value),t;};},function(t,e,n){var r=n(401),i=n(396);t.exports=n(148)?function(t,e,n){return r.f(t,e,i(1,n));}:function(t,e,n){return t[e]=n,t;};},function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t;};},function(t,e,n){var r=n(403);t.exports=function(t,e,n){if(r(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n);};case 2:return function(n,r){return t.call(e,n,r);};case 3:return function(n,r,i){return t.call(e,n,r,i);};}return function(){return t.apply(e,arguments);};};},function(t,e,n){var r=n(150),i=n(209),o=n(404),a=n(402),s=n(395),u=function u(t,e,n){var c,l,f,h=t&u.F,d=t&u.G,p=t&u.S,m=t&u.P,g=t&u.B,v=t&u.W,y=d?i:i[e]||(i[e]={}),b=y.prototype,x=d?r:p?r[e]:(r[e]||{}).prototype;for(c in d&&(n=e),n){(l=!h&&x&&void 0!==x[c])&&s(y,c)||(f=l?x[c]:n[c],y[c]=d&&"function"!=typeof x[c]?n[c]:g&&l?o(f,r):v&&x[c]==f?function(t){var e=function e(_e327,n,r){if(this instanceof t){switch(arguments.length){case 0:return new t();case 1:return new t(_e327);case 2:return new t(_e327,n);}return new t(_e327,n,r);}return t.apply(this,arguments);};return e.prototype=t.prototype,e;}(f):m&&"function"==typeof f?o(Function.call,f):f,m&&((y.virtual||(y.virtual={}))[c]=f,t&u.R&&b&&!b[c]&&a(b,c,f)));}};u.F=1,u.G=2,u.S=4,u.P=8,u.B=16,u.W=32,u.U=64,u.R=128,t.exports=u;},function(t,e,n){var r=n(405);r(r.G,{global:n(150)});},function(t,e,n){n(406),t.exports=n(209).global;},function(t,e,n){var r=function(t){var e,n=Object.prototype,r=n.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e];}try{u({},"");}catch(t){u=function u(t,e,n){return t[e]=n;};}function c(t,e,n,r){var i=e&&e.prototype instanceof g?e:g,o=Object.create(i.prototype),a=new S(r||[]);return o._invoke=function(t,e,n){var r=f;return function(i,o){if(r===d)throw new Error("Generator is already running");if(r===p){if("throw"===i)throw o;return F();}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var s=A(a,n);if(s){if(s===m)continue;return s;}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===f)throw r=p,n.arg;n.dispatchException(n.arg);}else "return"===n.method&&n.abrupt("return",n.arg);r=d;var u=l(t,e,n);if("normal"===u.type){if(r=n.done?p:h,u.arg===m)continue;return {value:u.arg,done:n.done};}"throw"===u.type&&(r=p,n.method="throw",n.arg=u.arg);}};}(t,n,a),o;}function l(t,e,n){try{return {type:"normal",arg:t.call(e,n)};}catch(t){return {type:"throw",arg:t};}}t.wrap=c;var f="suspendedStart",h="suspendedYield",d="executing",p="completed",m={};function g(){}function v(){}function y(){}var b={};u(b,o,function(){return this;});var x=Object.getPrototypeOf,w=x&&x(x(D([])));w&&w!==n&&r.call(w,o)&&(b=w);var k=y.prototype=g.prototype=Object.create(b);function E(t){["next","throw","return"].forEach(function(e){u(t,e,function(t){return this._invoke(e,t);});});}function C(t,e){var n;this._invoke=function(i,o){function a(){return new e(function(n,a){!function n(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==_typeof$1(f)&&r.call(f,"__await")?e.resolve(f.__await).then(function(t){n("next",t,a,s);},function(t){n("throw",t,a,s);}):e.resolve(f).then(function(t){c.value=t,a(c);},function(t){return n("throw",t,a,s);});}s(u.arg);}(i,o,n,a);});}return n=n?n.then(a,a):a();};}function A(t,n){var r=t.iterator[n.method];if(r===e){if(n.delegate=null,"throw"===n.method){if(t.iterator.return&&(n.method="return",n.arg=e,A(t,n),"throw"===n.method))return m;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method");}return m;}var i=l(r,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,m;var o=i.arg;return o?o.done?(n[t.resultName]=o.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,m):o:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m);}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e);}function _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e;}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0);}function D(t){if(t){var n=t[o];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function n(){for(;++i<t.length;){if(r.call(t,i))return n.value=t[i],n.done=!1,n;}return n.value=e,n.done=!0,n;};return a.next=a;}}return {next:F};}function F(){return {value:e,done:!0};}return v.prototype=y,u(k,"constructor",y),u(y,"constructor",v),v.displayName=u(y,s,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return !!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name));},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,u(t,s,"GeneratorFunction")),t.prototype=Object.create(k),t;},t.awrap=function(t){return {__await:t};},E(C.prototype),u(C.prototype,a,function(){return this;}),t.AsyncIterator=C,t.async=function(e,n,r,i,o){void 0===o&&(o=Promise);var a=new C(c(e,n,r,i),o);return t.isGeneratorFunction(n)?a:a.next().then(function(t){return t.done?t.value:a.next();});},E(k),u(k,s,"Generator"),u(k,o,function(){return this;}),u(k,"toString",function(){return "[object Generator]";}),t.keys=function(t){var e=[];for(var n in t){e.push(n);}return e.reverse(),function n(){for(;e.length;){var r=e.pop();if(r in t)return n.value=r,n.done=!1,n;}return n.done=!0,n;};},t.values=D,S.prototype={constructor:S,reset:function reset(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(_),!t)for(var n in this){"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e);}},stop:function stop(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval;},dispatchException:function dispatchException(t){if(this.done)throw t;var n=this;function i(r,i){return s.type="throw",s.arg=t,n.next=r,i&&(n.method="next",n.arg=e),!!i;}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc);}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);}else {if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc);}}}},abrupt:function abrupt(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break;}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(a);},complete:function complete(t,e){if("throw"===t.type)throw t.arg;return "break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m;},finish:function finish(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),_(n),m;}},catch:function _catch(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var i=r.arg;_(n);}return i;}}throw new Error("illegal catch attempt");},delegateYield:function delegateYield(t,n,r){return this.delegate={iterator:D(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),m;}},t;}(t.exports);try{regeneratorRuntime=r;}catch(t){"object"==(typeof globalThis==="undefined"?"undefined":_typeof$1(globalThis))?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r);}},function(t,e,n){for(var r=n(155),i=n(82),o=n(38),a=n(16),s=n(42),u=n(96),c=n(19),l=c("iterator"),f=c("toStringTag"),h=u.Array,d={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},p=i(d),m=0;m<p.length;m++){var g,v=p[m],y=d[v],b=a[v],x=b&&b.prototype;if(x&&(x[l]||s(x,l,h),x[f]||s(x,f,v),u[v]=h,y))for(g in r){x[g]||o(x,g,r[g],!0);}}},function(t,e,n){var r=n(8),i=n(152);r(r.G+r.B,{setImmediate:i.set,clearImmediate:i.clear});},function(t,e,n){var r=n(16),i=n(8),o=n(120),a=[].slice,s=/MSIE .\./.test(o),u=function u(t){return function(e,n){var r=arguments.length>2,i=!!r&&a.call(arguments,2);return t(r?function(){("function"==typeof e?e:Function(e)).apply(this,i);}:e,n);};};i(i.G+i.B+i.F*s,{setTimeout:u(r.setTimeout),setInterval:u(r.setInterval)});},function(t,e,n){n(411),n(410),n(409),t.exports=n(24);},function(t,e,n){var r=n(8),i=n(24),o=n(16),a=n(104),s=n(216);r(r.P+r.R,"Promise",{finally:function _finally(t){var e=a(this,i.Promise||o.Promise),n="function"==typeof t;return this.then(n?function(n){return s(e,t()).then(function(){return n;});}:t,n?function(n){return s(e,t()).then(function(){throw n;});}:t);}});},function(t,e,n){n(218),n(413),t.exports=n(24).Promise.finally;},function(t,e,n){var r=n(8),i=n(210)(!0);r(r.S,"Object",{entries:function entries(t){return i(t);}});},function(t,e,n){n(415),t.exports=n(24).Object.entries;},function(t,e,n){var r=n(8),i=n(210)(!1);r(r.S,"Object",{values:function values(t){return i(t);}});},function(t,e,n){n(417),t.exports=n(24).Object.values;},function(t,e,n){var r=n(8),i=n(212),o=n(41),a=n(53),s=n(158);r(r.S,"Object",{getOwnPropertyDescriptors:function getOwnPropertyDescriptors(t){for(var e,n,r=o(t),u=a.f,c=i(r),l={},f=0;c.length>f;){void 0!==(n=u(r,e=c[f++]))&&s(l,e,n);}return l;}});},function(t,e,n){n(419),t.exports=n(24).Object.getOwnPropertyDescriptors;},function(t,e,n){n(239)("asyncIterator");},function(t,e,n){n(421),t.exports=n(174).f("asyncIterator");},function(t,e,n){n(97)("trimRight",function(t){return function(){return t(this,2);};},"trimEnd");},function(t,e,n){n(423),t.exports=n(24).String.trimRight;},function(t,e,n){n(97)("trimLeft",function(t){return function(){return t(this,1);};},"trimStart");},function(t,e,n){n(425),t.exports=n(24).String.trimLeft;},function(t,e,n){var r=n(8),i=n(211),o=n(120),a=/Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(o);r(r.P+r.F*a,"String",{padEnd:function padEnd(t){return i(this,t,arguments.length>1?arguments[1]:void 0,!1);}});},function(t,e,n){n(427),t.exports=n(24).String.padEnd;},function(t,e,n){var r=n(8),i=n(211),o=n(120),a=/Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(o);r(r.P+r.F*a,"String",{padStart:function padStart(t){return i(this,t,arguments.length>1?arguments[1]:void 0,!0);}});},function(t,e,n){n(429),t.exports=n(24).String.padStart;},function(t,e,n){var r=n(126),i=n(13),o=n(22),a=n(56),s=n(19)("isConcatSpreadable");t.exports=function t(e,n,u,c,l,f,h,d){for(var p,m,g=l,v=0,y=!!h&&a(h,d,3);v<c;){if(v in u){if(p=y?y(u[v],v,n):u[v],m=!1,i(p)&&(m=void 0!==(m=p[s])?!!m:r(p)),m&&f>0)g=t(e,n,p,o(p.length),g,f-1)-1;else {if(g>=9007199254740991)throw TypeError();e[g]=p;}g++;}v++;}return g;};},function(t,e,n){var r=n(8),i=n(431),o=n(34),a=n(22),s=n(55),u=n(224);r(r.P,"Array",{flatMap:function flatMap(t){var e,n,r=o(this);return s(t),e=a(r.length),n=u(r,0),i(n,r,r,e,0,1,t,arguments[1]),n;}}),n(77)("flatMap");},function(t,e,n){n(432),t.exports=n(24).Array.flatMap;},function(t,e,n){var r=n(8),i=n(128)(!0);r(r.P,"Array",{includes:function includes(t){return i(this,t,arguments.length>1?arguments[1]:void 0);}}),n(77)("includes");},function(t,e,n){n(434),t.exports=n(24).Array.includes;},function(t,e,n){var r=n(8),i=n(170);i&&r(r.S,"Reflect",{setPrototypeOf:function setPrototypeOf(t,e){i.check(t,e);try{return i.set(t,e),!0;}catch(t){return !1;}}});},function(t,e,n){var r=n(26),i=n(53),o=n(78),a=n(43),s=n(8),u=n(85),c=n(14),l=n(13);s(s.S,"Reflect",{set:function t(e,n,s){var f,h,d=arguments.length<4?e:arguments[3],p=i.f(c(e),n);if(!p){if(l(h=o(e)))return t(h,n,s,d);p=u(0);}if(a(p,"value")){if(!1===p.writable||!l(d))return !1;if(f=i.f(d,n)){if(f.get||f.set||!1===f.writable)return !1;f.value=s,r.f(d,n,f);}else r.f(d,n,u(0,s));return !0;}return void 0!==p.set&&(p.set.call(d,s),!0);}});},function(t,e,n){var r=n(8),i=n(14),o=Object.preventExtensions;r(r.S,"Reflect",{preventExtensions:function preventExtensions(t){i(t);try{return o&&o(t),!0;}catch(t){return !1;}}});},function(t,e,n){var r=n(8);r(r.S,"Reflect",{ownKeys:n(212)});},function(t,e,n){var r=n(8),i=n(14),o=Object.isExtensible;r(r.S,"Reflect",{isExtensible:function isExtensible(t){return i(t),!o||o(t);}});},function(t,e,n){var r=n(8);r(r.S,"Reflect",{has:function has(t,e){return e in t;}});},function(t,e,n){var r=n(8),i=n(78),o=n(14);r(r.S,"Reflect",{getPrototypeOf:function getPrototypeOf(t){return i(o(t));}});},function(t,e,n){var r=n(53),i=n(8),o=n(14);i(i.S,"Reflect",{getOwnPropertyDescriptor:function getOwnPropertyDescriptor(t,e){return r.f(o(t),e);}});},function(t,e,n){var r=n(53),i=n(78),o=n(43),a=n(8),s=n(13),u=n(14);a(a.S,"Reflect",{get:function t(e,n){var a,c,l=arguments.length<3?e:arguments[2];return u(e)===l?e[n]:(a=r.f(e,n))?o(a,"value")?a.value:void 0!==a.get?a.get.call(l):void 0:s(c=i(e))?t(c,n,l):void 0;}});},function(t,e,n){var r=n(8),i=n(14),o=function o(t){this._t=i(t),this._i=0;var e,n=this._k=[];for(e in t){n.push(e);}};n(226)(o,"Object",function(){var t,e=this._k;do{if(this._i>=e.length)return {value:void 0,done:!0};}while(!((t=e[this._i++])in this._t));return {value:t,done:!1};}),r(r.S,"Reflect",{enumerate:function enumerate(t){return new o(t);}});},function(t,e,n){var r=n(8),i=n(53).f,o=n(14);r(r.S,"Reflect",{deleteProperty:function deleteProperty(t,e){var n=i(o(t),e);return !(n&&!n.configurable)&&delete t[e];}});},function(t,e,n){var r=n(26),i=n(8),o=n(14),a=n(66);i(i.S+i.F*n(15)(function(){Reflect.defineProperty(r.f({},1,{value:1}),1,{value:2});}),"Reflect",{defineProperty:function defineProperty(t,e,n){o(t),e=a(e,!0),o(n);try{return r.f(t,e,n),!0;}catch(t){return !1;}}});},function(t,e,n){var r=n(8),i=n(80),o=n(55),a=n(14),s=n(13),u=n(15),c=n(233),l=(n(16).Reflect||{}).construct,f=u(function(){function t(){}return !(l(function(){},[],t)instanceof t);}),h=!u(function(){l(function(){});});r(r.S+r.F*(f||h),"Reflect",{construct:function construct(t,e){o(t),a(e);var n=arguments.length<3?t:o(arguments[2]);if(h&&!f)return l(t,e,n);if(t==n){switch(e.length){case 0:return new t();case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);}var r=[null];return r.push.apply(r,e),new(c.apply(t,r))();}var u=n.prototype,d=i(s(u)?u:Object.prototype),p=Function.apply.call(t,d,e);return s(p)?p:d;}});},function(t,e,n){var r=n(8),i=n(55),o=n(14),a=(n(16).Reflect||{}).apply,s=Function.apply;r(r.S+r.F*!n(15)(function(){a(function(){});}),"Reflect",{apply:function apply(t,e,n){var r=i(t),u=o(n);return a?a(r,e,u):s.call(r,e,u);}});},function(t,e,n){n(60)("Float64",8,function(t){return function(e,n,r){return t(this,e,n,r);};});},function(t,e,n){n(60)("Float32",4,function(t){return function(e,n,r){return t(this,e,n,r);};});},function(t,e,n){n(60)("Uint32",4,function(t){return function(e,n,r){return t(this,e,n,r);};});},function(t,e,n){n(60)("Int32",4,function(t){return function(e,n,r){return t(this,e,n,r);};});},function(t,e,n){n(60)("Uint16",2,function(t){return function(e,n,r){return t(this,e,n,r);};});},function(t,e,n){n(60)("Int16",2,function(t){return function(e,n,r){return t(this,e,n,r);};});},function(t,e,n){n(60)("Uint8",1,function(t){return function(e,n,r){return t(this,e,n,r);};},!0);},function(t,e,n){n(60)("Uint8",1,function(t){return function(e,n,r){return t(this,e,n,r);};});},function(t,e,n){n(60)("Int8",1,function(t){return function(e,n,r){return t(this,e,n,r);};});},function(t,e,n){var r=n(8);r(r.G+r.W+r.F*!n(118).ABV,{DataView:n(151).DataView});},function(t,e,n){var r=n(8),i=n(118),o=n(151),a=n(14),s=n(81),u=n(22),c=n(13),l=n(16).ArrayBuffer,f=n(104),h=o.ArrayBuffer,d=o.DataView,p=i.ABV&&l.isView,m=h.prototype.slice,g=i.VIEW;r(r.G+r.W+r.F*(l!==h),{ArrayBuffer:h}),r(r.S+r.F*!i.CONSTR,"ArrayBuffer",{isView:function isView(t){return p&&p(t)||c(t)&&g in t;}}),r(r.P+r.U+r.F*n(15)(function(){return !new h(2).slice(1,void 0).byteLength;}),"ArrayBuffer",{slice:function slice(t,e){if(void 0!==m&&void 0===e)return m.call(a(this),t);for(var n=a(this).byteLength,r=s(t,n),i=s(void 0===e?n:e,n),o=new(f(this,h))(u(i-r)),c=new d(this),l=new d(o),p=0;r<i;){l.setUint8(p++,c.getUint8(r++));}return o;}}),n(95)("ArrayBuffer");},function(t,e,n){var r=n(214),i=n(76);n(119)("WeakSet",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0);};},{add:function add(t){return r.def(i(this,"WeakSet"),t,!0);}},r,!1,!0);},function(t,e,n){var r,i=n(16),o=n(51)(0),a=n(38),s=n(65),u=n(235),c=n(214),l=n(13),f=n(76),h=n(76),d=!i.ActiveXObject&&"ActiveXObject"in i,p=s.getWeak,m=Object.isExtensible,g=c.ufstore,v=function v(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0);};},y={get:function get(t){if(l(t)){var e=p(t);return !0===e?g(f(this,"WeakMap")).get(t):e?e[this._i]:void 0;}},set:function set(t,e){return c.def(f(this,"WeakMap"),t,e);}},b=t.exports=n(119)("WeakMap",v,y,c,!0,!0);h&&d&&(u((r=c.getConstructor(v,"WeakMap")).prototype,y),s.NEED=!0,o(["delete","has","get","set"],function(t){var e=b.prototype,n=e[t];a(e,t,function(e,i){if(l(e)&&!m(e)){this._f||(this._f=new r());var o=this._f[t](e,i);return "set"==t?this:o;}return n.call(this,e,i);});}));},function(t,e,n){var r=n(215),i=n(76);t.exports=n(119)("Set",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0);};},{add:function add(t){return r.def(i(this,"Set"),t=0===t?0:t,t);}},r);},function(t,e,n){var r=n(215),i=n(76);t.exports=n(119)("Map",function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0);};},{get:function get(t){var e=r.getEntry(i(this,"Map"),t);return e&&e.v;},set:function set(t,e){return r.def(i(this,"Map"),0===t?0:t,e);}},r,!0);},function(t,e){t.exports=function(t){try{return {e:!1,v:t()};}catch(t){return {e:!0,v:t};}};},function(t,e,n){var r=n(16),i=n(152).set,o=r.MutationObserver||r.WebKitMutationObserver,a=r.process,s=r.Promise,u="process"==n(62)(a);t.exports=function(){var t,e,n,c=function c(){var r,i;for(u&&(r=a.domain)&&r.exit();t;){i=t.fn,t=t.next;try{i();}catch(r){throw t?n():e=void 0,r;}}e=void 0,r&&r.enter();};if(u)n=function n(){a.nextTick(c);};else if(!o||r.navigator&&r.navigator.standalone){if(s&&s.resolve){var l=s.resolve(void 0);n=function n(){l.then(c);};}else n=function n(){i.call(r,c);};}else {var f=!0,h=document.createTextNode("");new o(c).observe(h,{characterData:!0}),n=function n(){h.data=f=!f;};}return function(r){var i={fn:r,next:void 0};e&&(e.next=i),t||(t=i,n()),e=i;};};},function(t,e,n){var r=n(161),i=n(14),o=n(104),a=n(153),s=n(22),u=n(123),c=n(154),l=n(15),f=Math.min,h=[].push,d=!l(function(){});n(122)("split",2,function(t,e,n,l){var p;return p="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(t,e){var i=String(this);if(void 0===t&&0===e)return [];if(!r(t))return n.call(i,t,e);for(var o,a,s,u=[],l=(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.unicode?"u":"")+(t.sticky?"y":""),f=0,d=void 0===e?4294967295:e>>>0,p=new RegExp(t.source,l+"g");(o=c.call(p,i))&&!((a=p.lastIndex)>f&&(u.push(i.slice(f,o.index)),o.length>1&&o.index<i.length&&h.apply(u,o.slice(1)),s=o[0].length,f=a,u.length>=d));){p.lastIndex===o.index&&p.lastIndex++;}return f===i.length?!s&&p.test("")||u.push(""):u.push(i.slice(f)),u.length>d?u.slice(0,d):u;}:"0".split(void 0,0).length?function(t,e){return void 0===t&&0===e?[]:n.call(this,t,e);}:n,[function(n,r){var i=t(this),o=void 0==n?void 0:n[e];return void 0!==o?o.call(n,i,r):p.call(String(i),n,r);},function(t,e){var r=l(p,t,this,e,p!==n);if(r.done)return r.value;var c=i(t),h=String(this),m=o(c,RegExp),g=c.unicode,v=(c.ignoreCase?"i":"")+(c.multiline?"m":"")+(c.unicode?"u":"")+(d?"y":"g"),y=new m(d?c:"^(?:"+c.source+")",v),b=void 0===e?4294967295:e>>>0;if(0===b)return [];if(0===h.length)return null===u(y,h)?[h]:[];for(var x=0,w=0,k=[];w<h.length;){y.lastIndex=d?w:0;var E,C=u(y,d?h:h.slice(w));if(null===C||(E=f(s(y.lastIndex+(d?0:w)),h.length))===x)w=a(h,w,g);else {if(k.push(h.slice(x,w)),k.length===b)return k;for(var A=1;A<=C.length-1;A++){if(k.push(C[A]),k.length===b)return k;}w=x=E;}}return k.push(h.slice(x)),k;}];});},function(t,e,n){var r=n(14),i=n(234),o=n(123);n(122)("search",1,function(t,e,n,a){return [function(n){var r=t(this),i=void 0==n?void 0:n[e];return void 0!==i?i.call(n,r):new RegExp(n)[e](String(r));},function(t){var e=a(n,t,this);if(e.done)return e.value;var s=r(t),u=String(this),c=s.lastIndex;i(c,0)||(s.lastIndex=0);var l=o(s,u);return i(s.lastIndex,c)||(s.lastIndex=c),null===l?-1:l.index;}];});},function(t,e,n){var r=n(14),i=n(34),o=n(22),a=n(54),s=n(153),u=n(123),c=Math.max,l=Math.min,f=Math.floor,h=/\$([$&`']|\d\d?|<[^>]*>)/g,d=/\$([$&`']|\d\d?)/g,p=function p(t){return void 0===t?t:String(t);};n(122)("replace",2,function(t,e,n,m){return [function(r,i){var o=t(this),a=void 0==r?void 0:r[e];return void 0!==a?a.call(r,o,i):n.call(String(o),r,i);},function(t,e){var i=m(n,t,this,e);if(i.done)return i.value;var f=r(t),h=String(this),d="function"==typeof e;d||(e=String(e));var v=f.global;if(v){var y=f.unicode;f.lastIndex=0;}for(var b=[];;){var x=u(f,h);if(null===x)break;if(b.push(x),!v)break;""===String(x[0])&&(f.lastIndex=s(h,o(f.lastIndex),y));}for(var w="",k=0,E=0;E<b.length;E++){x=b[E];for(var C=String(x[0]),A=c(l(a(x.index),h.length),0),O=[],_=1;_<x.length;_++){O.push(p(x[_]));}var S=x.groups;if(d){var D=[C].concat(O,A,h);void 0!==S&&D.push(S);var F=String(e.apply(void 0,D));}else F=g(C,h,A,O,S,e);A>=k&&(w+=h.slice(k,A)+F,k=A+C.length);}return w+h.slice(k);}];function g(t,e,r,o,a,s){var u=r+t.length,c=o.length,l=d;return void 0!==a&&(a=i(a),l=h),n.call(s,l,function(n,i){var s;switch(i.charAt(0)){case"$":return "$";case"&":return t;case"`":return e.slice(0,r);case"'":return e.slice(u);case"<":s=a[i.slice(1,-1)];break;default:var l=+i;if(0===l)return n;if(l>c){var h=f(l/10);return 0===h?n:h<=c?void 0===o[h-1]?i.charAt(1):o[h-1]+i.charAt(1):n;}s=o[l-1];}return void 0===s?"":s;});}});},function(t,e,n){var r=n(14),i=n(22),o=n(153),a=n(123);n(122)("match",1,function(t,e,n,s){return [function(n){var r=t(this),i=void 0==n?void 0:n[e];return void 0!==i?i.call(n,r):new RegExp(n)[e](String(r));},function(t){var e=s(n,t,this);if(e.done)return e.value;var u=r(t),c=String(this);if(!u.global)return a(u,c);var l=u.unicode;u.lastIndex=0;for(var f,h=[],d=0;null!==(f=a(u,c));){var p=String(f[0]);h[d]=p,""===p&&(u.lastIndex=o(c,i(u.lastIndex),l)),d++;}return 0===d?null:h;}];});},function(t,e,n){n(219);var r=n(14),i=n(124),o=n(27),a=/./.toString,s=function s(t){n(38)(RegExp.prototype,"toString",t,!0);};n(15)(function(){return "/a/b"!=a.call({source:"a",flags:"b"});})?s(function(){var t=r(this);return "/".concat(t.source,"/","flags"in t?t.flags:!o&&t instanceof RegExp?i.call(t):void 0);}):"toString"!=a.name&&s(function(){return a.call(this);});},function(t,e,n){var r=n(16),i=n(168),o=n(26).f,a=n(79).f,s=n(161),u=n(124),_c31=r.RegExp,l=_c31,f=_c31.prototype,h=/a/g,d=/a/g,p=new _c31(h)!==h;if(n(27)&&(!p||n(15)(function(){return d[n(19)("match")]=!1,_c31(h)!=h||_c31(d)==d||"/a/i"!=_c31(h,"i");}))){_c31=function c(t,e){var n=this instanceof _c31,r=s(t),o=void 0===e;return !n&&r&&t.constructor===_c31&&o?t:i(p?new l(r&&!o?t.source:t,e):l((r=t instanceof _c31)?t.source:t,r&&o?u.call(t):e),n?this:f,_c31);};for(var m=function m(t){(t in _c31)||o(_c31,t,{configurable:!0,get:function get(){return l[t];},set:function set(e){l[t]=e;}});},g=a(l),v=0;g.length>v;){m(g[v++]);}f.constructor=_c31,_c31.prototype=f,n(38)(r,"RegExp",_c31);}n(95)("RegExp");},function(t,e,n){n(95)("Array");},function(t,e,n){var r=n(8),i=n(51)(6),o="findIndex",a=!0;o in[]&&Array(1)[o](function(){a=!1;}),r(r.P+r.F*a,"Array",{findIndex:function findIndex(t){return i(this,t,arguments.length>1?arguments[1]:void 0);}}),n(77)(o);},function(t,e,n){var r=n(8),i=n(51)(5),o=!0;"find"in[]&&Array(1).find(function(){o=!1;}),r(r.P+r.F*o,"Array",{find:function find(t){return i(this,t,arguments.length>1?arguments[1]:void 0);}}),n(77)("find");},function(t,e,n){var r=n(8);r(r.P,"Array",{fill:n(156)}),n(77)("fill");},function(t,e,n){var r=n(8);r(r.P,"Array",{copyWithin:n(222)}),n(77)("copyWithin");},function(t,e,n){var r=n(8),i=n(41),o=n(54),a=n(22),s=[].lastIndexOf,u=!!s&&1/[1].lastIndexOf(1,-0)<0;r(r.P+r.F*(u||!n(49)(s)),"Array",{lastIndexOf:function lastIndexOf(t){if(u)return s.apply(this,arguments)||0;var e=i(this),n=a(e.length),r=n-1;for(arguments.length>1&&(r=Math.min(r,o(arguments[1]))),r<0&&(r=n+r);r>=0;r--){if(r in e&&e[r]===t)return r||0;}return -1;}});},function(t,e,n){var r=n(8),i=n(128)(!1),o=[].indexOf,a=!!o&&1/[1].indexOf(1,-0)<0;r(r.P+r.F*(a||!n(49)(o)),"Array",{indexOf:function indexOf(t){return a?o.apply(this,arguments)||0:i(this,t,arguments[1]);}});},function(t,e,n){var r=n(8),i=n(223);r(r.P+r.F*!n(49)([].reduceRight,!0),"Array",{reduceRight:function reduceRight(t){return i(this,t,arguments.length,arguments[1],!0);}});},function(t,e,n){var r=n(8),i=n(223);r(r.P+r.F*!n(49)([].reduce,!0),"Array",{reduce:function reduce(t){return i(this,t,arguments.length,arguments[1],!1);}});},function(t,e,n){var r=n(8),i=n(51)(4);r(r.P+r.F*!n(49)([].every,!0),"Array",{every:function every(t){return i(this,t,arguments[1]);}});},function(t,e,n){var r=n(8),i=n(51)(3);r(r.P+r.F*!n(49)([].some,!0),"Array",{some:function some(t){return i(this,t,arguments[1]);}});},function(t,e,n){var r=n(8),i=n(51)(2);r(r.P+r.F*!n(49)([].filter,!0),"Array",{filter:function filter(t){return i(this,t,arguments[1]);}});},function(t,e,n){var r=n(8),i=n(51)(1);r(r.P+r.F*!n(49)([].map,!0),"Array",{map:function map(t){return i(this,t,arguments[1]);}});},function(t,e,n){var r=n(13),i=n(126),o=n(19)("species");t.exports=function(t){var e;return i(t)&&("function"!=typeof(e=t.constructor)||e!==Array&&!i(e.prototype)||(e=void 0),r(e)&&null===(e=e[o])&&(e=void 0)),void 0===e?Array:e;};},function(t,e,n){var r=n(8),i=n(51)(0),o=n(49)([].forEach,!0);r(r.P+r.F*!o,"Array",{forEach:function forEach(t){return i(this,t,arguments[1]);}});},function(t,e,n){var r=n(8),i=n(55),o=n(34),a=n(15),s=[].sort,u=[1,2,3];r(r.P+r.F*(a(function(){u.sort(void 0);})||!a(function(){u.sort(null);})||!n(49)(s)),"Array",{sort:function sort(t){return void 0===t?s.call(o(this)):s.call(o(this),i(t));}});},function(t,e,n){var r=n(8),i=n(171),o=n(62),a=n(81),s=n(22),u=[].slice;r(r.P+r.F*n(15)(function(){i&&u.call(i);}),"Array",{slice:function slice(t,e){var n=s(this.length),r=o(this);if(e=void 0===e?n:e,"Array"==r)return u.call(this,t,e);for(var i=a(t,n),c=a(e,n),l=s(c-i),f=new Array(l),h=0;h<l;h++){f[h]="String"==r?this.charAt(i+h):this[i+h];}return f;}});},function(t,e,n){var r=n(8),i=n(41),o=[].join;r(r.P+r.F*(n(107)!=Object||!n(49)(o)),"Array",{join:function join(t){return o.call(i(this),void 0===t?",":t);}});},function(t,e,n){var r=n(8),i=n(158);r(r.S+r.F*n(15)(function(){function t(){}return !(Array.of.call(t)instanceof t);}),"Array",{of:function of(){for(var t=0,e=arguments.length,n=new("function"==typeof this?this:Array)(e);e>t;){i(n,t,arguments[t++]);}return n.length=e,n;}});},function(t,e,n){var r=n(56),i=n(8),o=n(34),a=n(225),s=n(159),u=n(22),c=n(158),l=n(157);i(i.S+i.F*!n(125)(function(t){Array.from(t);}),"Array",{from:function from(t){var e,n,i,f,h=o(t),d="function"==typeof this?this:Array,p=arguments.length,m=p>1?arguments[1]:void 0,g=void 0!==m,v=0,y=l(h);if(g&&(m=r(m,p>2?arguments[2]:void 0,2)),void 0==y||d==Array&&s(y))for(n=new d(e=u(h.length));e>v;v++){c(n,v,g?m(h[v],v):h[v]);}else for(f=y.call(h),n=new d();!(i=f.next()).done;v++){c(n,v,g?a(f,m,[i.value,v],!0):i.value);}return n.length=v,n;}});},function(t,e,n){var r=n(8);r(r.S,"Array",{isArray:n(126)});},function(t,e,n){var r=n(14),i=n(66);t.exports=function(t){if("string"!==t&&"number"!==t&&"default"!==t)throw TypeError("Incorrect hint");return i(r(this),"number"!=t);};},function(t,e,n){var r=n(19)("toPrimitive"),i=Date.prototype;r in i||n(42)(i,r,n(494));},function(t,e,n){var r=Date.prototype,i=r.toString,o=r.getTime;new Date(NaN)+""!="Invalid Date"&&n(38)(r,"toString",function(){var t=o.call(this);return t==t?i.call(this):"Invalid Date";});},function(t,e,n){var r=n(15),i=Date.prototype.getTime,o=Date.prototype.toISOString,a=function a(t){return t>9?t:"0"+t;};t.exports=r(function(){return "0385-07-25T07:06:39.999Z"!=o.call(new Date(-5e13-1));})||!r(function(){o.call(new Date(NaN));})?function(){if(!isFinite(i.call(this)))throw RangeError("Invalid time value");var t=this,e=t.getUTCFullYear(),n=t.getUTCMilliseconds(),r=e<0?"-":e>9999?"+":"";return r+("00000"+Math.abs(e)).slice(r?-6:-4)+"-"+a(t.getUTCMonth()+1)+"-"+a(t.getUTCDate())+"T"+a(t.getUTCHours())+":"+a(t.getUTCMinutes())+":"+a(t.getUTCSeconds())+"."+(n>99?n:"0"+a(n))+"Z";}:o;},function(t,e,n){var r=n(8),i=n(497);r(r.P+r.F*(Date.prototype.toISOString!==i),"Date",{toISOString:i});},function(t,e,n){var r=n(8),i=n(34),o=n(66);r(r.P+r.F*n(15)(function(){return null!==new Date(NaN).toJSON()||1!==Date.prototype.toJSON.call({toISOString:function toISOString(){return 1;}});}),"Date",{toJSON:function toJSON(t){var e=i(this),n=o(e);return "number"!=typeof n||isFinite(n)?e.toISOString():null;}});},function(t,e,n){var r=n(8);r(r.S,"Date",{now:function now(){return new Date().getTime();}});},function(t,e,n){n(37)("sup",function(t){return function(){return t(this,"sup","","");};});},function(t,e,n){n(37)("sub",function(t){return function(){return t(this,"sub","","");};});},function(t,e,n){n(37)("strike",function(t){return function(){return t(this,"strike","","");};});},function(t,e,n){n(37)("small",function(t){return function(){return t(this,"small","","");};});},function(t,e,n){n(37)("link",function(t){return function(e){return t(this,"a","href",e);};});},function(t,e,n){n(37)("italics",function(t){return function(){return t(this,"i","","");};});},function(t,e,n){n(37)("fontsize",function(t){return function(e){return t(this,"font","size",e);};});},function(t,e,n){n(37)("fontcolor",function(t){return function(e){return t(this,"font","color",e);};});},function(t,e,n){n(37)("fixed",function(t){return function(){return t(this,"tt","","");};});},function(t,e,n){n(37)("bold",function(t){return function(){return t(this,"b","","");};});},function(t,e,n){n(37)("blink",function(t){return function(){return t(this,"blink","","");};});},function(t,e,n){n(37)("big",function(t){return function(){return t(this,"big","","");};});},function(t,e,n){n(37)("anchor",function(t){return function(e){return t(this,"a","name",e);};});},function(t,e,n){var r=n(8),i=n(22),o=n(162),a="".startsWith;r(r.P+r.F*n(160)("startsWith"),"String",{startsWith:function startsWith(t){var e=o(this,t,"startsWith"),n=i(Math.min(arguments.length>1?arguments[1]:void 0,e.length)),r=String(t);return a?a.call(e,r,n):e.slice(n,n+r.length)===r;}});},function(t,e,n){var r=n(8);r(r.P,"String",{repeat:n(167)});},function(t,e,n){var r=n(8),i=n(162);r(r.P+r.F*n(160)("includes"),"String",{includes:function includes(t){return !!~i(this,t,"includes").indexOf(t,arguments.length>1?arguments[1]:void 0);}});},function(t,e,n){var r=n(8),i=n(22),o=n(162),a="".endsWith;r(r.P+r.F*n(160)("endsWith"),"String",{endsWith:function endsWith(t){var e=o(this,t,"endsWith"),n=arguments.length>1?arguments[1]:void 0,r=i(e.length),s=void 0===n?r:Math.min(i(n),r),u=String(t);return a?a.call(e,u,s):e.slice(s-u.length,s)===u;}});},function(t,e,n){var r=n(8),i=n(164)(!1);r(r.P,"String",{codePointAt:function codePointAt(t){return i(this,t);}});},function(t,e,n){var r=n(164)(!0);n(163)(String,"String",function(t){this._t=String(t),this._i=0;},function(){var t,e=this._t,n=this._i;return n>=e.length?{value:void 0,done:!0}:(t=r(e,n),this._i+=t.length,{value:t,done:!1});});},function(t,e,n){n(97)("trim",function(t){return function(){return t(this,3);};});},function(t,e,n){var r=n(8),i=n(41),o=n(22);r(r.S,"String",{raw:function raw(t){for(var e=i(t.raw),n=o(e.length),r=arguments.length,a=[],s=0;n>s;){a.push(String(e[s++])),s<r&&a.push(String(arguments[s]));}return a.join("");}});},function(t,e,n){var r=n(8),i=n(81),o=String.fromCharCode,a=String.fromCodePoint;r(r.S+r.F*(!!a&&1!=a.length),"String",{fromCodePoint:function fromCodePoint(t){for(var e,n=[],r=arguments.length,a=0;r>a;){if(e=+arguments[a++],i(e,1114111)!==e)throw RangeError(e+" is not a valid code point");n.push(e<65536?o(e):o(55296+((e-=65536)>>10),e%1024+56320));}return n.join("");}});},function(t,e,n){var r=n(8);r(r.S,"Math",{trunc:function trunc(t){return (t>0?Math.floor:Math.ceil)(t);}});},function(t,e,n){var r=n(8),i=n(165),o=Math.exp;r(r.S,"Math",{tanh:function tanh(t){var e=i(t=+t),n=i(-t);return e==1/0?1:n==1/0?-1:(e-n)/(o(t)+o(-t));}});},function(t,e,n){var r=n(8),i=n(165),o=Math.exp;r(r.S+r.F*n(15)(function(){return -2e-17!=!Math.sinh(-2e-17);}),"Math",{sinh:function sinh(t){return Math.abs(t=+t)<1?(i(t)-i(-t))/2:(o(t-1)-o(-t-1))*(Math.E/2);}});},function(t,e,n){var r=n(8);r(r.S,"Math",{sign:n(166)});},function(t,e,n){var r=n(8);r(r.S,"Math",{log2:function log2(t){return Math.log(t)/Math.LN2;}});},function(t,e,n){var r=n(8);r(r.S,"Math",{log1p:n(227)});},function(t,e,n){var r=n(8);r(r.S,"Math",{log10:function log10(t){return Math.log(t)*Math.LOG10E;}});},function(t,e,n){var r=n(8),i=Math.imul;r(r.S+r.F*n(15)(function(){return -5!=i(4294967295,5)||2!=i.length;}),"Math",{imul:function imul(t,e){var n=+t,r=+e,i=65535&n,o=65535&r;return 0|i*o+((65535&n>>>16)*o+i*(65535&r>>>16)<<16>>>0);}});},function(t,e,n){var r=n(8),i=Math.abs;r(r.S,"Math",{hypot:function hypot(t,e){for(var n,r,o=0,a=0,s=arguments.length,u=0;a<s;){u<(n=i(arguments[a++]))?(o=o*(r=u/n)*r+1,u=n):o+=n>0?(r=n/u)*r:n;}return u===1/0?1/0:u*Math.sqrt(o);}});},function(t,e,n){var r=n(166),i=Math.pow,o=i(2,-52),a=i(2,-23),s=i(2,127)*(2-a),u=i(2,-126);t.exports=Math.fround||function(t){var e,n,i=Math.abs(t),c=r(t);return i<u?c*function(t){return t+1/o-1/o;}(i/u/a)*u*a:(n=(e=(1+a/o)*i)-(e-i))>s||n!=n?c*(1/0):c*n;};},function(t,e,n){var r=n(8);r(r.S,"Math",{fround:n(532)});},function(t,e,n){var r=n(8),i=n(165);r(r.S+r.F*(i!=Math.expm1),"Math",{expm1:i});},function(t,e,n){var r=n(8),i=Math.exp;r(r.S,"Math",{cosh:function cosh(t){return (i(t=+t)+i(-t))/2;}});},function(t,e,n){var r=n(8);r(r.S,"Math",{clz32:function clz32(t){return (t>>>=0)?31-Math.floor(Math.log(t+.5)*Math.LOG2E):32;}});},function(t,e,n){var r=n(8),i=n(166);r(r.S,"Math",{cbrt:function cbrt(t){return i(t=+t)*Math.pow(Math.abs(t),1/3);}});},function(t,e,n){var r=n(8),i=Math.atanh;r(r.S+r.F*!(i&&1/i(-0)<0),"Math",{atanh:function atanh(t){return 0==(t=+t)?t:Math.log((1+t)/(1-t))/2;}});},function(t,e,n){var r=n(8),i=Math.asinh;r(r.S+r.F*!(i&&1/i(0)>0),"Math",{asinh:function t(e){return isFinite(e=+e)&&0!=e?e<0?-t(-e):Math.log(e+Math.sqrt(e*e+1)):e;}});},function(t,e,n){var r=n(8),i=n(227),o=Math.sqrt,a=Math.acosh;r(r.S+r.F*!(a&&710==Math.floor(a(Number.MAX_VALUE))&&a(1/0)==1/0),"Math",{acosh:function acosh(t){return (t=+t)<1?NaN:t>94906265.62425156?Math.log(t)+Math.LN2:i(t-1+o(t-1)*o(t+1));}});},function(t,e,n){var r=n(8),i=n(231);r(r.S+r.F*(Number.parseInt!=i),"Number",{parseInt:i});},function(t,e,n){var r=n(8),i=n(230);r(r.S+r.F*(Number.parseFloat!=i),"Number",{parseFloat:i});},function(t,e,n){var r=n(8);r(r.S,"Number",{MIN_SAFE_INTEGER:-9007199254740991});},function(t,e,n){var r=n(8);r(r.S,"Number",{MAX_SAFE_INTEGER:9007199254740991});},function(t,e,n){var r=n(8),i=n(228),o=Math.abs;r(r.S,"Number",{isSafeInteger:function isSafeInteger(t){return i(t)&&o(t)<=9007199254740991;}});},function(t,e,n){var r=n(8);r(r.S,"Number",{isNaN:function isNaN(t){return t!=t;}});},function(t,e,n){var r=n(8);r(r.S,"Number",{isInteger:n(228)});},function(t,e,n){var r=n(8),i=n(16).isFinite;r(r.S,"Number",{isFinite:function isFinite(t){return "number"==typeof t&&i(t);}});},function(t,e,n){var r=n(8);r(r.S,"Number",{EPSILON:Math.pow(2,-52)});},function(t,e,n){var r=n(8),i=n(15),o=n(229),a=1..toPrecision;r(r.P+r.F*(i(function(){return "1"!==a.call(1,void 0);})||!i(function(){a.call({});})),"Number",{toPrecision:function toPrecision(t){var e=o(this,"Number#toPrecision: incorrect invocation!");return void 0===t?a.call(e):a.call(e,t);}});},function(t,e,n){var r=n(8),i=n(54),o=n(229),a=n(167),s=1..toFixed,u=Math.floor,c=[0,0,0,0,0,0],l="Number.toFixed: incorrect invocation!",f=function f(t,e){for(var n=-1,r=e;++n<6;){r+=t*c[n],c[n]=r%1e7,r=u(r/1e7);}},h=function h(t){for(var e=6,n=0;--e>=0;){n+=c[e],c[e]=u(n/t),n=n%t*1e7;}},d=function d(){for(var t=6,e="";--t>=0;){if(""!==e||0===t||0!==c[t]){var n=String(c[t]);e=""===e?n:e+a.call("0",7-n.length)+n;}}return e;},p=function p(t,e,n){return 0===e?n:e%2==1?p(t,e-1,n*t):p(t*t,e/2,n);};r(r.P+r.F*(!!s&&("0.000"!==8e-5.toFixed(3)||"1"!==.9.toFixed(0)||"1.25"!==1.255.toFixed(2)||"1000000000000000128"!==0xde0b6b3a7640080.toFixed(0))||!n(15)(function(){s.call({});})),"Number",{toFixed:function toFixed(t){var e,n,r,s,u=o(this,l),c=i(t),m="",g="0";if(c<0||c>20)throw RangeError(l);if(u!=u)return "NaN";if(u<=-1e21||u>=1e21)return String(u);if(u<0&&(m="-",u=-u),u>1e-21)if(n=(e=function(t){for(var e=0,n=t;n>=4096;){e+=12,n/=4096;}for(;n>=2;){e+=1,n/=2;}return e;}(u*p(2,69,1))-69)<0?u*p(2,-e,1):u/p(2,e,1),n*=4503599627370496,(e=52-e)>0){for(f(0,n),r=c;r>=7;){f(1e7,0),r-=7;}for(f(p(10,r,1),0),r=e-1;r>=23;){h(1<<23),r-=23;}h(1<<r),f(1,1),h(2),g=d();}else f(0,n),f(1<<-e,0),g=d()+a.call("0",c);return g=c>0?m+((s=g.length)<=c?"0."+a.call("0",c-s)+g:g.slice(0,s-c)+"."+g.slice(s-c)):m+g;}});},function(t,e,n){var r=n(16),i=n(43),o=n(62),a=n(168),s=n(66),u=n(15),c=n(79).f,l=n(53).f,f=n(26).f,h=n(97).trim,_d11=r.Number,p=_d11,m=_d11.prototype,g="Number"==o(n(80)(m)),v=("trim"in String.prototype),y=function y(t){var e=s(t,!1);if("string"==typeof e&&e.length>2){var n,r,i,o=(e=v?e.trim():h(e,3)).charCodeAt(0);if(43===o||45===o){if(88===(n=e.charCodeAt(2))||120===n)return NaN;}else if(48===o){switch(e.charCodeAt(1)){case 66:case 98:r=2,i=49;break;case 79:case 111:r=8,i=55;break;default:return +e;}for(var a,u=e.slice(2),c=0,l=u.length;c<l;c++){if((a=u.charCodeAt(c))<48||a>i)return NaN;}return parseInt(u,r);}}return +e;};if(!_d11(" 0o1")||!_d11("0b1")||_d11("+0x1")){_d11=function d(t){var e=arguments.length<1?0:t,n=this;return n instanceof _d11&&(g?u(function(){m.valueOf.call(n);}):"Number"!=o(n))?a(new p(y(e)),n,_d11):y(e);};for(var b,x=n(27)?c(p):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger".split(","),w=0;x.length>w;w++){i(p,b=x[w])&&!i(_d11,b)&&f(_d11,b,l(p,b));}_d11.prototype=m,m.constructor=_d11,n(38)(r,"Number",_d11);}},function(t,e,n){var r=n(8),i=n(230);r(r.G+r.F*(parseFloat!=i),{parseFloat:i});},function(t,e,n){var r=n(8),i=n(231);r(r.G+r.F*(parseInt!=i),{parseInt:i});},function(t,e,n){var r=n(13),i=n(78),o=n(19)("hasInstance"),a=Function.prototype;o in a||n(26).f(a,o,{value:function value(t){if("function"!=typeof this||!r(t))return !1;if(!r(this.prototype))return t instanceof this;for(;t=i(t);){if(this.prototype===t)return !0;}return !1;}});},function(t,e,n){var r=n(26).f,i=Function.prototype,o=/^\s*function ([^ (]*)/;"name"in i||n(27)&&r(i,"name",{configurable:!0,get:function get(){try{return (""+this).match(o)[1];}catch(t){return "";}}});},function(t,e,n){var r=n(8);r(r.P,"Function",{bind:n(233)});},function(t,e,n){var r=n(105),i={};i[n(19)("toStringTag")]="z",i+""!="[object z]"&&n(38)(Object.prototype,"toString",function(){return "[object "+r(this)+"]";},!0);},function(t,e,n){var r=n(8);r(r.S,"Object",{setPrototypeOf:n(170).set});},function(t,e,n){var r=n(8);r(r.S,"Object",{is:n(234)});},function(t,e,n){var r=n(8);r(r.S+r.F,"Object",{assign:n(235)});},function(t,e,n){var r=n(13);n(52)("isExtensible",function(t){return function(e){return !!r(e)&&(!t||t(e));};});},function(t,e,n){var r=n(13);n(52)("isSealed",function(t){return function(e){return !r(e)||!!t&&t(e);};});},function(t,e,n){var r=n(13);n(52)("isFrozen",function(t){return function(e){return !r(e)||!!t&&t(e);};});},function(t,e,n){var r=n(13),i=n(65).onFreeze;n(52)("preventExtensions",function(t){return function(e){return t&&r(e)?t(i(e)):e;};});},function(t,e,n){var r=n(13),i=n(65).onFreeze;n(52)("seal",function(t){return function(e){return t&&r(e)?t(i(e)):e;};});},function(t,e,n){var r=n(13),i=n(65).onFreeze;n(52)("freeze",function(t){return function(e){return t&&r(e)?t(i(e)):e;};});},function(t,e,n){n(52)("getOwnPropertyNames",function(){return n(236).f;});},function(t,e,n){var r=n(34),i=n(82);n(52)("keys",function(){return function(t){return i(r(t));};});},function(t,e,n){var r=n(34),i=n(78);n(52)("getPrototypeOf",function(){return function(t){return i(r(t));};});},function(t,e,n){var r=n(41),i=n(53).f;n(52)("getOwnPropertyDescriptor",function(){return function(t,e){return i(r(t),e);};});},function(t,e,n){var r=n(8);r(r.S+r.F*!n(27),"Object",{defineProperties:n(237)});},function(t,e,n){var r=n(8);r(r.S+r.F*!n(27),"Object",{defineProperty:n(26).f});},function(t,e,n){var r=n(8);r(r.S,"Object",{create:n(80)});},function(t,e,n){var r=n(82),i=n(127),o=n(106);t.exports=function(t){var e=r(t),n=i.f;if(n)for(var a,s=n(t),u=o.f,c=0;s.length>c;){u.call(t,a=s[c++])&&e.push(a);}return e;};},function(t,e,n){t.exports=n(129)("native-function-to-string",Function.toString);},function(t,e,n){var r=n(16),i=n(43),o=n(27),a=n(8),s=n(38),u=n(65).KEY,c=n(15),l=n(129),f=n(98),h=n(84),d=n(19),p=n(174),m=n(239),g=n(575),v=n(126),y=n(14),b=n(13),x=n(34),w=n(41),k=n(66),E=n(85),C=n(80),A=n(236),O=n(53),_=n(127),S=n(26),D=n(82),F=O.f,T=S.f,N=A.f,_I2=r.Symbol,R=r.JSON,M=R&&R.stringify,j=d("_hidden"),B=d("toPrimitive"),P={}.propertyIsEnumerable,L=l("symbol-registry"),z=l("symbols"),U=l("op-symbols"),W=Object.prototype,V="function"==typeof _I2&&!!_.f,q=r.QObject,$=!q||!q.prototype||!q.prototype.findChild,H=o&&c(function(){return 7!=C(T({},"a",{get:function get(){return T(this,"a",{value:7}).a;}})).a;})?function(t,e,n){var r=F(W,e);r&&delete W[e],T(t,e,n),r&&t!==W&&T(W,e,r);}:T,G=function G(t){var e=z[t]=C(_I2.prototype);return e._k=t,e;},K=V&&"symbol"==_typeof$1(_I2.iterator)?function(t){return "symbol"==_typeof$1(t);}:function(t){return t instanceof _I2;},X=function X(t,e,n){return t===W&&X(U,e,n),y(t),e=k(e,!0),y(n),i(z,e)?(n.enumerable?(i(t,j)&&t[j][e]&&(t[j][e]=!1),n=C(n,{enumerable:E(0,!1)})):(i(t,j)||T(t,j,E(1,{})),t[j][e]=!0),H(t,e,n)):T(t,e,n);},Y=function Y(t,e){y(t);for(var n,r=g(e=w(e)),i=0,o=r.length;o>i;){X(t,n=r[i++],e[n]);}return t;},J=function J(t){var e=P.call(this,t=k(t,!0));return !(this===W&&i(z,t)&&!i(U,t))&&(!(e||!i(this,t)||!i(z,t)||i(this,j)&&this[j][t])||e);},Q=function Q(t,e){if(t=w(t),e=k(e,!0),t!==W||!i(z,e)||i(U,e)){var n=F(t,e);return !n||!i(z,e)||i(t,j)&&t[j][e]||(n.enumerable=!0),n;}},Z=function Z(t){for(var e,n=N(w(t)),r=[],o=0;n.length>o;){i(z,e=n[o++])||e==j||e==u||r.push(e);}return r;},tt=function tt(t){for(var e,n=t===W,r=N(n?U:w(t)),o=[],a=0;r.length>a;){!i(z,e=r[a++])||n&&!i(W,e)||o.push(z[e]);}return o;};V||(s((_I2=function I(){if(this instanceof _I2)throw TypeError("Symbol is not a constructor!");var t=h(arguments.length>0?arguments[0]:void 0),e=function e(n){this===W&&e.call(U,n),i(this,j)&&i(this[j],t)&&(this[j][t]=!1),H(this,t,E(1,n));};return o&&$&&H(W,t,{configurable:!0,set:e}),G(t);}).prototype,"toString",function(){return this._k;}),O.f=Q,S.f=X,n(79).f=A.f=Z,n(106).f=J,_.f=tt,o&&!n(83)&&s(W,"propertyIsEnumerable",J,!0),p.f=function(t){return G(d(t));}),a(a.G+a.W+a.F*!V,{Symbol:_I2});for(var et="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),nt=0;et.length>nt;){d(et[nt++]);}for(var rt=D(d.store),it=0;rt.length>it;){m(rt[it++]);}a(a.S+a.F*!V,"Symbol",{for:function _for(t){return i(L,t+="")?L[t]:L[t]=_I2(t);},keyFor:function keyFor(t){if(!K(t))throw TypeError(t+" is not a symbol!");for(var e in L){if(L[e]===t)return e;}},useSetter:function useSetter(){$=!0;},useSimple:function useSimple(){$=!1;}}),a(a.S+a.F*!V,"Object",{create:function create(t,e){return void 0===e?C(t):Y(C(t),e);},defineProperty:X,defineProperties:Y,getOwnPropertyDescriptor:Q,getOwnPropertyNames:Z,getOwnPropertySymbols:tt});var ot=c(function(){_.f(1);});a(a.S+a.F*ot,"Object",{getOwnPropertySymbols:function getOwnPropertySymbols(t){return _.f(x(t));}}),R&&a(a.S+a.F*(!V||c(function(){var t=_I2();return "[null]"!=M([t])||"{}"!=M({a:t})||"{}"!=M(Object(t));})),"JSON",{stringify:function stringify(t){for(var e,n,r=[t],i=1;arguments.length>i;){r.push(arguments[i++]);}if(n=e=r[1],(b(e)||void 0!==t)&&!K(t))return v(e)||(e=function e(t,_e328){if("function"==typeof n&&(_e328=n.call(this,t,_e328)),!K(_e328))return _e328;}),r[1]=e,M.apply(R,r);}}),_I2.prototype[B]||n(42)(_I2.prototype,B,_I2.prototype.valueOf),f(_I2,"Symbol"),f(Math,"Math",!0),f(r.JSON,"JSON",!0);},function(t,e,n){n(577),n(574),n(573),n(572),n(571),n(570),n(569),n(568),n(567),n(566),n(565),n(564),n(563),n(562),n(561),n(560),n(559),n(558),n(557),n(556),n(555),n(554),n(553),n(552),n(551),n(550),n(549),n(548),n(547),n(546),n(545),n(544),n(543),n(542),n(541),n(540),n(539),n(538),n(537),n(536),n(535),n(534),n(533),n(531),n(530),n(529),n(528),n(527),n(526),n(525),n(524),n(523),n(522),n(521),n(520),n(519),n(518),n(517),n(516),n(515),n(514),n(513),n(512),n(511),n(510),n(509),n(508),n(507),n(506),n(505),n(504),n(503),n(502),n(501),n(500),n(499),n(498),n(496),n(495),n(493),n(492),n(491),n(490),n(489),n(488),n(487),n(485),n(484),n(483),n(482),n(481),n(480),n(479),n(478),n(477),n(476),n(475),n(474),n(473),n(155),n(472),n(220),n(471),n(219),n(470),n(469),n(468),n(467),n(218),n(464),n(463),n(462),n(461),n(460),n(459),n(458),n(457),n(456),n(455),n(454),n(453),n(452),n(451),n(450),n(449),n(448),n(447),n(446),n(445),n(444),n(443),n(442),n(441),n(440),n(439),n(438),n(437),n(436),t.exports=n(24);},function(t,e,n){n(578),n(435),n(433),n(430),n(428),n(426),n(424),n(422),n(420),n(418),n(416),n(414),n(412),n(408);},function(t,e,n){n(579);var r=function(t){return t&&t.__esModule?t:{default:t};}(n(407));r.default._babelPolyfill&&"undefined"!=typeof console&&console.warn&&console.warn("@babel/polyfill is loaded more than once on this page. This is probably not desirable/intended and may have consequences if different versions of the polyfills are applied sequentially. If you do need to load the polyfill more than once, use @babel/polyfill/noConflict instead to bypass the warning."),r.default._babelPolyfill=!0;},function(t,e,n){n(580),t.exports=n(248);},function(t,e,n){var r={},i={},o=34,a=10,s=13;function u(t){return new Function("d","return {"+t.map(function(t,e){return JSON.stringify(t)+": d["+e+'] || ""';}).join(",")+"}");}function c(t){var e=Object.create(null),n=[];return t.forEach(function(t){for(var r in t){r in e||n.push(e[r]=r);}}),n;}function l(t,e){var n=t+"",r=n.length;return r<e?new Array(e-r+1).join(0)+n:n;}function f(t){var e=t.getUTCHours(),n=t.getUTCMinutes(),r=t.getUTCSeconds(),i=t.getUTCMilliseconds();return isNaN(t)?"Invalid Date":function(t){return t<0?"-"+l(-t,6):t>9999?"+"+l(t,6):l(t,4);}(t.getUTCFullYear())+"-"+l(t.getUTCMonth()+1,2)+"-"+l(t.getUTCDate(),2)+(i?"T"+l(e,2)+":"+l(n,2)+":"+l(r,2)+"."+l(i,3)+"Z":r?"T"+l(e,2)+":"+l(n,2)+":"+l(r,2)+"Z":n||e?"T"+l(e,2)+":"+l(n,2)+"Z":"");}e.a=function(t){var e=new RegExp('["'+t+"\n\r]"),n=t.charCodeAt(0);function l(t,e){var u,c=[],l=t.length,f=0,h=0,d=l<=0,p=!1;function m(){if(d)return i;if(p)return p=!1,r;var e,u,c=f;if(t.charCodeAt(c)===o){for(;f++<l&&t.charCodeAt(f)!==o||t.charCodeAt(++f)===o;){}return (e=f)>=l?d=!0:(u=t.charCodeAt(f++))===a?p=!0:u===s&&(p=!0,t.charCodeAt(f)===a&&++f),t.slice(c+1,e-1).replace(/""/g,'"');}for(;f<l;){if((u=t.charCodeAt(e=f++))===a)p=!0;else if(u===s)p=!0,t.charCodeAt(f)===a&&++f;else if(u!==n)continue;return t.slice(c,e);}return d=!0,t.slice(c,l);}for(t.charCodeAt(l-1)===a&&--l,t.charCodeAt(l-1)===s&&--l;(u=m())!==i;){for(var g=[];u!==r&&u!==i;){g.push(u),u=m();}e&&null==(g=e(g,h++))||c.push(g);}return c;}function h(e,n){return e.map(function(e){return n.map(function(t){return p(e[t]);}).join(t);});}function d(e){return e.map(p).join(t);}function p(t){return null==t?"":t instanceof Date?f(t):e.test(t+="")?'"'+t.replace(/"/g,'""')+'"':t;}return {parse:function parse(t,e){var n,r,i=l(t,function(t,i){if(n)return n(t,i-1);r=t,n=e?function(t,e){var n=u(t);return function(r,i){return e(n(r),i,t);};}(t,e):u(t);});return i.columns=r||[],i;},parseRows:l,format:function format(e,n){return null==n&&(n=c(e)),[n.map(p).join(t)].concat(h(e,n)).join("\n");},formatBody:function formatBody(t,e){return null==e&&(e=c(t)),h(t,e).join("\n");},formatRows:function formatRows(t){return t.map(d).join("\n");},formatRow:d,formatValue:p};};}]).default;});});

var formatMessageParse = createCommonjsModule(function (module, exports) {
  /*::
  export type AST = Element[]
  export type Element = string | Placeholder
  export type Placeholder = Plural | Styled | Typed | Simple
  export type Plural = [ string, 'plural' | 'selectordinal', number, SubMessages ]
  export type Styled = [ string, string, string | SubMessages ]
  export type Typed = [ string, string ]
  export type Simple = [ string ]
  export type SubMessages = { [string]: AST }
  export type Token = [ TokenType, string ]
  export type TokenType = 'text' | 'space' | 'id' | 'type' | 'style' | 'offset' | 'number' | 'selector' | 'syntax'
  type Context = {|
    pattern: string,
    index: number,
    tagsType: ?string,
    tokens: ?Token[]
  |}
  */

  var ARG_OPN = '{';
  var ARG_CLS = '}';
  var ARG_SEP = ',';
  var NUM_ARG = '#';
  var TAG_OPN = '<';
  var TAG_CLS = '>';
  var TAG_END = '</';
  var TAG_SELF_CLS = '/>';
  var ESC = '\'';
  var OFFSET = 'offset:';
  var simpleTypes = ['number', 'date', 'time', 'ordinal', 'duration', 'spellout'];
  var submTypes = ['plural', 'select', 'selectordinal'];
  /**
   * parse
   *
   * Turns this:
   *  `You have { numBananas, plural,
   *       =0 {no bananas}
   *      one {a banana}
   *    other {# bananas}
   *  } for sale`
   *
   * into this:
   *  [ "You have ", [ "numBananas", "plural", 0, {
   *       "=0": [ "no bananas" ],
   *      "one": [ "a banana" ],
   *    "other": [ [ '#' ], " bananas" ]
   *  } ], " for sale." ]
   *
   * tokens:
   *  [
   *    [ "text", "You have " ],
   *    [ "syntax", "{" ],
   *    [ "space", " " ],
   *    [ "id", "numBananas" ],
   *    [ "syntax", ", " ],
   *    [ "space", " " ],
   *    [ "type", "plural" ],
   *    [ "syntax", "," ],
   *    [ "space", "\n     " ],
   *    [ "selector", "=0" ],
   *    [ "space", " " ],
   *    [ "syntax", "{" ],
   *    [ "text", "no bananas" ],
   *    [ "syntax", "}" ],
   *    [ "space", "\n    " ],
   *    [ "selector", "one" ],
   *    [ "space", " " ],
   *    [ "syntax", "{" ],
   *    [ "text", "a banana" ],
   *    [ "syntax", "}" ],
   *    [ "space", "\n  " ],
   *    [ "selector", "other" ],
   *    [ "space", " " ],
   *    [ "syntax", "{" ],
   *    [ "syntax", "#" ],
   *    [ "text", " bananas" ],
   *    [ "syntax", "}" ],
   *    [ "space", "\n" ],
   *    [ "syntax", "}" ],
   *    [ "text", " for sale." ]
   *  ]
   **/

  exports = module.exports = function parse(pattern
  /*: string */
  , options
  /*:: ?: { tagsType?: string, tokens?: Token[] } */
  )
  /*: AST */
  {
    return parseAST({
      pattern: String(pattern),
      index: 0,
      tagsType: options && options.tagsType || null,
      tokens: options && options.tokens || null
    }, '');
  };

  function parseAST(current
  /*: Context */
  , parentType
  /*: string */
  )
  /*: AST */
  {
    var pattern = current.pattern;
    var length = pattern.length;
    var elements
    /*: AST */
    = [];
    var start = current.index;
    var text = parseText(current, parentType);
    if (text) elements.push(text);
    if (text && current.tokens) current.tokens.push(['text', pattern.slice(start, current.index)]);

    while (current.index < length) {
      if (pattern[current.index] === ARG_CLS) {
        if (!parentType) throw expected(current);
        break;
      }

      if (parentType && current.tagsType && pattern.slice(current.index, current.index + TAG_END.length) === TAG_END) break;
      elements.push(parsePlaceholder(current));
      start = current.index;
      text = parseText(current, parentType);
      if (text) elements.push(text);
      if (text && current.tokens) current.tokens.push(['text', pattern.slice(start, current.index)]);
    }

    return elements;
  }

  function parseText(current
  /*: Context */
  , parentType
  /*: string */
  )
  /*: string */
  {
    var pattern = current.pattern;
    var length = pattern.length;
    var isHashSpecial = parentType === 'plural' || parentType === 'selectordinal';
    var isAngleSpecial = !!current.tagsType;
    var isArgStyle = parentType === '{style}';
    var text = '';

    while (current.index < length) {
      var char = pattern[current.index];

      if (char === ARG_OPN || char === ARG_CLS || isHashSpecial && char === NUM_ARG || isAngleSpecial && char === TAG_OPN || isArgStyle && isWhitespace(char.charCodeAt(0))) {
        break;
      } else if (char === ESC) {
        char = pattern[++current.index];

        if (char === ESC) {
          // double is always 1 '
          text += char;
          ++current.index;
        } else if ( // only when necessary
        char === ARG_OPN || char === ARG_CLS || isHashSpecial && char === NUM_ARG || isAngleSpecial && char === TAG_OPN || isArgStyle) {
          text += char;

          while (++current.index < length) {
            char = pattern[current.index];

            if (char === ESC && pattern[current.index + 1] === ESC) {
              // double is always 1 '
              text += ESC;
              ++current.index;
            } else if (char === ESC) {
              // end of quoted
              ++current.index;
              break;
            } else {
              text += char;
            }
          }
        } else {
          // lone ' is just a '
          text += ESC; // already incremented
        }
      } else {
        text += char;
        ++current.index;
      }
    }

    return text;
  }

  function isWhitespace(code
  /*: number */
  )
  /*: boolean */
  {
    return code >= 0x09 && code <= 0x0D || code === 0x20 || code === 0x85 || code === 0xA0 || code === 0x180E || code >= 0x2000 && code <= 0x200D || code === 0x2028 || code === 0x2029 || code === 0x202F || code === 0x205F || code === 0x2060 || code === 0x3000 || code === 0xFEFF;
  }

  function skipWhitespace(current
  /*: Context */
  )
  /*: void */
  {
    var pattern = current.pattern;
    var length = pattern.length;
    var start = current.index;

    while (current.index < length && isWhitespace(pattern.charCodeAt(current.index))) {
      ++current.index;
    }

    if (start < current.index && current.tokens) {
      current.tokens.push(['space', current.pattern.slice(start, current.index)]);
    }
  }

  function parsePlaceholder(current
  /*: Context */
  )
  /*: Placeholder */
  {
    var pattern = current.pattern;

    if (pattern[current.index] === NUM_ARG) {
      if (current.tokens) current.tokens.push(['syntax', NUM_ARG]);
      ++current.index; // move passed #

      return [NUM_ARG];
    }

    var tag = parseTag(current);
    if (tag) return tag;
    /* istanbul ignore if should be unreachable if parseAST and parseText are right */

    if (pattern[current.index] !== ARG_OPN) throw expected(current, ARG_OPN);
    if (current.tokens) current.tokens.push(['syntax', ARG_OPN]);
    ++current.index; // move passed {

    skipWhitespace(current);
    var id = parseId(current);
    if (!id) throw expected(current, 'placeholder id');
    if (current.tokens) current.tokens.push(['id', id]);
    skipWhitespace(current);
    var char = pattern[current.index];

    if (char === ARG_CLS) {
      // end placeholder
      if (current.tokens) current.tokens.push(['syntax', ARG_CLS]);
      ++current.index; // move passed }

      return [id];
    }

    if (char !== ARG_SEP) throw expected(current, ARG_SEP + ' or ' + ARG_CLS);
    if (current.tokens) current.tokens.push(['syntax', ARG_SEP]);
    ++current.index; // move passed ,

    skipWhitespace(current);
    var type = parseId(current);
    if (!type) throw expected(current, 'placeholder type');
    if (current.tokens) current.tokens.push(['type', type]);
    skipWhitespace(current);
    char = pattern[current.index];

    if (char === ARG_CLS) {
      // end placeholder
      if (current.tokens) current.tokens.push(['syntax', ARG_CLS]);

      if (type === 'plural' || type === 'selectordinal' || type === 'select') {
        throw expected(current, type + ' sub-messages');
      }

      ++current.index; // move passed }

      return [id, type];
    }

    if (char !== ARG_SEP) throw expected(current, ARG_SEP + ' or ' + ARG_CLS);
    if (current.tokens) current.tokens.push(['syntax', ARG_SEP]);
    ++current.index; // move passed ,

    skipWhitespace(current);
    var arg;

    if (type === 'plural' || type === 'selectordinal') {
      var offset = parsePluralOffset(current);
      skipWhitespace(current);
      arg = [id, type, offset, parseSubMessages(current, type)];
    } else if (type === 'select') {
      arg = [id, type, parseSubMessages(current, type)];
    } else if (simpleTypes.indexOf(type) >= 0) {
      arg = [id, type, parseSimpleFormat(current)];
    } else {
      // custom placeholder type
      var index = current.index;
      var format
      /*: string | SubMessages */
      = parseSimpleFormat(current);
      skipWhitespace(current);

      if (pattern[current.index] === ARG_OPN) {
        current.index = index; // rewind, since should have been submessages

        format = parseSubMessages(current, type);
      }

      arg = [id, type, format];
    }

    skipWhitespace(current);
    if (pattern[current.index] !== ARG_CLS) throw expected(current, ARG_CLS);
    if (current.tokens) current.tokens.push(['syntax', ARG_CLS]);
    ++current.index; // move passed }

    return arg;
  }

  function parseTag(current
  /*: Context */
  )
  /*: ?Placeholder */
  {
    var tagsType = current.tagsType;
    if (!tagsType || current.pattern[current.index] !== TAG_OPN) return;

    if (current.pattern.slice(current.index, current.index + TAG_END.length) === TAG_END) {
      throw expected(current, null, 'closing tag without matching opening tag');
    }

    if (current.tokens) current.tokens.push(['syntax', TAG_OPN]);
    ++current.index; // move passed <

    var id = parseId(current, true);
    if (!id) throw expected(current, 'placeholder id');
    if (current.tokens) current.tokens.push(['id', id]);
    skipWhitespace(current);

    if (current.pattern.slice(current.index, current.index + TAG_SELF_CLS.length) === TAG_SELF_CLS) {
      if (current.tokens) current.tokens.push(['syntax', TAG_SELF_CLS]);
      current.index += TAG_SELF_CLS.length;
      return [id, tagsType];
    }

    if (current.pattern[current.index] !== TAG_CLS) throw expected(current, TAG_CLS);
    if (current.tokens) current.tokens.push(['syntax', TAG_CLS]);
    ++current.index; // move passed >

    var children = parseAST(current, tagsType);
    var end = current.index;
    if (current.pattern.slice(current.index, current.index + TAG_END.length) !== TAG_END) throw expected(current, TAG_END + id + TAG_CLS);
    if (current.tokens) current.tokens.push(['syntax', TAG_END]);
    current.index += TAG_END.length;
    var closeId = parseId(current, true);
    if (closeId && current.tokens) current.tokens.push(['id', closeId]);

    if (id !== closeId) {
      current.index = end; // rewind for better error message

      throw expected(current, TAG_END + id + TAG_CLS, TAG_END + closeId + TAG_CLS);
    }

    skipWhitespace(current);
    if (current.pattern[current.index] !== TAG_CLS) throw expected(current, TAG_CLS);
    if (current.tokens) current.tokens.push(['syntax', TAG_CLS]);
    ++current.index; // move passed >

    return [id, tagsType, {
      children: children
    }];
  }

  function parseId(current
  /*: Context */
  , isTag
  /*:: ?: boolean */
  )
  /*: string */
  {
    var pattern = current.pattern;
    var length = pattern.length;
    var id = '';

    while (current.index < length) {
      var char = pattern[current.index];
      if (char === ARG_OPN || char === ARG_CLS || char === ARG_SEP || char === NUM_ARG || char === ESC || isWhitespace(char.charCodeAt(0)) || isTag && (char === TAG_OPN || char === TAG_CLS || char === '/')) break;
      id += char;
      ++current.index;
    }

    return id;
  }

  function parseSimpleFormat(current
  /*: Context */
  )
  /*: string */
  {
    var start = current.index;
    var style = parseText(current, '{style}');
    if (!style) throw expected(current, 'placeholder style name');
    if (current.tokens) current.tokens.push(['style', current.pattern.slice(start, current.index)]);
    return style;
  }

  function parsePluralOffset(current
  /*: Context */
  )
  /*: number */
  {
    var pattern = current.pattern;
    var length = pattern.length;
    var offset = 0;

    if (pattern.slice(current.index, current.index + OFFSET.length) === OFFSET) {
      if (current.tokens) current.tokens.push(['offset', 'offset'], ['syntax', ':']);
      current.index += OFFSET.length; // move passed offset:

      skipWhitespace(current);
      var start = current.index;

      while (current.index < length && isDigit(pattern.charCodeAt(current.index))) {
        ++current.index;
      }

      if (start === current.index) throw expected(current, 'offset number');
      if (current.tokens) current.tokens.push(['number', pattern.slice(start, current.index)]);
      offset = +pattern.slice(start, current.index);
    }

    return offset;
  }

  function isDigit(code
  /*: number */
  )
  /*: boolean */
  {
    return code >= 0x30 && code <= 0x39;
  }

  function parseSubMessages(current
  /*: Context */
  , parentType
  /*: string */
  )
  /*: SubMessages */
  {
    var pattern = current.pattern;
    var length = pattern.length;
    var options
    /*: SubMessages */
    = {};

    while (current.index < length && pattern[current.index] !== ARG_CLS) {
      var selector = parseId(current);
      if (!selector) throw expected(current, 'sub-message selector');
      if (current.tokens) current.tokens.push(['selector', selector]);
      skipWhitespace(current);
      options[selector] = parseSubMessage(current, parentType);
      skipWhitespace(current);
    }

    if (!options.other && submTypes.indexOf(parentType) >= 0) {
      throw expected(current, null, null, '"other" sub-message must be specified in ' + parentType);
    }

    return options;
  }

  function parseSubMessage(current
  /*: Context */
  , parentType
  /*: string */
  )
  /*: AST */
  {
    if (current.pattern[current.index] !== ARG_OPN) throw expected(current, ARG_OPN + ' to start sub-message');
    if (current.tokens) current.tokens.push(['syntax', ARG_OPN]);
    ++current.index; // move passed {

    var message = parseAST(current, parentType);
    if (current.pattern[current.index] !== ARG_CLS) throw expected(current, ARG_CLS + ' to end sub-message');
    if (current.tokens) current.tokens.push(['syntax', ARG_CLS]);
    ++current.index; // move passed }

    return message;
  }

  function expected(current
  /*: Context */
  , expected
  /*:: ?: ?string */
  , found
  /*:: ?: ?string */
  , message
  /*:: ?: string */
  ) {
    var pattern = current.pattern;
    var lines = pattern.slice(0, current.index).split(/\r?\n/);
    var offset = current.index;
    var line = lines.length;
    var column = lines.slice(-1)[0].length;
    found = found || (current.index >= pattern.length ? 'end of message pattern' : parseId(current) || pattern[current.index]);
    if (!message) message = errorMessage(expected, found);
    message += ' in ' + pattern.replace(/\r?\n/g, '\n');
    return new SyntaxError(message, expected, found, offset, line, column);
  }

  function errorMessage(expected
  /*: ?string */
  , found
  /* string */
  ) {
    if (!expected) return 'Unexpected ' + found + ' found';
    return 'Expected ' + expected + ' but found ' + found;
  }
  /**
   * SyntaxError
   *  Holds information about bad syntax found in a message pattern
   **/


  function SyntaxError(message
  /*: string */
  , expected
  /*: ?string */
  , found
  /*: ?string */
  , offset
  /*: number */
  , line
  /*: number */
  , column
  /*: number */
  ) {
    Error.call(this, message);
    this.name = 'SyntaxError';
    this.message = message;
    this.expected = expected;
    this.found = found;
    this.offset = offset;
    this.line = line;
    this.column = column;
  }

  SyntaxError.prototype = Object.create(Error.prototype);
  exports.SyntaxError = SyntaxError;
});

// @flow
var LONG = 'long';
var SHORT = 'short';
var NARROW = 'narrow';
var NUMERIC = 'numeric';
var TWODIGIT = '2-digit';
/**
 * formatting information
 **/

var formatMessageFormats = {
  number: {
    decimal: {
      style: 'decimal'
    },
    integer: {
      style: 'decimal',
      maximumFractionDigits: 0
    },
    currency: {
      style: 'currency',
      currency: 'USD'
    },
    percent: {
      style: 'percent'
    },
    default: {
      style: 'decimal'
    }
  },
  date: {
    short: {
      month: NUMERIC,
      day: NUMERIC,
      year: TWODIGIT
    },
    medium: {
      month: SHORT,
      day: NUMERIC,
      year: NUMERIC
    },
    long: {
      month: LONG,
      day: NUMERIC,
      year: NUMERIC
    },
    full: {
      month: LONG,
      day: NUMERIC,
      year: NUMERIC,
      weekday: LONG
    },
    default: {
      month: SHORT,
      day: NUMERIC,
      year: NUMERIC
    }
  },
  time: {
    short: {
      hour: NUMERIC,
      minute: NUMERIC
    },
    medium: {
      hour: NUMERIC,
      minute: NUMERIC,
      second: NUMERIC
    },
    long: {
      hour: NUMERIC,
      minute: NUMERIC,
      second: NUMERIC,
      timeZoneName: SHORT
    },
    full: {
      hour: NUMERIC,
      minute: NUMERIC,
      second: NUMERIC,
      timeZoneName: SHORT
    },
    default: {
      hour: NUMERIC,
      minute: NUMERIC,
      second: NUMERIC
    }
  },
  duration: {
    default: {
      hours: {
        minimumIntegerDigits: 1,
        maximumFractionDigits: 0
      },
      minutes: {
        minimumIntegerDigits: 2,
        maximumFractionDigits: 0
      },
      seconds: {
        minimumIntegerDigits: 2,
        maximumFractionDigits: 3
      }
    }
  },
  parseNumberPattern: function parseNumberPattern(pattern
  /*: ?string */
  ) {
    if (!pattern) return;
    var options = {};
    var currency = pattern.match(/\b[A-Z]{3}\b/i);
    var syms = pattern.replace(/[^¤]/g, '').length;
    if (!syms && currency) syms = 1;

    if (syms) {
      options.style = 'currency';
      options.currencyDisplay = syms === 1 ? 'symbol' : syms === 2 ? 'code' : 'name';
      options.currency = currency ? currency[0].toUpperCase() : 'USD';
    } else if (pattern.indexOf('%') >= 0) {
      options.style = 'percent';
    }

    if (!/[@#0]/.test(pattern)) return options.style ? options : undefined;
    options.useGrouping = pattern.indexOf(',') >= 0;

    if (/E\+?[@#0]+/i.test(pattern) || pattern.indexOf('@') >= 0) {
      var size = pattern.replace(/E\+?[@#0]+|[^@#0]/gi, '');
      options.minimumSignificantDigits = Math.min(Math.max(size.replace(/[^@0]/g, '').length, 1), 21);
      options.maximumSignificantDigits = Math.min(Math.max(size.length, 1), 21);
    } else {
      var parts = pattern.replace(/[^#0.]/g, '').split('.');
      var integer = parts[0];
      var n = integer.length - 1;

      while (integer[n] === '0') {
        --n;
      }

      options.minimumIntegerDigits = Math.min(Math.max(integer.length - 1 - n, 1), 21);
      var fraction = parts[1] || '';
      n = 0;

      while (fraction[n] === '0') {
        ++n;
      }

      options.minimumFractionDigits = Math.min(Math.max(n, 0), 20);

      while (fraction[n] === '#') {
        ++n;
      }

      options.maximumFractionDigits = Math.min(Math.max(n, 0), 20);
    }

    return options;
  },
  parseDatePattern: function parseDatePattern(pattern
  /*: ?string */
  ) {
    if (!pattern) return;
    var options = {};

    for (var i = 0; i < pattern.length;) {
      var current = pattern[i];
      var n = 1;

      while (pattern[++i] === current) {
        ++n;
      }

      switch (current) {
        case 'G':
          options.era = n === 5 ? NARROW : n === 4 ? LONG : SHORT;
          break;

        case 'y':
        case 'Y':
          options.year = n === 2 ? TWODIGIT : NUMERIC;
          break;

        case 'M':
        case 'L':
          n = Math.min(Math.max(n - 1, 0), 4);
          options.month = [NUMERIC, TWODIGIT, SHORT, LONG, NARROW][n];
          break;

        case 'E':
        case 'e':
        case 'c':
          options.weekday = n === 5 ? NARROW : n === 4 ? LONG : SHORT;
          break;

        case 'd':
        case 'D':
          options.day = n === 2 ? TWODIGIT : NUMERIC;
          break;

        case 'h':
        case 'K':
          options.hour12 = true;
          options.hour = n === 2 ? TWODIGIT : NUMERIC;
          break;

        case 'H':
        case 'k':
          options.hour12 = false;
          options.hour = n === 2 ? TWODIGIT : NUMERIC;
          break;

        case 'm':
          options.minute = n === 2 ? TWODIGIT : NUMERIC;
          break;

        case 's':
        case 'S':
          options.second = n === 2 ? TWODIGIT : NUMERIC;
          break;

        case 'z':
        case 'Z':
        case 'v':
        case 'V':
          options.timeZoneName = n === 1 ? SHORT : LONG;
          break;
      }
    }

    return Object.keys(options).length ? options : undefined;
  }
};

// @flow
// "lookup" algorithm http://tools.ietf.org/html/rfc4647#section-3.4
// assumes normalized language tags, and matches in a case sensitive manner
var lookupClosestLocale = function lookupClosestLocale(locale
/*: string | string[] | void */
, available
/*: { [string]: any } */
)
/*: ?string */
{
  if (typeof locale === 'string' && available[locale]) return locale;
  var locales = [].concat(locale || []);

  for (var l = 0, ll = locales.length; l < ll; ++l) {
    var current = locales[l].split('-');

    while (current.length) {
      var candidate = current.join('-');
      if (available[candidate]) return candidate;
      current.pop();
    }
  }
};

// @flow
/*:: export type Rule = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other' */

var zero = 'zero',
    one = 'one',
    two = 'two',
    few = 'few',
    many = 'many',
    other = 'other';
var f = [function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 1 ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return 0 <= n && n <= 1 ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var n = +s;
  return i === 0 || n === 1 ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 0 ? zero : n === 1 ? one : n === 2 ? two : 3 <= n % 100 && n % 100 <= 10 ? few : 11 <= n % 100 && n % 100 <= 99 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var v = (s + '.').split('.')[1].length;
  return i === 1 && v === 0 ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n % 10 === 1 && n % 100 !== 11 ? one : 2 <= n % 10 && n % 10 <= 4 && (n % 100 < 12 || 14 < n % 100) ? few : n % 10 === 0 || 5 <= n % 10 && n % 10 <= 9 || 11 <= n % 100 && n % 100 <= 14 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n % 10 === 1 && n % 100 !== 11 && n % 100 !== 71 && n % 100 !== 91 ? one : n % 10 === 2 && n % 100 !== 12 && n % 100 !== 72 && n % 100 !== 92 ? two : (3 <= n % 10 && n % 10 <= 4 || n % 10 === 9) && (n % 100 < 10 || 19 < n % 100) && (n % 100 < 70 || 79 < n % 100) && (n % 100 < 90 || 99 < n % 100) ? few : n !== 0 && n % 1000000 === 0 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var v = (s + '.').split('.')[1].length;
  var f = +(s + '.').split('.')[1];
  return v === 0 && i % 10 === 1 && i % 100 !== 11 || f % 10 === 1 && f % 100 !== 11 ? one : v === 0 && 2 <= i % 10 && i % 10 <= 4 && (i % 100 < 12 || 14 < i % 100) || 2 <= f % 10 && f % 10 <= 4 && (f % 100 < 12 || 14 < f % 100) ? few : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var v = (s + '.').split('.')[1].length;
  return i === 1 && v === 0 ? one : 2 <= i && i <= 4 && v === 0 ? few : v !== 0 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 0 ? zero : n === 1 ? one : n === 2 ? two : n === 3 ? few : n === 6 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var t = +('' + s).replace(/^[^.]*.?|0+$/g, '');
  var n = +s;
  return n === 1 || t !== 0 && (i === 0 || i === 1) ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var v = (s + '.').split('.')[1].length;
  var f = +(s + '.').split('.')[1];
  return v === 0 && i % 100 === 1 || f % 100 === 1 ? one : v === 0 && i % 100 === 2 || f % 100 === 2 ? two : v === 0 && 3 <= i % 100 && i % 100 <= 4 || 3 <= f % 100 && f % 100 <= 4 ? few : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  return i === 0 || i === 1 ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var v = (s + '.').split('.')[1].length;
  var f = +(s + '.').split('.')[1];
  return v === 0 && (i === 1 || i === 2 || i === 3) || v === 0 && i % 10 !== 4 && i % 10 !== 6 && i % 10 !== 9 || v !== 0 && f % 10 !== 4 && f % 10 !== 6 && f % 10 !== 9 ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 1 ? one : n === 2 ? two : 3 <= n && n <= 6 ? few : 7 <= n && n <= 10 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 1 || n === 11 ? one : n === 2 || n === 12 ? two : 3 <= n && n <= 10 || 13 <= n && n <= 19 ? few : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var v = (s + '.').split('.')[1].length;
  return v === 0 && i % 10 === 1 ? one : v === 0 && i % 10 === 2 ? two : v === 0 && (i % 100 === 0 || i % 100 === 20 || i % 100 === 40 || i % 100 === 60 || i % 100 === 80) ? few : v !== 0 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var v = (s + '.').split('.')[1].length;
  var n = +s;
  return i === 1 && v === 0 ? one : i === 2 && v === 0 ? two : v === 0 && (n < 0 || 10 < n) && n % 10 === 0 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var t = +('' + s).replace(/^[^.]*.?|0+$/g, '');
  return t === 0 && i % 10 === 1 && i % 100 !== 11 || t !== 0 ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 1 ? one : n === 2 ? two : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 0 ? zero : n === 1 ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var n = +s;
  return n === 0 ? zero : (i === 0 || i === 1) && n !== 0 ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var f = +(s + '.').split('.')[1];
  var n = +s;
  return n % 10 === 1 && (n % 100 < 11 || 19 < n % 100) ? one : 2 <= n % 10 && n % 10 <= 9 && (n % 100 < 11 || 19 < n % 100) ? few : f !== 0 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var v = (s + '.').split('.')[1].length;
  var f = +(s + '.').split('.')[1];
  var n = +s;
  return n % 10 === 0 || 11 <= n % 100 && n % 100 <= 19 || v === 2 && 11 <= f % 100 && f % 100 <= 19 ? zero : n % 10 === 1 && n % 100 !== 11 || v === 2 && f % 10 === 1 && f % 100 !== 11 || v !== 2 && f % 10 === 1 ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var v = (s + '.').split('.')[1].length;
  var f = +(s + '.').split('.')[1];
  return v === 0 && i % 10 === 1 && i % 100 !== 11 || f % 10 === 1 && f % 100 !== 11 ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var v = (s + '.').split('.')[1].length;
  var n = +s;
  return i === 1 && v === 0 ? one : v !== 0 || n === 0 || n !== 1 && 1 <= n % 100 && n % 100 <= 19 ? few : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 1 ? one : n === 0 || 2 <= n % 100 && n % 100 <= 10 ? few : 11 <= n % 100 && n % 100 <= 19 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var v = (s + '.').split('.')[1].length;
  return i === 1 && v === 0 ? one : v === 0 && 2 <= i % 10 && i % 10 <= 4 && (i % 100 < 12 || 14 < i % 100) ? few : v === 0 && i !== 1 && 0 <= i % 10 && i % 10 <= 1 || v === 0 && 5 <= i % 10 && i % 10 <= 9 || v === 0 && 12 <= i % 100 && i % 100 <= 14 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  return 0 <= i && i <= 1 ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var v = (s + '.').split('.')[1].length;
  return v === 0 && i % 10 === 1 && i % 100 !== 11 ? one : v === 0 && 2 <= i % 10 && i % 10 <= 4 && (i % 100 < 12 || 14 < i % 100) ? few : v === 0 && i % 10 === 0 || v === 0 && 5 <= i % 10 && i % 10 <= 9 || v === 0 && 11 <= i % 100 && i % 100 <= 14 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var n = +s;
  return i === 0 || n === 1 ? one : 2 <= n && n <= 10 ? few : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var f = +(s + '.').split('.')[1];
  var n = +s;
  return n === 0 || n === 1 || i === 0 && f === 1 ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  var v = (s + '.').split('.')[1].length;
  return v === 0 && i % 100 === 1 ? one : v === 0 && i % 100 === 2 ? two : v === 0 && 3 <= i % 100 && i % 100 <= 4 || v !== 0 ? few : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return 0 <= n && n <= 1 || 11 <= n && n <= 99 ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 1 || n === 5 || n === 7 || n === 8 || n === 9 || n === 10 ? one : n === 2 || n === 3 ? two : n === 4 ? few : n === 6 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  return i % 10 === 1 || i % 10 === 2 || i % 10 === 5 || i % 10 === 7 || i % 10 === 8 || i % 100 === 20 || i % 100 === 50 || i % 100 === 70 || i % 100 === 80 ? one : i % 10 === 3 || i % 10 === 4 || i % 1000 === 100 || i % 1000 === 200 || i % 1000 === 300 || i % 1000 === 400 || i % 1000 === 500 || i % 1000 === 600 || i % 1000 === 700 || i % 1000 === 800 || i % 1000 === 900 ? few : i === 0 || i % 10 === 6 || i % 100 === 40 || i % 100 === 60 || i % 100 === 90 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return (n % 10 === 2 || n % 10 === 3) && n % 100 !== 12 && n % 100 !== 13 ? few : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 1 || n === 3 ? one : n === 2 ? two : n === 4 ? few : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 0 || n === 7 || n === 8 || n === 9 ? zero : n === 1 ? one : n === 2 ? two : n === 3 || n === 4 ? few : n === 5 || n === 6 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n % 10 === 1 && n % 100 !== 11 ? one : n % 10 === 2 && n % 100 !== 12 ? two : n % 10 === 3 && n % 100 !== 13 ? few : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 1 || n === 11 ? one : n === 2 || n === 12 ? two : n === 3 || n === 13 ? few : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 1 ? one : n === 2 || n === 3 ? two : n === 4 ? few : n === 6 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 1 || n === 5 ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 11 || n === 8 || n === 80 || n === 800 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  return i === 1 ? one : i === 0 || 2 <= i % 100 && i % 100 <= 20 || i % 100 === 40 || i % 100 === 60 || i % 100 === 80 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n % 10 === 6 || n % 10 === 9 || n % 10 === 0 && n !== 0 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var i = Math.floor(Math.abs(+s));
  return i % 10 === 1 && i % 100 !== 11 ? one : i % 10 === 2 && i % 100 !== 12 ? two : (i % 10 === 7 || i % 10 === 8) && i % 100 !== 17 && i % 100 !== 18 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 1 ? one : n === 2 || n === 3 ? two : n === 4 ? few : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return 1 <= n && n <= 4 ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 1 || n === 5 || 7 <= n && n <= 9 ? one : n === 2 || n === 3 ? two : n === 4 ? few : n === 6 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n === 1 ? one : n % 10 === 4 && n % 100 !== 14 ? many : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return (n % 10 === 1 || n % 10 === 2) && n % 100 !== 11 && n % 100 !== 12 ? one : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n % 10 === 6 || n % 10 === 9 || n === 10 ? few : other;
}, function (s
/*: string | number */
)
/*: Rule */
{
  var n = +s;
  return n % 10 === 3 && n % 100 !== 13 ? few : other;
}];
var plurals = {
  af: {
    cardinal: f[0]
  },
  ak: {
    cardinal: f[1]
  },
  am: {
    cardinal: f[2]
  },
  ar: {
    cardinal: f[3]
  },
  ars: {
    cardinal: f[3]
  },
  as: {
    cardinal: f[2],
    ordinal: f[34]
  },
  asa: {
    cardinal: f[0]
  },
  ast: {
    cardinal: f[4]
  },
  az: {
    cardinal: f[0],
    ordinal: f[35]
  },
  be: {
    cardinal: f[5],
    ordinal: f[36]
  },
  bem: {
    cardinal: f[0]
  },
  bez: {
    cardinal: f[0]
  },
  bg: {
    cardinal: f[0]
  },
  bh: {
    cardinal: f[1]
  },
  bn: {
    cardinal: f[2],
    ordinal: f[34]
  },
  br: {
    cardinal: f[6]
  },
  brx: {
    cardinal: f[0]
  },
  bs: {
    cardinal: f[7]
  },
  ca: {
    cardinal: f[4],
    ordinal: f[37]
  },
  ce: {
    cardinal: f[0]
  },
  cgg: {
    cardinal: f[0]
  },
  chr: {
    cardinal: f[0]
  },
  ckb: {
    cardinal: f[0]
  },
  cs: {
    cardinal: f[8]
  },
  cy: {
    cardinal: f[9],
    ordinal: f[38]
  },
  da: {
    cardinal: f[10]
  },
  de: {
    cardinal: f[4]
  },
  dsb: {
    cardinal: f[11]
  },
  dv: {
    cardinal: f[0]
  },
  ee: {
    cardinal: f[0]
  },
  el: {
    cardinal: f[0]
  },
  en: {
    cardinal: f[4],
    ordinal: f[39]
  },
  eo: {
    cardinal: f[0]
  },
  es: {
    cardinal: f[0]
  },
  et: {
    cardinal: f[4]
  },
  eu: {
    cardinal: f[0]
  },
  fa: {
    cardinal: f[2]
  },
  ff: {
    cardinal: f[12]
  },
  fi: {
    cardinal: f[4]
  },
  fil: {
    cardinal: f[13],
    ordinal: f[0]
  },
  fo: {
    cardinal: f[0]
  },
  fr: {
    cardinal: f[12],
    ordinal: f[0]
  },
  fur: {
    cardinal: f[0]
  },
  fy: {
    cardinal: f[4]
  },
  ga: {
    cardinal: f[14],
    ordinal: f[0]
  },
  gd: {
    cardinal: f[15],
    ordinal: f[40]
  },
  gl: {
    cardinal: f[4]
  },
  gsw: {
    cardinal: f[0]
  },
  gu: {
    cardinal: f[2],
    ordinal: f[41]
  },
  guw: {
    cardinal: f[1]
  },
  gv: {
    cardinal: f[16]
  },
  ha: {
    cardinal: f[0]
  },
  haw: {
    cardinal: f[0]
  },
  he: {
    cardinal: f[17]
  },
  hi: {
    cardinal: f[2],
    ordinal: f[41]
  },
  hr: {
    cardinal: f[7]
  },
  hsb: {
    cardinal: f[11]
  },
  hu: {
    cardinal: f[0],
    ordinal: f[42]
  },
  hy: {
    cardinal: f[12],
    ordinal: f[0]
  },
  ia: {
    cardinal: f[4]
  },
  io: {
    cardinal: f[4]
  },
  is: {
    cardinal: f[18]
  },
  it: {
    cardinal: f[4],
    ordinal: f[43]
  },
  iu: {
    cardinal: f[19]
  },
  iw: {
    cardinal: f[17]
  },
  jgo: {
    cardinal: f[0]
  },
  ji: {
    cardinal: f[4]
  },
  jmc: {
    cardinal: f[0]
  },
  ka: {
    cardinal: f[0],
    ordinal: f[44]
  },
  kab: {
    cardinal: f[12]
  },
  kaj: {
    cardinal: f[0]
  },
  kcg: {
    cardinal: f[0]
  },
  kk: {
    cardinal: f[0],
    ordinal: f[45]
  },
  kkj: {
    cardinal: f[0]
  },
  kl: {
    cardinal: f[0]
  },
  kn: {
    cardinal: f[2]
  },
  ks: {
    cardinal: f[0]
  },
  ksb: {
    cardinal: f[0]
  },
  ksh: {
    cardinal: f[20]
  },
  ku: {
    cardinal: f[0]
  },
  kw: {
    cardinal: f[19]
  },
  ky: {
    cardinal: f[0]
  },
  lag: {
    cardinal: f[21]
  },
  lb: {
    cardinal: f[0]
  },
  lg: {
    cardinal: f[0]
  },
  ln: {
    cardinal: f[1]
  },
  lt: {
    cardinal: f[22]
  },
  lv: {
    cardinal: f[23]
  },
  mas: {
    cardinal: f[0]
  },
  mg: {
    cardinal: f[1]
  },
  mgo: {
    cardinal: f[0]
  },
  mk: {
    cardinal: f[24],
    ordinal: f[46]
  },
  ml: {
    cardinal: f[0]
  },
  mn: {
    cardinal: f[0]
  },
  mo: {
    cardinal: f[25],
    ordinal: f[0]
  },
  mr: {
    cardinal: f[2],
    ordinal: f[47]
  },
  mt: {
    cardinal: f[26]
  },
  nah: {
    cardinal: f[0]
  },
  naq: {
    cardinal: f[19]
  },
  nb: {
    cardinal: f[0]
  },
  nd: {
    cardinal: f[0]
  },
  ne: {
    cardinal: f[0],
    ordinal: f[48]
  },
  nl: {
    cardinal: f[4]
  },
  nn: {
    cardinal: f[0]
  },
  nnh: {
    cardinal: f[0]
  },
  no: {
    cardinal: f[0]
  },
  nr: {
    cardinal: f[0]
  },
  nso: {
    cardinal: f[1]
  },
  ny: {
    cardinal: f[0]
  },
  nyn: {
    cardinal: f[0]
  },
  om: {
    cardinal: f[0]
  },
  or: {
    cardinal: f[0],
    ordinal: f[49]
  },
  os: {
    cardinal: f[0]
  },
  pa: {
    cardinal: f[1]
  },
  pap: {
    cardinal: f[0]
  },
  pl: {
    cardinal: f[27]
  },
  prg: {
    cardinal: f[23]
  },
  ps: {
    cardinal: f[0]
  },
  pt: {
    cardinal: f[28]
  },
  'pt-PT': {
    cardinal: f[4]
  },
  rm: {
    cardinal: f[0]
  },
  ro: {
    cardinal: f[25],
    ordinal: f[0]
  },
  rof: {
    cardinal: f[0]
  },
  ru: {
    cardinal: f[29]
  },
  rwk: {
    cardinal: f[0]
  },
  saq: {
    cardinal: f[0]
  },
  sc: {
    cardinal: f[4],
    ordinal: f[43]
  },
  scn: {
    cardinal: f[4],
    ordinal: f[43]
  },
  sd: {
    cardinal: f[0]
  },
  sdh: {
    cardinal: f[0]
  },
  se: {
    cardinal: f[19]
  },
  seh: {
    cardinal: f[0]
  },
  sh: {
    cardinal: f[7]
  },
  shi: {
    cardinal: f[30]
  },
  si: {
    cardinal: f[31]
  },
  sk: {
    cardinal: f[8]
  },
  sl: {
    cardinal: f[32]
  },
  sma: {
    cardinal: f[19]
  },
  smi: {
    cardinal: f[19]
  },
  smj: {
    cardinal: f[19]
  },
  smn: {
    cardinal: f[19]
  },
  sms: {
    cardinal: f[19]
  },
  sn: {
    cardinal: f[0]
  },
  so: {
    cardinal: f[0]
  },
  sq: {
    cardinal: f[0],
    ordinal: f[50]
  },
  sr: {
    cardinal: f[7]
  },
  ss: {
    cardinal: f[0]
  },
  ssy: {
    cardinal: f[0]
  },
  st: {
    cardinal: f[0]
  },
  sv: {
    cardinal: f[4],
    ordinal: f[51]
  },
  sw: {
    cardinal: f[4]
  },
  syr: {
    cardinal: f[0]
  },
  ta: {
    cardinal: f[0]
  },
  te: {
    cardinal: f[0]
  },
  teo: {
    cardinal: f[0]
  },
  ti: {
    cardinal: f[1]
  },
  tig: {
    cardinal: f[0]
  },
  tk: {
    cardinal: f[0],
    ordinal: f[52]
  },
  tl: {
    cardinal: f[13],
    ordinal: f[0]
  },
  tn: {
    cardinal: f[0]
  },
  tr: {
    cardinal: f[0]
  },
  ts: {
    cardinal: f[0]
  },
  tzm: {
    cardinal: f[33]
  },
  ug: {
    cardinal: f[0]
  },
  uk: {
    cardinal: f[29],
    ordinal: f[53]
  },
  ur: {
    cardinal: f[4]
  },
  uz: {
    cardinal: f[0]
  },
  ve: {
    cardinal: f[0]
  },
  vo: {
    cardinal: f[0]
  },
  vun: {
    cardinal: f[0]
  },
  wa: {
    cardinal: f[1]
  },
  wae: {
    cardinal: f[0]
  },
  xh: {
    cardinal: f[0]
  },
  xog: {
    cardinal: f[0]
  },
  yi: {
    cardinal: f[4]
  },
  zu: {
    cardinal: f[2]
  },
  lo: {
    ordinal: f[0]
  },
  ms: {
    ordinal: f[0]
  },
  vi: {
    ordinal: f[0]
  }
};

var formatMessageInterpret = createCommonjsModule(function (module, exports) {
  /*::
  import type {
    AST,
    SubMessages
  } from '../format-message-parse'
  type Locale = string
  type Locales = Locale | Locale[]
  type Placeholder = any[] // https://github.com/facebook/flow/issues/4050
  export type Type = (Placeholder, Locales) => (any, ?Object) => any
  export type Types = { [string]: Type }
  */

  exports = module.exports = function interpret(ast
  /*: AST */
  , locale
  /*:: ?: Locales */
  , types
  /*:: ?: Types */
  )
  /*: (args?: Object) => string */
  {
    return interpretAST(ast, null, locale || 'en', types || {}, true);
  };

  exports.toParts = function toParts(ast
  /*: AST */
  , locale
  /*:: ?: Locales */
  , types
  /*:: ?: Types */
  )
  /*: (args?: Object) => any[] */
  {
    return interpretAST(ast, null, locale || 'en', types || {}, false);
  };

  function interpretAST(elements
  /*: any[] */
  , parent
  /*: ?Placeholder */
  , locale
  /*: Locales */
  , types
  /*: Types */
  , join
  /*: boolean */
  )
  /*: Function */
  {
    var parts = elements.map(function (element) {
      return interpretElement(element, parent, locale, types, join);
    });

    if (!join) {
      return function format(args) {
        return parts.reduce(function (parts, part) {
          return parts.concat(part(args));
        }, []);
      };
    }

    if (parts.length === 1) return parts[0];
    return function format(args) {
      var message = '';

      for (var e = 0; e < parts.length; ++e) {
        message += parts[e](args);
      }

      return message;
    };
  }

  function interpretElement(element
  /*: Placeholder */
  , parent
  /*: ?Placeholder */
  , locale
  /*: Locales */
  , types
  /*: Types */
  , join
  /*: boolean */
  )
  /*: Function */
  {
    if (typeof element === 'string') {
      var value
      /*: string */
      = element;
      return function format() {
        return value;
      };
    }

    var id = element[0];
    var type = element[1];

    if (parent && element[0] === '#') {
      id = parent[0];
      var offset = parent[2];
      var formatter = (types.number || defaults.number)([id, 'number'], locale);
      return function format(args) {
        return formatter(getArg(id, args) - offset, args);
      };
    } // pre-process children


    var children;

    if (type === 'plural' || type === 'selectordinal') {
      children = {};
      Object.keys(element[3]).forEach(function (key) {
        children[key] = interpretAST(element[3][key], element, locale, types, join);
      });
      element = [element[0], element[1], element[2], children];
    } else if (element[2] && _typeof$1(element[2]) === 'object') {
      children = {};
      Object.keys(element[2]).forEach(function (key) {
        children[key] = interpretAST(element[2][key], element, locale, types, join);
      });
      element = [element[0], element[1], children];
    }

    var getFrmt = type && (types[type] || defaults[type]);

    if (getFrmt) {
      var frmt = getFrmt(element, locale);
      return function format(args) {
        return frmt(getArg(id, args), args);
      };
    }

    return join ? function format(args) {
      return String(getArg(id, args));
    } : function format(args) {
      return getArg(id, args);
    };
  }

  function getArg(id
  /*: string */
  , args
  /*: ?Object */
  )
  /*: any */
  {
    if (args && id in args) return args[id];
    var parts = id.split('.');
    var a = args;

    for (var i = 0, ii = parts.length; a && i < ii; ++i) {
      a = a[parts[i]];
    }

    return a;
  }

  function interpretNumber(element
  /*: Placeholder */
  , locales
  /*: Locales */
  ) {
    var style = element[2];
    var options = formatMessageFormats.number[style] || formatMessageFormats.parseNumberPattern(style) || formatMessageFormats.number.default;
    return new Intl.NumberFormat(locales, options).format;
  }

  function interpretDuration(element
  /*: Placeholder */
  , locales
  /*: Locales */
  ) {
    var style = element[2];
    var options = formatMessageFormats.duration[style] || formatMessageFormats.duration.default;
    var fs = new Intl.NumberFormat(locales, options.seconds).format;
    var fm = new Intl.NumberFormat(locales, options.minutes).format;
    var fh = new Intl.NumberFormat(locales, options.hours).format;
    var sep = /^fi$|^fi-|^da/.test(String(locales)) ? '.' : ':';
    return function (s, args) {
      s = +s;
      if (!isFinite(s)) return fs(s);
      var h = ~~(s / 60 / 60); // ~~ acts much like Math.trunc

      var m = ~~(s / 60 % 60);
      var dur = (h ? fh(Math.abs(h)) + sep : '') + fm(Math.abs(m)) + sep + fs(Math.abs(s % 60));
      return s < 0 ? fh(-1).replace(fh(1), dur) : dur;
    };
  }

  function interpretDateTime(element
  /*: Placeholder */
  , locales
  /*: Locales */
  ) {
    var type = element[1];
    var style = element[2];
    var options = formatMessageFormats[type][style] || formatMessageFormats.parseDatePattern(style) || formatMessageFormats[type].default;
    return new Intl.DateTimeFormat(locales, options).format;
  }

  function interpretPlural(element
  /*: Placeholder */
  , locales
  /*: Locales */
  ) {
    var type = element[1];
    var pluralType = type === 'selectordinal' ? 'ordinal' : 'cardinal';
    var offset = element[2];
    var children = element[3];
    var pluralRules;

    if (Intl.PluralRules && Intl.PluralRules.supportedLocalesOf(locales).length > 0) {
      pluralRules = new Intl.PluralRules(locales, {
        type: pluralType
      });
    } else {
      var locale = lookupClosestLocale(locales, plurals);
      var select = locale && plurals[locale][pluralType] || returnOther;
      pluralRules = {
        select: select
      };
    }

    return function (value, args) {
      var clause = children['=' + +value] || children[pluralRules.select(value - offset)] || children.other;
      return clause(args);
    };
  }

  function returnOther()
  /*:: n:number */
  {
    return 'other';
  }

  function interpretSelect(element
  /*: Placeholder */
  , locales
  /*: Locales */
  ) {
    var children = element[2];
    return function (value, args) {
      var clause = children[value] || children.other;
      return clause(args);
    };
  }

  var defaults
  /*: Types */
  = {
    number: interpretNumber,
    ordinal: interpretNumber,
    // TODO: support rbnf
    spellout: interpretNumber,
    // TODO: support rbnf
    duration: interpretDuration,
    date: interpretDateTime,
    time: interpretDateTime,
    plural: interpretPlural,
    selectordinal: interpretPlural,
    select: interpretSelect
  };
  exports.types = defaults;
});

var formatMessage$1 = createCommonjsModule(function (module, exports) {
  /*::
  import type { Types } from 'format-message-interpret'
  type Locale = string
  type Locales = Locale | Locale[]
  type Message = string | {|
    id?: string,
    default: string,
    description?: string
  |}
  type Translations = { [string]: ?{ [string]: string | Translation } }
  type Translation = {
    message: string,
    format?: (args?: Object) => string,
    toParts?: (args?: Object) => any[],
  }
  type Replacement = ?string | (string, string, locales?: Locales) => ?string
  type GenerateId = (string) => string
  type MissingTranslation = 'ignore' | 'warning' | 'error'
  type FormatObject = { [string]: * }
  type Options = {
    locale?: Locales,
    translations?: ?Translations,
    generateId?: GenerateId,
    missingReplacement?: Replacement,
    missingTranslation?: MissingTranslation,
    formats?: {
      number?: FormatObject,
      date?: FormatObject,
      time?: FormatObject
    },
    types?: Types
  }
  type Setup = {|
    locale: Locales,
    translations: Translations,
    generateId: GenerateId,
    missingReplacement: Replacement,
    missingTranslation: MissingTranslation,
    formats: {
      number: FormatObject,
      date: FormatObject,
      time: FormatObject
    },
    types: Types
  |}
  type FormatMessage = {
    (msg: Message, args?: Object, locales?: Locales): string,
    rich (msg: Message, args?: Object, locales?: Locales): any[],
    setup (opt?: Options): Setup,
    number (value: number, style?: string, locales?: Locales): string,
    date (value: number | Date, style?: string, locales?: Locales): string,
    time (value: number | Date, style?: string, locales?: Locales): string,
    select (value: any, options: Object): any,
    custom (placeholder: any[], locales: Locales, value: any, args: Object): any,
    plural (value: number, offset: any, options: any, locale: any): any,
    selectordinal (value: number, offset: any, options: any, locale: any): any,
    namespace (): FormatMessage
  }
  */

  function assign
  /*:: <T: Object> */
  (target
  /*: T */
  , source
  /*: Object */
  ) {
    Object.keys(source).forEach(function (key) {
      target[key] = source[key];
    });
    return target;
  }

  function namespace()
  /*: FormatMessage */
  {
    var formats = assign({}, formatMessageFormats);
    var currentLocales
    /*: Locales */
    = 'en';
    var translations
    /*: Translations */
    = {};

    var generateId
    /*: GenerateId */
    = function generateId(pattern) {
      return pattern;
    };

    var missingReplacement
    /*: Replacement */
    = null;
    var missingTranslation
    /*: MissingTranslation */
    = 'warning';
    var types
    /*: Types */
    = {};

    function formatMessage(msg
    /*: Message */
    , args
    /*:: ?: Object */
    , locales
    /*:: ?: Locales */
    ) {
      var pattern = typeof msg === 'string' ? msg : msg.default;
      var id = _typeof$1(msg) === 'object' && msg.id || generateId(pattern);
      var translated = translate(pattern, id, locales || currentLocales);
      var format = translated.format || (translated.format = formatMessageInterpret(formatMessageParse(translated.message), locales || currentLocales, types));
      return format(args);
    }

    formatMessage.rich = function rich(msg
    /*: Message */
    , args
    /*:: ?: Object */
    , locales
    /*:: ?: Locales */
    ) {
      var pattern = typeof msg === 'string' ? msg : msg.default;
      var id = _typeof$1(msg) === 'object' && msg.id || generateId(pattern);
      var translated = translate(pattern, id, locales || currentLocales);
      var format = translated.toParts || (translated.toParts = formatMessageInterpret.toParts(formatMessageParse(translated.message, {
        tagsType: tagsType
      }), locales || currentLocales, types));
      return format(args);
    };

    var tagsType = '<>';

    function richType(node
    /*: any[] */
    , locales
    /*: Locales */
    ) {
      var style = node[2];
      return function (fn, args) {
        var props = _typeof$1(style) === 'object' ? mapObject(style, args) : style;
        return typeof fn === 'function' ? fn(props) : fn;
      };
    }

    types[tagsType] = richType;

    function mapObject(object
    /* { [string]: (args?: Object) => any } */
    , args
    /*: ?Object */
    ) {
      return Object.keys(object).reduce(function (mapped, key) {
        mapped[key] = object[key](args);
        return mapped;
      }, {});
    }

    function translate(pattern
    /*: string */
    , id
    /*: string */
    , locales
    /*: Locales */
    )
    /*: Translation */
    {
      var locale = lookupClosestLocale(locales, translations) || 'en';
      var messages = translations[locale] || (translations[locale] = {});
      var translated = messages[id];

      if (typeof translated === 'string') {
        translated = messages[id] = {
          message: translated
        };
      }

      if (!translated) {
        var message = 'Translation for "' + id + '" in "' + locale + '" is missing';

        if (missingTranslation === 'warning') {
          /* istanbul ignore else */
          if (typeof console !== 'undefined') console.warn(message);
        } else if (missingTranslation !== 'ignore') {
          // 'error'
          throw new Error(message);
        }

        var replacement = typeof missingReplacement === 'function' ? missingReplacement(pattern, id, locale) || pattern : missingReplacement || pattern;
        translated = messages[id] = {
          message: replacement
        };
      }

      return translated;
    }

    formatMessage.setup = function setup(opt
    /*:: ?: Options */
    ) {
      opt = opt || {};
      if (opt.locale) currentLocales = opt.locale;
      if ('translations' in opt) translations = opt.translations || {};
      if (opt.generateId) generateId = opt.generateId;
      if ('missingReplacement' in opt) missingReplacement = opt.missingReplacement;
      if (opt.missingTranslation) missingTranslation = opt.missingTranslation;

      if (opt.formats) {
        if (opt.formats.number) assign(formats.number, opt.formats.number);
        if (opt.formats.date) assign(formats.date, opt.formats.date);
        if (opt.formats.time) assign(formats.time, opt.formats.time);
      }

      if (opt.types) {
        types = opt.types;
        types[tagsType] = richType;
      }

      return {
        locale: currentLocales,
        translations: translations,
        generateId: generateId,
        missingReplacement: missingReplacement,
        missingTranslation: missingTranslation,
        formats: formats,
        types: types
      };
    };

    formatMessage.number = function (value
    /*: number */
    , style
    /*:: ?: string */
    , locales
    /*:: ?: Locales */
    ) {
      var options = style && formats.number[style] || formats.parseNumberPattern(style) || formats.number.default;
      return new Intl.NumberFormat(locales || currentLocales, options).format(value);
    };

    formatMessage.date = function (value
    /*:: ?: number | Date */
    , style
    /*:: ?: string */
    , locales
    /*:: ?: Locales */
    ) {
      var options = style && formats.date[style] || formats.parseDatePattern(style) || formats.date.default;
      return new Intl.DateTimeFormat(locales || currentLocales, options).format(value);
    };

    formatMessage.time = function (value
    /*:: ?: number | Date */
    , style
    /*:: ?: string */
    , locales
    /*:: ?: Locales */
    ) {
      var options = style && formats.time[style] || formats.parseDatePattern(style) || formats.time.default;
      return new Intl.DateTimeFormat(locales || currentLocales, options).format(value);
    };

    formatMessage.select = function (value
    /*: any */
    , options
    /*: Object */
    ) {
      return options[value] || options.other;
    };

    formatMessage.custom = function (placeholder
    /*: any[] */
    , locales
    /*: Locales */
    , value
    /*: any */
    , args
    /*: Object */
    ) {
      if (!(placeholder[1] in types)) return value;
      return types[placeholder[1]](placeholder, locales)(value, args);
    };

    formatMessage.plural = plural.bind(null, 'cardinal');
    formatMessage.selectordinal = plural.bind(null, 'ordinal');

    function plural(pluralType
    /*: 'cardinal' | 'ordinal' */
    , value
    /*: number */
    , offset
    /*: any */
    , options
    /*: any */
    , locale
    /*: any */
    ) {
      if (_typeof$1(offset) === 'object' && _typeof$1(options) !== 'object') {
        // offset is optional
        locale = options;
        options = offset;
        offset = 0;
      }

      var closest = lookupClosestLocale(locale || currentLocales, plurals);
      var plural = closest && plurals[closest][pluralType] || returnOther;
      return options['=' + +value] || options[plural(value - offset)] || options.other;
    }

    function returnOther()
    /*:: n:number */
    {
      return 'other';
    }

    formatMessage.namespace = namespace;
    return formatMessage;
  }

  module.exports = namespace();
});

/**
 * Formatter which is used for translating.
 * When it was loaded as a module, 'formatMessage' will be replaced which is used in the runtime.
 * @type {Function}
 */

var formatMessage = formatMessage$1;
/**
 * URL to get this extension as a module.
 * When it was loaded as a module, 'extensionURL' will be replaced a URL which is retrieved from.
 * @type {string}
 */

var extensionURL = 'https://champierre.github.io/ml2scratch/ml2scratch.mjs';
var HAT_TIMEOUT = 100;
var blockIconURI = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAACXBIWXMAAAsTAAALEwEAmpwYAAABWWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyI+CiAgICAgICAgIDx0aWZmOk9yaWVudGF0aW9uPjE8L3RpZmY6T3JpZW50YXRpb24+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgpMwidZAAAFX0lEQVRYCe1YTWhcVRQ+8+YvmaRtkibYpBpbBEtSqKkGFy6iGxG36koUXCi40IW7FkQQcemyaotu3PiDuAjiItaoCGKTWmyxTFRobP4aHBKTppPJ/Lz3/L773s17982bISGVdjFnmHn33XvuOd/5zrnnPSbR8917rtzFYt3F2BS0FsC9ZqjFYIvBvTKw1/2pZgaSWEw0U9jjmoP9/DaTWIDctB/Q0omE2OJipGGyp3McvdKFnuO4kWgd70pLG64jNVx5WjkblTqABJcDiDm7LMIvQP4v4gJOwpLOdE7a4a8KJ3EtpQ4gmSO417vul+cGTiAsd0fc7CYIMpW2knLt1oq8uHBB0vCQA7wSrlE6DICsOaaVzBHc2OHju/G7a91Rx5bPCzPy9WZBBlI5pNsGWFMMgETPmlNpZQogZbsqqUQSs94954KaZN0E8+G18HxYnzoOPmkrJVu1irTBNrOkKsk0RVUxAHJCU6x1CS5pmdXBNa3HPbsVy/V2W0ClgOFHlWSMIdNzSCEK4JM/f5I3L30l65VNBc52vAaxCRbeuTwuZ/OTYivWvdBmVhfltelPZRF1RnH9jKixmiH7yBDSrAQOw6z7KrEHx18LotxCmt9fviLvzk3K+YXfPXt+BD8v/yFvzU7Iq1gneM1tfn1JzsyOy+xGQenrjPjG1YUM8iSLU0MqfYNhBYwbMhjW49ZjmU70nwE5t/SbrJU3xYJhsvfx/K+Y75ensZ5Q+fJ2ZlFj0jYgKZzWqChgmMylsvLhyDPyRs+DcrlalD7WY0SaADRjXgWYPhic2FgUska5VLgmn63/LYOpdllgzwyJSpdTUbUVmt4eqnWkvT/XJSf3H1Kdgyc4ymPdIdm2EBmQnAK6vmT2yZn5aelIZ+Xc9Sn0pU6ZQ3s4WWea3qLuwkZxMPChRtnGswQZMSnxdHcOkKYA8KiVkfPlm/LNlS8BLidDVlryYC8eSpzLMEhvHC6N6GqTFJuqCgBSMuvWpALGRtu6ANiWPNJI4PXVw/3c5YG0ocuTbzMLSlzUsTdK8aBgPg5M3JxvILgwwhLbAQr+6sPPyxdHn5CL/+bl7L2PyswjL8gwanAJJ9EyeIR3gNKHhI2Z/TTpp5LN2wH2PNrRD2tz6MjtUgIBUc6bpNgPjzixq4IIn8wekGPdh2UY3+nOXnmo74h6pj6eOygfFP8xKlwxlT4gk8sz6qnB+xqCPIRDMbivV0VfrJXlpavjMlUsyAgy8pdTlawRZMyTJOAtiMVC5BdQZ0fclJSqZbyBZGX0ngeUahVOV22kuVbCIzFIiGrMdklOLfwip65/L5LM4jSsyFjviHz72MuSSXrcDGJ+KpkBAS7KJESKD6QhgxoeI2eapk88q7YQHJ07oJVp4lvJ20NPyWk08w60Ia6xJMYGhuTHzCvqIFOPnwrKoL+jezvtNOj58U6zj8m41AHUwJJ+i1Bg4PT4wfvURgeAmUt+KLxn2r2x54hz3dkOvA0Nq/noj816RlOmBVW3KiiA1c5DGwyAXFfboLlFI5C0nwp1gx8+QUwJ0qKfEBq8qRfcJf2nSwK21lF37IE8MIGlQNcASEhbDAMn6qP5i3KjtK5SQOCExWsjofHoegCUK557nlPepQFqvrQmE+ipvajBFZz4uFaViP55xATyFfwG+1tta9uw4Z7pD3xi7EPzywKbgjl1E/3xwwGTPXhR5R3JieaGuwwGOUElvnoP4onRns3iMOjYuXp7RMdG22uoV4Ije36YhpM6gFwlyFtQL2pmjC2370YD8vmMNRwLUGtqA/r+Tlzj0n4ncDT02QLYkJodLrQY3CFRDdVaDDakZocL/wH/AdPykJ+gGwAAAABJRU5ErkJggg==';
var Message = {
  train_label_1: {
    'ja': 'ラベル1を学習する',
    'ja-Hira': 'ラベル1をがくしゅうする',
    'en': 'train label 1',
    'zh-cn': '学习标签1',
    'zh-tw': '學習標籤1'
  },
  train_label_2: {
    'ja': 'ラベル2を学習する',
    'ja-Hira': 'ラベル2をがくしゅうする',
    'en': 'train label 2',
    'zh-cn': '学习标签2',
    'zh-tw': '學習標籤2'
  },
  train_label_3: {
    'ja': 'ラベル3を学習する',
    'ja-Hira': 'ラベル3をがくしゅうする',
    'en': 'train label 3',
    'zh-cn': '学习标签3',
    'zh-tw': '學習標籤3'
  },
  train: {
    'ja': 'ラベル[LABEL]を学習する',
    'ja-Hira': 'ラベル[LABEL]をがくしゅうする',
    'en': 'train label [LABEL]',
    'zh-cn': '学习标签[LABEL]',
    'zh-tw': '學習標籤[LABEL]'
  },
  when_received_block: {
    'ja': 'ラベル[LABEL]を受け取ったとき',
    'ja-Hira': 'ラベル[LABEL]をうけとったとき',
    'en': 'when received label:[LABEL]',
    'zh-cn': '接收到类别[LABEL]时',
    'zh-tw': '接收到類別[LABEL]時'
  },
  label_block: {
    'ja': 'ラベル',
    'ja-Hira': 'ラベル',
    'en': 'label',
    'zh-cn': '标签',
    'zh-tw': '標籤'
  },
  counts_label_1: {
    'ja': 'ラベル1の枚数',
    'ja-Hira': 'ラベル1のまいすう',
    'en': 'counts of label 1',
    'zh-cn': '标签数量1',
    'zh-tw': '標籤數量1'
  },
  counts_label_2: {
    'ja': 'ラベル2の枚数',
    'ja-Hira': 'ラベル2のまいすう',
    'en': 'counts of label 2',
    'zh-cn': '标签数量2',
    'zh-tw': '標籤數量2'
  },
  counts_label_3: {
    'ja': 'ラベル3の枚数',
    'ja-Hira': 'ラベル3のまいすう',
    'en': 'counts of label 3',
    'zh-cn': '标签数量3',
    'zh-tw': '標籤數量3'
  },
  counts_label_4: {
    'ja': 'ラベル4の枚数',
    'ja-Hira': 'ラベル4のまいすう',
    'en': 'counts of label 4',
    'zh-cn': '标签数量4',
    'zh-tw': '標籤數量4'
  },
  counts_label_5: {
    'ja': 'ラベル5の枚数',
    'ja-Hira': 'ラベル5のまいすう',
    'en': 'counts of label 5',
    'zh-cn': '标签数量5',
    'zh-tw': '標籤數量5'
  },
  counts_label_6: {
    'ja': 'ラベル6の枚数',
    'ja-Hira': 'ラベル6のまいすう',
    'en': 'counts of label 6',
    'zh-cn': '标签数量6',
    'zh-tw': '標籤數量6'
  },
  counts_label_7: {
    'ja': 'ラベル7の枚数',
    'ja-Hira': 'ラベル7のまいすう',
    'en': 'counts of label 7',
    'zh-cn': '标签数量7',
    'zh-tw': '標籤數量7'
  },
  counts_label_8: {
    'ja': 'ラベル8の枚数',
    'ja-Hira': 'ラベル8のまいすう',
    'en': 'counts of label 8',
    'zh-cn': '标签数量8',
    'zh-tw': '標籤數量8'
  },
  counts_label_9: {
    'ja': 'ラベル9の枚数',
    'ja-Hira': 'ラベル9のまいすう',
    'en': 'counts of label 9',
    'zh-cn': '标签数量9',
    'zh-tw': '標籤數量9'
  },
  counts_label_10: {
    'ja': 'ラベル10の枚数',
    'ja-Hira': 'ラベル10のまいすう',
    'en': 'counts of label 10',
    'zh-cn': '标签数量10',
    'zh-tw': '標籤數量10'
  },
  counts_label: {
    'ja': 'ラベル[LABEL]の枚数',
    'ja-Hira': 'ラベル[LABEL]のまいすう',
    'en': 'counts of label [LABEL]',
    'zh-cn': '标签数量[LABEL]',
    'zh-tw': '標籤數量[LABEL]'
  },
  any: {
    'ja': 'のどれか',
    'ja-Hira': 'のどれか',
    'en': 'any',
    'zh-cn': '任何',
    'zh-tw': '任何'
  },
  all: {
    'ja': 'の全て',
    'ja-Hira': 'のすべて',
    'en': 'all',
    'zh-cn': '所有',
    'zh-tw': '所有量'
  },
  reset: {
    'ja': 'ラベル[LABEL]の学習をリセット',
    'ja-Hira': 'ラベル[LABEL]のがくしゅうをリセット',
    'en': 'reset label:[LABEL]',
    'zh-cn': '重置[LABEL]',
    'zh-tw': '重置[LABEL]'
  },
  download_learning_data: {
    'ja': '学習データをダウンロード',
    'ja-Hira': 'がくしゅうデータをダウンロード',
    'en': 'download learning data',
    'zh-cn': '下载学习数据',
    'zh-tw': '下載學習資料'
  },
  upload_learning_data: {
    'ja': '学習データをアップロード',
    'ja-Hira': 'がくしゅうデータをアップロード',
    'en': 'upload learning data',
    'zh-cn': '上传学习数据',
    'zh-tw': '上傳學習資料'
  },
  upload: {
    'ja': 'アップロード',
    'ja-Hira': 'アップロード',
    'en': 'upload',
    'zh-cn': '上传',
    'zh-tw': '上傳'
  },
  uploaded: {
    'ja': 'アップロードが完了しました。',
    'ja-Hira': 'アップロードがかんりょうしました。',
    'en': 'The upload is complete.',
    'zh-cn': '上传完成。',
    'zh-tw': '上傳完成。'
  },
  upload_instruction: {
    'ja': 'ファイルを選び、アップロードボタンをクリックして下さい。',
    'ja-Hira': 'ファイルをえらび、アップロードボタンをクリックしてください。',
    'en': 'Select a file and click the upload button.',
    'zh-cn': '选择一个文件，然后单击上传按钮。',
    'zh-tw': '選擇一個檔案，然後點擊上傳按鈕'
  },
  confirm_reset: {
    'ja': '本当にリセットしてもよろしいですか？',
    'ja-Hira': 'ほんとうにリセットしてもよろしいですか？',
    'en': 'Are you sure to reset?',
    'zh-cn': '你确定要重置吗？',
    'zh-tw': '您確定要重置嗎？'
  },
  toggle_classification: {
    'ja': 'ラベル付けを[CLASSIFICATION_STATE]にする',
    'ja-Hira': 'ラベルづけを[CLASSIFICATION_STATE]にする',
    'en': 'turn classification [CLASSIFICATION_STATE]',
    'zh-cn': '[CLASSIFICATION_STATE]分类',
    'zh-tw': '[CLASSIFICATION_STATE]分類'
  },
  set_classification_interval: {
    'ja': 'ラベル付けを[CLASSIFICATION_INTERVAL]秒間に1回行う',
    'ja-Hira': 'ラベルづけを[CLASSIFICATION_INTERVAL]びょうかんに1かいおこなう',
    'en': 'Label once every [CLASSIFICATION_INTERVAL] seconds',
    'zh-cn': '每隔[CLASSIFICATION_INTERVAL]秒标记一次',
    'zh-tw': '每隔[CLASSIFICATION_INTERVAL]秒標記一次'
  },
  video_toggle: {
    'ja': 'ビデオを[VIDEO_STATE]にする',
    'ja-Hira': 'ビデオを[VIDEO_STATE]にする',
    'en': 'turn video [VIDEO_STATE]',
    'zh-cn': '[VIDEO_STATE]摄像头',
    'zh-tw': '視訊設為[VIDEO_STATE]'
  },
  set_input: {
    'ja': '[INPUT]の画像を学習/判定する',
    'ja-Hira': '[INPUT]のがぞうをがくしゅう/はんていする',
    'en': 'Learn/Classify [INPUT] image',
    'zh-cn': '学习/分类[INPUT]图像',
    'zh-tw': '學習/分類[INPUT]影像'
  },
  on: {
    'ja': '入',
    'ja-Hira': 'いり',
    'en': 'on',
    'zh-cn': '开启',
    'zh-tw': '開啟'
  },
  off: {
    'ja': '切',
    'ja-Hira': 'きり',
    'en': 'off',
    'zh-cn': '关闭',
    'zh-tw': '關閉'
  },
  video_on_flipped: {
    'ja': '左右反転',
    'ja-Hira': 'さゆうはんてん',
    'en': 'on flipped',
    'zh-cn': '镜像开启',
    'zh-tw': '翻轉'
  },
  webcam: {
    'ja': 'カメラ',
    'ja-Hira': 'カメラ',
    'en': 'webcam',
    'zh-cn': '网络摄像头',
    'zh-tw': '網路攝影機'
  },
  stage: {
    'ja': 'ステージ',
    'ja-Hira': 'ステージ',
    'en': 'stage',
    'zh-cn': '舞台',
    'zh-tw': '舞台'
  },
  first_training_warning: {
    'ja': '最初の学習にはしばらく時間がかかるので、何度もクリックしないで下さい。',
    'ja-Hira': 'さいしょのがくしゅうにはしばらくじかんがかかるので、なんどもクリックしないでください。',
    'en': 'The first training will take a while, so do not click again and again.',
    'zh-cn': '第一项研究需要一段时间，所以不要一次又一次地点击。',
    'zh-tw': '第一次訓練需要一段時間，請稍後，不要一直點擊。'
  },
  switch_webcam: {
    'ja': 'カメラを[DEVICE]に切り替える',
    'ja-Hira': 'カメラを[DEVICE]にきりかえる',
    'en': 'switch webcam to [DEVICE]',
    'zh-cn': '网络摄像头切换到[DEVICE]',
    'zh-tw': '網路攝影機切換到[DEVICE]'
  }
};
var AvailableLocales = ['en', 'ja', 'ja-Hira', 'zh-cn', 'zh-tw'];

var Scratch3ML2ScratchBlocks = /*#__PURE__*/function () {
  function Scratch3ML2ScratchBlocks(runtime) {
    var _this = this;

    _classCallCheck(this, Scratch3ML2ScratchBlocks);

    this.runtime = runtime;

    if (runtime.formatMessage) {
      // Replace 'formatMessage' to a formatter which is used in the runtime.
      formatMessage = runtime.formatMessage;
    }

    this.when_received = false;
    this.when_received_arr = Array(8).fill(false);
    this.label = null;
    this.locale = this.setLocale();
    this.blockClickedAt = null;
    this.counts = null;
    this.firstTraining = true;
    this.interval = 1000;
    this.globalVideoTransparency = 0;
    this.setVideoTransparency({
      TRANSPARENCY: this.globalVideoTransparency
    });
    this.canvas = document.querySelector('canvas');
    this.runtime.ioDevices.video.enableVideo().then(function () {
      _this.input = _this.runtime.ioDevices.video.provider.video;
    });
    this.knnClassifier = ml5_min.KNNClassifier();
    this.featureExtractor = ml5_min.featureExtractor('MobileNet', function () {
      console.log('[featureExtractor] Model Loaded!');
      _this.timer = setInterval(function () {
        _this.classify();
      }, _this.interval);
    });
    this.devices = [{
      text: 'default',
      value: ''
    }];
    var dialog = document.createElement("DIALOG");
    dialog.id = "upload-dialog";
    dialog.innerHTML = "\n      <html><body>\n      <div>".concat(Message.upload_instruction[this.locale], "</p><input type=\"file\" id=\"upload-files\"><input type=\"button\" value=\"").concat(Message.upload[this.locale], "\" id=\"upload-button\"></div>\n      <div style=\"margin-top:10px;display:flex;justify-content:flex-end;\"><button id=\"close\" aria-label=\"close\" formnovalidate>\u9589\u3058\u308B</button></div>\n      </body><body>\n    ");
    this.uploadDialog = dialog;
    document.body.appendChild(dialog);

    document.getElementById("upload-button").onclick = function () {
      _this.uploadButtonClicked();
    };

    document.getElementById("close").onclick = function () {
      dialog.close();
    };

    try {
      navigator.mediaDevices.enumerateDevices().then(function (media) {
        var _iterator = _createForOfIteratorHelper(media),
            _step;

        try {
          for (_iterator.s(); !(_step = _iterator.n()).done;) {
            var device = _step.value;

            if (device.kind === 'videoinput') {
              _this.devices.push({
                text: device.label,
                value: device.deviceId
              });
            }
          }
        } catch (err) {
          _iterator.e(err);
        } finally {
          _iterator.f();
        }
      });
    } catch (e) {
      console.error("failed to load media devices!");
    }
  }

  _createClass(Scratch3ML2ScratchBlocks, [{
    key: "getInfo",
    value: function getInfo() {
      this.locale = this.setLocale();
      return {
        id: Scratch3ML2ScratchBlocks.EXTENSION_ID,
        name: Scratch3ML2ScratchBlocks.EXTENSION_NAME,
        extensionURL: Scratch3ML2ScratchBlocks.extensionURL,
        blockIconURI: blockIconURI,
        blocks: [{
          opcode: 'addExample1',
          blockType: blockType.COMMAND,
          text: Message.train_label_1[this.locale]
        }, {
          opcode: 'addExample2',
          blockType: blockType.COMMAND,
          text: Message.train_label_2[this.locale]
        }, {
          opcode: 'addExample3',
          blockType: blockType.COMMAND,
          text: Message.train_label_3[this.locale]
        }, {
          opcode: 'train',
          text: Message.train[this.locale],
          blockType: blockType.COMMAND,
          arguments: {
            LABEL: {
              type: argumentType.STRING,
              menu: 'train_menu',
              defaultValue: '4'
            }
          }
        }, {
          opcode: 'trainAny',
          text: Message.train[this.locale],
          blockType: blockType.COMMAND,
          arguments: {
            LABEL: {
              type: argumentType.STRING,
              defaultValue: '11'
            }
          }
        }, {
          opcode: 'getLabel',
          text: Message.label_block[this.locale],
          blockType: blockType.REPORTER
        }, {
          opcode: 'whenReceived',
          text: Message.when_received_block[this.locale],
          blockType: blockType.HAT,
          arguments: {
            LABEL: {
              type: argumentType.STRING,
              menu: 'received_menu',
              defaultValue: 'any'
            }
          }
        }, {
          opcode: 'whenReceivedAny',
          text: Message.when_received_block[this.locale],
          blockType: blockType.HAT,
          arguments: {
            LABEL: {
              type: argumentType.STRING,
              defaultValue: '11'
            }
          }
        }, {
          opcode: 'getCountByLabel1',
          text: Message.counts_label_1[this.locale],
          blockType: blockType.REPORTER
        }, {
          opcode: 'getCountByLabel2',
          text: Message.counts_label_2[this.locale],
          blockType: blockType.REPORTER
        }, {
          opcode: 'getCountByLabel3',
          text: Message.counts_label_3[this.locale],
          blockType: blockType.REPORTER
        }, {
          opcode: 'getCountByLabel4',
          text: Message.counts_label_4[this.locale],
          blockType: blockType.REPORTER
        }, {
          opcode: 'getCountByLabel5',
          text: Message.counts_label_5[this.locale],
          blockType: blockType.REPORTER
        }, {
          opcode: 'getCountByLabel6',
          text: Message.counts_label_6[this.locale],
          blockType: blockType.REPORTER
        }, {
          opcode: 'getCountByLabel7',
          text: Message.counts_label_7[this.locale],
          blockType: blockType.REPORTER
        }, {
          opcode: 'getCountByLabel8',
          text: Message.counts_label_8[this.locale],
          blockType: blockType.REPORTER
        }, {
          opcode: 'getCountByLabel9',
          text: Message.counts_label_9[this.locale],
          blockType: blockType.REPORTER
        }, {
          opcode: 'getCountByLabel10',
          text: Message.counts_label_10[this.locale],
          blockType: blockType.REPORTER
        }, {
          opcode: 'getCountByLabel',
          text: Message.counts_label[this.locale],
          blockType: blockType.REPORTER,
          arguments: {
            LABEL: {
              type: argumentType.STRING,
              defaultValue: '11'
            }
          }
        }, {
          opcode: 'reset',
          blockType: blockType.COMMAND,
          text: Message.reset[this.locale],
          arguments: {
            LABEL: {
              type: argumentType.STRING,
              menu: 'reset_menu',
              defaultValue: 'all'
            }
          }
        }, {
          opcode: 'resetAny',
          blockType: blockType.COMMAND,
          text: Message.reset[this.locale],
          arguments: {
            LABEL: {
              type: argumentType.STRING,
              defaultValue: '11'
            }
          }
        }, {
          opcode: 'download',
          text: Message.download_learning_data[this.locale],
          blockType: blockType.COMMAND
        }, {
          opcode: 'upload',
          text: Message.upload_learning_data[this.locale],
          blockType: blockType.COMMAND
        }, {
          opcode: 'toggleClassification',
          text: Message.toggle_classification[this.locale],
          blockType: blockType.COMMAND,
          arguments: {
            CLASSIFICATION_STATE: {
              type: argumentType.STRING,
              menu: 'classification_menu',
              defaultValue: 'off'
            }
          }
        }, {
          opcode: 'setClassificationInterval',
          text: Message.set_classification_interval[this.locale],
          blockType: blockType.COMMAND,
          arguments: {
            CLASSIFICATION_INTERVAL: {
              type: argumentType.STRING,
              menu: 'classification_interval_menu',
              defaultValue: '1'
            }
          }
        }, {
          opcode: 'videoToggle',
          text: Message.video_toggle[this.locale],
          blockType: blockType.COMMAND,
          arguments: {
            VIDEO_STATE: {
              type: argumentType.STRING,
              menu: 'video_menu',
              defaultValue: 'off'
            }
          }
        }, {
          opcode: 'setVideoTransparency',
          text: formatMessage({
            id: 'videoSensing.setVideoTransparency',
            default: 'set video transparency to [TRANSPARENCY]',
            description: 'Controls transparency of the video preview layer'
          }),
          arguments: {
            TRANSPARENCY: {
              type: argumentType.NUMBER,
              defaultValue: 50
            }
          }
        }, {
          opcode: 'setInput',
          text: Message.set_input[this.locale],
          blockType: blockType.COMMAND,
          arguments: {
            INPUT: {
              type: argumentType.STRING,
              menu: 'input_menu',
              defaultValue: 'webcam'
            }
          }
        }, {
          opcode: 'switchCamera',
          blockType: blockType.COMMAND,
          text: Message.switch_webcam[this.locale],
          arguments: {
            DEVICE: {
              type: argumentType.STRING,
              defaultValue: '',
              menu: 'mediadevices'
            }
          }
        }],
        menus: {
          received_menu: {
            items: this.getMenu('received')
          },
          reset_menu: {
            items: this.getMenu('reset')
          },
          train_menu: {
            items: this.getTrainMenu()
          },
          count_menu: {
            items: this.getTrainMenu()
          },
          video_menu: this.getVideoMenu(),
          classification_interval_menu: {
            acceptReporters: true,
            items: this.getClassificationIntervalMenu()
          },
          classification_menu: this.getClassificationMenu(),
          input_menu: this.getInputMenu(),
          mediadevices: {
            acceptReporters: true,
            items: 'getDevices'
          }
        }
      };
    }
    /**
     * The transparency setting of the video preview stored in a value
     * accessible by any object connected to the virtual machine.
     * @type {number}
     */

  }, {
    key: "globalVideoTransparency",
    get: function get() {
      var stage = this.runtime.getTargetForStage();

      if (stage) {
        return stage.videoTransparency;
      }

      return 50;
    },
    set: function set(transparency) {
      var stage = this.runtime.getTargetForStage();

      if (stage) {
        stage.videoTransparency = transparency;
      }

      return transparency;
    }
  }, {
    key: "addExample1",
    value: function addExample1() {
      this.firstTrainingWarning();
      var features = this.featureExtractor.infer(this.input);
      this.knnClassifier.addExample(features, '1');
      this.updateCounts();
    }
  }, {
    key: "addExample2",
    value: function addExample2() {
      this.firstTrainingWarning();
      var features = this.featureExtractor.infer(this.input);
      this.knnClassifier.addExample(features, '2');
      this.updateCounts();
    }
  }, {
    key: "addExample3",
    value: function addExample3() {
      this.firstTrainingWarning();
      var features = this.featureExtractor.infer(this.input);
      this.knnClassifier.addExample(features, '3');
      this.updateCounts();
    }
  }, {
    key: "train",
    value: function train(args) {
      this.firstTrainingWarning();
      var features = this.featureExtractor.infer(this.input);
      this.knnClassifier.addExample(features, args.LABEL);
      this.updateCounts();
    }
  }, {
    key: "trainAny",
    value: function trainAny(args) {
      this.train(args);
    }
  }, {
    key: "getLabel",
    value: function getLabel() {
      return this.label;
    }
  }, {
    key: "whenReceived",
    value: function whenReceived(args) {
      var _this2 = this;

      if (args.LABEL === 'any') {
        if (this.when_received) {
          setTimeout(function () {
            _this2.when_received = false;
          }, HAT_TIMEOUT);
          return true;
        }

        return false;
      } else {
        if (this.when_received_arr[args.LABEL]) {
          setTimeout(function () {
            _this2.when_received_arr[args.LABEL] = false;
          }, HAT_TIMEOUT);
          return true;
        }

        return false;
      }
    }
  }, {
    key: "whenReceivedAny",
    value: function whenReceivedAny(args) {
      return this.whenReceived(args);
    }
  }, {
    key: "getCountByLabel1",
    value: function getCountByLabel1() {
      if (this.counts) {
        return this.counts['1'];
      } else {
        return 0;
      }
    }
  }, {
    key: "getCountByLabel2",
    value: function getCountByLabel2() {
      if (this.counts) {
        return this.counts['2'];
      } else {
        return 0;
      }
    }
  }, {
    key: "getCountByLabel3",
    value: function getCountByLabel3() {
      if (this.counts) {
        return this.counts['3'];
      } else {
        return 0;
      }
    }
  }, {
    key: "getCountByLabel4",
    value: function getCountByLabel4() {
      if (this.counts) {
        return this.counts['4'];
      } else {
        return 0;
      }
    }
  }, {
    key: "getCountByLabel5",
    value: function getCountByLabel5() {
      if (this.counts) {
        return this.counts['5'];
      } else {
        return 0;
      }
    }
  }, {
    key: "getCountByLabel6",
    value: function getCountByLabel6() {
      if (this.counts) {
        return this.counts['6'];
      } else {
        return 0;
      }
    }
  }, {
    key: "getCountByLabel7",
    value: function getCountByLabel7() {
      if (this.counts) {
        return this.counts['7'];
      } else {
        return 0;
      }
    }
  }, {
    key: "getCountByLabel8",
    value: function getCountByLabel8() {
      if (this.counts) {
        return this.counts['8'];
      } else {
        return 0;
      }
    }
  }, {
    key: "getCountByLabel9",
    value: function getCountByLabel9() {
      if (this.counts) {
        return this.counts['9'];
      } else {
        return 0;
      }
    }
  }, {
    key: "getCountByLabel10",
    value: function getCountByLabel10() {
      if (this.counts) {
        return this.counts['10'];
      } else {
        return 0;
      }
    }
  }, {
    key: "getCountByLabel",
    value: function getCountByLabel(args) {
      if (this.counts[args.LABEL]) {
        return this.counts[args.LABEL];
      } else {
        return 0;
      }
    }
  }, {
    key: "reset",
    value: function reset(args) {
      var _this3 = this;

      if (this.actionRepeated()) {
        return;
      }
      setTimeout(function () {
        var result = confirm(Message.confirm_reset[_this3.locale]);

        if (result) {
          if (args.LABEL == 'all') {
            _this3.knnClassifier.clearAllLabels();

            for (var label in _this3.counts) {
              _this3.counts[label] = 0;
            }
          } else {
            if (_this3.counts[args.LABEL] > 0) {
              _this3.knnClassifier.clearLabel(args.LABEL);

              _this3.counts[args.LABEL] = 0;
            }
          }
        }
      }, 1000);
    }
  }, {
    key: "resetAny",
    value: function resetAny(args) {
      this.reset(args);
    }
  }, {
    key: "download",
    value: function download() {
      if (this.actionRepeated()) {
        return;
      }
      var fileName = String(Date.now());
      this.knnClassifier.save(fileName);
    }
  }, {
    key: "upload",
    value: function upload() {
      if (this.actionRepeated()) {
        return;
      }
      document.getElementById('upload-dialog').showModal();
    }
  }, {
    key: "toggleClassification",
    value: function toggleClassification(args) {
      var _this4 = this;

      var state = args.CLASSIFICATION_STATE;

      if (this.timer) {
        clearTimeout(this.timer);
      }

      if (state === 'on') {
        this.timer = setInterval(function () {
          _this4.classify();
        }, this.interval);
      }
    }
  }, {
    key: "setClassificationInterval",
    value: function setClassificationInterval(args) {
      var _this5 = this;

      if (this.timer) {
        clearTimeout(this.timer);
      }

      this.interval = args.CLASSIFICATION_INTERVAL * 1000;
      this.timer = setInterval(function () {
        _this5.classify();
      }, this.interval);
    }
  }, {
    key: "videoToggle",
    value: function videoToggle(args) {
      var _this6 = this;

      var state = args.VIDEO_STATE;

      if (state === 'off') {
        this.runtime.ioDevices.video.disableVideo();
      } else {
        this.runtime.ioDevices.video.enableVideo().then(function () {
          _this6.input = _this6.runtime.ioDevices.video.provider.video;
        });
        this.runtime.ioDevices.video.mirror = state === "on";
      }
    }
    /**
     * A scratch command block handle that configures the video preview's
     * transparency from passed arguments.
     * @param {object} args - the block arguments
     * @param {number} args.TRANSPARENCY - the transparency to set the video
     *   preview to
     */

  }, {
    key: "setVideoTransparency",
    value: function setVideoTransparency(args) {
      var transparency = cast.toNumber(args.TRANSPARENCY);
      this.globalVideoTransparency = transparency;
      this.runtime.ioDevices.video.setPreviewGhost(transparency);
    }
  }, {
    key: "setInput",
    value: function setInput(args) {
      var input = args.INPUT;

      if (input === 'webcam') {
        this.input = this.runtime.ioDevices.video.provider.video;
      } else {
        this.input = this.canvas;
      }
    }
  }, {
    key: "uploadButtonClicked",
    value: function uploadButtonClicked() {
      var _this7 = this;

      var files = document.getElementById('upload-files').files;

      if (files.length <= 0) {
        alert('Please select JSON file.');
        return false;
      }

      var fr = new FileReader();

      fr.onload = function (e) {
        var data = JSON.parse(e.target.result);

        _this7.knnClassifier.load(data, function () {
          console.log('uploaded!');

          _this7.updateCounts();

          alert(Message.uploaded[_this7.locale]);
        });
      };

      fr.onloadend = function (e) {
        document.getElementById('upload-files').value = "";
      };

      fr.readAsText(files.item(0));
      this.uploadDialog.close();
    }
  }, {
    key: "classify",
    value: function classify() {
      var _this8 = this;

      var numLabels = this.knnClassifier.getNumLabels();
      if (numLabels == 0) return;
      var features = this.featureExtractor.infer(this.input);
      this.knnClassifier.classify(features, function (err, result) {
        if (err) {
          console.error(err);
        } else {
          _this8.label = _this8.getTopConfidenceLabel(result.confidencesByLabel);
          _this8.when_received = true;
          _this8.when_received_arr[_this8.label] = true;
        }
      });
    }
  }, {
    key: "getTopConfidenceLabel",
    value: function getTopConfidenceLabel(confidences) {
      var topConfidenceLabel;
      var topConfidence = 0;

      for (var label in confidences) {
        if (confidences[label] > topConfidence) {
          topConfidenceLabel = label;
        }
      }

      return topConfidenceLabel;
    }
  }, {
    key: "updateCounts",
    value: function updateCounts() {
      this.counts = this.knnClassifier.getCountByLabel();
      console.debug(this.counts);
    }
  }, {
    key: "actionRepeated",
    value: function actionRepeated() {
      var currentTime = Date.now();

      if (this.blockClickedAt && this.blockClickedAt + 250 > currentTime) {
        console.log('Please do not repeat trigerring this block.');
        this.blockClickedAt = currentTime;
        return true;
      } else {
        this.blockClickedAt = currentTime;
        return false;
      }
    }
  }, {
    key: "getMenu",
    value: function getMenu(name) {
      var arr = [];
      var defaultValue = 'any';
      var text = Message.any[this.locale];

      if (name == 'reset') {
        defaultValue = 'all';
        text = Message.all[this.locale];
      }

      arr.push({
        text: text,
        value: defaultValue
      });

      for (var i = 1; i <= 10; i++) {
        var obj = {};
        obj.text = i.toString(10);
        obj.value = i.toString(10);
        arr.push(obj);
      }
      return arr;
    }
  }, {
    key: "getTrainMenu",
    value: function getTrainMenu() {
      var arr = [];

      for (var i = 4; i <= 10; i++) {
        var obj = {};
        obj.text = i.toString(10);
        obj.value = i.toString(10);
        arr.push(obj);
      }
      return arr;
    }
  }, {
    key: "getVideoMenu",
    value: function getVideoMenu() {
      return [{
        text: Message.off[this.locale],
        value: 'off'
      }, {
        text: Message.on[this.locale],
        value: 'on'
      }, {
        text: Message.video_on_flipped[this.locale],
        value: 'on-flipped'
      }];
    }
  }, {
    key: "getInputMenu",
    value: function getInputMenu() {
      return [{
        text: Message.webcam[this.locale],
        value: 'webcam'
      }, {
        text: Message.stage[this.locale],
        value: 'stage'
      }];
    }
  }, {
    key: "getClassificationIntervalMenu",
    value: function getClassificationIntervalMenu() {
      return [{
        text: '1',
        value: '1'
      }, {
        text: '0.5',
        value: '0.5'
      }, {
        text: '0.2',
        value: '0.2'
      }, {
        text: '0.1',
        value: '0.1'
      }];
    }
  }, {
    key: "getClassificationMenu",
    value: function getClassificationMenu() {
      return [{
        text: Message.off[this.locale],
        value: 'off'
      }, {
        text: Message.on[this.locale],
        value: 'on'
      }];
    }
  }, {
    key: "firstTrainingWarning",
    value: function firstTrainingWarning() {
      if (this.firstTraining) {
        alert(Message.first_training_warning[this.locale]);
        this.firstTraining = false;
      }
    }
  }, {
    key: "setLocale",
    value: function setLocale() {
      var locale = formatMessage.setup().locale;

      if (AvailableLocales.includes(locale)) {
        return locale;
      } else {
        return 'en';
      }
    }
  }, {
    key: "switchCamera",
    value: function switchCamera(args) {
      var _this9 = this;

      if (args.DEVICE !== '') {
        if (this.runtime.ioDevices.video.provider._track !== null) {
          this.runtime.ioDevices.video.provider._track.stop();

          var deviceId = args.DEVICE;
          navigator.mediaDevices.getUserMedia({
            audio: false,
            video: {
              deviceId: deviceId
            }
          }).then(function (stream) {
            try {
              _this9.runtime.ioDevices.video.provider._video.srcObject = stream;
            } catch (error) {
              _this9.runtime.ioDevices.video.provider._video.src = window.URL.createObjectURL(stream);
            } // Needed for Safari/Firefox, Chrome auto-plays.


            _this9.runtime.ioDevices.video.provider._video.play();

            _this9.runtime.ioDevices.video.provider._track = stream.getTracks()[0];
          });
        }
      }
    }
  }, {
    key: "getDevices",
    value: function getDevices() {
      return this.devices;
    }
  }], [{
    key: "EXTENSION_NAME",
    get:
    /**
     * @return {string} - the name of this extension.
     */
    function get() {
      return 'ML2Scratch';
    }
    /**
     * @return {string} - the ID of this extension.
     */

  }, {
    key: "EXTENSION_ID",
    get: function get() {
      return 'ml2scratch';
    }
    /**
     * URL to get this extension.
     * @type {string}
     */

  }, {
    key: "extensionURL",
    get: function get() {
      return extensionURL;
    }
    /**
     * Set URL to get this extension.
     * extensionURL will be reset when the module is loaded from the web.
     * @param {string} url - URL
     */
    ,
    set: function set(url) {
      extensionURL = url;
    }
  }]);

  return Scratch3ML2ScratchBlocks;
}();

var blockClass = Scratch3ML2ScratchBlocks; // loadable-extension needs this line.

var _ml2scratch = Scratch3ML2ScratchBlocks;
_ml2scratch.blockClass = blockClass;

export { _ml2scratch as __moduleExports, blockClass, entry };
