{"version":3,"file":"js/application-5c32e0ecd27603db5b48.js","sources":["webpack:///webpack/bootstrap","webpack:///./app/javascript/channels sync _channel\\.js$","webpack:///./app/javascript/channels/index.js","webpack:///./app/javascript/packs/Chart.bundle.js","webpack:///./app/javascript/packs/application.js","webpack:///./app/javascript/packs/chartkick.js","webpack:///./app/javascript/packs/slick.js","webpack:///./app/javascript/packs/sliderSetting.js","webpack:///./node_modules/@nathanvda/cocoon/cocoon.js","webpack:///./node_modules/@rails/activestorage/app/assets/javascripts/activestorage.js","webpack:///./node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js","webpack:///./node_modules/jquery/dist/jquery.js","webpack:///./node_modules/turbolinks/dist/turbolinks.js"],"sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/packs/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./app/javascript/packs/application.js\");\n","function webpackEmptyContext(req) {\n\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\te.code = 'MODULE_NOT_FOUND';\n\tthrow e;\n}\nwebpackEmptyContext.keys = function() { return []; };\nwebpackEmptyContext.resolve = webpackEmptyContext;\nmodule.exports = webpackEmptyContext;\nwebpackEmptyContext.id = \"./app/javascript/channels sync recursive _channel\\\\.js$\";","// Load all the channels within this directory and all subdirectories.\n// Channel files must be named *_channel.js.\n\nconst channels = require.context('.', true, /_channel\\.js$/)\nchannels.keys().forEach(channels)\n","/*!\n * Chart.js v4.4.0\n * https://www.chartjs.org\n * (c) 2023 Chart.js Contributors\n * Released under the MIT License\n *\n * @kurkle/color v0.3.2\n * https://github.com/kurkle/color#readme\n * (c) 2023 Jukka Kurkela\n * Released under the MIT License\n *\n * chartjs-adapter-date-fns v3.0.0\n * https://www.chartjs.org\n * (c) 2022 chartjs-adapter-date-fns Contributors\n * Released under the MIT license\n *\n * date-fns v2.30.0\n * https://date-fns.org\n * (c) 2021 Sasha Koss and Lesha Koss\n * Released under the MIT License\n */\n\nconsole.log(\"This is a test message(chart.bundle)\");\n\n(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Chart = factory());\n})(this, (function () { 'use strict';\n\n function _iterableToArrayLimit(arr, i) {\n var _i = null == arr ? null : \"undefined\" != typeof Symbol && arr[Symbol.iterator] || arr[\"@@iterator\"];\n if (null != _i) {\n var _s,\n _e,\n _x,\n _r,\n _arr = [],\n _n = !0,\n _d = !1;\n try {\n if (_x = (_i = _i.call(arr)).next, 0 === i) {\n if (Object(_i) !== _i) return;\n _n = !1;\n } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);\n } catch (err) {\n _d = !0, _e = err;\n } finally {\n try {\n if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;\n } finally {\n if (_d) throw _e;\n }\n }\n return _arr;\n }\n }\n function ownKeys(object, enumerableOnly) {\n var keys = Object.keys(object);\n if (Object.getOwnPropertySymbols) {\n var symbols = Object.getOwnPropertySymbols(object);\n enumerableOnly && (symbols = symbols.filter(function (sym) {\n return Object.getOwnPropertyDescriptor(object, sym).enumerable;\n })), keys.push.apply(keys, symbols);\n }\n return keys;\n }\n function _objectSpread2(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = null != arguments[i] ? arguments[i] : {};\n i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {\n _defineProperty$1(target, key, source[key]);\n }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {\n Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));\n });\n }\n return target;\n }\n function _typeof$1(obj) {\n \"@babel/helpers - typeof\";\n\n return _typeof$1 = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n }, _typeof$1(obj);\n }\n function _classCallCheck$1(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n }\n function _defineProperties$1(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, _toPropertyKey$1(descriptor.key), descriptor);\n }\n }\n function _createClass$1(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties$1(Constructor, staticProps);\n Object.defineProperty(Constructor, \"prototype\", {\n writable: false\n });\n return Constructor;\n }\n function _defineProperty$1(obj, key, value) {\n key = _toPropertyKey$1(key);\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n }\n function _inherits$1(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n Object.defineProperty(subClass, \"prototype\", {\n writable: false\n });\n if (superClass) _setPrototypeOf$1(subClass, superClass);\n }\n function _getPrototypeOf$1(o) {\n _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {\n return o.__proto__ || Object.getPrototypeOf(o);\n };\n return _getPrototypeOf$1(o);\n }\n function _setPrototypeOf$1(o, p) {\n _setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n return _setPrototypeOf$1(o, p);\n }\n function _isNativeReflectConstruct$1() {\n if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n if (Reflect.construct.sham) return false;\n if (typeof Proxy === \"function\") return true;\n try {\n Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n return true;\n } catch (e) {\n return false;\n }\n }\n function _assertThisInitialized$1(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n return self;\n }\n function _possibleConstructorReturn$1(self, call) {\n if (call && (typeof call === \"object\" || typeof call === \"function\")) {\n return call;\n } else if (call !== void 0) {\n throw new TypeError(\"Derived constructors may only return object or undefined\");\n }\n return _assertThisInitialized$1(self);\n }\n function _createSuper$1(Derived) {\n var hasNativeReflectConstruct = _isNativeReflectConstruct$1();\n return function _createSuperInternal() {\n var Super = _getPrototypeOf$1(Derived),\n result;\n if (hasNativeReflectConstruct) {\n var NewTarget = _getPrototypeOf$1(this).constructor;\n result = Reflect.construct(Super, arguments, NewTarget);\n } else {\n result = Super.apply(this, arguments);\n }\n return _possibleConstructorReturn$1(this, result);\n };\n }\n function _superPropBase(object, property) {\n while (!Object.prototype.hasOwnProperty.call(object, property)) {\n object = _getPrototypeOf$1(object);\n if (object === null) break;\n }\n return object;\n }\n function _get() {\n if (typeof Reflect !== \"undefined\" && Reflect.get) {\n _get = Reflect.get.bind();\n } else {\n _get = function _get(target, property, receiver) {\n var base = _superPropBase(target, property);\n if (!base) return;\n var desc = Object.getOwnPropertyDescriptor(base, property);\n if (desc.get) {\n return desc.get.call(arguments.length < 3 ? target : receiver);\n }\n return desc.value;\n };\n }\n return _get.apply(this, arguments);\n }\n function _slicedToArray(arr, i) {\n return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest();\n }\n function _toConsumableArray(arr) {\n return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread();\n }\n function _arrayWithoutHoles(arr) {\n if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);\n }\n function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n }\n function _iterableToArray(iter) {\n if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter);\n }\n function _unsupportedIterableToArray$1(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return _arrayLikeToArray$1(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(o);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);\n }\n function _arrayLikeToArray$1(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n return arr2;\n }\n function _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n }\n function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n }\n function _createForOfIteratorHelper$1(o, allowArrayLike) {\n var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"];\n if (!it) {\n if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === \"number\") {\n if (it) o = it;\n var i = 0;\n var F = function () {};\n return {\n s: F,\n n: function () {\n if (i >= o.length) return {\n done: true\n };\n return {\n done: false,\n value: o[i++]\n };\n },\n e: function (e) {\n throw e;\n },\n f: F\n };\n }\n throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n }\n var normalCompletion = true,\n didErr = false,\n err;\n return {\n s: function () {\n it = it.call(o);\n },\n n: function () {\n var step = it.next();\n normalCompletion = step.done;\n return step;\n },\n e: function (e) {\n didErr = true;\n err = e;\n },\n f: function () {\n try {\n if (!normalCompletion && it.return != null) it.return();\n } finally {\n if (didErr) throw err;\n }\n }\n };\n }\n function _toPrimitive$1(input, hint) {\n if (typeof input !== \"object\" || input === null) return input;\n var prim = input[Symbol.toPrimitive];\n if (prim !== undefined) {\n var res = prim.call(input, hint || \"default\");\n if (typeof res !== \"object\") return res;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (hint === \"string\" ? String : Number)(input);\n }\n function _toPropertyKey$1(arg) {\n var key = _toPrimitive$1(arg, \"string\");\n return typeof key === \"symbol\" ? key : String(key);\n }\n\n /*!\n * @kurkle/color v0.3.2\n * https://github.com/kurkle/color#readme\n * (c) 2023 Jukka Kurkela\n * Released under the MIT License\n */\n function round(v) {\n return v + 0.5 | 0;\n }\n var lim = function lim(v, l, h) {\n return Math.max(Math.min(v, h), l);\n };\n function p2b(v) {\n return lim(round(v * 2.55), 0, 255);\n }\n function n2b(v) {\n return lim(round(v * 255), 0, 255);\n }\n function b2n(v) {\n return lim(round(v / 2.55) / 100, 0, 1);\n }\n function n2p(v) {\n return lim(round(v * 100), 0, 100);\n }\n var map$1 = {\n 0: 0,\n 1: 1,\n 2: 2,\n 3: 3,\n 4: 4,\n 5: 5,\n 6: 6,\n 7: 7,\n 8: 8,\n 9: 9,\n A: 10,\n B: 11,\n C: 12,\n D: 13,\n E: 14,\n F: 15,\n a: 10,\n b: 11,\n c: 12,\n d: 13,\n e: 14,\n f: 15\n };\n var hex = _toConsumableArray('0123456789ABCDEF');\n var h1 = function h1(b) {\n return hex[b & 0xF];\n };\n var h2 = function h2(b) {\n return hex[(b & 0xF0) >> 4] + hex[b & 0xF];\n };\n var eq = function eq(b) {\n return (b & 0xF0) >> 4 === (b & 0xF);\n };\n var isShort = function isShort(v) {\n return eq(v.r) && eq(v.g) && eq(v.b) && eq(v.a);\n };\n function hexParse(str) {\n var len = str.length;\n var ret;\n if (str[0] === '#') {\n if (len === 4 || len === 5) {\n ret = {\n r: 255 & map$1[str[1]] * 17,\n g: 255 & map$1[str[2]] * 17,\n b: 255 & map$1[str[3]] * 17,\n a: len === 5 ? map$1[str[4]] * 17 : 255\n };\n } else if (len === 7 || len === 9) {\n ret = {\n r: map$1[str[1]] << 4 | map$1[str[2]],\n g: map$1[str[3]] << 4 | map$1[str[4]],\n b: map$1[str[5]] << 4 | map$1[str[6]],\n a: len === 9 ? map$1[str[7]] << 4 | map$1[str[8]] : 255\n };\n }\n }\n return ret;\n }\n var alpha = function alpha(a, f) {\n return a < 255 ? f(a) : '';\n };\n function _hexString(v) {\n var f = isShort(v) ? h1 : h2;\n return v ? '#' + f(v.r) + f(v.g) + f(v.b) + alpha(v.a, f) : undefined;\n }\n var HUE_RE = /^(hsla?|hwb|hsv)\\(\\s*([-+.e\\d]+)(?:deg)?[\\s,]+([-+.e\\d]+)%[\\s,]+([-+.e\\d]+)%(?:[\\s,]+([-+.e\\d]+)(%)?)?\\s*\\)$/;\n function hsl2rgbn(h, s, l) {\n var a = s * Math.min(l, 1 - l);\n var f = function f(n) {\n var k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (n + h / 30) % 12;\n return l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);\n };\n return [f(0), f(8), f(4)];\n }\n function hsv2rgbn(h, s, v) {\n var f = function f(n) {\n var k = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (n + h / 60) % 6;\n return v - v * s * Math.max(Math.min(k, 4 - k, 1), 0);\n };\n return [f(5), f(3), f(1)];\n }\n function hwb2rgbn(h, w, b) {\n var rgb = hsl2rgbn(h, 1, 0.5);\n var i;\n if (w + b > 1) {\n i = 1 / (w + b);\n w *= i;\n b *= i;\n }\n for (i = 0; i < 3; i++) {\n rgb[i] *= 1 - w - b;\n rgb[i] += w;\n }\n return rgb;\n }\n function hueValue(r, g, b, d, max) {\n if (r === max) {\n return (g - b) / d + (g < b ? 6 : 0);\n }\n if (g === max) {\n return (b - r) / d + 2;\n }\n return (r - g) / d + 4;\n }\n function rgb2hsl(v) {\n var range = 255;\n var r = v.r / range;\n var g = v.g / range;\n var b = v.b / range;\n var max = Math.max(r, g, b);\n var min = Math.min(r, g, b);\n var l = (max + min) / 2;\n var h, s, d;\n if (max !== min) {\n d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n h = hueValue(r, g, b, d, max);\n h = h * 60 + 0.5;\n }\n return [h | 0, s || 0, l];\n }\n function calln(f, a, b, c) {\n return (Array.isArray(a) ? f(a[0], a[1], a[2]) : f(a, b, c)).map(n2b);\n }\n function hsl2rgb(h, s, l) {\n return calln(hsl2rgbn, h, s, l);\n }\n function hwb2rgb(h, w, b) {\n return calln(hwb2rgbn, h, w, b);\n }\n function hsv2rgb(h, s, v) {\n return calln(hsv2rgbn, h, s, v);\n }\n function hue(h) {\n return (h % 360 + 360) % 360;\n }\n function hueParse(str) {\n var m = HUE_RE.exec(str);\n var a = 255;\n var v;\n if (!m) {\n return;\n }\n if (m[5] !== v) {\n a = m[6] ? p2b(+m[5]) : n2b(+m[5]);\n }\n var h = hue(+m[2]);\n var p1 = +m[3] / 100;\n var p2 = +m[4] / 100;\n if (m[1] === 'hwb') {\n v = hwb2rgb(h, p1, p2);\n } else if (m[1] === 'hsv') {\n v = hsv2rgb(h, p1, p2);\n } else {\n v = hsl2rgb(h, p1, p2);\n }\n return {\n r: v[0],\n g: v[1],\n b: v[2],\n a: a\n };\n }\n function _rotate(v, deg) {\n var h = rgb2hsl(v);\n h[0] = hue(h[0] + deg);\n h = hsl2rgb(h);\n v.r = h[0];\n v.g = h[1];\n v.b = h[2];\n }\n function _hslString(v) {\n if (!v) {\n return;\n }\n var a = rgb2hsl(v);\n var h = a[0];\n var s = n2p(a[1]);\n var l = n2p(a[2]);\n return v.a < 255 ? \"hsla(\".concat(h, \", \").concat(s, \"%, \").concat(l, \"%, \").concat(b2n(v.a), \")\") : \"hsl(\".concat(h, \", \").concat(s, \"%, \").concat(l, \"%)\");\n }\n var map$2 = {\n x: 'dark',\n Z: 'light',\n Y: 're',\n X: 'blu',\n W: 'gr',\n V: 'medium',\n U: 'slate',\n A: 'ee',\n T: 'ol',\n S: 'or',\n B: 'ra',\n C: 'lateg',\n D: 'ights',\n R: 'in',\n Q: 'turquois',\n E: 'hi',\n P: 'ro',\n O: 'al',\n N: 'le',\n M: 'de',\n L: 'yello',\n F: 'en',\n K: 'ch',\n G: 'arks',\n H: 'ea',\n I: 'ightg',\n J: 'wh'\n };\n var names$1 = {\n OiceXe: 'f0f8ff',\n antiquewEte: 'faebd7',\n aqua: 'ffff',\n aquamarRe: '7fffd4',\n azuY: 'f0ffff',\n beige: 'f5f5dc',\n bisque: 'ffe4c4',\n black: '0',\n blanKedOmond: 'ffebcd',\n Xe: 'ff',\n XeviTet: '8a2be2',\n bPwn: 'a52a2a',\n burlywood: 'deb887',\n caMtXe: '5f9ea0',\n KartYuse: '7fff00',\n KocTate: 'd2691e',\n cSO: 'ff7f50',\n cSnflowerXe: '6495ed',\n cSnsilk: 'fff8dc',\n crimson: 'dc143c',\n cyan: 'ffff',\n xXe: '8b',\n xcyan: '8b8b',\n xgTMnPd: 'b8860b',\n xWay: 'a9a9a9',\n xgYF: '6400',\n xgYy: 'a9a9a9',\n xkhaki: 'bdb76b',\n xmagFta: '8b008b',\n xTivegYF: '556b2f',\n xSange: 'ff8c00',\n xScEd: '9932cc',\n xYd: '8b0000',\n xsOmon: 'e9967a',\n xsHgYF: '8fbc8f',\n xUXe: '483d8b',\n xUWay: '2f4f4f',\n xUgYy: '2f4f4f',\n xQe: 'ced1',\n xviTet: '9400d3',\n dAppRk: 'ff1493',\n dApskyXe: 'bfff',\n dimWay: '696969',\n dimgYy: '696969',\n dodgerXe: '1e90ff',\n fiYbrick: 'b22222',\n flSOwEte: 'fffaf0',\n foYstWAn: '228b22',\n fuKsia: 'ff00ff',\n gaRsbSo: 'dcdcdc',\n ghostwEte: 'f8f8ff',\n gTd: 'ffd700',\n gTMnPd: 'daa520',\n Way: '808080',\n gYF: '8000',\n gYFLw: 'adff2f',\n gYy: '808080',\n honeyMw: 'f0fff0',\n hotpRk: 'ff69b4',\n RdianYd: 'cd5c5c',\n Rdigo: '4b0082',\n ivSy: 'fffff0',\n khaki: 'f0e68c',\n lavFMr: 'e6e6fa',\n lavFMrXsh: 'fff0f5',\n lawngYF: '7cfc00',\n NmoncEffon: 'fffacd',\n ZXe: 'add8e6',\n ZcSO: 'f08080',\n Zcyan: 'e0ffff',\n ZgTMnPdLw: 'fafad2',\n ZWay: 'd3d3d3',\n ZgYF: '90ee90',\n ZgYy: 'd3d3d3',\n ZpRk: 'ffb6c1',\n ZsOmon: 'ffa07a',\n ZsHgYF: '20b2aa',\n ZskyXe: '87cefa',\n ZUWay: '778899',\n ZUgYy: '778899',\n ZstAlXe: 'b0c4de',\n ZLw: 'ffffe0',\n lime: 'ff00',\n limegYF: '32cd32',\n lRF: 'faf0e6',\n magFta: 'ff00ff',\n maPon: '800000',\n VaquamarRe: '66cdaa',\n VXe: 'cd',\n VScEd: 'ba55d3',\n VpurpN: '9370db',\n VsHgYF: '3cb371',\n VUXe: '7b68ee',\n VsprRggYF: 'fa9a',\n VQe: '48d1cc',\n VviTetYd: 'c71585',\n midnightXe: '191970',\n mRtcYam: 'f5fffa',\n mistyPse: 'ffe4e1',\n moccasR: 'ffe4b5',\n navajowEte: 'ffdead',\n navy: '80',\n Tdlace: 'fdf5e6',\n Tive: '808000',\n TivedBb: '6b8e23',\n Sange: 'ffa500',\n SangeYd: 'ff4500',\n ScEd: 'da70d6',\n pOegTMnPd: 'eee8aa',\n pOegYF: '98fb98',\n pOeQe: 'afeeee',\n pOeviTetYd: 'db7093',\n papayawEp: 'ffefd5',\n pHKpuff: 'ffdab9',\n peru: 'cd853f',\n pRk: 'ffc0cb',\n plum: 'dda0dd',\n powMrXe: 'b0e0e6',\n purpN: '800080',\n YbeccapurpN: '663399',\n Yd: 'ff0000',\n Psybrown: 'bc8f8f',\n PyOXe: '4169e1',\n saddNbPwn: '8b4513',\n sOmon: 'fa8072',\n sandybPwn: 'f4a460',\n sHgYF: '2e8b57',\n sHshell: 'fff5ee',\n siFna: 'a0522d',\n silver: 'c0c0c0',\n skyXe: '87ceeb',\n UXe: '6a5acd',\n UWay: '708090',\n UgYy: '708090',\n snow: 'fffafa',\n sprRggYF: 'ff7f',\n stAlXe: '4682b4',\n tan: 'd2b48c',\n teO: '8080',\n tEstN: 'd8bfd8',\n tomato: 'ff6347',\n Qe: '40e0d0',\n viTet: 'ee82ee',\n JHt: 'f5deb3',\n wEte: 'ffffff',\n wEtesmoke: 'f5f5f5',\n Lw: 'ffff00',\n LwgYF: '9acd32'\n };\n function unpack() {\n var unpacked = {};\n var keys = Object.keys(names$1);\n var tkeys = Object.keys(map$2);\n var i, j, k, ok, nk;\n for (i = 0; i < keys.length; i++) {\n ok = nk = keys[i];\n for (j = 0; j < tkeys.length; j++) {\n k = tkeys[j];\n nk = nk.replace(k, map$2[k]);\n }\n k = parseInt(names$1[ok], 16);\n unpacked[nk] = [k >> 16 & 0xFF, k >> 8 & 0xFF, k & 0xFF];\n }\n return unpacked;\n }\n var names;\n function nameParse(str) {\n if (!names) {\n names = unpack();\n names.transparent = [0, 0, 0, 0];\n }\n var a = names[str.toLowerCase()];\n return a && {\n r: a[0],\n g: a[1],\n b: a[2],\n a: a.length === 4 ? a[3] : 255\n };\n }\n var RGB_RE = /^rgba?\\(\\s*([-+.\\d]+)(%)?[\\s,]+([-+.e\\d]+)(%)?[\\s,]+([-+.e\\d]+)(%)?(?:[\\s,/]+([-+.e\\d]+)(%)?)?\\s*\\)$/;\n function rgbParse(str) {\n var m = RGB_RE.exec(str);\n var a = 255;\n var r, g, b;\n if (!m) {\n return;\n }\n if (m[7] !== r) {\n var v = +m[7];\n a = m[8] ? p2b(v) : lim(v * 255, 0, 255);\n }\n r = +m[1];\n g = +m[3];\n b = +m[5];\n r = 255 & (m[2] ? p2b(r) : lim(r, 0, 255));\n g = 255 & (m[4] ? p2b(g) : lim(g, 0, 255));\n b = 255 & (m[6] ? p2b(b) : lim(b, 0, 255));\n return {\n r: r,\n g: g,\n b: b,\n a: a\n };\n }\n function _rgbString(v) {\n return v && (v.a < 255 ? \"rgba(\".concat(v.r, \", \").concat(v.g, \", \").concat(v.b, \", \").concat(b2n(v.a), \")\") : \"rgb(\".concat(v.r, \", \").concat(v.g, \", \").concat(v.b, \")\"));\n }\n var to = function to(v) {\n return v <= 0.0031308 ? v * 12.92 : Math.pow(v, 1.0 / 2.4) * 1.055 - 0.055;\n };\n var from = function from(v) {\n return v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);\n };\n function _interpolate(rgb1, rgb2, t) {\n var r = from(b2n(rgb1.r));\n var g = from(b2n(rgb1.g));\n var b = from(b2n(rgb1.b));\n return {\n r: n2b(to(r + t * (from(b2n(rgb2.r)) - r))),\n g: n2b(to(g + t * (from(b2n(rgb2.g)) - g))),\n b: n2b(to(b + t * (from(b2n(rgb2.b)) - b))),\n a: rgb1.a + t * (rgb2.a - rgb1.a)\n };\n }\n function modHSL(v, i, ratio) {\n if (v) {\n var tmp = rgb2hsl(v);\n tmp[i] = Math.max(0, Math.min(tmp[i] + tmp[i] * ratio, i === 0 ? 360 : 1));\n tmp = hsl2rgb(tmp);\n v.r = tmp[0];\n v.g = tmp[1];\n v.b = tmp[2];\n }\n }\n function clone$1(v, proto) {\n return v ? Object.assign(proto || {}, v) : v;\n }\n function fromObject(input) {\n var v = {\n r: 0,\n g: 0,\n b: 0,\n a: 255\n };\n if (Array.isArray(input)) {\n if (input.length >= 3) {\n v = {\n r: input[0],\n g: input[1],\n b: input[2],\n a: 255\n };\n if (input.length > 3) {\n v.a = n2b(input[3]);\n }\n }\n } else {\n v = clone$1(input, {\n r: 0,\n g: 0,\n b: 0,\n a: 1\n });\n v.a = n2b(v.a);\n }\n return v;\n }\n function functionParse(str) {\n if (str.charAt(0) === 'r') {\n return rgbParse(str);\n }\n return hueParse(str);\n }\n var Color = /*#__PURE__*/function () {\n function Color(input) {\n _classCallCheck$1(this, Color);\n if (input instanceof Color) {\n return input;\n }\n var type = _typeof$1(input);\n var v;\n if (type === 'object') {\n v = fromObject(input);\n } else if (type === 'string') {\n v = hexParse(input) || nameParse(input) || functionParse(input);\n }\n this._rgb = v;\n this._valid = !!v;\n }\n _createClass$1(Color, [{\n key: \"valid\",\n get: function get() {\n return this._valid;\n }\n }, {\n key: \"rgb\",\n get: function get() {\n var v = clone$1(this._rgb);\n if (v) {\n v.a = b2n(v.a);\n }\n return v;\n },\n set: function set(obj) {\n this._rgb = fromObject(obj);\n }\n }, {\n key: \"rgbString\",\n value: function rgbString() {\n return this._valid ? _rgbString(this._rgb) : undefined;\n }\n }, {\n key: \"hexString\",\n value: function hexString() {\n return this._valid ? _hexString(this._rgb) : undefined;\n }\n }, {\n key: \"hslString\",\n value: function hslString() {\n return this._valid ? _hslString(this._rgb) : undefined;\n }\n }, {\n key: \"mix\",\n value: function mix(color, weight) {\n if (color) {\n var c1 = this.rgb;\n var c2 = color.rgb;\n var w2;\n var p = weight === w2 ? 0.5 : weight;\n var w = 2 * p - 1;\n var a = c1.a - c2.a;\n var w1 = ((w * a === -1 ? w : (w + a) / (1 + w * a)) + 1) / 2.0;\n w2 = 1 - w1;\n c1.r = 0xFF & w1 * c1.r + w2 * c2.r + 0.5;\n c1.g = 0xFF & w1 * c1.g + w2 * c2.g + 0.5;\n c1.b = 0xFF & w1 * c1.b + w2 * c2.b + 0.5;\n c1.a = p * c1.a + (1 - p) * c2.a;\n this.rgb = c1;\n }\n return this;\n }\n }, {\n key: \"interpolate\",\n value: function interpolate(color, t) {\n if (color) {\n this._rgb = _interpolate(this._rgb, color._rgb, t);\n }\n return this;\n }\n }, {\n key: \"clone\",\n value: function clone() {\n return new Color(this.rgb);\n }\n }, {\n key: \"alpha\",\n value: function alpha(a) {\n this._rgb.a = n2b(a);\n return this;\n }\n }, {\n key: \"clearer\",\n value: function clearer(ratio) {\n var rgb = this._rgb;\n rgb.a *= 1 - ratio;\n return this;\n }\n }, {\n key: \"greyscale\",\n value: function greyscale() {\n var rgb = this._rgb;\n var val = round(rgb.r * 0.3 + rgb.g * 0.59 + rgb.b * 0.11);\n rgb.r = rgb.g = rgb.b = val;\n return this;\n }\n }, {\n key: \"opaquer\",\n value: function opaquer(ratio) {\n var rgb = this._rgb;\n rgb.a *= 1 + ratio;\n return this;\n }\n }, {\n key: \"negate\",\n value: function negate() {\n var v = this._rgb;\n v.r = 255 - v.r;\n v.g = 255 - v.g;\n v.b = 255 - v.b;\n return this;\n }\n }, {\n key: \"lighten\",\n value: function lighten(ratio) {\n modHSL(this._rgb, 2, ratio);\n return this;\n }\n }, {\n key: \"darken\",\n value: function darken(ratio) {\n modHSL(this._rgb, 2, -ratio);\n return this;\n }\n }, {\n key: \"saturate\",\n value: function saturate(ratio) {\n modHSL(this._rgb, 1, ratio);\n return this;\n }\n }, {\n key: \"desaturate\",\n value: function desaturate(ratio) {\n modHSL(this._rgb, 1, -ratio);\n return this;\n }\n }, {\n key: \"rotate\",\n value: function rotate(deg) {\n _rotate(this._rgb, deg);\n return this;\n }\n }]);\n return Color;\n }();\n\n /**\n * @namespace Chart.helpers\n */ /**\n * An empty function that can be used, for example, for optional callback.\n */\n function noop() {\n /* noop */}\n /**\n * Returns a unique id, sequentially generated from a global variable.\n */\n var uid = function () {\n var id = 0;\n return function () {\n return id++;\n };\n }();\n /**\n * Returns true if `value` is neither null nor undefined, else returns false.\n * @param value - The value to test.\n * @since 2.7.0\n */\n function isNullOrUndef(value) {\n return value === null || typeof value === 'undefined';\n }\n /**\n * Returns true if `value` is an array (including typed arrays), else returns false.\n * @param value - The value to test.\n * @function\n */\n function isArray(value) {\n if (Array.isArray && Array.isArray(value)) {\n return true;\n }\n var type = Object.prototype.toString.call(value);\n if (type.slice(0, 7) === '[object' && type.slice(-6) === 'Array]') {\n return true;\n }\n return false;\n }\n /**\n * Returns true if `value` is an object (excluding null), else returns false.\n * @param value - The value to test.\n * @since 2.7.0\n */\n function isObject(value) {\n return value !== null && Object.prototype.toString.call(value) === '[object Object]';\n }\n /**\n * Returns true if `value` is a finite number, else returns false\n * @param value - The value to test.\n */\n function isNumberFinite(value) {\n return (typeof value === 'number' || value instanceof Number) && isFinite(+value);\n }\n /**\n * Returns `value` if finite, else returns `defaultValue`.\n * @param value - The value to return if defined.\n * @param defaultValue - The value to return if `value` is not finite.\n */\n function finiteOrDefault(value, defaultValue) {\n return isNumberFinite(value) ? value : defaultValue;\n }\n /**\n * Returns `value` if defined, else returns `defaultValue`.\n * @param value - The value to return if defined.\n * @param defaultValue - The value to return if `value` is undefined.\n */\n function valueOrDefault(value, defaultValue) {\n return typeof value === 'undefined' ? defaultValue : value;\n }\n var toPercentage = function toPercentage(value, dimension) {\n return typeof value === 'string' && value.endsWith('%') ? parseFloat(value) / 100 : +value / dimension;\n };\n var toDimension = function toDimension(value, dimension) {\n return typeof value === 'string' && value.endsWith('%') ? parseFloat(value) / 100 * dimension : +value;\n };\n /**\n * Calls `fn` with the given `args` in the scope defined by `thisArg` and returns the\n * value returned by `fn`. If `fn` is not a function, this method returns undefined.\n * @param fn - The function to call.\n * @param args - The arguments with which `fn` should be called.\n * @param [thisArg] - The value of `this` provided for the call to `fn`.\n */\n function callback(fn, args, thisArg) {\n if (fn && typeof fn.call === 'function') {\n return fn.apply(thisArg, args);\n }\n }\n function each(loopable, fn, thisArg, reverse) {\n var i, len, keys;\n if (isArray(loopable)) {\n len = loopable.length;\n if (reverse) {\n for (i = len - 1; i >= 0; i--) {\n fn.call(thisArg, loopable[i], i);\n }\n } else {\n for (i = 0; i < len; i++) {\n fn.call(thisArg, loopable[i], i);\n }\n }\n } else if (isObject(loopable)) {\n keys = Object.keys(loopable);\n len = keys.length;\n for (i = 0; i < len; i++) {\n fn.call(thisArg, loopable[keys[i]], keys[i]);\n }\n }\n }\n /**\n * Returns true if the `a0` and `a1` arrays have the same content, else returns false.\n * @param a0 - The array to compare\n * @param a1 - The array to compare\n * @private\n */\n function _elementsEqual(a0, a1) {\n var i, ilen, v0, v1;\n if (!a0 || !a1 || a0.length !== a1.length) {\n return false;\n }\n for (i = 0, ilen = a0.length; i < ilen; ++i) {\n v0 = a0[i];\n v1 = a1[i];\n if (v0.datasetIndex !== v1.datasetIndex || v0.index !== v1.index) {\n return false;\n }\n }\n return true;\n }\n /**\n * Returns a deep copy of `source` without keeping references on objects and arrays.\n * @param source - The value to clone.\n */\n function clone(source) {\n if (isArray(source)) {\n return source.map(clone);\n }\n if (isObject(source)) {\n var target = Object.create(null);\n var keys = Object.keys(source);\n var klen = keys.length;\n var k = 0;\n for (; k < klen; ++k) {\n target[keys[k]] = clone(source[keys[k]]);\n }\n return target;\n }\n return source;\n }\n function isValidKey(key) {\n return ['__proto__', 'prototype', 'constructor'].indexOf(key) === -1;\n }\n /**\n * The default merger when Chart.helpers.merge is called without merger option.\n * Note(SB): also used by mergeConfig and mergeScaleConfig as fallback.\n * @private\n */\n function _merger(key, target, source, options) {\n if (!isValidKey(key)) {\n return;\n }\n var tval = target[key];\n var sval = source[key];\n if (isObject(tval) && isObject(sval)) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n merge(tval, sval, options);\n } else {\n target[key] = clone(sval);\n }\n }\n function merge(target, source, options) {\n var sources = isArray(source) ? source : [source];\n var ilen = sources.length;\n if (!isObject(target)) {\n return target;\n }\n options = options || {};\n var merger = options.merger || _merger;\n var current;\n for (var i = 0; i < ilen; ++i) {\n current = sources[i];\n if (!isObject(current)) {\n continue;\n }\n var keys = Object.keys(current);\n for (var k = 0, klen = keys.length; k < klen; ++k) {\n merger(keys[k], target, current, options);\n }\n }\n return target;\n }\n function mergeIf(target, source) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n return merge(target, source, {\n merger: _mergerIf\n });\n }\n /**\n * Merges source[key] in target[key] only if target[key] is undefined.\n * @private\n */\n function _mergerIf(key, target, source) {\n if (!isValidKey(key)) {\n return;\n }\n var tval = target[key];\n var sval = source[key];\n if (isObject(tval) && isObject(sval)) {\n mergeIf(tval, sval);\n } else if (!Object.prototype.hasOwnProperty.call(target, key)) {\n target[key] = clone(sval);\n }\n }\n /**\n * @private\n */\n function _deprecated(scope, value, previous, current) {\n if (value !== undefined) {\n console.warn(scope + ': \"' + previous + '\" is deprecated. Please use \"' + current + '\" instead');\n }\n }\n // resolveObjectKey resolver cache\n var keyResolvers = {\n // Chart.helpers.core resolveObjectKey should resolve empty key to root object\n '': function _(v) {\n return v;\n },\n // default resolvers\n x: function x(o) {\n return o.x;\n },\n y: function y(o) {\n return o.y;\n }\n };\n /**\n * @private\n */\n function _splitKey(key) {\n var parts = key.split('.');\n var keys = [];\n var tmp = '';\n var _iterator = _createForOfIteratorHelper$1(parts),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var part = _step.value;\n tmp += part;\n if (tmp.endsWith('\\\\')) {\n tmp = tmp.slice(0, -1) + '.';\n } else {\n keys.push(tmp);\n tmp = '';\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n return keys;\n }\n function _getKeyResolver(key) {\n var keys = _splitKey(key);\n return function (obj) {\n var _iterator2 = _createForOfIteratorHelper$1(keys),\n _step2;\n try {\n for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n var k = _step2.value;\n if (k === '') {\n break;\n }\n obj = obj && obj[k];\n }\n } catch (err) {\n _iterator2.e(err);\n } finally {\n _iterator2.f();\n }\n return obj;\n };\n }\n function resolveObjectKey(obj, key) {\n var resolver = keyResolvers[key] || (keyResolvers[key] = _getKeyResolver(key));\n return resolver(obj);\n }\n /**\n * @private\n */\n function _capitalize(str) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n }\n var defined = function defined(value) {\n return typeof value !== 'undefined';\n };\n var isFunction = function isFunction(value) {\n return typeof value === 'function';\n };\n // Adapted from https://stackoverflow.com/questions/31128855/comparing-ecma6-sets-for-equality#31129384\n var setsEqual = function setsEqual(a, b) {\n if (a.size !== b.size) {\n return false;\n }\n var _iterator3 = _createForOfIteratorHelper$1(a),\n _step3;\n try {\n for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {\n var item = _step3.value;\n if (!b.has(item)) {\n return false;\n }\n }\n } catch (err) {\n _iterator3.e(err);\n } finally {\n _iterator3.f();\n }\n return true;\n };\n /**\n * @param e - The event\n * @private\n */\n function _isClickEvent(e) {\n return e.type === 'mouseup' || e.type === 'click' || e.type === 'contextmenu';\n }\n\n /**\n * @alias Chart.helpers.math\n * @namespace\n */\n var PI = Math.PI;\n var TAU = 2 * PI;\n var PITAU = TAU + PI;\n var INFINITY = Number.POSITIVE_INFINITY;\n var RAD_PER_DEG = PI / 180;\n var HALF_PI = PI / 2;\n var QUARTER_PI = PI / 4;\n var TWO_THIRDS_PI = PI * 2 / 3;\n var log10 = Math.log10;\n var sign = Math.sign;\n function almostEquals(x, y, epsilon) {\n return Math.abs(x - y) < epsilon;\n }\n /**\n * Implementation of the nice number algorithm used in determining where axis labels will go\n */\n function niceNum(range) {\n var roundedRange = Math.round(range);\n range = almostEquals(range, roundedRange, range / 1000) ? roundedRange : range;\n var niceRange = Math.pow(10, Math.floor(log10(range)));\n var fraction = range / niceRange;\n var niceFraction = fraction <= 1 ? 1 : fraction <= 2 ? 2 : fraction <= 5 ? 5 : 10;\n return niceFraction * niceRange;\n }\n /**\n * Returns an array of factors sorted from 1 to sqrt(value)\n * @private\n */\n function _factorize(value) {\n var result = [];\n var sqrt = Math.sqrt(value);\n var i;\n for (i = 1; i < sqrt; i++) {\n if (value % i === 0) {\n result.push(i);\n result.push(value / i);\n }\n }\n if (sqrt === (sqrt | 0)) {\n result.push(sqrt);\n }\n result.sort(function (a, b) {\n return a - b;\n }).pop();\n return result;\n }\n function isNumber(n) {\n return !isNaN(parseFloat(n)) && isFinite(n);\n }\n function almostWhole(x, epsilon) {\n var rounded = Math.round(x);\n return rounded - epsilon <= x && rounded + epsilon >= x;\n }\n /**\n * @private\n */\n function _setMinAndMaxByKey(array, target, property) {\n var i, ilen, value;\n for (i = 0, ilen = array.length; i < ilen; i++) {\n value = array[i][property];\n if (!isNaN(value)) {\n target.min = Math.min(target.min, value);\n target.max = Math.max(target.max, value);\n }\n }\n }\n function toRadians(degrees) {\n return degrees * (PI / 180);\n }\n function toDegrees(radians) {\n return radians * (180 / PI);\n }\n /**\n * Returns the number of decimal places\n * i.e. the number of digits after the decimal point, of the value of this Number.\n * @param x - A number.\n * @returns The number of decimal places.\n * @private\n */\n function _decimalPlaces(x) {\n if (!isNumberFinite(x)) {\n return;\n }\n var e = 1;\n var p = 0;\n while (Math.round(x * e) / e !== x) {\n e *= 10;\n p++;\n }\n return p;\n }\n // Gets the angle from vertical upright to the point about a centre.\n function getAngleFromPoint(centrePoint, anglePoint) {\n var distanceFromXCenter = anglePoint.x - centrePoint.x;\n var distanceFromYCenter = anglePoint.y - centrePoint.y;\n var radialDistanceFromCenter = Math.sqrt(distanceFromXCenter * distanceFromXCenter + distanceFromYCenter * distanceFromYCenter);\n var angle = Math.atan2(distanceFromYCenter, distanceFromXCenter);\n if (angle < -0.5 * PI) {\n angle += TAU; // make sure the returned angle is in the range of (-PI/2, 3PI/2]\n }\n\n return {\n angle: angle,\n distance: radialDistanceFromCenter\n };\n }\n function distanceBetweenPoints(pt1, pt2) {\n return Math.sqrt(Math.pow(pt2.x - pt1.x, 2) + Math.pow(pt2.y - pt1.y, 2));\n }\n /**\n * Shortest distance between angles, in either direction.\n * @private\n */\n function _angleDiff(a, b) {\n return (a - b + PITAU) % TAU - PI;\n }\n /**\n * Normalize angle to be between 0 and 2*PI\n * @private\n */\n function _normalizeAngle(a) {\n return (a % TAU + TAU) % TAU;\n }\n /**\n * @private\n */\n function _angleBetween(angle, start, end, sameAngleIsFullCircle) {\n var a = _normalizeAngle(angle);\n var s = _normalizeAngle(start);\n var e = _normalizeAngle(end);\n var angleToStart = _normalizeAngle(s - a);\n var angleToEnd = _normalizeAngle(e - a);\n var startToAngle = _normalizeAngle(a - s);\n var endToAngle = _normalizeAngle(a - e);\n return a === s || a === e || sameAngleIsFullCircle && s === e || angleToStart > angleToEnd && startToAngle < endToAngle;\n }\n /**\n * Limit `value` between `min` and `max`\n * @param value\n * @param min\n * @param max\n * @private\n */\n function _limitValue(value, min, max) {\n return Math.max(min, Math.min(max, value));\n }\n /**\n * @param {number} value\n * @private\n */\n function _int16Range(value) {\n return _limitValue(value, -32768, 32767);\n }\n /**\n * @param value\n * @param start\n * @param end\n * @param [epsilon]\n * @private\n */\n function _isBetween(value, start, end) {\n var epsilon = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1e-6;\n return value >= Math.min(start, end) - epsilon && value <= Math.max(start, end) + epsilon;\n }\n function _lookup(table, value, cmp) {\n cmp = cmp || function (index) {\n return table[index] < value;\n };\n var hi = table.length - 1;\n var lo = 0;\n var mid;\n while (hi - lo > 1) {\n mid = lo + hi >> 1;\n if (cmp(mid)) {\n lo = mid;\n } else {\n hi = mid;\n }\n }\n return {\n lo: lo,\n hi: hi\n };\n }\n /**\n * Binary search\n * @param table - the table search. must be sorted!\n * @param key - property name for the value in each entry\n * @param value - value to find\n * @param last - lookup last index\n * @private\n */\n var _lookupByKey = function _lookupByKey(table, key, value, last) {\n return _lookup(table, value, last ? function (index) {\n var ti = table[index][key];\n return ti < value || ti === value && table[index + 1][key] === value;\n } : function (index) {\n return table[index][key] < value;\n });\n };\n /**\n * Reverse binary search\n * @param table - the table search. must be sorted!\n * @param key - property name for the value in each entry\n * @param value - value to find\n * @private\n */\n var _rlookupByKey = function _rlookupByKey(table, key, value) {\n return _lookup(table, value, function (index) {\n return table[index][key] >= value;\n });\n };\n /**\n * Return subset of `values` between `min` and `max` inclusive.\n * Values are assumed to be in sorted order.\n * @param values - sorted array of values\n * @param min - min value\n * @param max - max value\n */\n function _filterBetween(values, min, max) {\n var start = 0;\n var end = values.length;\n while (start < end && values[start] < min) {\n start++;\n }\n while (end > start && values[end - 1] > max) {\n end--;\n }\n return start > 0 || end < values.length ? values.slice(start, end) : values;\n }\n var arrayEvents = ['push', 'pop', 'shift', 'splice', 'unshift'];\n function listenArrayEvents(array, listener) {\n if (array._chartjs) {\n array._chartjs.listeners.push(listener);\n return;\n }\n Object.defineProperty(array, '_chartjs', {\n configurable: true,\n enumerable: false,\n value: {\n listeners: [listener]\n }\n });\n arrayEvents.forEach(function (key) {\n var method = '_onData' + _capitalize(key);\n var base = array[key];\n Object.defineProperty(array, key, {\n configurable: true,\n enumerable: false,\n value: function value() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n var res = base.apply(this, args);\n array._chartjs.listeners.forEach(function (object) {\n if (typeof object[method] === 'function') {\n object[method].apply(object, args);\n }\n });\n return res;\n }\n });\n });\n }\n function unlistenArrayEvents(array, listener) {\n var stub = array._chartjs;\n if (!stub) {\n return;\n }\n var listeners = stub.listeners;\n var index = listeners.indexOf(listener);\n if (index !== -1) {\n listeners.splice(index, 1);\n }\n if (listeners.length > 0) {\n return;\n }\n arrayEvents.forEach(function (key) {\n delete array[key];\n });\n delete array._chartjs;\n }\n /**\n * @param items\n */\n function _arrayUnique(items) {\n var set = new Set(items);\n if (set.size === items.length) {\n return items;\n }\n return Array.from(set);\n }\n function fontString(pixelSize, fontStyle, fontFamily) {\n return fontStyle + ' ' + pixelSize + 'px ' + fontFamily;\n }\n /**\n * Request animation polyfill\n */\n var requestAnimFrame = function () {\n if (typeof window === 'undefined') {\n return function (callback) {\n return callback();\n };\n }\n return window.requestAnimationFrame;\n }();\n /**\n * Throttles calling `fn` once per animation frame\n * Latest arguments are used on the actual call\n */\n function throttled(fn, thisArg) {\n var argsToUse = [];\n var ticking = false;\n return function () {\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n // Save the args for use later\n argsToUse = args;\n if (!ticking) {\n ticking = true;\n requestAnimFrame.call(window, function () {\n ticking = false;\n fn.apply(thisArg, argsToUse);\n });\n }\n };\n }\n /**\n * Debounces calling `fn` for `delay` ms\n */\n function debounce(fn, delay) {\n var timeout;\n return function () {\n for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n args[_key3] = arguments[_key3];\n }\n if (delay) {\n clearTimeout(timeout);\n timeout = setTimeout(fn, delay, args);\n } else {\n fn.apply(this, args);\n }\n return delay;\n };\n }\n /**\n * Converts 'start' to 'left', 'end' to 'right' and others to 'center'\n * @private\n */\n var _toLeftRightCenter = function _toLeftRightCenter(align) {\n return align === 'start' ? 'left' : align === 'end' ? 'right' : 'center';\n };\n /**\n * Returns `start`, `end` or `(start + end) / 2` depending on `align`. Defaults to `center`\n * @private\n */\n var _alignStartEnd = function _alignStartEnd(align, start, end) {\n return align === 'start' ? start : align === 'end' ? end : (start + end) / 2;\n };\n /**\n * Returns `left`, `right` or `(left + right) / 2` depending on `align`. Defaults to `left`\n * @private\n */\n var _textX = function _textX(align, left, right, rtl) {\n var check = rtl ? 'left' : 'right';\n return align === check ? right : align === 'center' ? (left + right) / 2 : left;\n };\n /**\n * Return start and count of visible points.\n * @private\n */\n function _getStartAndCountOfVisiblePoints(meta, points, animationsDisabled) {\n var pointCount = points.length;\n var start = 0;\n var count = pointCount;\n if (meta._sorted) {\n var iScale = meta.iScale,\n _parsed = meta._parsed;\n var axis = iScale.axis;\n var _iScale$getUserBounds = iScale.getUserBounds(),\n min = _iScale$getUserBounds.min,\n max = _iScale$getUserBounds.max,\n minDefined = _iScale$getUserBounds.minDefined,\n maxDefined = _iScale$getUserBounds.maxDefined;\n if (minDefined) {\n start = _limitValue(Math.min(\n // @ts-expect-error Need to type _parsed\n _lookupByKey(_parsed, axis, min).lo,\n // @ts-expect-error Need to fix types on _lookupByKey\n animationsDisabled ? pointCount : _lookupByKey(points, axis, iScale.getPixelForValue(min)).lo), 0, pointCount - 1);\n }\n if (maxDefined) {\n count = _limitValue(Math.max(\n // @ts-expect-error Need to type _parsed\n _lookupByKey(_parsed, iScale.axis, max, true).hi + 1,\n // @ts-expect-error Need to fix types on _lookupByKey\n animationsDisabled ? 0 : _lookupByKey(points, axis, iScale.getPixelForValue(max), true).hi + 1), start, pointCount) - start;\n } else {\n count = pointCount - start;\n }\n }\n return {\n start: start,\n count: count\n };\n }\n /**\n * Checks if the scale ranges have changed.\n * @param {object} meta - dataset meta.\n * @returns {boolean}\n * @private\n */\n function _scaleRangesChanged(meta) {\n var xScale = meta.xScale,\n yScale = meta.yScale,\n _scaleRanges = meta._scaleRanges;\n var newRanges = {\n xmin: xScale.min,\n xmax: xScale.max,\n ymin: yScale.min,\n ymax: yScale.max\n };\n if (!_scaleRanges) {\n meta._scaleRanges = newRanges;\n return true;\n }\n var changed = _scaleRanges.xmin !== xScale.min || _scaleRanges.xmax !== xScale.max || _scaleRanges.ymin !== yScale.min || _scaleRanges.ymax !== yScale.max;\n Object.assign(_scaleRanges, newRanges);\n return changed;\n }\n var atEdge = function atEdge(t) {\n return t === 0 || t === 1;\n };\n var elasticIn = function elasticIn(t, s, p) {\n return -(Math.pow(2, 10 * (t -= 1)) * Math.sin((t - s) * TAU / p));\n };\n var elasticOut = function elasticOut(t, s, p) {\n return Math.pow(2, -10 * t) * Math.sin((t - s) * TAU / p) + 1;\n };\n /**\n * Easing functions adapted from Robert Penner's easing equations.\n * @namespace Chart.helpers.easing.effects\n * @see http://www.robertpenner.com/easing/\n */\n var effects = {\n linear: function linear(t) {\n return t;\n },\n easeInQuad: function easeInQuad(t) {\n return t * t;\n },\n easeOutQuad: function easeOutQuad(t) {\n return -t * (t - 2);\n },\n easeInOutQuad: function easeInOutQuad(t) {\n return (t /= 0.5) < 1 ? 0.5 * t * t : -0.5 * (--t * (t - 2) - 1);\n },\n easeInCubic: function easeInCubic(t) {\n return t * t * t;\n },\n easeOutCubic: function easeOutCubic(t) {\n return (t -= 1) * t * t + 1;\n },\n easeInOutCubic: function easeInOutCubic(t) {\n return (t /= 0.5) < 1 ? 0.5 * t * t * t : 0.5 * ((t -= 2) * t * t + 2);\n },\n easeInQuart: function easeInQuart(t) {\n return t * t * t * t;\n },\n easeOutQuart: function easeOutQuart(t) {\n return -((t -= 1) * t * t * t - 1);\n },\n easeInOutQuart: function easeInOutQuart(t) {\n return (t /= 0.5) < 1 ? 0.5 * t * t * t * t : -0.5 * ((t -= 2) * t * t * t - 2);\n },\n easeInQuint: function easeInQuint(t) {\n return t * t * t * t * t;\n },\n easeOutQuint: function easeOutQuint(t) {\n return (t -= 1) * t * t * t * t + 1;\n },\n easeInOutQuint: function easeInOutQuint(t) {\n return (t /= 0.5) < 1 ? 0.5 * t * t * t * t * t : 0.5 * ((t -= 2) * t * t * t * t + 2);\n },\n easeInSine: function easeInSine(t) {\n return -Math.cos(t * HALF_PI) + 1;\n },\n easeOutSine: function easeOutSine(t) {\n return Math.sin(t * HALF_PI);\n },\n easeInOutSine: function easeInOutSine(t) {\n return -0.5 * (Math.cos(PI * t) - 1);\n },\n easeInExpo: function easeInExpo(t) {\n return t === 0 ? 0 : Math.pow(2, 10 * (t - 1));\n },\n easeOutExpo: function easeOutExpo(t) {\n return t === 1 ? 1 : -Math.pow(2, -10 * t) + 1;\n },\n easeInOutExpo: function easeInOutExpo(t) {\n return atEdge(t) ? t : t < 0.5 ? 0.5 * Math.pow(2, 10 * (t * 2 - 1)) : 0.5 * (-Math.pow(2, -10 * (t * 2 - 1)) + 2);\n },\n easeInCirc: function easeInCirc(t) {\n return t >= 1 ? t : -(Math.sqrt(1 - t * t) - 1);\n },\n easeOutCirc: function easeOutCirc(t) {\n return Math.sqrt(1 - (t -= 1) * t);\n },\n easeInOutCirc: function easeInOutCirc(t) {\n return (t /= 0.5) < 1 ? -0.5 * (Math.sqrt(1 - t * t) - 1) : 0.5 * (Math.sqrt(1 - (t -= 2) * t) + 1);\n },\n easeInElastic: function easeInElastic(t) {\n return atEdge(t) ? t : elasticIn(t, 0.075, 0.3);\n },\n easeOutElastic: function easeOutElastic(t) {\n return atEdge(t) ? t : elasticOut(t, 0.075, 0.3);\n },\n easeInOutElastic: function easeInOutElastic(t) {\n var s = 0.1125;\n var p = 0.45;\n return atEdge(t) ? t : t < 0.5 ? 0.5 * elasticIn(t * 2, s, p) : 0.5 + 0.5 * elasticOut(t * 2 - 1, s, p);\n },\n easeInBack: function easeInBack(t) {\n var s = 1.70158;\n return t * t * ((s + 1) * t - s);\n },\n easeOutBack: function easeOutBack(t) {\n var s = 1.70158;\n return (t -= 1) * t * ((s + 1) * t + s) + 1;\n },\n easeInOutBack: function easeInOutBack(t) {\n var s = 1.70158;\n if ((t /= 0.5) < 1) {\n return 0.5 * (t * t * (((s *= 1.525) + 1) * t - s));\n }\n return 0.5 * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2);\n },\n easeInBounce: function easeInBounce(t) {\n return 1 - effects.easeOutBounce(1 - t);\n },\n easeOutBounce: function easeOutBounce(t) {\n var m = 7.5625;\n var d = 2.75;\n if (t < 1 / d) {\n return m * t * t;\n }\n if (t < 2 / d) {\n return m * (t -= 1.5 / d) * t + 0.75;\n }\n if (t < 2.5 / d) {\n return m * (t -= 2.25 / d) * t + 0.9375;\n }\n return m * (t -= 2.625 / d) * t + 0.984375;\n },\n easeInOutBounce: function easeInOutBounce(t) {\n return t < 0.5 ? effects.easeInBounce(t * 2) * 0.5 : effects.easeOutBounce(t * 2 - 1) * 0.5 + 0.5;\n }\n };\n function isPatternOrGradient(value) {\n if (value && _typeof$1(value) === 'object') {\n var type = value.toString();\n return type === '[object CanvasPattern]' || type === '[object CanvasGradient]';\n }\n return false;\n }\n function color(value) {\n return isPatternOrGradient(value) ? value : new Color(value);\n }\n function getHoverColor(value) {\n return isPatternOrGradient(value) ? value : new Color(value).saturate(0.5).darken(0.1).hexString();\n }\n var numbers = ['x', 'y', 'borderWidth', 'radius', 'tension'];\n var colors = ['color', 'borderColor', 'backgroundColor'];\n function applyAnimationsDefaults(defaults) {\n defaults.set('animation', {\n delay: undefined,\n duration: 1000,\n easing: 'easeOutQuart',\n fn: undefined,\n from: undefined,\n loop: undefined,\n to: undefined,\n type: undefined\n });\n defaults.describe('animation', {\n _fallback: false,\n _indexable: false,\n _scriptable: function _scriptable(name) {\n return name !== 'onProgress' && name !== 'onComplete' && name !== 'fn';\n }\n });\n defaults.set('animations', {\n colors: {\n type: 'color',\n properties: colors\n },\n numbers: {\n type: 'number',\n properties: numbers\n }\n });\n defaults.describe('animations', {\n _fallback: 'animation'\n });\n defaults.set('transitions', {\n active: {\n animation: {\n duration: 400\n }\n },\n resize: {\n animation: {\n duration: 0\n }\n },\n show: {\n animations: {\n colors: {\n from: 'transparent'\n },\n visible: {\n type: 'boolean',\n duration: 0\n }\n }\n },\n hide: {\n animations: {\n colors: {\n to: 'transparent'\n },\n visible: {\n type: 'boolean',\n easing: 'linear',\n fn: function fn(v) {\n return v | 0;\n }\n }\n }\n }\n });\n }\n function applyLayoutsDefaults(defaults) {\n defaults.set('layout', {\n autoPadding: true,\n padding: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n }\n });\n }\n var intlCache = new Map();\n function getNumberFormat(locale, options) {\n options = options || {};\n var cacheKey = locale + JSON.stringify(options);\n var formatter = intlCache.get(cacheKey);\n if (!formatter) {\n formatter = new Intl.NumberFormat(locale, options);\n intlCache.set(cacheKey, formatter);\n }\n return formatter;\n }\n function formatNumber(num, locale, options) {\n return getNumberFormat(locale, options).format(num);\n }\n var formatters$4 = {\n values: function values(value) {\n return isArray(value) ? value : '' + value;\n },\n numeric: function numeric(tickValue, index, ticks) {\n if (tickValue === 0) {\n return '0';\n }\n var locale = this.chart.options.locale;\n var notation;\n var delta = tickValue;\n if (ticks.length > 1) {\n var maxTick = Math.max(Math.abs(ticks[0].value), Math.abs(ticks[ticks.length - 1].value));\n if (maxTick < 1e-4 || maxTick > 1e+15) {\n notation = 'scientific';\n }\n delta = calculateDelta(tickValue, ticks);\n }\n var logDelta = log10(Math.abs(delta));\n var numDecimal = isNaN(logDelta) ? 1 : Math.max(Math.min(-1 * Math.floor(logDelta), 20), 0);\n var options = {\n notation: notation,\n minimumFractionDigits: numDecimal,\n maximumFractionDigits: numDecimal\n };\n Object.assign(options, this.options.ticks.format);\n return formatNumber(tickValue, locale, options);\n },\n logarithmic: function logarithmic(tickValue, index, ticks) {\n if (tickValue === 0) {\n return '0';\n }\n var remain = ticks[index].significand || tickValue / Math.pow(10, Math.floor(log10(tickValue)));\n if ([1, 2, 3, 5, 10, 15].includes(remain) || index > 0.8 * ticks.length) {\n return formatters$4.numeric.call(this, tickValue, index, ticks);\n }\n return '';\n }\n };\n function calculateDelta(tickValue, ticks) {\n var delta = ticks.length > 3 ? ticks[2].value - ticks[1].value : ticks[1].value - ticks[0].value;\n if (Math.abs(delta) >= 1 && tickValue !== Math.floor(tickValue)) {\n delta = tickValue - Math.floor(tickValue);\n }\n return delta;\n }\n var Ticks = {\n formatters: formatters$4\n };\n function applyScaleDefaults(defaults) {\n defaults.set('scale', {\n display: true,\n offset: false,\n reverse: false,\n beginAtZero: false,\n bounds: 'ticks',\n clip: true,\n grace: 0,\n grid: {\n display: true,\n lineWidth: 1,\n drawOnChartArea: true,\n drawTicks: true,\n tickLength: 8,\n tickWidth: function tickWidth(_ctx, options) {\n return options.lineWidth;\n },\n tickColor: function tickColor(_ctx, options) {\n return options.color;\n },\n offset: false\n },\n border: {\n display: true,\n dash: [],\n dashOffset: 0.0,\n width: 1\n },\n title: {\n display: false,\n text: '',\n padding: {\n top: 4,\n bottom: 4\n }\n },\n ticks: {\n minRotation: 0,\n maxRotation: 50,\n mirror: false,\n textStrokeWidth: 0,\n textStrokeColor: '',\n padding: 3,\n display: true,\n autoSkip: true,\n autoSkipPadding: 3,\n labelOffset: 0,\n callback: Ticks.formatters.values,\n minor: {},\n major: {},\n align: 'center',\n crossAlign: 'near',\n showLabelBackdrop: false,\n backdropColor: 'rgba(255, 255, 255, 0.75)',\n backdropPadding: 2\n }\n });\n defaults.route('scale.ticks', 'color', '', 'color');\n defaults.route('scale.grid', 'color', '', 'borderColor');\n defaults.route('scale.border', 'color', '', 'borderColor');\n defaults.route('scale.title', 'color', '', 'color');\n defaults.describe('scale', {\n _fallback: false,\n _scriptable: function _scriptable(name) {\n return !name.startsWith('before') && !name.startsWith('after') && name !== 'callback' && name !== 'parser';\n },\n _indexable: function _indexable(name) {\n return name !== 'borderDash' && name !== 'tickBorderDash' && name !== 'dash';\n }\n });\n defaults.describe('scales', {\n _fallback: 'scale'\n });\n defaults.describe('scale.ticks', {\n _scriptable: function _scriptable(name) {\n return name !== 'backdropPadding' && name !== 'callback';\n },\n _indexable: function _indexable(name) {\n return name !== 'backdropPadding';\n }\n });\n }\n var overrides = Object.create(null);\n var descriptors = Object.create(null);\n function getScope$1(node, key) {\n if (!key) {\n return node;\n }\n var keys = key.split('.');\n for (var i = 0, n = keys.length; i < n; ++i) {\n var k = keys[i];\n node = node[k] || (node[k] = Object.create(null));\n }\n return node;\n }\n function _set(root, scope, values) {\n if (typeof scope === 'string') {\n return merge(getScope$1(root, scope), values);\n }\n return merge(getScope$1(root, ''), scope);\n }\n var Defaults = /*#__PURE__*/function () {\n function Defaults(_descriptors, _appliers) {\n _classCallCheck$1(this, Defaults);\n this.animation = undefined;\n this.backgroundColor = 'rgba(0,0,0,0.1)';\n this.borderColor = 'rgba(0,0,0,0.1)';\n this.color = '#666';\n this.datasets = {};\n this.devicePixelRatio = function (context) {\n return context.chart.platform.getDevicePixelRatio();\n };\n this.elements = {};\n this.events = ['mousemove', 'mouseout', 'click', 'touchstart', 'touchmove'];\n this.font = {\n family: \"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif\",\n size: 12,\n style: 'normal',\n lineHeight: 1.2,\n weight: null\n };\n this.hover = {};\n this.hoverBackgroundColor = function (ctx, options) {\n return getHoverColor(options.backgroundColor);\n };\n this.hoverBorderColor = function (ctx, options) {\n return getHoverColor(options.borderColor);\n };\n this.hoverColor = function (ctx, options) {\n return getHoverColor(options.color);\n };\n this.indexAxis = 'x';\n this.interaction = {\n mode: 'nearest',\n intersect: true,\n includeInvisible: false\n };\n this.maintainAspectRatio = true;\n this.onHover = null;\n this.onClick = null;\n this.parsing = true;\n this.plugins = {};\n this.responsive = true;\n this.scale = undefined;\n this.scales = {};\n this.showLine = true;\n this.drawActiveElementsOnTop = true;\n this.describe(_descriptors);\n this.apply(_appliers);\n }\n _createClass$1(Defaults, [{\n key: \"set\",\n value: function set(scope, values) {\n return _set(this, scope, values);\n }\n }, {\n key: \"get\",\n value: function get(scope) {\n return getScope$1(this, scope);\n }\n }, {\n key: \"describe\",\n value: function describe(scope, values) {\n return _set(descriptors, scope, values);\n }\n }, {\n key: \"override\",\n value: function override(scope, values) {\n return _set(overrides, scope, values);\n }\n }, {\n key: \"route\",\n value: function route(scope, name, targetScope, targetName) {\n var _Object$definePropert;\n var scopeObject = getScope$1(this, scope);\n var targetScopeObject = getScope$1(this, targetScope);\n var privateName = '_' + name;\n Object.defineProperties(scopeObject, (_Object$definePropert = {}, _defineProperty$1(_Object$definePropert, privateName, {\n value: scopeObject[name],\n writable: true\n }), _defineProperty$1(_Object$definePropert, name, {\n enumerable: true,\n get: function get() {\n var local = this[privateName];\n var target = targetScopeObject[targetName];\n if (isObject(local)) {\n return Object.assign({}, target, local);\n }\n return valueOrDefault(local, target);\n },\n set: function set(value) {\n this[privateName] = value;\n }\n }), _Object$definePropert));\n }\n }, {\n key: \"apply\",\n value: function apply(appliers) {\n var _this = this;\n appliers.forEach(function (apply) {\n return apply(_this);\n });\n }\n }]);\n return Defaults;\n }();\n var defaults = /* #__PURE__ */new Defaults({\n _scriptable: function _scriptable(name) {\n return !name.startsWith('on');\n },\n _indexable: function _indexable(name) {\n return name !== 'events';\n },\n hover: {\n _fallback: 'interaction'\n },\n interaction: {\n _scriptable: false,\n _indexable: false\n }\n }, [applyAnimationsDefaults, applyLayoutsDefaults, applyScaleDefaults]);\n\n /**\n * Converts the given font object into a CSS font string.\n * @param font - A font object.\n * @return The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font\n * @private\n */\n function toFontString(font) {\n if (!font || isNullOrUndef(font.size) || isNullOrUndef(font.family)) {\n return null;\n }\n return (font.style ? font.style + ' ' : '') + (font.weight ? font.weight + ' ' : '') + font.size + 'px ' + font.family;\n }\n /**\n * @private\n */\n function _measureText(ctx, data, gc, longest, string) {\n var textWidth = data[string];\n if (!textWidth) {\n textWidth = data[string] = ctx.measureText(string).width;\n gc.push(string);\n }\n if (textWidth > longest) {\n longest = textWidth;\n }\n return longest;\n }\n /**\n * @private\n */ // eslint-disable-next-line complexity\n function _longestText(ctx, font, arrayOfThings, cache) {\n cache = cache || {};\n var data = cache.data = cache.data || {};\n var gc = cache.garbageCollect = cache.garbageCollect || [];\n if (cache.font !== font) {\n data = cache.data = {};\n gc = cache.garbageCollect = [];\n cache.font = font;\n }\n ctx.save();\n ctx.font = font;\n var longest = 0;\n var ilen = arrayOfThings.length;\n var i, j, jlen, thing, nestedThing;\n for (i = 0; i < ilen; i++) {\n thing = arrayOfThings[i];\n // Undefined strings and arrays should not be measured\n if (thing !== undefined && thing !== null && !isArray(thing)) {\n longest = _measureText(ctx, data, gc, longest, thing);\n } else if (isArray(thing)) {\n // if it is an array lets measure each element\n // to do maybe simplify this function a bit so we can do this more recursively?\n for (j = 0, jlen = thing.length; j < jlen; j++) {\n nestedThing = thing[j];\n // Undefined strings and arrays should not be measured\n if (nestedThing !== undefined && nestedThing !== null && !isArray(nestedThing)) {\n longest = _measureText(ctx, data, gc, longest, nestedThing);\n }\n }\n }\n }\n ctx.restore();\n var gcLen = gc.length / 2;\n if (gcLen > arrayOfThings.length) {\n for (i = 0; i < gcLen; i++) {\n delete data[gc[i]];\n }\n gc.splice(0, gcLen);\n }\n return longest;\n }\n /**\n * Returns the aligned pixel value to avoid anti-aliasing blur\n * @param chart - The chart instance.\n * @param pixel - A pixel value.\n * @param width - The width of the element.\n * @returns The aligned pixel value.\n * @private\n */\n function _alignPixel(chart, pixel, width) {\n var devicePixelRatio = chart.currentDevicePixelRatio;\n var halfWidth = width !== 0 ? Math.max(width / 2, 0.5) : 0;\n return Math.round((pixel - halfWidth) * devicePixelRatio) / devicePixelRatio + halfWidth;\n }\n /**\n * Clears the entire canvas.\n */\n function clearCanvas(canvas, ctx) {\n ctx = ctx || canvas.getContext('2d');\n ctx.save();\n // canvas.width and canvas.height do not consider the canvas transform,\n // while clearRect does\n ctx.resetTransform();\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n ctx.restore();\n }\n function drawPoint(ctx, options, x, y) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n drawPointLegend(ctx, options, x, y, null);\n }\n // eslint-disable-next-line complexity\n function drawPointLegend(ctx, options, x, y, w) {\n var type, xOffset, yOffset, size, cornerRadius, width, xOffsetW, yOffsetW;\n var style = options.pointStyle;\n var rotation = options.rotation;\n var radius = options.radius;\n var rad = (rotation || 0) * RAD_PER_DEG;\n if (style && _typeof$1(style) === 'object') {\n type = style.toString();\n if (type === '[object HTMLImageElement]' || type === '[object HTMLCanvasElement]') {\n ctx.save();\n ctx.translate(x, y);\n ctx.rotate(rad);\n ctx.drawImage(style, -style.width / 2, -style.height / 2, style.width, style.height);\n ctx.restore();\n return;\n }\n }\n if (isNaN(radius) || radius <= 0) {\n return;\n }\n ctx.beginPath();\n switch (style) {\n // Default includes circle\n default:\n if (w) {\n ctx.ellipse(x, y, w / 2, radius, 0, 0, TAU);\n } else {\n ctx.arc(x, y, radius, 0, TAU);\n }\n ctx.closePath();\n break;\n case 'triangle':\n width = w ? w / 2 : radius;\n ctx.moveTo(x + Math.sin(rad) * width, y - Math.cos(rad) * radius);\n rad += TWO_THIRDS_PI;\n ctx.lineTo(x + Math.sin(rad) * width, y - Math.cos(rad) * radius);\n rad += TWO_THIRDS_PI;\n ctx.lineTo(x + Math.sin(rad) * width, y - Math.cos(rad) * radius);\n ctx.closePath();\n break;\n case 'rectRounded':\n // NOTE: the rounded rect implementation changed to use `arc` instead of\n // `quadraticCurveTo` since it generates better results when rect is\n // almost a circle. 0.516 (instead of 0.5) produces results with visually\n // closer proportion to the previous impl and it is inscribed in the\n // circle with `radius`. For more details, see the following PRs:\n // https://github.com/chartjs/Chart.js/issues/5597\n // https://github.com/chartjs/Chart.js/issues/5858\n cornerRadius = radius * 0.516;\n size = radius - cornerRadius;\n xOffset = Math.cos(rad + QUARTER_PI) * size;\n xOffsetW = Math.cos(rad + QUARTER_PI) * (w ? w / 2 - cornerRadius : size);\n yOffset = Math.sin(rad + QUARTER_PI) * size;\n yOffsetW = Math.sin(rad + QUARTER_PI) * (w ? w / 2 - cornerRadius : size);\n ctx.arc(x - xOffsetW, y - yOffset, cornerRadius, rad - PI, rad - HALF_PI);\n ctx.arc(x + yOffsetW, y - xOffset, cornerRadius, rad - HALF_PI, rad);\n ctx.arc(x + xOffsetW, y + yOffset, cornerRadius, rad, rad + HALF_PI);\n ctx.arc(x - yOffsetW, y + xOffset, cornerRadius, rad + HALF_PI, rad + PI);\n ctx.closePath();\n break;\n case 'rect':\n if (!rotation) {\n size = Math.SQRT1_2 * radius;\n width = w ? w / 2 : size;\n ctx.rect(x - width, y - size, 2 * width, 2 * size);\n break;\n }\n rad += QUARTER_PI;\n /* falls through */\n case 'rectRot':\n xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);\n xOffset = Math.cos(rad) * radius;\n yOffset = Math.sin(rad) * radius;\n yOffsetW = Math.sin(rad) * (w ? w / 2 : radius);\n ctx.moveTo(x - xOffsetW, y - yOffset);\n ctx.lineTo(x + yOffsetW, y - xOffset);\n ctx.lineTo(x + xOffsetW, y + yOffset);\n ctx.lineTo(x - yOffsetW, y + xOffset);\n ctx.closePath();\n break;\n case 'crossRot':\n rad += QUARTER_PI;\n /* falls through */\n case 'cross':\n xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);\n xOffset = Math.cos(rad) * radius;\n yOffset = Math.sin(rad) * radius;\n yOffsetW = Math.sin(rad) * (w ? w / 2 : radius);\n ctx.moveTo(x - xOffsetW, y - yOffset);\n ctx.lineTo(x + xOffsetW, y + yOffset);\n ctx.moveTo(x + yOffsetW, y - xOffset);\n ctx.lineTo(x - yOffsetW, y + xOffset);\n break;\n case 'star':\n xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);\n xOffset = Math.cos(rad) * radius;\n yOffset = Math.sin(rad) * radius;\n yOffsetW = Math.sin(rad) * (w ? w / 2 : radius);\n ctx.moveTo(x - xOffsetW, y - yOffset);\n ctx.lineTo(x + xOffsetW, y + yOffset);\n ctx.moveTo(x + yOffsetW, y - xOffset);\n ctx.lineTo(x - yOffsetW, y + xOffset);\n rad += QUARTER_PI;\n xOffsetW = Math.cos(rad) * (w ? w / 2 : radius);\n xOffset = Math.cos(rad) * radius;\n yOffset = Math.sin(rad) * radius;\n yOffsetW = Math.sin(rad) * (w ? w / 2 : radius);\n ctx.moveTo(x - xOffsetW, y - yOffset);\n ctx.lineTo(x + xOffsetW, y + yOffset);\n ctx.moveTo(x + yOffsetW, y - xOffset);\n ctx.lineTo(x - yOffsetW, y + xOffset);\n break;\n case 'line':\n xOffset = w ? w / 2 : Math.cos(rad) * radius;\n yOffset = Math.sin(rad) * radius;\n ctx.moveTo(x - xOffset, y - yOffset);\n ctx.lineTo(x + xOffset, y + yOffset);\n break;\n case 'dash':\n ctx.moveTo(x, y);\n ctx.lineTo(x + Math.cos(rad) * (w ? w / 2 : radius), y + Math.sin(rad) * radius);\n break;\n case false:\n ctx.closePath();\n break;\n }\n ctx.fill();\n if (options.borderWidth > 0) {\n ctx.stroke();\n }\n }\n /**\n * Returns true if the point is inside the rectangle\n * @param point - The point to test\n * @param area - The rectangle\n * @param margin - allowed margin\n * @private\n */\n function _isPointInArea(point, area, margin) {\n margin = margin || 0.5; // margin - default is to match rounded decimals\n return !area || point && point.x > area.left - margin && point.x < area.right + margin && point.y > area.top - margin && point.y < area.bottom + margin;\n }\n function clipArea(ctx, area) {\n ctx.save();\n ctx.beginPath();\n ctx.rect(area.left, area.top, area.right - area.left, area.bottom - area.top);\n ctx.clip();\n }\n function unclipArea(ctx) {\n ctx.restore();\n }\n /**\n * @private\n */\n function _steppedLineTo(ctx, previous, target, flip, mode) {\n if (!previous) {\n return ctx.lineTo(target.x, target.y);\n }\n if (mode === 'middle') {\n var midpoint = (previous.x + target.x) / 2.0;\n ctx.lineTo(midpoint, previous.y);\n ctx.lineTo(midpoint, target.y);\n } else if (mode === 'after' !== !!flip) {\n ctx.lineTo(previous.x, target.y);\n } else {\n ctx.lineTo(target.x, previous.y);\n }\n ctx.lineTo(target.x, target.y);\n }\n /**\n * @private\n */\n function _bezierCurveTo(ctx, previous, target, flip) {\n if (!previous) {\n return ctx.lineTo(target.x, target.y);\n }\n ctx.bezierCurveTo(flip ? previous.cp1x : previous.cp2x, flip ? previous.cp1y : previous.cp2y, flip ? target.cp2x : target.cp1x, flip ? target.cp2y : target.cp1y, target.x, target.y);\n }\n function setRenderOpts(ctx, opts) {\n if (opts.translation) {\n ctx.translate(opts.translation[0], opts.translation[1]);\n }\n if (!isNullOrUndef(opts.rotation)) {\n ctx.rotate(opts.rotation);\n }\n if (opts.color) {\n ctx.fillStyle = opts.color;\n }\n if (opts.textAlign) {\n ctx.textAlign = opts.textAlign;\n }\n if (opts.textBaseline) {\n ctx.textBaseline = opts.textBaseline;\n }\n }\n function decorateText(ctx, x, y, line, opts) {\n if (opts.strikethrough || opts.underline) {\n /**\n * Now that IE11 support has been dropped, we can use more\n * of the TextMetrics object. The actual bounding boxes\n * are unflagged in Chrome, Firefox, Edge, and Safari so they\n * can be safely used.\n * See https://developer.mozilla.org/en-US/docs/Web/API/TextMetrics#Browser_compatibility\n */\n var metrics = ctx.measureText(line);\n var left = x - metrics.actualBoundingBoxLeft;\n var right = x + metrics.actualBoundingBoxRight;\n var top = y - metrics.actualBoundingBoxAscent;\n var bottom = y + metrics.actualBoundingBoxDescent;\n var yDecoration = opts.strikethrough ? (top + bottom) / 2 : bottom;\n ctx.strokeStyle = ctx.fillStyle;\n ctx.beginPath();\n ctx.lineWidth = opts.decorationWidth || 2;\n ctx.moveTo(left, yDecoration);\n ctx.lineTo(right, yDecoration);\n ctx.stroke();\n }\n }\n function drawBackdrop(ctx, opts) {\n var oldColor = ctx.fillStyle;\n ctx.fillStyle = opts.color;\n ctx.fillRect(opts.left, opts.top, opts.width, opts.height);\n ctx.fillStyle = oldColor;\n }\n /**\n * Render text onto the canvas\n */\n function renderText(ctx, text, x, y, font) {\n var opts = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};\n var lines = isArray(text) ? text : [text];\n var stroke = opts.strokeWidth > 0 && opts.strokeColor !== '';\n var i, line;\n ctx.save();\n ctx.font = font.string;\n setRenderOpts(ctx, opts);\n for (i = 0; i < lines.length; ++i) {\n line = lines[i];\n if (opts.backdrop) {\n drawBackdrop(ctx, opts.backdrop);\n }\n if (stroke) {\n if (opts.strokeColor) {\n ctx.strokeStyle = opts.strokeColor;\n }\n if (!isNullOrUndef(opts.strokeWidth)) {\n ctx.lineWidth = opts.strokeWidth;\n }\n ctx.strokeText(line, x, y, opts.maxWidth);\n }\n ctx.fillText(line, x, y, opts.maxWidth);\n decorateText(ctx, x, y, line, opts);\n y += Number(font.lineHeight);\n }\n ctx.restore();\n }\n /**\n * Add a path of a rectangle with rounded corners to the current sub-path\n * @param ctx - Context\n * @param rect - Bounding rect\n */\n function addRoundedRectPath(ctx, rect) {\n var x = rect.x,\n y = rect.y,\n w = rect.w,\n h = rect.h,\n radius = rect.radius;\n // top left arc\n ctx.arc(x + radius.topLeft, y + radius.topLeft, radius.topLeft, 1.5 * PI, PI, true);\n // line from top left to bottom left\n ctx.lineTo(x, y + h - radius.bottomLeft);\n // bottom left arc\n ctx.arc(x + radius.bottomLeft, y + h - radius.bottomLeft, radius.bottomLeft, PI, HALF_PI, true);\n // line from bottom left to bottom right\n ctx.lineTo(x + w - radius.bottomRight, y + h);\n // bottom right arc\n ctx.arc(x + w - radius.bottomRight, y + h - radius.bottomRight, radius.bottomRight, HALF_PI, 0, true);\n // line from bottom right to top right\n ctx.lineTo(x + w, y + radius.topRight);\n // top right arc\n ctx.arc(x + w - radius.topRight, y + radius.topRight, radius.topRight, 0, -HALF_PI, true);\n // line from top right to top left\n ctx.lineTo(x + radius.topLeft, y);\n }\n var LINE_HEIGHT = /^(normal|(\\d+(?:\\.\\d+)?)(px|em|%)?)$/;\n var FONT_STYLE = /^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;\n /**\n * @alias Chart.helpers.options\n * @namespace\n */ /**\n * Converts the given line height `value` in pixels for a specific font `size`.\n * @param value - The lineHeight to parse (eg. 1.6, '14px', '75%', '1.6em').\n * @param size - The font size (in pixels) used to resolve relative `value`.\n * @returns The effective line height in pixels (size * 1.2 if value is invalid).\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/line-height\n * @since 2.7.0\n */\n function toLineHeight(value, size) {\n var matches = ('' + value).match(LINE_HEIGHT);\n if (!matches || matches[1] === 'normal') {\n return size * 1.2;\n }\n value = +matches[2];\n switch (matches[3]) {\n case 'px':\n return value;\n case '%':\n value /= 100;\n break;\n }\n return size * value;\n }\n var numberOrZero = function numberOrZero(v) {\n return +v || 0;\n };\n function _readValueToProps(value, props) {\n var ret = {};\n var objProps = isObject(props);\n var keys = objProps ? Object.keys(props) : props;\n var read = isObject(value) ? objProps ? function (prop) {\n return valueOrDefault(value[prop], value[props[prop]]);\n } : function (prop) {\n return value[prop];\n } : function () {\n return value;\n };\n var _iterator4 = _createForOfIteratorHelper$1(keys),\n _step4;\n try {\n for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {\n var prop = _step4.value;\n ret[prop] = numberOrZero(read(prop));\n }\n } catch (err) {\n _iterator4.e(err);\n } finally {\n _iterator4.f();\n }\n return ret;\n }\n /**\n * Converts the given value into a TRBL object.\n * @param value - If a number, set the value to all TRBL component,\n * else, if an object, use defined properties and sets undefined ones to 0.\n * x / y are shorthands for same value for left/right and top/bottom.\n * @returns The padding values (top, right, bottom, left)\n * @since 3.0.0\n */\n function toTRBL(value) {\n return _readValueToProps(value, {\n top: 'y',\n right: 'x',\n bottom: 'y',\n left: 'x'\n });\n }\n /**\n * Converts the given value into a TRBL corners object (similar with css border-radius).\n * @param value - If a number, set the value to all TRBL corner components,\n * else, if an object, use defined properties and sets undefined ones to 0.\n * @returns The TRBL corner values (topLeft, topRight, bottomLeft, bottomRight)\n * @since 3.0.0\n */\n function toTRBLCorners(value) {\n return _readValueToProps(value, ['topLeft', 'topRight', 'bottomLeft', 'bottomRight']);\n }\n /**\n * Converts the given value into a padding object with pre-computed width/height.\n * @param value - If a number, set the value to all TRBL component,\n * else, if an object, use defined properties and sets undefined ones to 0.\n * x / y are shorthands for same value for left/right and top/bottom.\n * @returns The padding values (top, right, bottom, left, width, height)\n * @since 2.7.0\n */\n function toPadding(value) {\n var obj = toTRBL(value);\n obj.width = obj.left + obj.right;\n obj.height = obj.top + obj.bottom;\n return obj;\n }\n /**\n * Parses font options and returns the font object.\n * @param options - A object that contains font options to be parsed.\n * @param fallback - A object that contains fallback font options.\n * @return The font object.\n * @private\n */\n function toFont(options, fallback) {\n options = options || {};\n fallback = fallback || defaults.font;\n var size = valueOrDefault(options.size, fallback.size);\n if (typeof size === 'string') {\n size = parseInt(size, 10);\n }\n var style = valueOrDefault(options.style, fallback.style);\n if (style && !('' + style).match(FONT_STYLE)) {\n console.warn('Invalid font style specified: \"' + style + '\"');\n style = undefined;\n }\n var font = {\n family: valueOrDefault(options.family, fallback.family),\n lineHeight: toLineHeight(valueOrDefault(options.lineHeight, fallback.lineHeight), size),\n size: size,\n style: style,\n weight: valueOrDefault(options.weight, fallback.weight),\n string: ''\n };\n font.string = toFontString(font);\n return font;\n }\n /**\n * Evaluates the given `inputs` sequentially and returns the first defined value.\n * @param inputs - An array of values, falling back to the last value.\n * @param context - If defined and the current value is a function, the value\n * is called with `context` as first argument and the result becomes the new input.\n * @param index - If defined and the current value is an array, the value\n * at `index` become the new input.\n * @param info - object to return information about resolution in\n * @param info.cacheable - Will be set to `false` if option is not cacheable.\n * @since 2.7.0\n */\n function resolve(inputs, context, index, info) {\n var cacheable = true;\n var i, ilen, value;\n for (i = 0, ilen = inputs.length; i < ilen; ++i) {\n value = inputs[i];\n if (value === undefined) {\n continue;\n }\n if (context !== undefined && typeof value === 'function') {\n value = value(context);\n cacheable = false;\n }\n if (index !== undefined && isArray(value)) {\n value = value[index % value.length];\n cacheable = false;\n }\n if (value !== undefined) {\n if (info && !cacheable) {\n info.cacheable = false;\n }\n return value;\n }\n }\n }\n /**\n * @param minmax\n * @param grace\n * @param beginAtZero\n * @private\n */\n function _addGrace(minmax, grace, beginAtZero) {\n var min = minmax.min,\n max = minmax.max;\n var change = toDimension(grace, (max - min) / 2);\n var keepZero = function keepZero(value, add) {\n return beginAtZero && value === 0 ? 0 : value + add;\n };\n return {\n min: keepZero(min, -Math.abs(change)),\n max: keepZero(max, change)\n };\n }\n function createContext(parentContext, context) {\n return Object.assign(Object.create(parentContext), context);\n }\n\n /**\n * Creates a Proxy for resolving raw values for options.\n * @param scopes - The option scopes to look for values, in resolution order\n * @param prefixes - The prefixes for values, in resolution order.\n * @param rootScopes - The root option scopes\n * @param fallback - Parent scopes fallback\n * @param getTarget - callback for getting the target for changed values\n * @returns Proxy\n * @private\n */\n function _createResolver(scopes) {\n var _cache;\n var prefixes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [''];\n var rootScopes = arguments.length > 2 ? arguments[2] : undefined;\n var fallback = arguments.length > 3 ? arguments[3] : undefined;\n var getTarget = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : function () {\n return scopes[0];\n };\n var finalRootScopes = rootScopes || scopes;\n if (typeof fallback === 'undefined') {\n fallback = _resolve('_fallback', scopes);\n }\n var cache = (_cache = {}, _defineProperty$1(_cache, Symbol.toStringTag, 'Object'), _defineProperty$1(_cache, \"_cacheable\", true), _defineProperty$1(_cache, \"_scopes\", scopes), _defineProperty$1(_cache, \"_rootScopes\", finalRootScopes), _defineProperty$1(_cache, \"_fallback\", fallback), _defineProperty$1(_cache, \"_getTarget\", getTarget), _defineProperty$1(_cache, \"override\", function override(scope) {\n return _createResolver([scope].concat(_toConsumableArray(scopes)), prefixes, finalRootScopes, fallback);\n }), _cache);\n return new Proxy(cache, {\n /**\n * A trap for the delete operator.\n */\n deleteProperty: function deleteProperty(target, prop) {\n delete target[prop]; // remove from cache\n delete target._keys; // remove cached keys\n delete scopes[0][prop]; // remove from top level scope\n return true;\n },\n /**\n * A trap for getting property values.\n */\n get: function get(target, prop) {\n return _cached(target, prop, function () {\n return _resolveWithPrefixes(prop, prefixes, scopes, target);\n });\n },\n /**\n * A trap for Object.getOwnPropertyDescriptor.\n * Also used by Object.hasOwnProperty.\n */\n getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, prop) {\n return Reflect.getOwnPropertyDescriptor(target._scopes[0], prop);\n },\n /**\n * A trap for Object.getPrototypeOf.\n */\n getPrototypeOf: function getPrototypeOf() {\n return Reflect.getPrototypeOf(scopes[0]);\n },\n /**\n * A trap for the in operator.\n */\n has: function has(target, prop) {\n return getKeysFromAllScopes(target).includes(prop);\n },\n /**\n * A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.\n */\n ownKeys: function ownKeys(target) {\n return getKeysFromAllScopes(target);\n },\n /**\n * A trap for setting property values.\n */\n set: function set(target, prop, value) {\n var storage = target._storage || (target._storage = getTarget());\n target[prop] = storage[prop] = value; // set to top level scope + cache\n delete target._keys; // remove cached keys\n return true;\n }\n });\n }\n /**\n * Returns an Proxy for resolving option values with context.\n * @param proxy - The Proxy returned by `_createResolver`\n * @param context - Context object for scriptable/indexable options\n * @param subProxy - The proxy provided for scriptable options\n * @param descriptorDefaults - Defaults for descriptors\n * @private\n */\n function _attachContext(proxy, context, subProxy, descriptorDefaults) {\n var cache = {\n _cacheable: false,\n _proxy: proxy,\n _context: context,\n _subProxy: subProxy,\n _stack: new Set(),\n _descriptors: _descriptors(proxy, descriptorDefaults),\n setContext: function setContext(ctx) {\n return _attachContext(proxy, ctx, subProxy, descriptorDefaults);\n },\n override: function override(scope) {\n return _attachContext(proxy.override(scope), context, subProxy, descriptorDefaults);\n }\n };\n return new Proxy(cache, {\n /**\n * A trap for the delete operator.\n */\n deleteProperty: function deleteProperty(target, prop) {\n delete target[prop]; // remove from cache\n delete proxy[prop]; // remove from proxy\n return true;\n },\n /**\n * A trap for getting property values.\n */\n get: function get(target, prop, receiver) {\n return _cached(target, prop, function () {\n return _resolveWithContext(target, prop, receiver);\n });\n },\n /**\n * A trap for Object.getOwnPropertyDescriptor.\n * Also used by Object.hasOwnProperty.\n */\n getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, prop) {\n return target._descriptors.allKeys ? Reflect.has(proxy, prop) ? {\n enumerable: true,\n configurable: true\n } : undefined : Reflect.getOwnPropertyDescriptor(proxy, prop);\n },\n /**\n * A trap for Object.getPrototypeOf.\n */\n getPrototypeOf: function getPrototypeOf() {\n return Reflect.getPrototypeOf(proxy);\n },\n /**\n * A trap for the in operator.\n */\n has: function has(target, prop) {\n return Reflect.has(proxy, prop);\n },\n /**\n * A trap for Object.getOwnPropertyNames and Object.getOwnPropertySymbols.\n */\n ownKeys: function ownKeys() {\n return Reflect.ownKeys(proxy);\n },\n /**\n * A trap for setting property values.\n */\n set: function set(target, prop, value) {\n proxy[prop] = value; // set to proxy\n delete target[prop]; // remove from cache\n return true;\n }\n });\n }\n /**\n * @private\n */\n function _descriptors(proxy) {\n var defaults = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {\n scriptable: true,\n indexable: true\n };\n var _proxy$_scriptable = proxy._scriptable,\n _scriptable = _proxy$_scriptable === void 0 ? defaults.scriptable : _proxy$_scriptable,\n _proxy$_indexable = proxy._indexable,\n _indexable = _proxy$_indexable === void 0 ? defaults.indexable : _proxy$_indexable,\n _proxy$_allKeys = proxy._allKeys,\n _allKeys = _proxy$_allKeys === void 0 ? defaults.allKeys : _proxy$_allKeys;\n return {\n allKeys: _allKeys,\n scriptable: _scriptable,\n indexable: _indexable,\n isScriptable: isFunction(_scriptable) ? _scriptable : function () {\n return _scriptable;\n },\n isIndexable: isFunction(_indexable) ? _indexable : function () {\n return _indexable;\n }\n };\n }\n var readKey = function readKey(prefix, name) {\n return prefix ? prefix + _capitalize(name) : name;\n };\n var needsSubResolver = function needsSubResolver(prop, value) {\n return isObject(value) && prop !== 'adapters' && (Object.getPrototypeOf(value) === null || value.constructor === Object);\n };\n function _cached(target, prop, resolve) {\n if (Object.prototype.hasOwnProperty.call(target, prop)) {\n return target[prop];\n }\n var value = resolve();\n // cache the resolved value\n target[prop] = value;\n return value;\n }\n function _resolveWithContext(target, prop, receiver) {\n var _proxy = target._proxy,\n _context = target._context,\n _subProxy = target._subProxy,\n descriptors = target._descriptors;\n var value = _proxy[prop]; // resolve from proxy\n // resolve with context\n if (isFunction(value) && descriptors.isScriptable(prop)) {\n value = _resolveScriptable(prop, value, target, receiver);\n }\n if (isArray(value) && value.length) {\n value = _resolveArray(prop, value, target, descriptors.isIndexable);\n }\n if (needsSubResolver(prop, value)) {\n // if the resolved value is an object, create a sub resolver for it\n value = _attachContext(value, _context, _subProxy && _subProxy[prop], descriptors);\n }\n return value;\n }\n function _resolveScriptable(prop, getValue, target, receiver) {\n var _proxy = target._proxy,\n _context = target._context,\n _subProxy = target._subProxy,\n _stack = target._stack;\n if (_stack.has(prop)) {\n throw new Error('Recursion detected: ' + Array.from(_stack).join('->') + '->' + prop);\n }\n _stack.add(prop);\n var value = getValue(_context, _subProxy || receiver);\n _stack[\"delete\"](prop);\n if (needsSubResolver(prop, value)) {\n // When scriptable option returns an object, create a resolver on that.\n value = createSubResolver(_proxy._scopes, _proxy, prop, value);\n }\n return value;\n }\n function _resolveArray(prop, value, target, isIndexable) {\n var _proxy = target._proxy,\n _context = target._context,\n _subProxy = target._subProxy,\n descriptors = target._descriptors;\n if (typeof _context.index !== 'undefined' && isIndexable(prop)) {\n return value[_context.index % value.length];\n } else if (isObject(value[0])) {\n // Array of objects, return array or resolvers\n var arr = value;\n var scopes = _proxy._scopes.filter(function (s) {\n return s !== arr;\n });\n value = [];\n var _iterator5 = _createForOfIteratorHelper$1(arr),\n _step5;\n try {\n for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {\n var item = _step5.value;\n var resolver = createSubResolver(scopes, _proxy, prop, item);\n value.push(_attachContext(resolver, _context, _subProxy && _subProxy[prop], descriptors));\n }\n } catch (err) {\n _iterator5.e(err);\n } finally {\n _iterator5.f();\n }\n }\n return value;\n }\n function resolveFallback(fallback, prop, value) {\n return isFunction(fallback) ? fallback(prop, value) : fallback;\n }\n var getScope = function getScope(key, parent) {\n return key === true ? parent : typeof key === 'string' ? resolveObjectKey(parent, key) : undefined;\n };\n function addScopes(set, parentScopes, key, parentFallback, value) {\n var _iterator6 = _createForOfIteratorHelper$1(parentScopes),\n _step6;\n try {\n for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {\n var parent = _step6.value;\n var scope = getScope(key, parent);\n if (scope) {\n set.add(scope);\n var fallback = resolveFallback(scope._fallback, key, value);\n if (typeof fallback !== 'undefined' && fallback !== key && fallback !== parentFallback) {\n // When we reach the descriptor that defines a new _fallback, return that.\n // The fallback will resume to that new scope.\n return fallback;\n }\n } else if (scope === false && typeof parentFallback !== 'undefined' && key !== parentFallback) {\n // Fallback to `false` results to `false`, when falling back to different key.\n // For example `interaction` from `hover` or `plugins.tooltip` and `animation` from `animations`\n return null;\n }\n }\n } catch (err) {\n _iterator6.e(err);\n } finally {\n _iterator6.f();\n }\n return false;\n }\n function createSubResolver(parentScopes, resolver, prop, value) {\n var rootScopes = resolver._rootScopes;\n var fallback = resolveFallback(resolver._fallback, prop, value);\n var allScopes = [].concat(_toConsumableArray(parentScopes), _toConsumableArray(rootScopes));\n var set = new Set();\n set.add(value);\n var key = addScopesFromKey(set, allScopes, prop, fallback || prop, value);\n if (key === null) {\n return false;\n }\n if (typeof fallback !== 'undefined' && fallback !== prop) {\n key = addScopesFromKey(set, allScopes, fallback, key, value);\n if (key === null) {\n return false;\n }\n }\n return _createResolver(Array.from(set), [''], rootScopes, fallback, function () {\n return subGetTarget(resolver, prop, value);\n });\n }\n function addScopesFromKey(set, allScopes, key, fallback, item) {\n while (key) {\n key = addScopes(set, allScopes, key, fallback, item);\n }\n return key;\n }\n function subGetTarget(resolver, prop, value) {\n var parent = resolver._getTarget();\n if (!(prop in parent)) {\n parent[prop] = {};\n }\n var target = parent[prop];\n if (isArray(target) && isObject(value)) {\n // For array of objects, the object is used to store updated values\n return value;\n }\n return target || {};\n }\n function _resolveWithPrefixes(prop, prefixes, scopes, proxy) {\n var value;\n var _iterator7 = _createForOfIteratorHelper$1(prefixes),\n _step7;\n try {\n for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {\n var prefix = _step7.value;\n value = _resolve(readKey(prefix, prop), scopes);\n if (typeof value !== 'undefined') {\n return needsSubResolver(prop, value) ? createSubResolver(scopes, proxy, prop, value) : value;\n }\n }\n } catch (err) {\n _iterator7.e(err);\n } finally {\n _iterator7.f();\n }\n }\n function _resolve(key, scopes) {\n var _iterator8 = _createForOfIteratorHelper$1(scopes),\n _step8;\n try {\n for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {\n var scope = _step8.value;\n if (!scope) {\n continue;\n }\n var value = scope[key];\n if (typeof value !== 'undefined') {\n return value;\n }\n }\n } catch (err) {\n _iterator8.e(err);\n } finally {\n _iterator8.f();\n }\n }\n function getKeysFromAllScopes(target) {\n var keys = target._keys;\n if (!keys) {\n keys = target._keys = resolveKeysFromAllScopes(target._scopes);\n }\n return keys;\n }\n function resolveKeysFromAllScopes(scopes) {\n var set = new Set();\n var _iterator9 = _createForOfIteratorHelper$1(scopes),\n _step9;\n try {\n for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {\n var scope = _step9.value;\n var _iterator10 = _createForOfIteratorHelper$1(Object.keys(scope).filter(function (k) {\n return !k.startsWith('_');\n })),\n _step10;\n try {\n for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {\n var key = _step10.value;\n set.add(key);\n }\n } catch (err) {\n _iterator10.e(err);\n } finally {\n _iterator10.f();\n }\n }\n } catch (err) {\n _iterator9.e(err);\n } finally {\n _iterator9.f();\n }\n return Array.from(set);\n }\n function _parseObjectDataRadialScale(meta, data, start, count) {\n var iScale = meta.iScale;\n var _this$_parsing$key = this._parsing.key,\n key = _this$_parsing$key === void 0 ? 'r' : _this$_parsing$key;\n var parsed = new Array(count);\n var i, ilen, index, item;\n for (i = 0, ilen = count; i < ilen; ++i) {\n index = i + start;\n item = data[index];\n parsed[i] = {\n r: iScale.parse(resolveObjectKey(item, key), index)\n };\n }\n return parsed;\n }\n var EPSILON = Number.EPSILON || 1e-14;\n var getPoint = function getPoint(points, i) {\n return i < points.length && !points[i].skip && points[i];\n };\n var getValueAxis = function getValueAxis(indexAxis) {\n return indexAxis === 'x' ? 'y' : 'x';\n };\n function splineCurve(firstPoint, middlePoint, afterPoint, t) {\n // Props to Rob Spencer at scaled innovation for his post on splining between points\n // http://scaledinnovation.com/analytics/splines/aboutSplines.html\n // This function must also respect \"skipped\" points\n var previous = firstPoint.skip ? middlePoint : firstPoint;\n var current = middlePoint;\n var next = afterPoint.skip ? middlePoint : afterPoint;\n var d01 = distanceBetweenPoints(current, previous);\n var d12 = distanceBetweenPoints(next, current);\n var s01 = d01 / (d01 + d12);\n var s12 = d12 / (d01 + d12);\n // If all points are the same, s01 & s02 will be inf\n s01 = isNaN(s01) ? 0 : s01;\n s12 = isNaN(s12) ? 0 : s12;\n var fa = t * s01; // scaling factor for triangle Ta\n var fb = t * s12;\n return {\n previous: {\n x: current.x - fa * (next.x - previous.x),\n y: current.y - fa * (next.y - previous.y)\n },\n next: {\n x: current.x + fb * (next.x - previous.x),\n y: current.y + fb * (next.y - previous.y)\n }\n };\n }\n /**\n * Adjust tangents to ensure monotonic properties\n */\n function monotoneAdjust(points, deltaK, mK) {\n var pointsLen = points.length;\n var alphaK, betaK, tauK, squaredMagnitude, pointCurrent;\n var pointAfter = getPoint(points, 0);\n for (var i = 0; i < pointsLen - 1; ++i) {\n pointCurrent = pointAfter;\n pointAfter = getPoint(points, i + 1);\n if (!pointCurrent || !pointAfter) {\n continue;\n }\n if (almostEquals(deltaK[i], 0, EPSILON)) {\n mK[i] = mK[i + 1] = 0;\n continue;\n }\n alphaK = mK[i] / deltaK[i];\n betaK = mK[i + 1] / deltaK[i];\n squaredMagnitude = Math.pow(alphaK, 2) + Math.pow(betaK, 2);\n if (squaredMagnitude <= 9) {\n continue;\n }\n tauK = 3 / Math.sqrt(squaredMagnitude);\n mK[i] = alphaK * tauK * deltaK[i];\n mK[i + 1] = betaK * tauK * deltaK[i];\n }\n }\n function monotoneCompute(points, mK) {\n var indexAxis = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'x';\n var valueAxis = getValueAxis(indexAxis);\n var pointsLen = points.length;\n var delta, pointBefore, pointCurrent;\n var pointAfter = getPoint(points, 0);\n for (var i = 0; i < pointsLen; ++i) {\n pointBefore = pointCurrent;\n pointCurrent = pointAfter;\n pointAfter = getPoint(points, i + 1);\n if (!pointCurrent) {\n continue;\n }\n var iPixel = pointCurrent[indexAxis];\n var vPixel = pointCurrent[valueAxis];\n if (pointBefore) {\n delta = (iPixel - pointBefore[indexAxis]) / 3;\n pointCurrent[\"cp1\".concat(indexAxis)] = iPixel - delta;\n pointCurrent[\"cp1\".concat(valueAxis)] = vPixel - delta * mK[i];\n }\n if (pointAfter) {\n delta = (pointAfter[indexAxis] - iPixel) / 3;\n pointCurrent[\"cp2\".concat(indexAxis)] = iPixel + delta;\n pointCurrent[\"cp2\".concat(valueAxis)] = vPixel + delta * mK[i];\n }\n }\n }\n /**\n * This function calculates Bézier control points in a similar way than |splineCurve|,\n * but preserves monotonicity of the provided data and ensures no local extremums are added\n * between the dataset discrete points due to the interpolation.\n * See : https://en.wikipedia.org/wiki/Monotone_cubic_interpolation\n */\n function splineCurveMonotone(points) {\n var indexAxis = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'x';\n var valueAxis = getValueAxis(indexAxis);\n var pointsLen = points.length;\n var deltaK = Array(pointsLen).fill(0);\n var mK = Array(pointsLen);\n // Calculate slopes (deltaK) and initialize tangents (mK)\n var i, pointBefore, pointCurrent;\n var pointAfter = getPoint(points, 0);\n for (i = 0; i < pointsLen; ++i) {\n pointBefore = pointCurrent;\n pointCurrent = pointAfter;\n pointAfter = getPoint(points, i + 1);\n if (!pointCurrent) {\n continue;\n }\n if (pointAfter) {\n var slopeDelta = pointAfter[indexAxis] - pointCurrent[indexAxis];\n // In the case of two points that appear at the same x pixel, slopeDeltaX is 0\n deltaK[i] = slopeDelta !== 0 ? (pointAfter[valueAxis] - pointCurrent[valueAxis]) / slopeDelta : 0;\n }\n mK[i] = !pointBefore ? deltaK[i] : !pointAfter ? deltaK[i - 1] : sign(deltaK[i - 1]) !== sign(deltaK[i]) ? 0 : (deltaK[i - 1] + deltaK[i]) / 2;\n }\n monotoneAdjust(points, deltaK, mK);\n monotoneCompute(points, mK, indexAxis);\n }\n function capControlPoint(pt, min, max) {\n return Math.max(Math.min(pt, max), min);\n }\n function capBezierPoints(points, area) {\n var i, ilen, point, inArea, inAreaPrev;\n var inAreaNext = _isPointInArea(points[0], area);\n for (i = 0, ilen = points.length; i < ilen; ++i) {\n inAreaPrev = inArea;\n inArea = inAreaNext;\n inAreaNext = i < ilen - 1 && _isPointInArea(points[i + 1], area);\n if (!inArea) {\n continue;\n }\n point = points[i];\n if (inAreaPrev) {\n point.cp1x = capControlPoint(point.cp1x, area.left, area.right);\n point.cp1y = capControlPoint(point.cp1y, area.top, area.bottom);\n }\n if (inAreaNext) {\n point.cp2x = capControlPoint(point.cp2x, area.left, area.right);\n point.cp2y = capControlPoint(point.cp2y, area.top, area.bottom);\n }\n }\n }\n /**\n * @private\n */\n function _updateBezierControlPoints(points, options, area, loop, indexAxis) {\n var i, ilen, point, controlPoints;\n // Only consider points that are drawn in case the spanGaps option is used\n if (options.spanGaps) {\n points = points.filter(function (pt) {\n return !pt.skip;\n });\n }\n if (options.cubicInterpolationMode === 'monotone') {\n splineCurveMonotone(points, indexAxis);\n } else {\n var prev = loop ? points[points.length - 1] : points[0];\n for (i = 0, ilen = points.length; i < ilen; ++i) {\n point = points[i];\n controlPoints = splineCurve(prev, point, points[Math.min(i + 1, ilen - (loop ? 0 : 1)) % ilen], options.tension);\n point.cp1x = controlPoints.previous.x;\n point.cp1y = controlPoints.previous.y;\n point.cp2x = controlPoints.next.x;\n point.cp2y = controlPoints.next.y;\n prev = point;\n }\n }\n if (options.capBezierPoints) {\n capBezierPoints(points, area);\n }\n }\n\n /**\n * Note: typedefs are auto-exported, so use a made-up `dom` namespace where\n * necessary to avoid duplicates with `export * from './helpers`; see\n * https://github.com/microsoft/TypeScript/issues/46011\n * @typedef { import('../core/core.controller.js').default } dom.Chart\n * @typedef { import('../../types').ChartEvent } ChartEvent\n */ /**\n * @private\n */\n function _isDomSupported() {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\n }\n /**\n * @private\n */\n function _getParentNode(domNode) {\n var parent = domNode.parentNode;\n if (parent && parent.toString() === '[object ShadowRoot]') {\n parent = parent.host;\n }\n return parent;\n }\n /**\n * convert max-width/max-height values that may be percentages into a number\n * @private\n */\n function parseMaxStyle(styleValue, node, parentProperty) {\n var valueInPixels;\n if (typeof styleValue === 'string') {\n valueInPixels = parseInt(styleValue, 10);\n if (styleValue.indexOf('%') !== -1) {\n // percentage * size in dimension\n valueInPixels = valueInPixels / 100 * node.parentNode[parentProperty];\n }\n } else {\n valueInPixels = styleValue;\n }\n return valueInPixels;\n }\n var getComputedStyle = function getComputedStyle(element) {\n return element.ownerDocument.defaultView.getComputedStyle(element, null);\n };\n function getStyle(el, property) {\n return getComputedStyle(el).getPropertyValue(property);\n }\n var positions = ['top', 'right', 'bottom', 'left'];\n function getPositionedStyle(styles, style, suffix) {\n var result = {};\n suffix = suffix ? '-' + suffix : '';\n for (var i = 0; i < 4; i++) {\n var pos = positions[i];\n result[pos] = parseFloat(styles[style + '-' + pos + suffix]) || 0;\n }\n result.width = result.left + result.right;\n result.height = result.top + result.bottom;\n return result;\n }\n var useOffsetPos = function useOffsetPos(x, y, target) {\n return (x > 0 || y > 0) && (!target || !target.shadowRoot);\n };\n /**\n * @param e\n * @param canvas\n * @returns Canvas position\n */\n function getCanvasPosition(e, canvas) {\n var touches = e.touches;\n var source = touches && touches.length ? touches[0] : e;\n var offsetX = source.offsetX,\n offsetY = source.offsetY;\n var box = false;\n var x, y;\n if (useOffsetPos(offsetX, offsetY, e.target)) {\n x = offsetX;\n y = offsetY;\n } else {\n var rect = canvas.getBoundingClientRect();\n x = source.clientX - rect.left;\n y = source.clientY - rect.top;\n box = true;\n }\n return {\n x: x,\n y: y,\n box: box\n };\n }\n /**\n * Gets an event's x, y coordinates, relative to the chart area\n * @param event\n * @param chart\n * @returns x and y coordinates of the event\n */\n function getRelativePosition(event, chart) {\n if ('native' in event) {\n return event;\n }\n var canvas = chart.canvas,\n currentDevicePixelRatio = chart.currentDevicePixelRatio;\n var style = getComputedStyle(canvas);\n var borderBox = style.boxSizing === 'border-box';\n var paddings = getPositionedStyle(style, 'padding');\n var borders = getPositionedStyle(style, 'border', 'width');\n var _getCanvasPosition = getCanvasPosition(event, canvas),\n x = _getCanvasPosition.x,\n y = _getCanvasPosition.y,\n box = _getCanvasPosition.box;\n var xOffset = paddings.left + (box && borders.left);\n var yOffset = paddings.top + (box && borders.top);\n var width = chart.width,\n height = chart.height;\n if (borderBox) {\n width -= paddings.width + borders.width;\n height -= paddings.height + borders.height;\n }\n return {\n x: Math.round((x - xOffset) / width * canvas.width / currentDevicePixelRatio),\n y: Math.round((y - yOffset) / height * canvas.height / currentDevicePixelRatio)\n };\n }\n function getContainerSize(canvas, width, height) {\n var maxWidth, maxHeight;\n if (width === undefined || height === undefined) {\n var container = _getParentNode(canvas);\n if (!container) {\n width = canvas.clientWidth;\n height = canvas.clientHeight;\n } else {\n var rect = container.getBoundingClientRect(); // this is the border box of the container\n var containerStyle = getComputedStyle(container);\n var containerBorder = getPositionedStyle(containerStyle, 'border', 'width');\n var containerPadding = getPositionedStyle(containerStyle, 'padding');\n width = rect.width - containerPadding.width - containerBorder.width;\n height = rect.height - containerPadding.height - containerBorder.height;\n maxWidth = parseMaxStyle(containerStyle.maxWidth, container, 'clientWidth');\n maxHeight = parseMaxStyle(containerStyle.maxHeight, container, 'clientHeight');\n }\n }\n return {\n width: width,\n height: height,\n maxWidth: maxWidth || INFINITY,\n maxHeight: maxHeight || INFINITY\n };\n }\n var round1 = function round1(v) {\n return Math.round(v * 10) / 10;\n };\n // eslint-disable-next-line complexity\n function getMaximumSize(canvas, bbWidth, bbHeight, aspectRatio) {\n var style = getComputedStyle(canvas);\n var margins = getPositionedStyle(style, 'margin');\n var maxWidth = parseMaxStyle(style.maxWidth, canvas, 'clientWidth') || INFINITY;\n var maxHeight = parseMaxStyle(style.maxHeight, canvas, 'clientHeight') || INFINITY;\n var containerSize = getContainerSize(canvas, bbWidth, bbHeight);\n var width = containerSize.width,\n height = containerSize.height;\n if (style.boxSizing === 'content-box') {\n var borders = getPositionedStyle(style, 'border', 'width');\n var paddings = getPositionedStyle(style, 'padding');\n width -= paddings.width + borders.width;\n height -= paddings.height + borders.height;\n }\n width = Math.max(0, width - margins.width);\n height = Math.max(0, aspectRatio ? width / aspectRatio : height - margins.height);\n width = round1(Math.min(width, maxWidth, containerSize.maxWidth));\n height = round1(Math.min(height, maxHeight, containerSize.maxHeight));\n if (width && !height) {\n // https://github.com/chartjs/Chart.js/issues/4659\n // If the canvas has width, but no height, default to aspectRatio of 2 (canvas default)\n height = round1(width / 2);\n }\n var maintainHeight = bbWidth !== undefined || bbHeight !== undefined;\n if (maintainHeight && aspectRatio && containerSize.height && height > containerSize.height) {\n height = containerSize.height;\n width = round1(Math.floor(height * aspectRatio));\n }\n return {\n width: width,\n height: height\n };\n }\n /**\n * @param chart\n * @param forceRatio\n * @param forceStyle\n * @returns True if the canvas context size or transformation has changed.\n */\n function retinaScale(chart, forceRatio, forceStyle) {\n var pixelRatio = forceRatio || 1;\n var deviceHeight = Math.floor(chart.height * pixelRatio);\n var deviceWidth = Math.floor(chart.width * pixelRatio);\n chart.height = Math.floor(chart.height);\n chart.width = Math.floor(chart.width);\n var canvas = chart.canvas;\n // If no style has been set on the canvas, the render size is used as display size,\n // making the chart visually bigger, so let's enforce it to the \"correct\" values.\n // See https://github.com/chartjs/Chart.js/issues/3575\n if (canvas.style && (forceStyle || !canvas.style.height && !canvas.style.width)) {\n canvas.style.height = \"\".concat(chart.height, \"px\");\n canvas.style.width = \"\".concat(chart.width, \"px\");\n }\n if (chart.currentDevicePixelRatio !== pixelRatio || canvas.height !== deviceHeight || canvas.width !== deviceWidth) {\n chart.currentDevicePixelRatio = pixelRatio;\n canvas.height = deviceHeight;\n canvas.width = deviceWidth;\n chart.ctx.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);\n return true;\n }\n return false;\n }\n /**\n * Detects support for options object argument in addEventListener.\n * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support\n * @private\n */\n var supportsEventListenerOptions = function () {\n var passiveSupported = false;\n try {\n var options = {\n get passive() {\n passiveSupported = true;\n return false;\n }\n };\n window.addEventListener('test', null, options);\n window.removeEventListener('test', null, options);\n } catch (e) {\n // continue regardless of error\n }\n return passiveSupported;\n }();\n /**\n * The \"used\" size is the final value of a dimension property after all calculations have\n * been performed. This method uses the computed style of `element` but returns undefined\n * if the computed style is not expressed in pixels. That can happen in some cases where\n * `element` has a size relative to its parent and this last one is not yet displayed,\n * for example because of `display: none` on a parent node.\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/used_value\n * @returns Size in pixels or undefined if unknown.\n */\n function readUsedSize(element, property) {\n var value = getStyle(element, property);\n var matches = value && value.match(/^(\\d+)(\\.\\d+)?px$/);\n return matches ? +matches[1] : undefined;\n }\n\n /**\n * @private\n */\n function _pointInLine(p1, p2, t, mode) {\n return {\n x: p1.x + t * (p2.x - p1.x),\n y: p1.y + t * (p2.y - p1.y)\n };\n }\n /**\n * @private\n */\n function _steppedInterpolation(p1, p2, t, mode) {\n return {\n x: p1.x + t * (p2.x - p1.x),\n y: mode === 'middle' ? t < 0.5 ? p1.y : p2.y : mode === 'after' ? t < 1 ? p1.y : p2.y : t > 0 ? p2.y : p1.y\n };\n }\n /**\n * @private\n */\n function _bezierInterpolation(p1, p2, t, mode) {\n var cp1 = {\n x: p1.cp2x,\n y: p1.cp2y\n };\n var cp2 = {\n x: p2.cp1x,\n y: p2.cp1y\n };\n var a = _pointInLine(p1, cp1, t);\n var b = _pointInLine(cp1, cp2, t);\n var c = _pointInLine(cp2, p2, t);\n var d = _pointInLine(a, b, t);\n var e = _pointInLine(b, c, t);\n return _pointInLine(d, e, t);\n }\n var getRightToLeftAdapter = function getRightToLeftAdapter(rectX, width) {\n return {\n x: function x(_x) {\n return rectX + rectX + width - _x;\n },\n setWidth: function setWidth(w) {\n width = w;\n },\n textAlign: function textAlign(align) {\n if (align === 'center') {\n return align;\n }\n return align === 'right' ? 'left' : 'right';\n },\n xPlus: function xPlus(x, value) {\n return x - value;\n },\n leftForLtr: function leftForLtr(x, itemWidth) {\n return x - itemWidth;\n }\n };\n };\n var getLeftToRightAdapter = function getLeftToRightAdapter() {\n return {\n x: function x(_x2) {\n return _x2;\n },\n setWidth: function setWidth(w) {},\n textAlign: function textAlign(align) {\n return align;\n },\n xPlus: function xPlus(x, value) {\n return x + value;\n },\n leftForLtr: function leftForLtr(x, _itemWidth) {\n return x;\n }\n };\n };\n function getRtlAdapter(rtl, rectX, width) {\n return rtl ? getRightToLeftAdapter(rectX, width) : getLeftToRightAdapter();\n }\n function overrideTextDirection(ctx, direction) {\n var style, original;\n if (direction === 'ltr' || direction === 'rtl') {\n style = ctx.canvas.style;\n original = [style.getPropertyValue('direction'), style.getPropertyPriority('direction')];\n style.setProperty('direction', direction, 'important');\n ctx.prevTextDirection = original;\n }\n }\n function restoreTextDirection(ctx, original) {\n if (original !== undefined) {\n delete ctx.prevTextDirection;\n ctx.canvas.style.setProperty('direction', original[0], original[1]);\n }\n }\n function propertyFn(property) {\n if (property === 'angle') {\n return {\n between: _angleBetween,\n compare: _angleDiff,\n normalize: _normalizeAngle\n };\n }\n return {\n between: _isBetween,\n compare: function compare(a, b) {\n return a - b;\n },\n normalize: function normalize(x) {\n return x;\n }\n };\n }\n function normalizeSegment(_ref) {\n var start = _ref.start,\n end = _ref.end,\n count = _ref.count,\n loop = _ref.loop,\n style = _ref.style;\n return {\n start: start % count,\n end: end % count,\n loop: loop && (end - start + 1) % count === 0,\n style: style\n };\n }\n function getSegment(segment, points, bounds) {\n var property = bounds.property,\n startBound = bounds.start,\n endBound = bounds.end;\n var _propertyFn = propertyFn(property),\n between = _propertyFn.between,\n normalize = _propertyFn.normalize;\n var count = points.length;\n var start = segment.start,\n end = segment.end,\n loop = segment.loop;\n var i, ilen;\n if (loop) {\n start += count;\n end += count;\n for (i = 0, ilen = count; i < ilen; ++i) {\n if (!between(normalize(points[start % count][property]), startBound, endBound)) {\n break;\n }\n start--;\n end--;\n }\n start %= count;\n end %= count;\n }\n if (end < start) {\n end += count;\n }\n return {\n start: start,\n end: end,\n loop: loop,\n style: segment.style\n };\n }\n function _boundSegment(segment, points, bounds) {\n if (!bounds) {\n return [segment];\n }\n var property = bounds.property,\n startBound = bounds.start,\n endBound = bounds.end;\n var count = points.length;\n var _propertyFn2 = propertyFn(property),\n compare = _propertyFn2.compare,\n between = _propertyFn2.between,\n normalize = _propertyFn2.normalize;\n var _getSegment = getSegment(segment, points, bounds),\n start = _getSegment.start,\n end = _getSegment.end,\n loop = _getSegment.loop,\n style = _getSegment.style;\n var result = [];\n var inside = false;\n var subStart = null;\n var value, point, prevValue;\n var startIsBefore = function startIsBefore() {\n return between(startBound, prevValue, value) && compare(startBound, prevValue) !== 0;\n };\n var endIsBefore = function endIsBefore() {\n return compare(endBound, value) === 0 || between(endBound, prevValue, value);\n };\n var shouldStart = function shouldStart() {\n return inside || startIsBefore();\n };\n var shouldStop = function shouldStop() {\n return !inside || endIsBefore();\n };\n for (var i = start, prev = start; i <= end; ++i) {\n point = points[i % count];\n if (point.skip) {\n continue;\n }\n value = normalize(point[property]);\n if (value === prevValue) {\n continue;\n }\n inside = between(value, startBound, endBound);\n if (subStart === null && shouldStart()) {\n subStart = compare(value, startBound) === 0 ? i : prev;\n }\n if (subStart !== null && shouldStop()) {\n result.push(normalizeSegment({\n start: subStart,\n end: i,\n loop: loop,\n count: count,\n style: style\n }));\n subStart = null;\n }\n prev = i;\n prevValue = value;\n }\n if (subStart !== null) {\n result.push(normalizeSegment({\n start: subStart,\n end: end,\n loop: loop,\n count: count,\n style: style\n }));\n }\n return result;\n }\n function _boundSegments(line, bounds) {\n var result = [];\n var segments = line.segments;\n for (var i = 0; i < segments.length; i++) {\n var sub = _boundSegment(segments[i], line.points, bounds);\n if (sub.length) {\n result.push.apply(result, _toConsumableArray(sub));\n }\n }\n return result;\n }\n function findStartAndEnd(points, count, loop, spanGaps) {\n var start = 0;\n var end = count - 1;\n if (loop && !spanGaps) {\n while (start < count && !points[start].skip) {\n start++;\n }\n }\n while (start < count && points[start].skip) {\n start++;\n }\n start %= count;\n if (loop) {\n end += start;\n }\n while (end > start && points[end % count].skip) {\n end--;\n }\n end %= count;\n return {\n start: start,\n end: end\n };\n }\n function solidSegments(points, start, max, loop) {\n var count = points.length;\n var result = [];\n var last = start;\n var prev = points[start];\n var end;\n for (end = start + 1; end <= max; ++end) {\n var cur = points[end % count];\n if (cur.skip || cur.stop) {\n if (!prev.skip) {\n loop = false;\n result.push({\n start: start % count,\n end: (end - 1) % count,\n loop: loop\n });\n start = last = cur.stop ? end : null;\n }\n } else {\n last = end;\n if (prev.skip) {\n start = end;\n }\n }\n prev = cur;\n }\n if (last !== null) {\n result.push({\n start: start % count,\n end: last % count,\n loop: loop\n });\n }\n return result;\n }\n function _computeSegments(line, segmentOptions) {\n var points = line.points;\n var spanGaps = line.options.spanGaps;\n var count = points.length;\n if (!count) {\n return [];\n }\n var loop = !!line._loop;\n var _findStartAndEnd = findStartAndEnd(points, count, loop, spanGaps),\n start = _findStartAndEnd.start,\n end = _findStartAndEnd.end;\n if (spanGaps === true) {\n return splitByStyles(line, [{\n start: start,\n end: end,\n loop: loop\n }], points, segmentOptions);\n }\n var max = end < start ? end + count : end;\n var completeLoop = !!line._fullLoop && start === 0 && end === count - 1;\n return splitByStyles(line, solidSegments(points, start, max, completeLoop), points, segmentOptions);\n }\n function splitByStyles(line, segments, points, segmentOptions) {\n if (!segmentOptions || !segmentOptions.setContext || !points) {\n return segments;\n }\n return doSplitByStyles(line, segments, points, segmentOptions);\n }\n function doSplitByStyles(line, segments, points, segmentOptions) {\n var chartContext = line._chart.getContext();\n var baseStyle = readStyle(line.options);\n var datasetIndex = line._datasetIndex,\n spanGaps = line.options.spanGaps;\n var count = points.length;\n var result = [];\n var prevStyle = baseStyle;\n var start = segments[0].start;\n var i = start;\n function addStyle(s, e, l, st) {\n var dir = spanGaps ? -1 : 1;\n if (s === e) {\n return;\n }\n s += count;\n while (points[s % count].skip) {\n s -= dir;\n }\n while (points[e % count].skip) {\n e += dir;\n }\n if (s % count !== e % count) {\n result.push({\n start: s % count,\n end: e % count,\n loop: l,\n style: st\n });\n prevStyle = st;\n start = e % count;\n }\n }\n var _iterator11 = _createForOfIteratorHelper$1(segments),\n _step11;\n try {\n for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {\n var segment = _step11.value;\n start = spanGaps ? start : segment.start;\n var prev = points[start % count];\n var style = void 0;\n for (i = start + 1; i <= segment.end; i++) {\n var pt = points[i % count];\n style = readStyle(segmentOptions.setContext(createContext(chartContext, {\n type: 'segment',\n p0: prev,\n p1: pt,\n p0DataIndex: (i - 1) % count,\n p1DataIndex: i % count,\n datasetIndex: datasetIndex\n })));\n if (styleChanged(style, prevStyle)) {\n addStyle(start, i - 1, segment.loop, prevStyle);\n }\n prev = pt;\n prevStyle = style;\n }\n if (start < i - 1) {\n addStyle(start, i - 1, segment.loop, prevStyle);\n }\n }\n } catch (err) {\n _iterator11.e(err);\n } finally {\n _iterator11.f();\n }\n return result;\n }\n function readStyle(options) {\n return {\n backgroundColor: options.backgroundColor,\n borderCapStyle: options.borderCapStyle,\n borderDash: options.borderDash,\n borderDashOffset: options.borderDashOffset,\n borderJoinStyle: options.borderJoinStyle,\n borderWidth: options.borderWidth,\n borderColor: options.borderColor\n };\n }\n function styleChanged(style, prevStyle) {\n if (!prevStyle) {\n return false;\n }\n var cache = [];\n var replacer = function replacer(key, value) {\n if (!isPatternOrGradient(value)) {\n return value;\n }\n if (!cache.includes(value)) {\n cache.push(value);\n }\n return cache.indexOf(value);\n };\n return JSON.stringify(style, replacer) !== JSON.stringify(prevStyle, replacer);\n }\n\n var Animator = /*#__PURE__*/function () {\n function Animator() {\n _classCallCheck$1(this, Animator);\n this._request = null;\n this._charts = new Map();\n this._running = false;\n this._lastDate = undefined;\n }\n _createClass$1(Animator, [{\n key: \"_notify\",\n value: function _notify(chart, anims, date, type) {\n var callbacks = anims.listeners[type];\n var numSteps = anims.duration;\n callbacks.forEach(function (fn) {\n return fn({\n chart: chart,\n initial: anims.initial,\n numSteps: numSteps,\n currentStep: Math.min(date - anims.start, numSteps)\n });\n });\n }\n }, {\n key: \"_refresh\",\n value: function _refresh() {\n var _this = this;\n if (this._request) {\n return;\n }\n this._running = true;\n this._request = requestAnimFrame.call(window, function () {\n _this._update();\n _this._request = null;\n if (_this._running) {\n _this._refresh();\n }\n });\n }\n }, {\n key: \"_update\",\n value: function _update() {\n var _this2 = this;\n var date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Date.now();\n var remaining = 0;\n this._charts.forEach(function (anims, chart) {\n if (!anims.running || !anims.items.length) {\n return;\n }\n var items = anims.items;\n var i = items.length - 1;\n var draw = false;\n var item;\n for (; i >= 0; --i) {\n item = items[i];\n if (item._active) {\n if (item._total > anims.duration) {\n anims.duration = item._total;\n }\n item.tick(date);\n draw = true;\n } else {\n items[i] = items[items.length - 1];\n items.pop();\n }\n }\n if (draw) {\n chart.draw();\n _this2._notify(chart, anims, date, 'progress');\n }\n if (!items.length) {\n anims.running = false;\n _this2._notify(chart, anims, date, 'complete');\n anims.initial = false;\n }\n remaining += items.length;\n });\n this._lastDate = date;\n if (remaining === 0) {\n this._running = false;\n }\n }\n }, {\n key: \"_getAnims\",\n value: function _getAnims(chart) {\n var charts = this._charts;\n var anims = charts.get(chart);\n if (!anims) {\n anims = {\n running: false,\n initial: true,\n items: [],\n listeners: {\n complete: [],\n progress: []\n }\n };\n charts.set(chart, anims);\n }\n return anims;\n }\n }, {\n key: \"listen\",\n value: function listen(chart, event, cb) {\n this._getAnims(chart).listeners[event].push(cb);\n }\n }, {\n key: \"add\",\n value: function add(chart, items) {\n var _this$_getAnims$items;\n if (!items || !items.length) {\n return;\n }\n (_this$_getAnims$items = this._getAnims(chart).items).push.apply(_this$_getAnims$items, _toConsumableArray(items));\n }\n }, {\n key: \"has\",\n value: function has(chart) {\n return this._getAnims(chart).items.length > 0;\n }\n }, {\n key: \"start\",\n value: function start(chart) {\n var anims = this._charts.get(chart);\n if (!anims) {\n return;\n }\n anims.running = true;\n anims.start = Date.now();\n anims.duration = anims.items.reduce(function (acc, cur) {\n return Math.max(acc, cur._duration);\n }, 0);\n this._refresh();\n }\n }, {\n key: \"running\",\n value: function running(chart) {\n if (!this._running) {\n return false;\n }\n var anims = this._charts.get(chart);\n if (!anims || !anims.running || !anims.items.length) {\n return false;\n }\n return true;\n }\n }, {\n key: \"stop\",\n value: function stop(chart) {\n var anims = this._charts.get(chart);\n if (!anims || !anims.items.length) {\n return;\n }\n var items = anims.items;\n var i = items.length - 1;\n for (; i >= 0; --i) {\n items[i].cancel();\n }\n anims.items = [];\n this._notify(chart, anims, Date.now(), 'complete');\n }\n }, {\n key: \"remove\",\n value: function remove(chart) {\n return this._charts[\"delete\"](chart);\n }\n }]);\n return Animator;\n }();\n var animator = /* #__PURE__ */new Animator();\n var transparent = 'transparent';\n var interpolators = {\n \"boolean\": function boolean(from, to, factor) {\n return factor > 0.5 ? to : from;\n },\n color: function color$1(from, to, factor) {\n var c0 = color(from || transparent);\n var c1 = c0.valid && color(to || transparent);\n return c1 && c1.valid ? c1.mix(c0, factor).hexString() : to;\n },\n number: function number(from, to, factor) {\n return from + (to - from) * factor;\n }\n };\n var Animation = /*#__PURE__*/function () {\n function Animation(cfg, target, prop, to) {\n _classCallCheck$1(this, Animation);\n var currentValue = target[prop];\n to = resolve([cfg.to, to, currentValue, cfg.from]);\n var from = resolve([cfg.from, currentValue, to]);\n this._active = true;\n this._fn = cfg.fn || interpolators[cfg.type || _typeof$1(from)];\n this._easing = effects[cfg.easing] || effects.linear;\n this._start = Math.floor(Date.now() + (cfg.delay || 0));\n this._duration = this._total = Math.floor(cfg.duration);\n this._loop = !!cfg.loop;\n this._target = target;\n this._prop = prop;\n this._from = from;\n this._to = to;\n this._promises = undefined;\n }\n _createClass$1(Animation, [{\n key: \"active\",\n value: function active() {\n return this._active;\n }\n }, {\n key: \"update\",\n value: function update(cfg, to, date) {\n if (this._active) {\n this._notify(false);\n var currentValue = this._target[this._prop];\n var elapsed = date - this._start;\n var remain = this._duration - elapsed;\n this._start = date;\n this._duration = Math.floor(Math.max(remain, cfg.duration));\n this._total += elapsed;\n this._loop = !!cfg.loop;\n this._to = resolve([cfg.to, to, currentValue, cfg.from]);\n this._from = resolve([cfg.from, currentValue, to]);\n }\n }\n }, {\n key: \"cancel\",\n value: function cancel() {\n if (this._active) {\n this.tick(Date.now());\n this._active = false;\n this._notify(false);\n }\n }\n }, {\n key: \"tick\",\n value: function tick(date) {\n var elapsed = date - this._start;\n var duration = this._duration;\n var prop = this._prop;\n var from = this._from;\n var loop = this._loop;\n var to = this._to;\n var factor;\n this._active = from !== to && (loop || elapsed < duration);\n if (!this._active) {\n this._target[prop] = to;\n this._notify(true);\n return;\n }\n if (elapsed < 0) {\n this._target[prop] = from;\n return;\n }\n factor = elapsed / duration % 2;\n factor = loop && factor > 1 ? 2 - factor : factor;\n factor = this._easing(Math.min(1, Math.max(0, factor)));\n this._target[prop] = this._fn(from, to, factor);\n }\n }, {\n key: \"wait\",\n value: function wait() {\n var promises = this._promises || (this._promises = []);\n return new Promise(function (res, rej) {\n promises.push({\n res: res,\n rej: rej\n });\n });\n }\n }, {\n key: \"_notify\",\n value: function _notify(resolved) {\n var method = resolved ? 'res' : 'rej';\n var promises = this._promises || [];\n for (var i = 0; i < promises.length; i++) {\n promises[i][method]();\n }\n }\n }]);\n return Animation;\n }();\n var Animations = /*#__PURE__*/function () {\n function Animations(chart, config) {\n _classCallCheck$1(this, Animations);\n this._chart = chart;\n this._properties = new Map();\n this.configure(config);\n }\n _createClass$1(Animations, [{\n key: \"configure\",\n value: function configure(config) {\n if (!isObject(config)) {\n return;\n }\n var animationOptions = Object.keys(defaults.animation);\n var animatedProps = this._properties;\n Object.getOwnPropertyNames(config).forEach(function (key) {\n var cfg = config[key];\n if (!isObject(cfg)) {\n return;\n }\n var resolved = {};\n for (var _i = 0, _animationOptions = animationOptions; _i < _animationOptions.length; _i++) {\n var option = _animationOptions[_i];\n resolved[option] = cfg[option];\n }\n (isArray(cfg.properties) && cfg.properties || [key]).forEach(function (prop) {\n if (prop === key || !animatedProps.has(prop)) {\n animatedProps.set(prop, resolved);\n }\n });\n });\n }\n }, {\n key: \"_animateOptions\",\n value: function _animateOptions(target, values) {\n var newOptions = values.options;\n var options = resolveTargetOptions(target, newOptions);\n if (!options) {\n return [];\n }\n var animations = this._createAnimations(options, newOptions);\n if (newOptions.$shared) {\n awaitAll(target.options.$animations, newOptions).then(function () {\n target.options = newOptions;\n }, function () {});\n }\n return animations;\n }\n }, {\n key: \"_createAnimations\",\n value: function _createAnimations(target, values) {\n var animatedProps = this._properties;\n var animations = [];\n var running = target.$animations || (target.$animations = {});\n var props = Object.keys(values);\n var date = Date.now();\n var i;\n for (i = props.length - 1; i >= 0; --i) {\n var prop = props[i];\n if (prop.charAt(0) === '$') {\n continue;\n }\n if (prop === 'options') {\n animations.push.apply(animations, _toConsumableArray(this._animateOptions(target, values)));\n continue;\n }\n var value = values[prop];\n var animation = running[prop];\n var cfg = animatedProps.get(prop);\n if (animation) {\n if (cfg && animation.active()) {\n animation.update(cfg, value, date);\n continue;\n } else {\n animation.cancel();\n }\n }\n if (!cfg || !cfg.duration) {\n target[prop] = value;\n continue;\n }\n running[prop] = animation = new Animation(cfg, target, prop, value);\n animations.push(animation);\n }\n return animations;\n }\n }, {\n key: \"update\",\n value: function update(target, values) {\n if (this._properties.size === 0) {\n Object.assign(target, values);\n return;\n }\n var animations = this._createAnimations(target, values);\n if (animations.length) {\n animator.add(this._chart, animations);\n return true;\n }\n }\n }]);\n return Animations;\n }();\n function awaitAll(animations, properties) {\n var running = [];\n var keys = Object.keys(properties);\n for (var i = 0; i < keys.length; i++) {\n var anim = animations[keys[i]];\n if (anim && anim.active()) {\n running.push(anim.wait());\n }\n }\n return Promise.all(running);\n }\n function resolveTargetOptions(target, newOptions) {\n if (!newOptions) {\n return;\n }\n var options = target.options;\n if (!options) {\n target.options = newOptions;\n return;\n }\n if (options.$shared) {\n target.options = options = Object.assign({}, options, {\n $shared: false,\n $animations: {}\n });\n }\n return options;\n }\n function scaleClip(scale, allowedOverflow) {\n var opts = scale && scale.options || {};\n var reverse = opts.reverse;\n var min = opts.min === undefined ? allowedOverflow : 0;\n var max = opts.max === undefined ? allowedOverflow : 0;\n return {\n start: reverse ? max : min,\n end: reverse ? min : max\n };\n }\n function defaultClip(xScale, yScale, allowedOverflow) {\n if (allowedOverflow === false) {\n return false;\n }\n var x = scaleClip(xScale, allowedOverflow);\n var y = scaleClip(yScale, allowedOverflow);\n return {\n top: y.end,\n right: x.end,\n bottom: y.start,\n left: x.start\n };\n }\n function toClip(value) {\n var t, r, b, l;\n if (isObject(value)) {\n t = value.top;\n r = value.right;\n b = value.bottom;\n l = value.left;\n } else {\n t = r = b = l = value;\n }\n return {\n top: t,\n right: r,\n bottom: b,\n left: l,\n disabled: value === false\n };\n }\n function getSortedDatasetIndices(chart, filterVisible) {\n var keys = [];\n var metasets = chart._getSortedDatasetMetas(filterVisible);\n var i, ilen;\n for (i = 0, ilen = metasets.length; i < ilen; ++i) {\n keys.push(metasets[i].index);\n }\n return keys;\n }\n function _applyStack(stack, value, dsIndex) {\n var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};\n var keys = stack.keys;\n var singleMode = options.mode === 'single';\n var i, ilen, datasetIndex, otherValue;\n if (value === null) {\n return;\n }\n for (i = 0, ilen = keys.length; i < ilen; ++i) {\n datasetIndex = +keys[i];\n if (datasetIndex === dsIndex) {\n if (options.all) {\n continue;\n }\n break;\n }\n otherValue = stack.values[datasetIndex];\n if (isNumberFinite(otherValue) && (singleMode || value === 0 || sign(value) === sign(otherValue))) {\n value += otherValue;\n }\n }\n return value;\n }\n function convertObjectDataToArray(data) {\n var keys = Object.keys(data);\n var adata = new Array(keys.length);\n var i, ilen, key;\n for (i = 0, ilen = keys.length; i < ilen; ++i) {\n key = keys[i];\n adata[i] = {\n x: key,\n y: data[key]\n };\n }\n return adata;\n }\n function isStacked(scale, meta) {\n var stacked = scale && scale.options.stacked;\n return stacked || stacked === undefined && meta.stack !== undefined;\n }\n function getStackKey(indexScale, valueScale, meta) {\n return \"\".concat(indexScale.id, \".\").concat(valueScale.id, \".\").concat(meta.stack || meta.type);\n }\n function getUserBounds(scale) {\n var _scale$getUserBounds = scale.getUserBounds(),\n min = _scale$getUserBounds.min,\n max = _scale$getUserBounds.max,\n minDefined = _scale$getUserBounds.minDefined,\n maxDefined = _scale$getUserBounds.maxDefined;\n return {\n min: minDefined ? min : Number.NEGATIVE_INFINITY,\n max: maxDefined ? max : Number.POSITIVE_INFINITY\n };\n }\n function getOrCreateStack(stacks, stackKey, indexValue) {\n var subStack = stacks[stackKey] || (stacks[stackKey] = {});\n return subStack[indexValue] || (subStack[indexValue] = {});\n }\n function getLastIndexInStack(stack, vScale, positive, type) {\n var _iterator = _createForOfIteratorHelper$1(vScale.getMatchingVisibleMetas(type).reverse()),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var meta = _step.value;\n var value = stack[meta.index];\n if (positive && value > 0 || !positive && value < 0) {\n return meta.index;\n }\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n return null;\n }\n function updateStacks(controller, parsed) {\n var chart = controller.chart,\n meta = controller._cachedMeta;\n var stacks = chart._stacks || (chart._stacks = {});\n var iScale = meta.iScale,\n vScale = meta.vScale,\n datasetIndex = meta.index;\n var iAxis = iScale.axis;\n var vAxis = vScale.axis;\n var key = getStackKey(iScale, vScale, meta);\n var ilen = parsed.length;\n var stack;\n for (var i = 0; i < ilen; ++i) {\n var item = parsed[i];\n var _index = item[iAxis],\n value = item[vAxis];\n var itemStacks = item._stacks || (item._stacks = {});\n stack = itemStacks[vAxis] = getOrCreateStack(stacks, key, _index);\n stack[datasetIndex] = value;\n stack._top = getLastIndexInStack(stack, vScale, true, meta.type);\n stack._bottom = getLastIndexInStack(stack, vScale, false, meta.type);\n var visualValues = stack._visualValues || (stack._visualValues = {});\n visualValues[datasetIndex] = value;\n }\n }\n function getFirstScaleId(chart, axis) {\n var scales = chart.scales;\n return Object.keys(scales).filter(function (key) {\n return scales[key].axis === axis;\n }).shift();\n }\n function createDatasetContext(parent, index) {\n return createContext(parent, {\n active: false,\n dataset: undefined,\n datasetIndex: index,\n index: index,\n mode: 'default',\n type: 'dataset'\n });\n }\n function createDataContext(parent, index, element) {\n return createContext(parent, {\n active: false,\n dataIndex: index,\n parsed: undefined,\n raw: undefined,\n element: element,\n index: index,\n mode: 'default',\n type: 'data'\n });\n }\n function clearStacks(meta, items) {\n var datasetIndex = meta.controller.index;\n var axis = meta.vScale && meta.vScale.axis;\n if (!axis) {\n return;\n }\n items = items || meta._parsed;\n var _iterator2 = _createForOfIteratorHelper$1(items),\n _step2;\n try {\n for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n var parsed = _step2.value;\n var stacks = parsed._stacks;\n if (!stacks || stacks[axis] === undefined || stacks[axis][datasetIndex] === undefined) {\n return;\n }\n delete stacks[axis][datasetIndex];\n if (stacks[axis]._visualValues !== undefined && stacks[axis]._visualValues[datasetIndex] !== undefined) {\n delete stacks[axis]._visualValues[datasetIndex];\n }\n }\n } catch (err) {\n _iterator2.e(err);\n } finally {\n _iterator2.f();\n }\n }\n var isDirectUpdateMode = function isDirectUpdateMode(mode) {\n return mode === 'reset' || mode === 'none';\n };\n var cloneIfNotShared = function cloneIfNotShared(cached, shared) {\n return shared ? cached : Object.assign({}, cached);\n };\n var createStack = function createStack(canStack, meta, chart) {\n return canStack && !meta.hidden && meta._stacked && {\n keys: getSortedDatasetIndices(chart, true),\n values: null\n };\n };\n var DatasetController = /*#__PURE__*/function () {\n function DatasetController(chart, datasetIndex) {\n _classCallCheck$1(this, DatasetController);\n this.chart = chart;\n this._ctx = chart.ctx;\n this.index = datasetIndex;\n this._cachedDataOpts = {};\n this._cachedMeta = this.getMeta();\n this._type = this._cachedMeta.type;\n this.options = undefined;\n this._parsing = false;\n this._data = undefined;\n this._objectData = undefined;\n this._sharedOptions = undefined;\n this._drawStart = undefined;\n this._drawCount = undefined;\n this.enableOptionSharing = false;\n this.supportsDecimation = false;\n this.$context = undefined;\n this._syncList = [];\n this.datasetElementType = (this instanceof DatasetController ? this.constructor : void 0).datasetElementType;\n this.dataElementType = (this instanceof DatasetController ? this.constructor : void 0).dataElementType;\n this.initialize();\n }\n _createClass$1(DatasetController, [{\n key: \"initialize\",\n value: function initialize() {\n var meta = this._cachedMeta;\n this.configure();\n this.linkScales();\n meta._stacked = isStacked(meta.vScale, meta);\n this.addElements();\n if (this.options.fill && !this.chart.isPluginEnabled('filler')) {\n console.warn(\"Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options\");\n }\n }\n }, {\n key: \"updateIndex\",\n value: function updateIndex(datasetIndex) {\n if (this.index !== datasetIndex) {\n clearStacks(this._cachedMeta);\n }\n this.index = datasetIndex;\n }\n }, {\n key: \"linkScales\",\n value: function linkScales() {\n var chart = this.chart;\n var meta = this._cachedMeta;\n var dataset = this.getDataset();\n var chooseId = function chooseId(axis, x, y, r) {\n return axis === 'x' ? x : axis === 'r' ? r : y;\n };\n var xid = meta.xAxisID = valueOrDefault(dataset.xAxisID, getFirstScaleId(chart, 'x'));\n var yid = meta.yAxisID = valueOrDefault(dataset.yAxisID, getFirstScaleId(chart, 'y'));\n var rid = meta.rAxisID = valueOrDefault(dataset.rAxisID, getFirstScaleId(chart, 'r'));\n var indexAxis = meta.indexAxis;\n var iid = meta.iAxisID = chooseId(indexAxis, xid, yid, rid);\n var vid = meta.vAxisID = chooseId(indexAxis, yid, xid, rid);\n meta.xScale = this.getScaleForId(xid);\n meta.yScale = this.getScaleForId(yid);\n meta.rScale = this.getScaleForId(rid);\n meta.iScale = this.getScaleForId(iid);\n meta.vScale = this.getScaleForId(vid);\n }\n }, {\n key: \"getDataset\",\n value: function getDataset() {\n return this.chart.data.datasets[this.index];\n }\n }, {\n key: \"getMeta\",\n value: function getMeta() {\n return this.chart.getDatasetMeta(this.index);\n }\n }, {\n key: \"getScaleForId\",\n value: function getScaleForId(scaleID) {\n return this.chart.scales[scaleID];\n }\n }, {\n key: \"_getOtherScale\",\n value: function _getOtherScale(scale) {\n var meta = this._cachedMeta;\n return scale === meta.iScale ? meta.vScale : meta.iScale;\n }\n }, {\n key: \"reset\",\n value: function reset() {\n this._update('reset');\n }\n }, {\n key: \"_destroy\",\n value: function _destroy() {\n var meta = this._cachedMeta;\n if (this._data) {\n unlistenArrayEvents(this._data, this);\n }\n if (meta._stacked) {\n clearStacks(meta);\n }\n }\n }, {\n key: \"_dataCheck\",\n value: function _dataCheck() {\n var dataset = this.getDataset();\n var data = dataset.data || (dataset.data = []);\n var _data = this._data;\n if (isObject(data)) {\n this._data = convertObjectDataToArray(data);\n } else if (_data !== data) {\n if (_data) {\n unlistenArrayEvents(_data, this);\n var meta = this._cachedMeta;\n clearStacks(meta);\n meta._parsed = [];\n }\n if (data && Object.isExtensible(data)) {\n listenArrayEvents(data, this);\n }\n this._syncList = [];\n this._data = data;\n }\n }\n }, {\n key: \"addElements\",\n value: function addElements() {\n var meta = this._cachedMeta;\n this._dataCheck();\n if (this.datasetElementType) {\n meta.dataset = new this.datasetElementType();\n }\n }\n }, {\n key: \"buildOrUpdateElements\",\n value: function buildOrUpdateElements(resetNewElements) {\n var meta = this._cachedMeta;\n var dataset = this.getDataset();\n var stackChanged = false;\n this._dataCheck();\n var oldStacked = meta._stacked;\n meta._stacked = isStacked(meta.vScale, meta);\n if (meta.stack !== dataset.stack) {\n stackChanged = true;\n clearStacks(meta);\n meta.stack = dataset.stack;\n }\n this._resyncElements(resetNewElements);\n if (stackChanged || oldStacked !== meta._stacked) {\n updateStacks(this, meta._parsed);\n }\n }\n }, {\n key: \"configure\",\n value: function configure() {\n var config = this.chart.config;\n var scopeKeys = config.datasetScopeKeys(this._type);\n var scopes = config.getOptionScopes(this.getDataset(), scopeKeys, true);\n this.options = config.createResolver(scopes, this.getContext());\n this._parsing = this.options.parsing;\n this._cachedDataOpts = {};\n }\n }, {\n key: \"parse\",\n value: function parse(start, count) {\n var meta = this._cachedMeta,\n data = this._data;\n var iScale = meta.iScale,\n _stacked = meta._stacked;\n var iAxis = iScale.axis;\n var sorted = start === 0 && count === data.length ? true : meta._sorted;\n var prev = start > 0 && meta._parsed[start - 1];\n var i, cur, parsed;\n if (this._parsing === false) {\n meta._parsed = data;\n meta._sorted = true;\n parsed = data;\n } else {\n if (isArray(data[start])) {\n parsed = this.parseArrayData(meta, data, start, count);\n } else if (isObject(data[start])) {\n parsed = this.parseObjectData(meta, data, start, count);\n } else {\n parsed = this.parsePrimitiveData(meta, data, start, count);\n }\n var isNotInOrderComparedToPrev = function isNotInOrderComparedToPrev() {\n return cur[iAxis] === null || prev && cur[iAxis] < prev[iAxis];\n };\n for (i = 0; i < count; ++i) {\n meta._parsed[i + start] = cur = parsed[i];\n if (sorted) {\n if (isNotInOrderComparedToPrev()) {\n sorted = false;\n }\n prev = cur;\n }\n }\n meta._sorted = sorted;\n }\n if (_stacked) {\n updateStacks(this, parsed);\n }\n }\n }, {\n key: \"parsePrimitiveData\",\n value: function parsePrimitiveData(meta, data, start, count) {\n var iScale = meta.iScale,\n vScale = meta.vScale;\n var iAxis = iScale.axis;\n var vAxis = vScale.axis;\n var labels = iScale.getLabels();\n var singleScale = iScale === vScale;\n var parsed = new Array(count);\n var i, ilen, index;\n for (i = 0, ilen = count; i < ilen; ++i) {\n var _parsed$i;\n index = i + start;\n parsed[i] = (_parsed$i = {}, _defineProperty$1(_parsed$i, iAxis, singleScale || iScale.parse(labels[index], index)), _defineProperty$1(_parsed$i, vAxis, vScale.parse(data[index], index)), _parsed$i);\n }\n return parsed;\n }\n }, {\n key: \"parseArrayData\",\n value: function parseArrayData(meta, data, start, count) {\n var xScale = meta.xScale,\n yScale = meta.yScale;\n var parsed = new Array(count);\n var i, ilen, index, item;\n for (i = 0, ilen = count; i < ilen; ++i) {\n index = i + start;\n item = data[index];\n parsed[i] = {\n x: xScale.parse(item[0], index),\n y: yScale.parse(item[1], index)\n };\n }\n return parsed;\n }\n }, {\n key: \"parseObjectData\",\n value: function parseObjectData(meta, data, start, count) {\n var xScale = meta.xScale,\n yScale = meta.yScale;\n var _this$_parsing = this._parsing,\n _this$_parsing$xAxisK = _this$_parsing.xAxisKey,\n xAxisKey = _this$_parsing$xAxisK === void 0 ? 'x' : _this$_parsing$xAxisK,\n _this$_parsing$yAxisK = _this$_parsing.yAxisKey,\n yAxisKey = _this$_parsing$yAxisK === void 0 ? 'y' : _this$_parsing$yAxisK;\n var parsed = new Array(count);\n var i, ilen, index, item;\n for (i = 0, ilen = count; i < ilen; ++i) {\n index = i + start;\n item = data[index];\n parsed[i] = {\n x: xScale.parse(resolveObjectKey(item, xAxisKey), index),\n y: yScale.parse(resolveObjectKey(item, yAxisKey), index)\n };\n }\n return parsed;\n }\n }, {\n key: \"getParsed\",\n value: function getParsed(index) {\n return this._cachedMeta._parsed[index];\n }\n }, {\n key: \"getDataElement\",\n value: function getDataElement(index) {\n return this._cachedMeta.data[index];\n }\n }, {\n key: \"applyStack\",\n value: function applyStack(scale, parsed, mode) {\n var chart = this.chart;\n var meta = this._cachedMeta;\n var value = parsed[scale.axis];\n var stack = {\n keys: getSortedDatasetIndices(chart, true),\n values: parsed._stacks[scale.axis]._visualValues\n };\n return _applyStack(stack, value, meta.index, {\n mode: mode\n });\n }\n }, {\n key: \"updateRangeFromParsed\",\n value: function updateRangeFromParsed(range, scale, parsed, stack) {\n var parsedValue = parsed[scale.axis];\n var value = parsedValue === null ? NaN : parsedValue;\n var values = stack && parsed._stacks[scale.axis];\n if (stack && values) {\n stack.values = values;\n value = _applyStack(stack, parsedValue, this._cachedMeta.index);\n }\n range.min = Math.min(range.min, value);\n range.max = Math.max(range.max, value);\n }\n }, {\n key: \"getMinMax\",\n value: function getMinMax(scale, canStack) {\n var meta = this._cachedMeta;\n var _parsed = meta._parsed;\n var sorted = meta._sorted && scale === meta.iScale;\n var ilen = _parsed.length;\n var otherScale = this._getOtherScale(scale);\n var stack = createStack(canStack, meta, this.chart);\n var range = {\n min: Number.POSITIVE_INFINITY,\n max: Number.NEGATIVE_INFINITY\n };\n var _getUserBounds = getUserBounds(otherScale),\n otherMin = _getUserBounds.min,\n otherMax = _getUserBounds.max;\n var i, parsed;\n function _skip() {\n parsed = _parsed[i];\n var otherValue = parsed[otherScale.axis];\n return !isNumberFinite(parsed[scale.axis]) || otherMin > otherValue || otherMax < otherValue;\n }\n for (i = 0; i < ilen; ++i) {\n if (_skip()) {\n continue;\n }\n this.updateRangeFromParsed(range, scale, parsed, stack);\n if (sorted) {\n break;\n }\n }\n if (sorted) {\n for (i = ilen - 1; i >= 0; --i) {\n if (_skip()) {\n continue;\n }\n this.updateRangeFromParsed(range, scale, parsed, stack);\n break;\n }\n }\n return range;\n }\n }, {\n key: \"getAllParsedValues\",\n value: function getAllParsedValues(scale) {\n var parsed = this._cachedMeta._parsed;\n var values = [];\n var i, ilen, value;\n for (i = 0, ilen = parsed.length; i < ilen; ++i) {\n value = parsed[i][scale.axis];\n if (isNumberFinite(value)) {\n values.push(value);\n }\n }\n return values;\n }\n }, {\n key: \"getMaxOverflow\",\n value: function getMaxOverflow() {\n return false;\n }\n }, {\n key: \"getLabelAndValue\",\n value: function getLabelAndValue(index) {\n var meta = this._cachedMeta;\n var iScale = meta.iScale;\n var vScale = meta.vScale;\n var parsed = this.getParsed(index);\n return {\n label: iScale ? '' + iScale.getLabelForValue(parsed[iScale.axis]) : '',\n value: vScale ? '' + vScale.getLabelForValue(parsed[vScale.axis]) : ''\n };\n }\n }, {\n key: \"_update\",\n value: function _update(mode) {\n var meta = this._cachedMeta;\n this.update(mode || 'default');\n meta._clip = toClip(valueOrDefault(this.options.clip, defaultClip(meta.xScale, meta.yScale, this.getMaxOverflow())));\n }\n }, {\n key: \"update\",\n value: function update(mode) {}\n }, {\n key: \"draw\",\n value: function draw() {\n var ctx = this._ctx;\n var chart = this.chart;\n var meta = this._cachedMeta;\n var elements = meta.data || [];\n var area = chart.chartArea;\n var active = [];\n var start = this._drawStart || 0;\n var count = this._drawCount || elements.length - start;\n var drawActiveElementsOnTop = this.options.drawActiveElementsOnTop;\n var i;\n if (meta.dataset) {\n meta.dataset.draw(ctx, area, start, count);\n }\n for (i = start; i < start + count; ++i) {\n var element = elements[i];\n if (element.hidden) {\n continue;\n }\n if (element.active && drawActiveElementsOnTop) {\n active.push(element);\n } else {\n element.draw(ctx, area);\n }\n }\n for (i = 0; i < active.length; ++i) {\n active[i].draw(ctx, area);\n }\n }\n }, {\n key: \"getStyle\",\n value: function getStyle(index, active) {\n var mode = active ? 'active' : 'default';\n return index === undefined && this._cachedMeta.dataset ? this.resolveDatasetElementOptions(mode) : this.resolveDataElementOptions(index || 0, mode);\n }\n }, {\n key: \"getContext\",\n value: function getContext(index, active, mode) {\n var dataset = this.getDataset();\n var context;\n if (index >= 0 && index < this._cachedMeta.data.length) {\n var element = this._cachedMeta.data[index];\n context = element.$context || (element.$context = createDataContext(this.getContext(), index, element));\n context.parsed = this.getParsed(index);\n context.raw = dataset.data[index];\n context.index = context.dataIndex = index;\n } else {\n context = this.$context || (this.$context = createDatasetContext(this.chart.getContext(), this.index));\n context.dataset = dataset;\n context.index = context.datasetIndex = this.index;\n }\n context.active = !!active;\n context.mode = mode;\n return context;\n }\n }, {\n key: \"resolveDatasetElementOptions\",\n value: function resolveDatasetElementOptions(mode) {\n return this._resolveElementOptions(this.datasetElementType.id, mode);\n }\n }, {\n key: \"resolveDataElementOptions\",\n value: function resolveDataElementOptions(index, mode) {\n return this._resolveElementOptions(this.dataElementType.id, mode, index);\n }\n }, {\n key: \"_resolveElementOptions\",\n value: function _resolveElementOptions(elementType) {\n var _this3 = this;\n var mode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';\n var index = arguments.length > 2 ? arguments[2] : undefined;\n var active = mode === 'active';\n var cache = this._cachedDataOpts;\n var cacheKey = elementType + '-' + mode;\n var cached = cache[cacheKey];\n var sharing = this.enableOptionSharing && defined(index);\n if (cached) {\n return cloneIfNotShared(cached, sharing);\n }\n var config = this.chart.config;\n var scopeKeys = config.datasetElementScopeKeys(this._type, elementType);\n var prefixes = active ? [\"\".concat(elementType, \"Hover\"), 'hover', elementType, ''] : [elementType, ''];\n var scopes = config.getOptionScopes(this.getDataset(), scopeKeys);\n var names = Object.keys(defaults.elements[elementType]);\n var context = function context() {\n return _this3.getContext(index, active, mode);\n };\n var values = config.resolveNamedOptions(scopes, names, context, prefixes);\n if (values.$shared) {\n values.$shared = sharing;\n cache[cacheKey] = Object.freeze(cloneIfNotShared(values, sharing));\n }\n return values;\n }\n }, {\n key: \"_resolveAnimations\",\n value: function _resolveAnimations(index, transition, active) {\n var chart = this.chart;\n var cache = this._cachedDataOpts;\n var cacheKey = \"animation-\".concat(transition);\n var cached = cache[cacheKey];\n if (cached) {\n return cached;\n }\n var options;\n if (chart.options.animation !== false) {\n var config = this.chart.config;\n var scopeKeys = config.datasetAnimationScopeKeys(this._type, transition);\n var scopes = config.getOptionScopes(this.getDataset(), scopeKeys);\n options = config.createResolver(scopes, this.getContext(index, active, transition));\n }\n var animations = new Animations(chart, options && options.animations);\n if (options && options._cacheable) {\n cache[cacheKey] = Object.freeze(animations);\n }\n return animations;\n }\n }, {\n key: \"getSharedOptions\",\n value: function getSharedOptions(options) {\n if (!options.$shared) {\n return;\n }\n return this._sharedOptions || (this._sharedOptions = Object.assign({}, options));\n }\n }, {\n key: \"includeOptions\",\n value: function includeOptions(mode, sharedOptions) {\n return !sharedOptions || isDirectUpdateMode(mode) || this.chart._animationsDisabled;\n }\n }, {\n key: \"_getSharedOptions\",\n value: function _getSharedOptions(start, mode) {\n var firstOpts = this.resolveDataElementOptions(start, mode);\n var previouslySharedOptions = this._sharedOptions;\n var sharedOptions = this.getSharedOptions(firstOpts);\n var includeOptions = this.includeOptions(mode, sharedOptions) || sharedOptions !== previouslySharedOptions;\n this.updateSharedOptions(sharedOptions, mode, firstOpts);\n return {\n sharedOptions: sharedOptions,\n includeOptions: includeOptions\n };\n }\n }, {\n key: \"updateElement\",\n value: function updateElement(element, index, properties, mode) {\n if (isDirectUpdateMode(mode)) {\n Object.assign(element, properties);\n } else {\n this._resolveAnimations(index, mode).update(element, properties);\n }\n }\n }, {\n key: \"updateSharedOptions\",\n value: function updateSharedOptions(sharedOptions, mode, newOptions) {\n if (sharedOptions && !isDirectUpdateMode(mode)) {\n this._resolveAnimations(undefined, mode).update(sharedOptions, newOptions);\n }\n }\n }, {\n key: \"_setStyle\",\n value: function _setStyle(element, index, mode, active) {\n element.active = active;\n var options = this.getStyle(index, active);\n this._resolveAnimations(index, mode, active).update(element, {\n options: !active && this.getSharedOptions(options) || options\n });\n }\n }, {\n key: \"removeHoverStyle\",\n value: function removeHoverStyle(element, datasetIndex, index) {\n this._setStyle(element, index, 'active', false);\n }\n }, {\n key: \"setHoverStyle\",\n value: function setHoverStyle(element, datasetIndex, index) {\n this._setStyle(element, index, 'active', true);\n }\n }, {\n key: \"_removeDatasetHoverStyle\",\n value: function _removeDatasetHoverStyle() {\n var element = this._cachedMeta.dataset;\n if (element) {\n this._setStyle(element, undefined, 'active', false);\n }\n }\n }, {\n key: \"_setDatasetHoverStyle\",\n value: function _setDatasetHoverStyle() {\n var element = this._cachedMeta.dataset;\n if (element) {\n this._setStyle(element, undefined, 'active', true);\n }\n }\n }, {\n key: \"_resyncElements\",\n value: function _resyncElements(resetNewElements) {\n var data = this._data;\n var elements = this._cachedMeta.data;\n var _iterator3 = _createForOfIteratorHelper$1(this._syncList),\n _step3;\n try {\n for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {\n var _step3$value = _slicedToArray(_step3.value, 3),\n method = _step3$value[0],\n arg1 = _step3$value[1],\n arg2 = _step3$value[2];\n this[method](arg1, arg2);\n }\n } catch (err) {\n _iterator3.e(err);\n } finally {\n _iterator3.f();\n }\n this._syncList = [];\n var numMeta = elements.length;\n var numData = data.length;\n var count = Math.min(numData, numMeta);\n if (count) {\n this.parse(0, count);\n }\n if (numData > numMeta) {\n this._insertElements(numMeta, numData - numMeta, resetNewElements);\n } else if (numData < numMeta) {\n this._removeElements(numData, numMeta - numData);\n }\n }\n }, {\n key: \"_insertElements\",\n value: function _insertElements(start, count) {\n var resetNewElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;\n var meta = this._cachedMeta;\n var data = meta.data;\n var end = start + count;\n var i;\n var move = function move(arr) {\n arr.length += count;\n for (i = arr.length - 1; i >= end; i--) {\n arr[i] = arr[i - count];\n }\n };\n move(data);\n for (i = start; i < end; ++i) {\n data[i] = new this.dataElementType();\n }\n if (this._parsing) {\n move(meta._parsed);\n }\n this.parse(start, count);\n if (resetNewElements) {\n this.updateElements(data, start, count, 'reset');\n }\n }\n }, {\n key: \"updateElements\",\n value: function updateElements(element, start, count, mode) {}\n }, {\n key: \"_removeElements\",\n value: function _removeElements(start, count) {\n var meta = this._cachedMeta;\n if (this._parsing) {\n var removed = meta._parsed.splice(start, count);\n if (meta._stacked) {\n clearStacks(meta, removed);\n }\n }\n meta.data.splice(start, count);\n }\n }, {\n key: \"_sync\",\n value: function _sync(args) {\n if (this._parsing) {\n this._syncList.push(args);\n } else {\n var _args2 = _slicedToArray(args, 3),\n method = _args2[0],\n arg1 = _args2[1],\n arg2 = _args2[2];\n this[method](arg1, arg2);\n }\n this.chart._dataChanges.push([this.index].concat(_toConsumableArray(args)));\n }\n }, {\n key: \"_onDataPush\",\n value: function _onDataPush() {\n var count = arguments.length;\n this._sync(['_insertElements', this.getDataset().data.length - count, count]);\n }\n }, {\n key: \"_onDataPop\",\n value: function _onDataPop() {\n this._sync(['_removeElements', this._cachedMeta.data.length - 1, 1]);\n }\n }, {\n key: \"_onDataShift\",\n value: function _onDataShift() {\n this._sync(['_removeElements', 0, 1]);\n }\n }, {\n key: \"_onDataSplice\",\n value: function _onDataSplice(start, count) {\n if (count) {\n this._sync(['_removeElements', start, count]);\n }\n var newCount = arguments.length - 2;\n if (newCount) {\n this._sync(['_insertElements', start, newCount]);\n }\n }\n }, {\n key: \"_onDataUnshift\",\n value: function _onDataUnshift() {\n this._sync(['_insertElements', 0, arguments.length]);\n }\n }]);\n return DatasetController;\n }();\n _defineProperty$1(DatasetController, \"defaults\", {});\n _defineProperty$1(DatasetController, \"datasetElementType\", null);\n _defineProperty$1(DatasetController, \"dataElementType\", null);\n function getAllScaleValues(scale, type) {\n if (!scale._cache.$bar) {\n var visibleMetas = scale.getMatchingVisibleMetas(type);\n var values = [];\n for (var i = 0, ilen = visibleMetas.length; i < ilen; i++) {\n values = values.concat(visibleMetas[i].controller.getAllParsedValues(scale));\n }\n scale._cache.$bar = _arrayUnique(values.sort(function (a, b) {\n return a - b;\n }));\n }\n return scale._cache.$bar;\n }\n function computeMinSampleSize(meta) {\n var scale = meta.iScale;\n var values = getAllScaleValues(scale, meta.type);\n var min = scale._length;\n var i, ilen, curr, prev;\n var updateMinAndPrev = function updateMinAndPrev() {\n if (curr === 32767 || curr === -32768) {\n return;\n }\n if (defined(prev)) {\n min = Math.min(min, Math.abs(curr - prev) || min);\n }\n prev = curr;\n };\n for (i = 0, ilen = values.length; i < ilen; ++i) {\n curr = scale.getPixelForValue(values[i]);\n updateMinAndPrev();\n }\n prev = undefined;\n for (i = 0, ilen = scale.ticks.length; i < ilen; ++i) {\n curr = scale.getPixelForTick(i);\n updateMinAndPrev();\n }\n return min;\n }\n function computeFitCategoryTraits(index, ruler, options, stackCount) {\n var thickness = options.barThickness;\n var size, ratio;\n if (isNullOrUndef(thickness)) {\n size = ruler.min * options.categoryPercentage;\n ratio = options.barPercentage;\n } else {\n size = thickness * stackCount;\n ratio = 1;\n }\n return {\n chunk: size / stackCount,\n ratio: ratio,\n start: ruler.pixels[index] - size / 2\n };\n }\n function computeFlexCategoryTraits(index, ruler, options, stackCount) {\n var pixels = ruler.pixels;\n var curr = pixels[index];\n var prev = index > 0 ? pixels[index - 1] : null;\n var next = index < pixels.length - 1 ? pixels[index + 1] : null;\n var percent = options.categoryPercentage;\n if (prev === null) {\n prev = curr - (next === null ? ruler.end - ruler.start : next - curr);\n }\n if (next === null) {\n next = curr + curr - prev;\n }\n var start = curr - (curr - Math.min(prev, next)) / 2 * percent;\n var size = Math.abs(next - prev) / 2 * percent;\n return {\n chunk: size / stackCount,\n ratio: options.barPercentage,\n start: start\n };\n }\n function parseFloatBar(entry, item, vScale, i) {\n var startValue = vScale.parse(entry[0], i);\n var endValue = vScale.parse(entry[1], i);\n var min = Math.min(startValue, endValue);\n var max = Math.max(startValue, endValue);\n var barStart = min;\n var barEnd = max;\n if (Math.abs(min) > Math.abs(max)) {\n barStart = max;\n barEnd = min;\n }\n item[vScale.axis] = barEnd;\n item._custom = {\n barStart: barStart,\n barEnd: barEnd,\n start: startValue,\n end: endValue,\n min: min,\n max: max\n };\n }\n function parseValue(entry, item, vScale, i) {\n if (isArray(entry)) {\n parseFloatBar(entry, item, vScale, i);\n } else {\n item[vScale.axis] = vScale.parse(entry, i);\n }\n return item;\n }\n function parseArrayOrPrimitive(meta, data, start, count) {\n var iScale = meta.iScale;\n var vScale = meta.vScale;\n var labels = iScale.getLabels();\n var singleScale = iScale === vScale;\n var parsed = [];\n var i, ilen, item, entry;\n for (i = start, ilen = start + count; i < ilen; ++i) {\n entry = data[i];\n item = {};\n item[iScale.axis] = singleScale || iScale.parse(labels[i], i);\n parsed.push(parseValue(entry, item, vScale, i));\n }\n return parsed;\n }\n function isFloatBar(custom) {\n return custom && custom.barStart !== undefined && custom.barEnd !== undefined;\n }\n function barSign(size, vScale, actualBase) {\n if (size !== 0) {\n return sign(size);\n }\n return (vScale.isHorizontal() ? 1 : -1) * (vScale.min >= actualBase ? 1 : -1);\n }\n function borderProps(properties) {\n var reverse, start, end, top, bottom;\n if (properties.horizontal) {\n reverse = properties.base > properties.x;\n start = 'left';\n end = 'right';\n } else {\n reverse = properties.base < properties.y;\n start = 'bottom';\n end = 'top';\n }\n if (reverse) {\n top = 'end';\n bottom = 'start';\n } else {\n top = 'start';\n bottom = 'end';\n }\n return {\n start: start,\n end: end,\n reverse: reverse,\n top: top,\n bottom: bottom\n };\n }\n function setBorderSkipped(properties, options, stack, index) {\n var edge = options.borderSkipped;\n var res = {};\n if (!edge) {\n properties.borderSkipped = res;\n return;\n }\n if (edge === true) {\n properties.borderSkipped = {\n top: true,\n right: true,\n bottom: true,\n left: true\n };\n return;\n }\n var _borderProps = borderProps(properties),\n start = _borderProps.start,\n end = _borderProps.end,\n reverse = _borderProps.reverse,\n top = _borderProps.top,\n bottom = _borderProps.bottom;\n if (edge === 'middle' && stack) {\n properties.enableBorderRadius = true;\n if ((stack._top || 0) === index) {\n edge = top;\n } else if ((stack._bottom || 0) === index) {\n edge = bottom;\n } else {\n res[parseEdge(bottom, start, end, reverse)] = true;\n edge = top;\n }\n }\n res[parseEdge(edge, start, end, reverse)] = true;\n properties.borderSkipped = res;\n }\n function parseEdge(edge, a, b, reverse) {\n if (reverse) {\n edge = swap(edge, a, b);\n edge = startEnd(edge, b, a);\n } else {\n edge = startEnd(edge, a, b);\n }\n return edge;\n }\n function swap(orig, v1, v2) {\n return orig === v1 ? v2 : orig === v2 ? v1 : orig;\n }\n function startEnd(v, start, end) {\n return v === 'start' ? start : v === 'end' ? end : v;\n }\n function setInflateAmount(properties, _ref, ratio) {\n var inflateAmount = _ref.inflateAmount;\n properties.inflateAmount = inflateAmount === 'auto' ? ratio === 1 ? 0.33 : 0 : inflateAmount;\n }\n var BarController = /*#__PURE__*/function (_DatasetController) {\n _inherits$1(BarController, _DatasetController);\n var _super = _createSuper$1(BarController);\n function BarController() {\n _classCallCheck$1(this, BarController);\n return _super.apply(this, arguments);\n }\n _createClass$1(BarController, [{\n key: \"parsePrimitiveData\",\n value: function parsePrimitiveData(meta, data, start, count) {\n return parseArrayOrPrimitive(meta, data, start, count);\n }\n }, {\n key: \"parseArrayData\",\n value: function parseArrayData(meta, data, start, count) {\n return parseArrayOrPrimitive(meta, data, start, count);\n }\n }, {\n key: \"parseObjectData\",\n value: function parseObjectData(meta, data, start, count) {\n var iScale = meta.iScale,\n vScale = meta.vScale;\n var _this$_parsing2 = this._parsing,\n _this$_parsing2$xAxis = _this$_parsing2.xAxisKey,\n xAxisKey = _this$_parsing2$xAxis === void 0 ? 'x' : _this$_parsing2$xAxis,\n _this$_parsing2$yAxis = _this$_parsing2.yAxisKey,\n yAxisKey = _this$_parsing2$yAxis === void 0 ? 'y' : _this$_parsing2$yAxis;\n var iAxisKey = iScale.axis === 'x' ? xAxisKey : yAxisKey;\n var vAxisKey = vScale.axis === 'x' ? xAxisKey : yAxisKey;\n var parsed = [];\n var i, ilen, item, obj;\n for (i = start, ilen = start + count; i < ilen; ++i) {\n obj = data[i];\n item = {};\n item[iScale.axis] = iScale.parse(resolveObjectKey(obj, iAxisKey), i);\n parsed.push(parseValue(resolveObjectKey(obj, vAxisKey), item, vScale, i));\n }\n return parsed;\n }\n }, {\n key: \"updateRangeFromParsed\",\n value: function updateRangeFromParsed(range, scale, parsed, stack) {\n _get(_getPrototypeOf$1(BarController.prototype), \"updateRangeFromParsed\", this).call(this, range, scale, parsed, stack);\n var custom = parsed._custom;\n if (custom && scale === this._cachedMeta.vScale) {\n range.min = Math.min(range.min, custom.min);\n range.max = Math.max(range.max, custom.max);\n }\n }\n }, {\n key: \"getMaxOverflow\",\n value: function getMaxOverflow() {\n return 0;\n }\n }, {\n key: \"getLabelAndValue\",\n value: function getLabelAndValue(index) {\n var meta = this._cachedMeta;\n var iScale = meta.iScale,\n vScale = meta.vScale;\n var parsed = this.getParsed(index);\n var custom = parsed._custom;\n var value = isFloatBar(custom) ? '[' + custom.start + ', ' + custom.end + ']' : '' + vScale.getLabelForValue(parsed[vScale.axis]);\n return {\n label: '' + iScale.getLabelForValue(parsed[iScale.axis]),\n value: value\n };\n }\n }, {\n key: \"initialize\",\n value: function initialize() {\n this.enableOptionSharing = true;\n _get(_getPrototypeOf$1(BarController.prototype), \"initialize\", this).call(this);\n var meta = this._cachedMeta;\n meta.stack = this.getDataset().stack;\n }\n }, {\n key: \"update\",\n value: function update(mode) {\n var meta = this._cachedMeta;\n this.updateElements(meta.data, 0, meta.data.length, mode);\n }\n }, {\n key: \"updateElements\",\n value: function updateElements(bars, start, count, mode) {\n var reset = mode === 'reset';\n var index = this.index,\n vScale = this._cachedMeta.vScale;\n var base = vScale.getBasePixel();\n var horizontal = vScale.isHorizontal();\n var ruler = this._getRuler();\n var _this$_getSharedOptio = this._getSharedOptions(start, mode),\n sharedOptions = _this$_getSharedOptio.sharedOptions,\n includeOptions = _this$_getSharedOptio.includeOptions;\n for (var i = start; i < start + count; i++) {\n var parsed = this.getParsed(i);\n var vpixels = reset || isNullOrUndef(parsed[vScale.axis]) ? {\n base: base,\n head: base\n } : this._calculateBarValuePixels(i);\n var ipixels = this._calculateBarIndexPixels(i, ruler);\n var stack = (parsed._stacks || {})[vScale.axis];\n var properties = {\n horizontal: horizontal,\n base: vpixels.base,\n enableBorderRadius: !stack || isFloatBar(parsed._custom) || index === stack._top || index === stack._bottom,\n x: horizontal ? vpixels.head : ipixels.center,\n y: horizontal ? ipixels.center : vpixels.head,\n height: horizontal ? ipixels.size : Math.abs(vpixels.size),\n width: horizontal ? Math.abs(vpixels.size) : ipixels.size\n };\n if (includeOptions) {\n properties.options = sharedOptions || this.resolveDataElementOptions(i, bars[i].active ? 'active' : mode);\n }\n var options = properties.options || bars[i].options;\n setBorderSkipped(properties, options, stack, index);\n setInflateAmount(properties, options, ruler.ratio);\n this.updateElement(bars[i], i, properties, mode);\n }\n }\n }, {\n key: \"_getStacks\",\n value: function _getStacks(last, dataIndex) {\n var iScale = this._cachedMeta.iScale;\n var metasets = iScale.getMatchingVisibleMetas(this._type).filter(function (meta) {\n return meta.controller.options.grouped;\n });\n var stacked = iScale.options.stacked;\n var stacks = [];\n var skipNull = function skipNull(meta) {\n var parsed = meta.controller.getParsed(dataIndex);\n var val = parsed && parsed[meta.vScale.axis];\n if (isNullOrUndef(val) || isNaN(val)) {\n return true;\n }\n };\n var _iterator4 = _createForOfIteratorHelper$1(metasets),\n _step4;\n try {\n for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {\n var meta = _step4.value;\n if (dataIndex !== undefined && skipNull(meta)) {\n continue;\n }\n if (stacked === false || stacks.indexOf(meta.stack) === -1 || stacked === undefined && meta.stack === undefined) {\n stacks.push(meta.stack);\n }\n if (meta.index === last) {\n break;\n }\n }\n } catch (err) {\n _iterator4.e(err);\n } finally {\n _iterator4.f();\n }\n if (!stacks.length) {\n stacks.push(undefined);\n }\n return stacks;\n }\n }, {\n key: \"_getStackCount\",\n value: function _getStackCount(index) {\n return this._getStacks(undefined, index).length;\n }\n }, {\n key: \"_getStackIndex\",\n value: function _getStackIndex(datasetIndex, name, dataIndex) {\n var stacks = this._getStacks(datasetIndex, dataIndex);\n var index = name !== undefined ? stacks.indexOf(name) : -1;\n return index === -1 ? stacks.length - 1 : index;\n }\n }, {\n key: \"_getRuler\",\n value: function _getRuler() {\n var opts = this.options;\n var meta = this._cachedMeta;\n var iScale = meta.iScale;\n var pixels = [];\n var i, ilen;\n for (i = 0, ilen = meta.data.length; i < ilen; ++i) {\n pixels.push(iScale.getPixelForValue(this.getParsed(i)[iScale.axis], i));\n }\n var barThickness = opts.barThickness;\n var min = barThickness || computeMinSampleSize(meta);\n return {\n min: min,\n pixels: pixels,\n start: iScale._startPixel,\n end: iScale._endPixel,\n stackCount: this._getStackCount(),\n scale: iScale,\n grouped: opts.grouped,\n ratio: barThickness ? 1 : opts.categoryPercentage * opts.barPercentage\n };\n }\n }, {\n key: \"_calculateBarValuePixels\",\n value: function _calculateBarValuePixels(index) {\n var _this$_cachedMeta = this._cachedMeta,\n vScale = _this$_cachedMeta.vScale,\n _stacked = _this$_cachedMeta._stacked,\n datasetIndex = _this$_cachedMeta.index,\n _this$options = this.options,\n baseValue = _this$options.base,\n minBarLength = _this$options.minBarLength;\n var actualBase = baseValue || 0;\n var parsed = this.getParsed(index);\n var custom = parsed._custom;\n var floating = isFloatBar(custom);\n var value = parsed[vScale.axis];\n var start = 0;\n var length = _stacked ? this.applyStack(vScale, parsed, _stacked) : value;\n var head, size;\n if (length !== value) {\n start = length - value;\n length = value;\n }\n if (floating) {\n value = custom.barStart;\n length = custom.barEnd - custom.barStart;\n if (value !== 0 && sign(value) !== sign(custom.barEnd)) {\n start = 0;\n }\n start += value;\n }\n var startValue = !isNullOrUndef(baseValue) && !floating ? baseValue : start;\n var base = vScale.getPixelForValue(startValue);\n if (this.chart.getDataVisibility(index)) {\n head = vScale.getPixelForValue(start + length);\n } else {\n head = base;\n }\n size = head - base;\n if (Math.abs(size) < minBarLength) {\n size = barSign(size, vScale, actualBase) * minBarLength;\n if (value === actualBase) {\n base -= size / 2;\n }\n var startPixel = vScale.getPixelForDecimal(0);\n var endPixel = vScale.getPixelForDecimal(1);\n var min = Math.min(startPixel, endPixel);\n var max = Math.max(startPixel, endPixel);\n base = Math.max(Math.min(base, max), min);\n head = base + size;\n if (_stacked && !floating) {\n parsed._stacks[vScale.axis]._visualValues[datasetIndex] = vScale.getValueForPixel(head) - vScale.getValueForPixel(base);\n }\n }\n if (base === vScale.getPixelForValue(actualBase)) {\n var halfGrid = sign(size) * vScale.getLineWidthForValue(actualBase) / 2;\n base += halfGrid;\n size -= halfGrid;\n }\n return {\n size: size,\n base: base,\n head: head,\n center: head + size / 2\n };\n }\n }, {\n key: \"_calculateBarIndexPixels\",\n value: function _calculateBarIndexPixels(index, ruler) {\n var scale = ruler.scale;\n var options = this.options;\n var skipNull = options.skipNull;\n var maxBarThickness = valueOrDefault(options.maxBarThickness, Infinity);\n var center, size;\n if (ruler.grouped) {\n var stackCount = skipNull ? this._getStackCount(index) : ruler.stackCount;\n var range = options.barThickness === 'flex' ? computeFlexCategoryTraits(index, ruler, options, stackCount) : computeFitCategoryTraits(index, ruler, options, stackCount);\n var stackIndex = this._getStackIndex(this.index, this._cachedMeta.stack, skipNull ? index : undefined);\n center = range.start + range.chunk * stackIndex + range.chunk / 2;\n size = Math.min(maxBarThickness, range.chunk * range.ratio);\n } else {\n center = scale.getPixelForValue(this.getParsed(index)[scale.axis], index);\n size = Math.min(maxBarThickness, ruler.min * ruler.ratio);\n }\n return {\n base: center - size / 2,\n head: center + size / 2,\n center: center,\n size: size\n };\n }\n }, {\n key: \"draw\",\n value: function draw() {\n var meta = this._cachedMeta;\n var vScale = meta.vScale;\n var rects = meta.data;\n var ilen = rects.length;\n var i = 0;\n for (; i < ilen; ++i) {\n if (this.getParsed(i)[vScale.axis] !== null) {\n rects[i].draw(this._ctx);\n }\n }\n }\n }]);\n return BarController;\n }(DatasetController);\n _defineProperty$1(BarController, \"id\", 'bar');\n _defineProperty$1(BarController, \"defaults\", {\n datasetElementType: false,\n dataElementType: 'bar',\n categoryPercentage: 0.8,\n barPercentage: 0.9,\n grouped: true,\n animations: {\n numbers: {\n type: 'number',\n properties: ['x', 'y', 'base', 'width', 'height']\n }\n }\n });\n _defineProperty$1(BarController, \"overrides\", {\n scales: {\n _index_: {\n type: 'category',\n offset: true,\n grid: {\n offset: true\n }\n },\n _value_: {\n type: 'linear',\n beginAtZero: true\n }\n }\n });\n var BubbleController = /*#__PURE__*/function (_DatasetController2) {\n _inherits$1(BubbleController, _DatasetController2);\n var _super2 = _createSuper$1(BubbleController);\n function BubbleController() {\n _classCallCheck$1(this, BubbleController);\n return _super2.apply(this, arguments);\n }\n _createClass$1(BubbleController, [{\n key: \"initialize\",\n value: function initialize() {\n this.enableOptionSharing = true;\n _get(_getPrototypeOf$1(BubbleController.prototype), \"initialize\", this).call(this);\n }\n }, {\n key: \"parsePrimitiveData\",\n value: function parsePrimitiveData(meta, data, start, count) {\n var parsed = _get(_getPrototypeOf$1(BubbleController.prototype), \"parsePrimitiveData\", this).call(this, meta, data, start, count);\n for (var i = 0; i < parsed.length; i++) {\n parsed[i]._custom = this.resolveDataElementOptions(i + start).radius;\n }\n return parsed;\n }\n }, {\n key: \"parseArrayData\",\n value: function parseArrayData(meta, data, start, count) {\n var parsed = _get(_getPrototypeOf$1(BubbleController.prototype), \"parseArrayData\", this).call(this, meta, data, start, count);\n for (var i = 0; i < parsed.length; i++) {\n var item = data[start + i];\n parsed[i]._custom = valueOrDefault(item[2], this.resolveDataElementOptions(i + start).radius);\n }\n return parsed;\n }\n }, {\n key: \"parseObjectData\",\n value: function parseObjectData(meta, data, start, count) {\n var parsed = _get(_getPrototypeOf$1(BubbleController.prototype), \"parseObjectData\", this).call(this, meta, data, start, count);\n for (var i = 0; i < parsed.length; i++) {\n var item = data[start + i];\n parsed[i]._custom = valueOrDefault(item && item.r && +item.r, this.resolveDataElementOptions(i + start).radius);\n }\n return parsed;\n }\n }, {\n key: \"getMaxOverflow\",\n value: function getMaxOverflow() {\n var data = this._cachedMeta.data;\n var max = 0;\n for (var i = data.length - 1; i >= 0; --i) {\n max = Math.max(max, data[i].size(this.resolveDataElementOptions(i)) / 2);\n }\n return max > 0 && max;\n }\n }, {\n key: \"getLabelAndValue\",\n value: function getLabelAndValue(index) {\n var meta = this._cachedMeta;\n var labels = this.chart.data.labels || [];\n var xScale = meta.xScale,\n yScale = meta.yScale;\n var parsed = this.getParsed(index);\n var x = xScale.getLabelForValue(parsed.x);\n var y = yScale.getLabelForValue(parsed.y);\n var r = parsed._custom;\n return {\n label: labels[index] || '',\n value: '(' + x + ', ' + y + (r ? ', ' + r : '') + ')'\n };\n }\n }, {\n key: \"update\",\n value: function update(mode) {\n var points = this._cachedMeta.data;\n this.updateElements(points, 0, points.length, mode);\n }\n }, {\n key: \"updateElements\",\n value: function updateElements(points, start, count, mode) {\n var reset = mode === 'reset';\n var _this$_cachedMeta2 = this._cachedMeta,\n iScale = _this$_cachedMeta2.iScale,\n vScale = _this$_cachedMeta2.vScale;\n var _this$_getSharedOptio2 = this._getSharedOptions(start, mode),\n sharedOptions = _this$_getSharedOptio2.sharedOptions,\n includeOptions = _this$_getSharedOptio2.includeOptions;\n var iAxis = iScale.axis;\n var vAxis = vScale.axis;\n for (var i = start; i < start + count; i++) {\n var point = points[i];\n var parsed = !reset && this.getParsed(i);\n var properties = {};\n var iPixel = properties[iAxis] = reset ? iScale.getPixelForDecimal(0.5) : iScale.getPixelForValue(parsed[iAxis]);\n var vPixel = properties[vAxis] = reset ? vScale.getBasePixel() : vScale.getPixelForValue(parsed[vAxis]);\n properties.skip = isNaN(iPixel) || isNaN(vPixel);\n if (includeOptions) {\n properties.options = sharedOptions || this.resolveDataElementOptions(i, point.active ? 'active' : mode);\n if (reset) {\n properties.options.radius = 0;\n }\n }\n this.updateElement(point, i, properties, mode);\n }\n }\n }, {\n key: \"resolveDataElementOptions\",\n value: function resolveDataElementOptions(index, mode) {\n var parsed = this.getParsed(index);\n var values = _get(_getPrototypeOf$1(BubbleController.prototype), \"resolveDataElementOptions\", this).call(this, index, mode);\n if (values.$shared) {\n values = Object.assign({}, values, {\n $shared: false\n });\n }\n var radius = values.radius;\n if (mode !== 'active') {\n values.radius = 0;\n }\n values.radius += valueOrDefault(parsed && parsed._custom, radius);\n return values;\n }\n }]);\n return BubbleController;\n }(DatasetController);\n _defineProperty$1(BubbleController, \"id\", 'bubble');\n _defineProperty$1(BubbleController, \"defaults\", {\n datasetElementType: false,\n dataElementType: 'point',\n animations: {\n numbers: {\n type: 'number',\n properties: ['x', 'y', 'borderWidth', 'radius']\n }\n }\n });\n _defineProperty$1(BubbleController, \"overrides\", {\n scales: {\n x: {\n type: 'linear'\n },\n y: {\n type: 'linear'\n }\n }\n });\n function getRatioAndOffset(rotation, circumference, cutout) {\n var ratioX = 1;\n var ratioY = 1;\n var offsetX = 0;\n var offsetY = 0;\n if (circumference < TAU) {\n var startAngle = rotation;\n var endAngle = startAngle + circumference;\n var startX = Math.cos(startAngle);\n var startY = Math.sin(startAngle);\n var endX = Math.cos(endAngle);\n var endY = Math.sin(endAngle);\n var calcMax = function calcMax(angle, a, b) {\n return _angleBetween(angle, startAngle, endAngle, true) ? 1 : Math.max(a, a * cutout, b, b * cutout);\n };\n var calcMin = function calcMin(angle, a, b) {\n return _angleBetween(angle, startAngle, endAngle, true) ? -1 : Math.min(a, a * cutout, b, b * cutout);\n };\n var maxX = calcMax(0, startX, endX);\n var maxY = calcMax(HALF_PI, startY, endY);\n var minX = calcMin(PI, startX, endX);\n var minY = calcMin(PI + HALF_PI, startY, endY);\n ratioX = (maxX - minX) / 2;\n ratioY = (maxY - minY) / 2;\n offsetX = -(maxX + minX) / 2;\n offsetY = -(maxY + minY) / 2;\n }\n return {\n ratioX: ratioX,\n ratioY: ratioY,\n offsetX: offsetX,\n offsetY: offsetY\n };\n }\n var DoughnutController = /*#__PURE__*/function (_DatasetController3) {\n _inherits$1(DoughnutController, _DatasetController3);\n var _super3 = _createSuper$1(DoughnutController);\n function DoughnutController(chart, datasetIndex) {\n var _this4;\n _classCallCheck$1(this, DoughnutController);\n _this4 = _super3.call(this, chart, datasetIndex);\n _this4.enableOptionSharing = true;\n _this4.innerRadius = undefined;\n _this4.outerRadius = undefined;\n _this4.offsetX = undefined;\n _this4.offsetY = undefined;\n return _this4;\n }\n _createClass$1(DoughnutController, [{\n key: \"linkScales\",\n value: function linkScales() {}\n }, {\n key: \"parse\",\n value: function parse(start, count) {\n var data = this.getDataset().data;\n var meta = this._cachedMeta;\n if (this._parsing === false) {\n meta._parsed = data;\n } else {\n var getter = function getter(i) {\n return +data[i];\n };\n if (isObject(data[start])) {\n var _this$_parsing$key = this._parsing.key,\n key = _this$_parsing$key === void 0 ? 'value' : _this$_parsing$key;\n getter = function getter(i) {\n return +resolveObjectKey(data[i], key);\n };\n }\n var i, ilen;\n for (i = start, ilen = start + count; i < ilen; ++i) {\n meta._parsed[i] = getter(i);\n }\n }\n }\n }, {\n key: \"_getRotation\",\n value: function _getRotation() {\n return toRadians(this.options.rotation - 90);\n }\n }, {\n key: \"_getCircumference\",\n value: function _getCircumference() {\n return toRadians(this.options.circumference);\n }\n }, {\n key: \"_getRotationExtents\",\n value: function _getRotationExtents() {\n var min = TAU;\n var max = -TAU;\n for (var i = 0; i < this.chart.data.datasets.length; ++i) {\n if (this.chart.isDatasetVisible(i) && this.chart.getDatasetMeta(i).type === this._type) {\n var controller = this.chart.getDatasetMeta(i).controller;\n var rotation = controller._getRotation();\n var circumference = controller._getCircumference();\n min = Math.min(min, rotation);\n max = Math.max(max, rotation + circumference);\n }\n }\n return {\n rotation: min,\n circumference: max - min\n };\n }\n }, {\n key: \"update\",\n value: function update(mode) {\n var chart = this.chart;\n var chartArea = chart.chartArea;\n var meta = this._cachedMeta;\n var arcs = meta.data;\n var spacing = this.getMaxBorderWidth() + this.getMaxOffset(arcs) + this.options.spacing;\n var maxSize = Math.max((Math.min(chartArea.width, chartArea.height) - spacing) / 2, 0);\n var cutout = Math.min(toPercentage(this.options.cutout, maxSize), 1);\n var chartWeight = this._getRingWeight(this.index);\n var _this$_getRotationExt = this._getRotationExtents(),\n circumference = _this$_getRotationExt.circumference,\n rotation = _this$_getRotationExt.rotation;\n var _getRatioAndOffset = getRatioAndOffset(rotation, circumference, cutout),\n ratioX = _getRatioAndOffset.ratioX,\n ratioY = _getRatioAndOffset.ratioY,\n offsetX = _getRatioAndOffset.offsetX,\n offsetY = _getRatioAndOffset.offsetY;\n var maxWidth = (chartArea.width - spacing) / ratioX;\n var maxHeight = (chartArea.height - spacing) / ratioY;\n var maxRadius = Math.max(Math.min(maxWidth, maxHeight) / 2, 0);\n var outerRadius = toDimension(this.options.radius, maxRadius);\n var innerRadius = Math.max(outerRadius * cutout, 0);\n var radiusLength = (outerRadius - innerRadius) / this._getVisibleDatasetWeightTotal();\n this.offsetX = offsetX * outerRadius;\n this.offsetY = offsetY * outerRadius;\n meta.total = this.calculateTotal();\n this.outerRadius = outerRadius - radiusLength * this._getRingWeightOffset(this.index);\n this.innerRadius = Math.max(this.outerRadius - radiusLength * chartWeight, 0);\n this.updateElements(arcs, 0, arcs.length, mode);\n }\n }, {\n key: \"_circumference\",\n value: function _circumference(i, reset) {\n var opts = this.options;\n var meta = this._cachedMeta;\n var circumference = this._getCircumference();\n if (reset && opts.animation.animateRotate || !this.chart.getDataVisibility(i) || meta._parsed[i] === null || meta.data[i].hidden) {\n return 0;\n }\n return this.calculateCircumference(meta._parsed[i] * circumference / TAU);\n }\n }, {\n key: \"updateElements\",\n value: function updateElements(arcs, start, count, mode) {\n var reset = mode === 'reset';\n var chart = this.chart;\n var chartArea = chart.chartArea;\n var opts = chart.options;\n var animationOpts = opts.animation;\n var centerX = (chartArea.left + chartArea.right) / 2;\n var centerY = (chartArea.top + chartArea.bottom) / 2;\n var animateScale = reset && animationOpts.animateScale;\n var innerRadius = animateScale ? 0 : this.innerRadius;\n var outerRadius = animateScale ? 0 : this.outerRadius;\n var _this$_getSharedOptio3 = this._getSharedOptions(start, mode),\n sharedOptions = _this$_getSharedOptio3.sharedOptions,\n includeOptions = _this$_getSharedOptio3.includeOptions;\n var startAngle = this._getRotation();\n var i;\n for (i = 0; i < start; ++i) {\n startAngle += this._circumference(i, reset);\n }\n for (i = start; i < start + count; ++i) {\n var circumference = this._circumference(i, reset);\n var arc = arcs[i];\n var properties = {\n x: centerX + this.offsetX,\n y: centerY + this.offsetY,\n startAngle: startAngle,\n endAngle: startAngle + circumference,\n circumference: circumference,\n outerRadius: outerRadius,\n innerRadius: innerRadius\n };\n if (includeOptions) {\n properties.options = sharedOptions || this.resolveDataElementOptions(i, arc.active ? 'active' : mode);\n }\n startAngle += circumference;\n this.updateElement(arc, i, properties, mode);\n }\n }\n }, {\n key: \"calculateTotal\",\n value: function calculateTotal() {\n var meta = this._cachedMeta;\n var metaData = meta.data;\n var total = 0;\n var i;\n for (i = 0; i < metaData.length; i++) {\n var value = meta._parsed[i];\n if (value !== null && !isNaN(value) && this.chart.getDataVisibility(i) && !metaData[i].hidden) {\n total += Math.abs(value);\n }\n }\n return total;\n }\n }, {\n key: \"calculateCircumference\",\n value: function calculateCircumference(value) {\n var total = this._cachedMeta.total;\n if (total > 0 && !isNaN(value)) {\n return TAU * (Math.abs(value) / total);\n }\n return 0;\n }\n }, {\n key: \"getLabelAndValue\",\n value: function getLabelAndValue(index) {\n var meta = this._cachedMeta;\n var chart = this.chart;\n var labels = chart.data.labels || [];\n var value = formatNumber(meta._parsed[index], chart.options.locale);\n return {\n label: labels[index] || '',\n value: value\n };\n }\n }, {\n key: \"getMaxBorderWidth\",\n value: function getMaxBorderWidth(arcs) {\n var max = 0;\n var chart = this.chart;\n var i, ilen, meta, controller, options;\n if (!arcs) {\n for (i = 0, ilen = chart.data.datasets.length; i < ilen; ++i) {\n if (chart.isDatasetVisible(i)) {\n meta = chart.getDatasetMeta(i);\n arcs = meta.data;\n controller = meta.controller;\n break;\n }\n }\n }\n if (!arcs) {\n return 0;\n }\n for (i = 0, ilen = arcs.length; i < ilen; ++i) {\n options = controller.resolveDataElementOptions(i);\n if (options.borderAlign !== 'inner') {\n max = Math.max(max, options.borderWidth || 0, options.hoverBorderWidth || 0);\n }\n }\n return max;\n }\n }, {\n key: \"getMaxOffset\",\n value: function getMaxOffset(arcs) {\n var max = 0;\n for (var i = 0, ilen = arcs.length; i < ilen; ++i) {\n var options = this.resolveDataElementOptions(i);\n max = Math.max(max, options.offset || 0, options.hoverOffset || 0);\n }\n return max;\n }\n }, {\n key: \"_getRingWeightOffset\",\n value: function _getRingWeightOffset(datasetIndex) {\n var ringWeightOffset = 0;\n for (var i = 0; i < datasetIndex; ++i) {\n if (this.chart.isDatasetVisible(i)) {\n ringWeightOffset += this._getRingWeight(i);\n }\n }\n return ringWeightOffset;\n }\n }, {\n key: \"_getRingWeight\",\n value: function _getRingWeight(datasetIndex) {\n return Math.max(valueOrDefault(this.chart.data.datasets[datasetIndex].weight, 1), 0);\n }\n }, {\n key: \"_getVisibleDatasetWeightTotal\",\n value: function _getVisibleDatasetWeightTotal() {\n return this._getRingWeightOffset(this.chart.data.datasets.length) || 1;\n }\n }]);\n return DoughnutController;\n }(DatasetController);\n _defineProperty$1(DoughnutController, \"id\", 'doughnut');\n _defineProperty$1(DoughnutController, \"defaults\", {\n datasetElementType: false,\n dataElementType: 'arc',\n animation: {\n animateRotate: true,\n animateScale: false\n },\n animations: {\n numbers: {\n type: 'number',\n properties: ['circumference', 'endAngle', 'innerRadius', 'outerRadius', 'startAngle', 'x', 'y', 'offset', 'borderWidth', 'spacing']\n }\n },\n cutout: '50%',\n rotation: 0,\n circumference: 360,\n radius: '100%',\n spacing: 0,\n indexAxis: 'r'\n });\n _defineProperty$1(DoughnutController, \"descriptors\", {\n _scriptable: function _scriptable(name) {\n return name !== 'spacing';\n },\n _indexable: function _indexable(name) {\n return name !== 'spacing' && !name.startsWith('borderDash') && !name.startsWith('hoverBorderDash');\n }\n });\n _defineProperty$1(DoughnutController, \"overrides\", {\n aspectRatio: 1,\n plugins: {\n legend: {\n labels: {\n generateLabels: function generateLabels(chart) {\n var data = chart.data;\n if (data.labels.length && data.datasets.length) {\n var _chart$legend$options2 = chart.legend.options.labels,\n pointStyle = _chart$legend$options2.pointStyle,\n color = _chart$legend$options2.color;\n return data.labels.map(function (label, i) {\n var meta = chart.getDatasetMeta(0);\n var style = meta.controller.getStyle(i);\n return {\n text: label,\n fillStyle: style.backgroundColor,\n strokeStyle: style.borderColor,\n fontColor: color,\n lineWidth: style.borderWidth,\n pointStyle: pointStyle,\n hidden: !chart.getDataVisibility(i),\n index: i\n };\n });\n }\n return [];\n }\n },\n onClick: function onClick(e, legendItem, legend) {\n legend.chart.toggleDataVisibility(legendItem.index);\n legend.chart.update();\n }\n }\n }\n });\n var LineController = /*#__PURE__*/function (_DatasetController4) {\n _inherits$1(LineController, _DatasetController4);\n var _super4 = _createSuper$1(LineController);\n function LineController() {\n _classCallCheck$1(this, LineController);\n return _super4.apply(this, arguments);\n }\n _createClass$1(LineController, [{\n key: \"initialize\",\n value: function initialize() {\n this.enableOptionSharing = true;\n this.supportsDecimation = true;\n _get(_getPrototypeOf$1(LineController.prototype), \"initialize\", this).call(this);\n }\n }, {\n key: \"update\",\n value: function update(mode) {\n var meta = this._cachedMeta;\n var line = meta.dataset,\n _meta$data = meta.data,\n points = _meta$data === void 0 ? [] : _meta$data,\n _dataset = meta._dataset;\n var animationsDisabled = this.chart._animationsDisabled;\n var _getStartAndCountOfVi = _getStartAndCountOfVisiblePoints(meta, points, animationsDisabled),\n start = _getStartAndCountOfVi.start,\n count = _getStartAndCountOfVi.count;\n this._drawStart = start;\n this._drawCount = count;\n if (_scaleRangesChanged(meta)) {\n start = 0;\n count = points.length;\n }\n line._chart = this.chart;\n line._datasetIndex = this.index;\n line._decimated = !!_dataset._decimated;\n line.points = points;\n var options = this.resolveDatasetElementOptions(mode);\n if (!this.options.showLine) {\n options.borderWidth = 0;\n }\n options.segment = this.options.segment;\n this.updateElement(line, undefined, {\n animated: !animationsDisabled,\n options: options\n }, mode);\n this.updateElements(points, start, count, mode);\n }\n }, {\n key: \"updateElements\",\n value: function updateElements(points, start, count, mode) {\n var reset = mode === 'reset';\n var _this$_cachedMeta3 = this._cachedMeta,\n iScale = _this$_cachedMeta3.iScale,\n vScale = _this$_cachedMeta3.vScale,\n _stacked = _this$_cachedMeta3._stacked,\n _dataset = _this$_cachedMeta3._dataset;\n var _this$_getSharedOptio4 = this._getSharedOptions(start, mode),\n sharedOptions = _this$_getSharedOptio4.sharedOptions,\n includeOptions = _this$_getSharedOptio4.includeOptions;\n var iAxis = iScale.axis;\n var vAxis = vScale.axis;\n var _this$options2 = this.options,\n spanGaps = _this$options2.spanGaps,\n segment = _this$options2.segment;\n var maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;\n var directUpdate = this.chart._animationsDisabled || reset || mode === 'none';\n var end = start + count;\n var pointsCount = points.length;\n var prevParsed = start > 0 && this.getParsed(start - 1);\n for (var i = 0; i < pointsCount; ++i) {\n var point = points[i];\n var properties = directUpdate ? point : {};\n if (i < start || i >= end) {\n properties.skip = true;\n continue;\n }\n var parsed = this.getParsed(i);\n var nullData = isNullOrUndef(parsed[vAxis]);\n var iPixel = properties[iAxis] = iScale.getPixelForValue(parsed[iAxis], i);\n var vPixel = properties[vAxis] = reset || nullData ? vScale.getBasePixel() : vScale.getPixelForValue(_stacked ? this.applyStack(vScale, parsed, _stacked) : parsed[vAxis], i);\n properties.skip = isNaN(iPixel) || isNaN(vPixel) || nullData;\n properties.stop = i > 0 && Math.abs(parsed[iAxis] - prevParsed[iAxis]) > maxGapLength;\n if (segment) {\n properties.parsed = parsed;\n properties.raw = _dataset.data[i];\n }\n if (includeOptions) {\n properties.options = sharedOptions || this.resolveDataElementOptions(i, point.active ? 'active' : mode);\n }\n if (!directUpdate) {\n this.updateElement(point, i, properties, mode);\n }\n prevParsed = parsed;\n }\n }\n }, {\n key: \"getMaxOverflow\",\n value: function getMaxOverflow() {\n var meta = this._cachedMeta;\n var dataset = meta.dataset;\n var border = dataset.options && dataset.options.borderWidth || 0;\n var data = meta.data || [];\n if (!data.length) {\n return border;\n }\n var firstPoint = data[0].size(this.resolveDataElementOptions(0));\n var lastPoint = data[data.length - 1].size(this.resolveDataElementOptions(data.length - 1));\n return Math.max(border, firstPoint, lastPoint) / 2;\n }\n }, {\n key: \"draw\",\n value: function draw() {\n var meta = this._cachedMeta;\n meta.dataset.updateControlPoints(this.chart.chartArea, meta.iScale.axis);\n _get(_getPrototypeOf$1(LineController.prototype), \"draw\", this).call(this);\n }\n }]);\n return LineController;\n }(DatasetController);\n _defineProperty$1(LineController, \"id\", 'line');\n _defineProperty$1(LineController, \"defaults\", {\n datasetElementType: 'line',\n dataElementType: 'point',\n showLine: true,\n spanGaps: false\n });\n _defineProperty$1(LineController, \"overrides\", {\n scales: {\n _index_: {\n type: 'category'\n },\n _value_: {\n type: 'linear'\n }\n }\n });\n var PolarAreaController = /*#__PURE__*/function (_DatasetController5) {\n _inherits$1(PolarAreaController, _DatasetController5);\n var _super5 = _createSuper$1(PolarAreaController);\n function PolarAreaController(chart, datasetIndex) {\n var _this5;\n _classCallCheck$1(this, PolarAreaController);\n _this5 = _super5.call(this, chart, datasetIndex);\n _this5.innerRadius = undefined;\n _this5.outerRadius = undefined;\n return _this5;\n }\n _createClass$1(PolarAreaController, [{\n key: \"getLabelAndValue\",\n value: function getLabelAndValue(index) {\n var meta = this._cachedMeta;\n var chart = this.chart;\n var labels = chart.data.labels || [];\n var value = formatNumber(meta._parsed[index].r, chart.options.locale);\n return {\n label: labels[index] || '',\n value: value\n };\n }\n }, {\n key: \"parseObjectData\",\n value: function parseObjectData(meta, data, start, count) {\n return _parseObjectDataRadialScale.bind(this)(meta, data, start, count);\n }\n }, {\n key: \"update\",\n value: function update(mode) {\n var arcs = this._cachedMeta.data;\n this._updateRadius();\n this.updateElements(arcs, 0, arcs.length, mode);\n }\n }, {\n key: \"getMinMax\",\n value: function getMinMax() {\n var _this6 = this;\n var meta = this._cachedMeta;\n var range = {\n min: Number.POSITIVE_INFINITY,\n max: Number.NEGATIVE_INFINITY\n };\n meta.data.forEach(function (element, index) {\n var parsed = _this6.getParsed(index).r;\n if (!isNaN(parsed) && _this6.chart.getDataVisibility(index)) {\n if (parsed < range.min) {\n range.min = parsed;\n }\n if (parsed > range.max) {\n range.max = parsed;\n }\n }\n });\n return range;\n }\n }, {\n key: \"_updateRadius\",\n value: function _updateRadius() {\n var chart = this.chart;\n var chartArea = chart.chartArea;\n var opts = chart.options;\n var minSize = Math.min(chartArea.right - chartArea.left, chartArea.bottom - chartArea.top);\n var outerRadius = Math.max(minSize / 2, 0);\n var innerRadius = Math.max(opts.cutoutPercentage ? outerRadius / 100 * opts.cutoutPercentage : 1, 0);\n var radiusLength = (outerRadius - innerRadius) / chart.getVisibleDatasetCount();\n this.outerRadius = outerRadius - radiusLength * this.index;\n this.innerRadius = this.outerRadius - radiusLength;\n }\n }, {\n key: \"updateElements\",\n value: function updateElements(arcs, start, count, mode) {\n var reset = mode === 'reset';\n var chart = this.chart;\n var opts = chart.options;\n var animationOpts = opts.animation;\n var scale = this._cachedMeta.rScale;\n var centerX = scale.xCenter;\n var centerY = scale.yCenter;\n var datasetStartAngle = scale.getIndexAngle(0) - 0.5 * PI;\n var angle = datasetStartAngle;\n var i;\n var defaultAngle = 360 / this.countVisibleElements();\n for (i = 0; i < start; ++i) {\n angle += this._computeAngle(i, mode, defaultAngle);\n }\n for (i = start; i < start + count; i++) {\n var arc = arcs[i];\n var startAngle = angle;\n var endAngle = angle + this._computeAngle(i, mode, defaultAngle);\n var outerRadius = chart.getDataVisibility(i) ? scale.getDistanceFromCenterForValue(this.getParsed(i).r) : 0;\n angle = endAngle;\n if (reset) {\n if (animationOpts.animateScale) {\n outerRadius = 0;\n }\n if (animationOpts.animateRotate) {\n startAngle = endAngle = datasetStartAngle;\n }\n }\n var properties = {\n x: centerX,\n y: centerY,\n innerRadius: 0,\n outerRadius: outerRadius,\n startAngle: startAngle,\n endAngle: endAngle,\n options: this.resolveDataElementOptions(i, arc.active ? 'active' : mode)\n };\n this.updateElement(arc, i, properties, mode);\n }\n }\n }, {\n key: \"countVisibleElements\",\n value: function countVisibleElements() {\n var _this7 = this;\n var meta = this._cachedMeta;\n var count = 0;\n meta.data.forEach(function (element, index) {\n if (!isNaN(_this7.getParsed(index).r) && _this7.chart.getDataVisibility(index)) {\n count++;\n }\n });\n return count;\n }\n }, {\n key: \"_computeAngle\",\n value: function _computeAngle(index, mode, defaultAngle) {\n return this.chart.getDataVisibility(index) ? toRadians(this.resolveDataElementOptions(index, mode).angle || defaultAngle) : 0;\n }\n }]);\n return PolarAreaController;\n }(DatasetController);\n _defineProperty$1(PolarAreaController, \"id\", 'polarArea');\n _defineProperty$1(PolarAreaController, \"defaults\", {\n dataElementType: 'arc',\n animation: {\n animateRotate: true,\n animateScale: true\n },\n animations: {\n numbers: {\n type: 'number',\n properties: ['x', 'y', 'startAngle', 'endAngle', 'innerRadius', 'outerRadius']\n }\n },\n indexAxis: 'r',\n startAngle: 0\n });\n _defineProperty$1(PolarAreaController, \"overrides\", {\n aspectRatio: 1,\n plugins: {\n legend: {\n labels: {\n generateLabels: function generateLabels(chart) {\n var data = chart.data;\n if (data.labels.length && data.datasets.length) {\n var _chart$legend$options3 = chart.legend.options.labels,\n pointStyle = _chart$legend$options3.pointStyle,\n color = _chart$legend$options3.color;\n return data.labels.map(function (label, i) {\n var meta = chart.getDatasetMeta(0);\n var style = meta.controller.getStyle(i);\n return {\n text: label,\n fillStyle: style.backgroundColor,\n strokeStyle: style.borderColor,\n fontColor: color,\n lineWidth: style.borderWidth,\n pointStyle: pointStyle,\n hidden: !chart.getDataVisibility(i),\n index: i\n };\n });\n }\n return [];\n }\n },\n onClick: function onClick(e, legendItem, legend) {\n legend.chart.toggleDataVisibility(legendItem.index);\n legend.chart.update();\n }\n }\n },\n scales: {\n r: {\n type: 'radialLinear',\n angleLines: {\n display: false\n },\n beginAtZero: true,\n grid: {\n circular: true\n },\n pointLabels: {\n display: false\n },\n startAngle: 0\n }\n }\n });\n var PieController = /*#__PURE__*/function (_DoughnutController) {\n _inherits$1(PieController, _DoughnutController);\n var _super6 = _createSuper$1(PieController);\n function PieController() {\n _classCallCheck$1(this, PieController);\n return _super6.apply(this, arguments);\n }\n return _createClass$1(PieController);\n }(DoughnutController);\n _defineProperty$1(PieController, \"id\", 'pie');\n _defineProperty$1(PieController, \"defaults\", {\n cutout: 0,\n rotation: 0,\n circumference: 360,\n radius: '100%'\n });\n var RadarController = /*#__PURE__*/function (_DatasetController6) {\n _inherits$1(RadarController, _DatasetController6);\n var _super7 = _createSuper$1(RadarController);\n function RadarController() {\n _classCallCheck$1(this, RadarController);\n return _super7.apply(this, arguments);\n }\n _createClass$1(RadarController, [{\n key: \"getLabelAndValue\",\n value: function getLabelAndValue(index) {\n var vScale = this._cachedMeta.vScale;\n var parsed = this.getParsed(index);\n return {\n label: vScale.getLabels()[index],\n value: '' + vScale.getLabelForValue(parsed[vScale.axis])\n };\n }\n }, {\n key: \"parseObjectData\",\n value: function parseObjectData(meta, data, start, count) {\n return _parseObjectDataRadialScale.bind(this)(meta, data, start, count);\n }\n }, {\n key: \"update\",\n value: function update(mode) {\n var meta = this._cachedMeta;\n var line = meta.dataset;\n var points = meta.data || [];\n var labels = meta.iScale.getLabels();\n line.points = points;\n if (mode !== 'resize') {\n var options = this.resolveDatasetElementOptions(mode);\n if (!this.options.showLine) {\n options.borderWidth = 0;\n }\n var properties = {\n _loop: true,\n _fullLoop: labels.length === points.length,\n options: options\n };\n this.updateElement(line, undefined, properties, mode);\n }\n this.updateElements(points, 0, points.length, mode);\n }\n }, {\n key: \"updateElements\",\n value: function updateElements(points, start, count, mode) {\n var scale = this._cachedMeta.rScale;\n var reset = mode === 'reset';\n for (var i = start; i < start + count; i++) {\n var point = points[i];\n var options = this.resolveDataElementOptions(i, point.active ? 'active' : mode);\n var pointPosition = scale.getPointPositionForValue(i, this.getParsed(i).r);\n var x = reset ? scale.xCenter : pointPosition.x;\n var y = reset ? scale.yCenter : pointPosition.y;\n var properties = {\n x: x,\n y: y,\n angle: pointPosition.angle,\n skip: isNaN(x) || isNaN(y),\n options: options\n };\n this.updateElement(point, i, properties, mode);\n }\n }\n }]);\n return RadarController;\n }(DatasetController);\n _defineProperty$1(RadarController, \"id\", 'radar');\n _defineProperty$1(RadarController, \"defaults\", {\n datasetElementType: 'line',\n dataElementType: 'point',\n indexAxis: 'r',\n showLine: true,\n elements: {\n line: {\n fill: 'start'\n }\n }\n });\n _defineProperty$1(RadarController, \"overrides\", {\n aspectRatio: 1,\n scales: {\n r: {\n type: 'radialLinear'\n }\n }\n });\n var ScatterController = /*#__PURE__*/function (_DatasetController7) {\n _inherits$1(ScatterController, _DatasetController7);\n var _super8 = _createSuper$1(ScatterController);\n function ScatterController() {\n _classCallCheck$1(this, ScatterController);\n return _super8.apply(this, arguments);\n }\n _createClass$1(ScatterController, [{\n key: \"getLabelAndValue\",\n value: function getLabelAndValue(index) {\n var meta = this._cachedMeta;\n var labels = this.chart.data.labels || [];\n var xScale = meta.xScale,\n yScale = meta.yScale;\n var parsed = this.getParsed(index);\n var x = xScale.getLabelForValue(parsed.x);\n var y = yScale.getLabelForValue(parsed.y);\n return {\n label: labels[index] || '',\n value: '(' + x + ', ' + y + ')'\n };\n }\n }, {\n key: \"update\",\n value: function update(mode) {\n var meta = this._cachedMeta;\n var _meta$data2 = meta.data,\n points = _meta$data2 === void 0 ? [] : _meta$data2;\n var animationsDisabled = this.chart._animationsDisabled;\n var _getStartAndCountOfVi2 = _getStartAndCountOfVisiblePoints(meta, points, animationsDisabled),\n start = _getStartAndCountOfVi2.start,\n count = _getStartAndCountOfVi2.count;\n this._drawStart = start;\n this._drawCount = count;\n if (_scaleRangesChanged(meta)) {\n start = 0;\n count = points.length;\n }\n if (this.options.showLine) {\n if (!this.datasetElementType) {\n this.addElements();\n }\n var line = meta.dataset,\n _dataset = meta._dataset;\n line._chart = this.chart;\n line._datasetIndex = this.index;\n line._decimated = !!_dataset._decimated;\n line.points = points;\n var options = this.resolveDatasetElementOptions(mode);\n options.segment = this.options.segment;\n this.updateElement(line, undefined, {\n animated: !animationsDisabled,\n options: options\n }, mode);\n } else if (this.datasetElementType) {\n delete meta.dataset;\n this.datasetElementType = false;\n }\n this.updateElements(points, start, count, mode);\n }\n }, {\n key: \"addElements\",\n value: function addElements() {\n var showLine = this.options.showLine;\n if (!this.datasetElementType && showLine) {\n this.datasetElementType = this.chart.registry.getElement('line');\n }\n _get(_getPrototypeOf$1(ScatterController.prototype), \"addElements\", this).call(this);\n }\n }, {\n key: \"updateElements\",\n value: function updateElements(points, start, count, mode) {\n var reset = mode === 'reset';\n var _this$_cachedMeta4 = this._cachedMeta,\n iScale = _this$_cachedMeta4.iScale,\n vScale = _this$_cachedMeta4.vScale,\n _stacked = _this$_cachedMeta4._stacked,\n _dataset = _this$_cachedMeta4._dataset;\n var firstOpts = this.resolveDataElementOptions(start, mode);\n var sharedOptions = this.getSharedOptions(firstOpts);\n var includeOptions = this.includeOptions(mode, sharedOptions);\n var iAxis = iScale.axis;\n var vAxis = vScale.axis;\n var _this$options3 = this.options,\n spanGaps = _this$options3.spanGaps,\n segment = _this$options3.segment;\n var maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;\n var directUpdate = this.chart._animationsDisabled || reset || mode === 'none';\n var prevParsed = start > 0 && this.getParsed(start - 1);\n for (var i = start; i < start + count; ++i) {\n var point = points[i];\n var parsed = this.getParsed(i);\n var properties = directUpdate ? point : {};\n var nullData = isNullOrUndef(parsed[vAxis]);\n var iPixel = properties[iAxis] = iScale.getPixelForValue(parsed[iAxis], i);\n var vPixel = properties[vAxis] = reset || nullData ? vScale.getBasePixel() : vScale.getPixelForValue(_stacked ? this.applyStack(vScale, parsed, _stacked) : parsed[vAxis], i);\n properties.skip = isNaN(iPixel) || isNaN(vPixel) || nullData;\n properties.stop = i > 0 && Math.abs(parsed[iAxis] - prevParsed[iAxis]) > maxGapLength;\n if (segment) {\n properties.parsed = parsed;\n properties.raw = _dataset.data[i];\n }\n if (includeOptions) {\n properties.options = sharedOptions || this.resolveDataElementOptions(i, point.active ? 'active' : mode);\n }\n if (!directUpdate) {\n this.updateElement(point, i, properties, mode);\n }\n prevParsed = parsed;\n }\n this.updateSharedOptions(sharedOptions, mode, firstOpts);\n }\n }, {\n key: \"getMaxOverflow\",\n value: function getMaxOverflow() {\n var meta = this._cachedMeta;\n var data = meta.data || [];\n if (!this.options.showLine) {\n var max = 0;\n for (var i = data.length - 1; i >= 0; --i) {\n max = Math.max(max, data[i].size(this.resolveDataElementOptions(i)) / 2);\n }\n return max > 0 && max;\n }\n var dataset = meta.dataset;\n var border = dataset.options && dataset.options.borderWidth || 0;\n if (!data.length) {\n return border;\n }\n var firstPoint = data[0].size(this.resolveDataElementOptions(0));\n var lastPoint = data[data.length - 1].size(this.resolveDataElementOptions(data.length - 1));\n return Math.max(border, firstPoint, lastPoint) / 2;\n }\n }]);\n return ScatterController;\n }(DatasetController);\n _defineProperty$1(ScatterController, \"id\", 'scatter');\n _defineProperty$1(ScatterController, \"defaults\", {\n datasetElementType: false,\n dataElementType: 'point',\n showLine: false,\n fill: false\n });\n _defineProperty$1(ScatterController, \"overrides\", {\n interaction: {\n mode: 'point'\n },\n scales: {\n x: {\n type: 'linear'\n },\n y: {\n type: 'linear'\n }\n }\n });\n var controllers = /*#__PURE__*/Object.freeze({\n __proto__: null,\n BarController: BarController,\n BubbleController: BubbleController,\n DoughnutController: DoughnutController,\n LineController: LineController,\n PieController: PieController,\n PolarAreaController: PolarAreaController,\n RadarController: RadarController,\n ScatterController: ScatterController\n });\n\n /**\n * @namespace Chart._adapters\n * @since 2.8.0\n * @private\n */\n function _abstract() {\n throw new Error('This method is not implemented: Check that a complete date adapter is provided.');\n }\n /**\n * Date adapter (current used by the time scale)\n * @namespace Chart._adapters._date\n * @memberof Chart._adapters\n * @private\n */\n var DateAdapterBase = /*#__PURE__*/function () {\n function DateAdapterBase(options) {\n _classCallCheck$1(this, DateAdapterBase);\n _defineProperty$1(this, \"options\", void 0);\n this.options = options || {};\n }\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n _createClass$1(DateAdapterBase, [{\n key: \"init\",\n value: function init() {}\n }, {\n key: \"formats\",\n value: function formats() {\n return _abstract();\n }\n }, {\n key: \"parse\",\n value: function parse() {\n return _abstract();\n }\n }, {\n key: \"format\",\n value: function format() {\n return _abstract();\n }\n }, {\n key: \"add\",\n value: function add() {\n return _abstract();\n }\n }, {\n key: \"diff\",\n value: function diff() {\n return _abstract();\n }\n }, {\n key: \"startOf\",\n value: function startOf() {\n return _abstract();\n }\n }, {\n key: \"endOf\",\n value: function endOf() {\n return _abstract();\n }\n }], [{\n key: \"override\",\n value:\n /**\n * Override default date adapter methods.\n * Accepts type parameter to define options type.\n * @example\n * Chart._adapters._date.override<{myAdapterOption: string}>({\n * init() {\n * console.log(this.options.myAdapterOption);\n * }\n * })\n */\n function override(members) {\n Object.assign(DateAdapterBase.prototype, members);\n }\n }]);\n return DateAdapterBase;\n }();\n var adapters = {\n _date: DateAdapterBase\n };\n function binarySearch(metaset, axis, value, intersect) {\n var controller = metaset.controller,\n data = metaset.data,\n _sorted = metaset._sorted;\n var iScale = controller._cachedMeta.iScale;\n if (iScale && axis === iScale.axis && axis !== 'r' && _sorted && data.length) {\n var lookupMethod = iScale._reversePixels ? _rlookupByKey : _lookupByKey;\n if (!intersect) {\n return lookupMethod(data, axis, value);\n } else if (controller._sharedOptions) {\n var el = data[0];\n var range = typeof el.getRange === 'function' && el.getRange(axis);\n if (range) {\n var start = lookupMethod(data, axis, value - range);\n var end = lookupMethod(data, axis, value + range);\n return {\n lo: start.lo,\n hi: end.hi\n };\n }\n }\n }\n return {\n lo: 0,\n hi: data.length - 1\n };\n }\n function evaluateInteractionItems(chart, axis, position, handler, intersect) {\n var metasets = chart.getSortedVisibleDatasetMetas();\n var value = position[axis];\n for (var i = 0, ilen = metasets.length; i < ilen; ++i) {\n var _metasets$i = metasets[i],\n _index2 = _metasets$i.index,\n data = _metasets$i.data;\n var _binarySearch = binarySearch(metasets[i], axis, value, intersect),\n lo = _binarySearch.lo,\n hi = _binarySearch.hi;\n for (var j = lo; j <= hi; ++j) {\n var element = data[j];\n if (!element.skip) {\n handler(element, _index2, j);\n }\n }\n }\n }\n function getDistanceMetricForAxis(axis) {\n var useX = axis.indexOf('x') !== -1;\n var useY = axis.indexOf('y') !== -1;\n return function (pt1, pt2) {\n var deltaX = useX ? Math.abs(pt1.x - pt2.x) : 0;\n var deltaY = useY ? Math.abs(pt1.y - pt2.y) : 0;\n return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));\n };\n }\n function getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible) {\n var items = [];\n if (!includeInvisible && !chart.isPointInArea(position)) {\n return items;\n }\n var evaluationFunc = function evaluationFunc(element, datasetIndex, index) {\n if (!includeInvisible && !_isPointInArea(element, chart.chartArea, 0)) {\n return;\n }\n if (element.inRange(position.x, position.y, useFinalPosition)) {\n items.push({\n element: element,\n datasetIndex: datasetIndex,\n index: index\n });\n }\n };\n evaluateInteractionItems(chart, axis, position, evaluationFunc, true);\n return items;\n }\n function getNearestRadialItems(chart, position, axis, useFinalPosition) {\n var items = [];\n function evaluationFunc(element, datasetIndex, index) {\n var _element$getProps = element.getProps(['startAngle', 'endAngle'], useFinalPosition),\n startAngle = _element$getProps.startAngle,\n endAngle = _element$getProps.endAngle;\n var _getAngleFromPoint = getAngleFromPoint(element, {\n x: position.x,\n y: position.y\n }),\n angle = _getAngleFromPoint.angle;\n if (_angleBetween(angle, startAngle, endAngle)) {\n items.push({\n element: element,\n datasetIndex: datasetIndex,\n index: index\n });\n }\n }\n evaluateInteractionItems(chart, axis, position, evaluationFunc);\n return items;\n }\n function getNearestCartesianItems(chart, position, axis, intersect, useFinalPosition, includeInvisible) {\n var items = [];\n var distanceMetric = getDistanceMetricForAxis(axis);\n var minDistance = Number.POSITIVE_INFINITY;\n function evaluationFunc(element, datasetIndex, index) {\n var inRange = element.inRange(position.x, position.y, useFinalPosition);\n if (intersect && !inRange) {\n return;\n }\n var center = element.getCenterPoint(useFinalPosition);\n var pointInArea = !!includeInvisible || chart.isPointInArea(center);\n if (!pointInArea && !inRange) {\n return;\n }\n var distance = distanceMetric(position, center);\n if (distance < minDistance) {\n items = [{\n element: element,\n datasetIndex: datasetIndex,\n index: index\n }];\n minDistance = distance;\n } else if (distance === minDistance) {\n items.push({\n element: element,\n datasetIndex: datasetIndex,\n index: index\n });\n }\n }\n evaluateInteractionItems(chart, axis, position, evaluationFunc);\n return items;\n }\n function getNearestItems(chart, position, axis, intersect, useFinalPosition, includeInvisible) {\n if (!includeInvisible && !chart.isPointInArea(position)) {\n return [];\n }\n return axis === 'r' && !intersect ? getNearestRadialItems(chart, position, axis, useFinalPosition) : getNearestCartesianItems(chart, position, axis, intersect, useFinalPosition, includeInvisible);\n }\n function getAxisItems(chart, position, axis, intersect, useFinalPosition) {\n var items = [];\n var rangeMethod = axis === 'x' ? 'inXRange' : 'inYRange';\n var intersectsItem = false;\n evaluateInteractionItems(chart, axis, position, function (element, datasetIndex, index) {\n if (element[rangeMethod](position[axis], useFinalPosition)) {\n items.push({\n element: element,\n datasetIndex: datasetIndex,\n index: index\n });\n intersectsItem = intersectsItem || element.inRange(position.x, position.y, useFinalPosition);\n }\n });\n if (intersect && !intersectsItem) {\n return [];\n }\n return items;\n }\n var Interaction = {\n evaluateInteractionItems: evaluateInteractionItems,\n modes: {\n index: function index(chart, e, options, useFinalPosition) {\n var position = getRelativePosition(e, chart);\n var axis = options.axis || 'x';\n var includeInvisible = options.includeInvisible || false;\n var items = options.intersect ? getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible) : getNearestItems(chart, position, axis, false, useFinalPosition, includeInvisible);\n var elements = [];\n if (!items.length) {\n return [];\n }\n chart.getSortedVisibleDatasetMetas().forEach(function (meta) {\n var index = items[0].index;\n var element = meta.data[index];\n if (element && !element.skip) {\n elements.push({\n element: element,\n datasetIndex: meta.index,\n index: index\n });\n }\n });\n return elements;\n },\n dataset: function dataset(chart, e, options, useFinalPosition) {\n var position = getRelativePosition(e, chart);\n var axis = options.axis || 'xy';\n var includeInvisible = options.includeInvisible || false;\n var items = options.intersect ? getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible) : getNearestItems(chart, position, axis, false, useFinalPosition, includeInvisible);\n if (items.length > 0) {\n var datasetIndex = items[0].datasetIndex;\n var data = chart.getDatasetMeta(datasetIndex).data;\n items = [];\n for (var i = 0; i < data.length; ++i) {\n items.push({\n element: data[i],\n datasetIndex: datasetIndex,\n index: i\n });\n }\n }\n return items;\n },\n point: function point(chart, e, options, useFinalPosition) {\n var position = getRelativePosition(e, chart);\n var axis = options.axis || 'xy';\n var includeInvisible = options.includeInvisible || false;\n return getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible);\n },\n nearest: function nearest(chart, e, options, useFinalPosition) {\n var position = getRelativePosition(e, chart);\n var axis = options.axis || 'xy';\n var includeInvisible = options.includeInvisible || false;\n return getNearestItems(chart, position, axis, options.intersect, useFinalPosition, includeInvisible);\n },\n x: function x(chart, e, options, useFinalPosition) {\n var position = getRelativePosition(e, chart);\n return getAxisItems(chart, position, 'x', options.intersect, useFinalPosition);\n },\n y: function y(chart, e, options, useFinalPosition) {\n var position = getRelativePosition(e, chart);\n return getAxisItems(chart, position, 'y', options.intersect, useFinalPosition);\n }\n }\n };\n var STATIC_POSITIONS = ['left', 'top', 'right', 'bottom'];\n function filterByPosition(array, position) {\n return array.filter(function (v) {\n return v.pos === position;\n });\n }\n function filterDynamicPositionByAxis(array, axis) {\n return array.filter(function (v) {\n return STATIC_POSITIONS.indexOf(v.pos) === -1 && v.box.axis === axis;\n });\n }\n function sortByWeight(array, reverse) {\n return array.sort(function (a, b) {\n var v0 = reverse ? b : a;\n var v1 = reverse ? a : b;\n return v0.weight === v1.weight ? v0.index - v1.index : v0.weight - v1.weight;\n });\n }\n function wrapBoxes(boxes) {\n var layoutBoxes = [];\n var i, ilen, box, pos, stack, stackWeight;\n for (i = 0, ilen = (boxes || []).length; i < ilen; ++i) {\n box = boxes[i];\n var _box = box;\n pos = _box.position;\n var _box$options = _box.options;\n stack = _box$options.stack;\n var _box$options$stackWei = _box$options.stackWeight;\n stackWeight = _box$options$stackWei === void 0 ? 1 : _box$options$stackWei;\n layoutBoxes.push({\n index: i,\n box: box,\n pos: pos,\n horizontal: box.isHorizontal(),\n weight: box.weight,\n stack: stack && pos + stack,\n stackWeight: stackWeight\n });\n }\n return layoutBoxes;\n }\n function buildStacks(layouts) {\n var stacks = {};\n var _iterator5 = _createForOfIteratorHelper$1(layouts),\n _step5;\n try {\n for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {\n var wrap = _step5.value;\n var stack = wrap.stack,\n pos = wrap.pos,\n stackWeight = wrap.stackWeight;\n if (!stack || !STATIC_POSITIONS.includes(pos)) {\n continue;\n }\n var _stack = stacks[stack] || (stacks[stack] = {\n count: 0,\n placed: 0,\n weight: 0,\n size: 0\n });\n _stack.count++;\n _stack.weight += stackWeight;\n }\n } catch (err) {\n _iterator5.e(err);\n } finally {\n _iterator5.f();\n }\n return stacks;\n }\n function setLayoutDims(layouts, params) {\n var stacks = buildStacks(layouts);\n var vBoxMaxWidth = params.vBoxMaxWidth,\n hBoxMaxHeight = params.hBoxMaxHeight;\n var i, ilen, layout;\n for (i = 0, ilen = layouts.length; i < ilen; ++i) {\n layout = layouts[i];\n var fullSize = layout.box.fullSize;\n var stack = stacks[layout.stack];\n var factor = stack && layout.stackWeight / stack.weight;\n if (layout.horizontal) {\n layout.width = factor ? factor * vBoxMaxWidth : fullSize && params.availableWidth;\n layout.height = hBoxMaxHeight;\n } else {\n layout.width = vBoxMaxWidth;\n layout.height = factor ? factor * hBoxMaxHeight : fullSize && params.availableHeight;\n }\n }\n return stacks;\n }\n function buildLayoutBoxes(boxes) {\n var layoutBoxes = wrapBoxes(boxes);\n var fullSize = sortByWeight(layoutBoxes.filter(function (wrap) {\n return wrap.box.fullSize;\n }), true);\n var left = sortByWeight(filterByPosition(layoutBoxes, 'left'), true);\n var right = sortByWeight(filterByPosition(layoutBoxes, 'right'));\n var top = sortByWeight(filterByPosition(layoutBoxes, 'top'), true);\n var bottom = sortByWeight(filterByPosition(layoutBoxes, 'bottom'));\n var centerHorizontal = filterDynamicPositionByAxis(layoutBoxes, 'x');\n var centerVertical = filterDynamicPositionByAxis(layoutBoxes, 'y');\n return {\n fullSize: fullSize,\n leftAndTop: left.concat(top),\n rightAndBottom: right.concat(centerVertical).concat(bottom).concat(centerHorizontal),\n chartArea: filterByPosition(layoutBoxes, 'chartArea'),\n vertical: left.concat(right).concat(centerVertical),\n horizontal: top.concat(bottom).concat(centerHorizontal)\n };\n }\n function getCombinedMax(maxPadding, chartArea, a, b) {\n return Math.max(maxPadding[a], chartArea[a]) + Math.max(maxPadding[b], chartArea[b]);\n }\n function updateMaxPadding(maxPadding, boxPadding) {\n maxPadding.top = Math.max(maxPadding.top, boxPadding.top);\n maxPadding.left = Math.max(maxPadding.left, boxPadding.left);\n maxPadding.bottom = Math.max(maxPadding.bottom, boxPadding.bottom);\n maxPadding.right = Math.max(maxPadding.right, boxPadding.right);\n }\n function updateDims(chartArea, params, layout, stacks) {\n var pos = layout.pos,\n box = layout.box;\n var maxPadding = chartArea.maxPadding;\n if (!isObject(pos)) {\n if (layout.size) {\n chartArea[pos] -= layout.size;\n }\n var stack = stacks[layout.stack] || {\n size: 0,\n count: 1\n };\n stack.size = Math.max(stack.size, layout.horizontal ? box.height : box.width);\n layout.size = stack.size / stack.count;\n chartArea[pos] += layout.size;\n }\n if (box.getPadding) {\n updateMaxPadding(maxPadding, box.getPadding());\n }\n var newWidth = Math.max(0, params.outerWidth - getCombinedMax(maxPadding, chartArea, 'left', 'right'));\n var newHeight = Math.max(0, params.outerHeight - getCombinedMax(maxPadding, chartArea, 'top', 'bottom'));\n var widthChanged = newWidth !== chartArea.w;\n var heightChanged = newHeight !== chartArea.h;\n chartArea.w = newWidth;\n chartArea.h = newHeight;\n return layout.horizontal ? {\n same: widthChanged,\n other: heightChanged\n } : {\n same: heightChanged,\n other: widthChanged\n };\n }\n function handleMaxPadding(chartArea) {\n var maxPadding = chartArea.maxPadding;\n function updatePos(pos) {\n var change = Math.max(maxPadding[pos] - chartArea[pos], 0);\n chartArea[pos] += change;\n return change;\n }\n chartArea.y += updatePos('top');\n chartArea.x += updatePos('left');\n updatePos('right');\n updatePos('bottom');\n }\n function getMargins(horizontal, chartArea) {\n var maxPadding = chartArea.maxPadding;\n function marginForPositions(positions) {\n var margin = {\n left: 0,\n top: 0,\n right: 0,\n bottom: 0\n };\n positions.forEach(function (pos) {\n margin[pos] = Math.max(chartArea[pos], maxPadding[pos]);\n });\n return margin;\n }\n return horizontal ? marginForPositions(['left', 'right']) : marginForPositions(['top', 'bottom']);\n }\n function fitBoxes(boxes, chartArea, params, stacks) {\n var refitBoxes = [];\n var i, ilen, layout, box, refit, changed;\n for (i = 0, ilen = boxes.length, refit = 0; i < ilen; ++i) {\n layout = boxes[i];\n box = layout.box;\n box.update(layout.width || chartArea.w, layout.height || chartArea.h, getMargins(layout.horizontal, chartArea));\n var _updateDims = updateDims(chartArea, params, layout, stacks),\n same = _updateDims.same,\n other = _updateDims.other;\n refit |= same && refitBoxes.length;\n changed = changed || other;\n if (!box.fullSize) {\n refitBoxes.push(layout);\n }\n }\n return refit && fitBoxes(refitBoxes, chartArea, params, stacks) || changed;\n }\n function setBoxDims(box, left, top, width, height) {\n box.top = top;\n box.left = left;\n box.right = left + width;\n box.bottom = top + height;\n box.width = width;\n box.height = height;\n }\n function placeBoxes(boxes, chartArea, params, stacks) {\n var userPadding = params.padding;\n var x = chartArea.x,\n y = chartArea.y;\n var _iterator6 = _createForOfIteratorHelper$1(boxes),\n _step6;\n try {\n for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {\n var layout = _step6.value;\n var box = layout.box;\n var stack = stacks[layout.stack] || {\n count: 1,\n placed: 0,\n weight: 1\n };\n var weight = layout.stackWeight / stack.weight || 1;\n if (layout.horizontal) {\n var width = chartArea.w * weight;\n var height = stack.size || box.height;\n if (defined(stack.start)) {\n y = stack.start;\n }\n if (box.fullSize) {\n setBoxDims(box, userPadding.left, y, params.outerWidth - userPadding.right - userPadding.left, height);\n } else {\n setBoxDims(box, chartArea.left + stack.placed, y, width, height);\n }\n stack.start = y;\n stack.placed += width;\n y = box.bottom;\n } else {\n var _height = chartArea.h * weight;\n var _width = stack.size || box.width;\n if (defined(stack.start)) {\n x = stack.start;\n }\n if (box.fullSize) {\n setBoxDims(box, x, userPadding.top, _width, params.outerHeight - userPadding.bottom - userPadding.top);\n } else {\n setBoxDims(box, x, chartArea.top + stack.placed, _width, _height);\n }\n stack.start = x;\n stack.placed += _height;\n x = box.right;\n }\n }\n } catch (err) {\n _iterator6.e(err);\n } finally {\n _iterator6.f();\n }\n chartArea.x = x;\n chartArea.y = y;\n }\n var layouts = {\n addBox: function addBox(chart, item) {\n if (!chart.boxes) {\n chart.boxes = [];\n }\n item.fullSize = item.fullSize || false;\n item.position = item.position || 'top';\n item.weight = item.weight || 0;\n item._layers = item._layers || function () {\n return [{\n z: 0,\n draw: function draw(chartArea) {\n item.draw(chartArea);\n }\n }];\n };\n chart.boxes.push(item);\n },\n removeBox: function removeBox(chart, layoutItem) {\n var index = chart.boxes ? chart.boxes.indexOf(layoutItem) : -1;\n if (index !== -1) {\n chart.boxes.splice(index, 1);\n }\n },\n configure: function configure(chart, item, options) {\n item.fullSize = options.fullSize;\n item.position = options.position;\n item.weight = options.weight;\n },\n update: function update(chart, width, height, minPadding) {\n if (!chart) {\n return;\n }\n var padding = toPadding(chart.options.layout.padding);\n var availableWidth = Math.max(width - padding.width, 0);\n var availableHeight = Math.max(height - padding.height, 0);\n var boxes = buildLayoutBoxes(chart.boxes);\n var verticalBoxes = boxes.vertical;\n var horizontalBoxes = boxes.horizontal;\n each(chart.boxes, function (box) {\n if (typeof box.beforeLayout === 'function') {\n box.beforeLayout();\n }\n });\n var visibleVerticalBoxCount = verticalBoxes.reduce(function (total, wrap) {\n return wrap.box.options && wrap.box.options.display === false ? total : total + 1;\n }, 0) || 1;\n var params = Object.freeze({\n outerWidth: width,\n outerHeight: height,\n padding: padding,\n availableWidth: availableWidth,\n availableHeight: availableHeight,\n vBoxMaxWidth: availableWidth / 2 / visibleVerticalBoxCount,\n hBoxMaxHeight: availableHeight / 2\n });\n var maxPadding = Object.assign({}, padding);\n updateMaxPadding(maxPadding, toPadding(minPadding));\n var chartArea = Object.assign({\n maxPadding: maxPadding,\n w: availableWidth,\n h: availableHeight,\n x: padding.left,\n y: padding.top\n }, padding);\n var stacks = setLayoutDims(verticalBoxes.concat(horizontalBoxes), params);\n fitBoxes(boxes.fullSize, chartArea, params, stacks);\n fitBoxes(verticalBoxes, chartArea, params, stacks);\n if (fitBoxes(horizontalBoxes, chartArea, params, stacks)) {\n fitBoxes(verticalBoxes, chartArea, params, stacks);\n }\n handleMaxPadding(chartArea);\n placeBoxes(boxes.leftAndTop, chartArea, params, stacks);\n chartArea.x += chartArea.w;\n chartArea.y += chartArea.h;\n placeBoxes(boxes.rightAndBottom, chartArea, params, stacks);\n chart.chartArea = {\n left: chartArea.left,\n top: chartArea.top,\n right: chartArea.left + chartArea.w,\n bottom: chartArea.top + chartArea.h,\n height: chartArea.h,\n width: chartArea.w\n };\n each(boxes.chartArea, function (layout) {\n var box = layout.box;\n Object.assign(box, chart.chartArea);\n box.update(chartArea.w, chartArea.h, {\n left: 0,\n top: 0,\n right: 0,\n bottom: 0\n });\n });\n }\n };\n var BasePlatform = /*#__PURE__*/function () {\n function BasePlatform() {\n _classCallCheck$1(this, BasePlatform);\n }\n _createClass$1(BasePlatform, [{\n key: \"acquireContext\",\n value: function acquireContext(canvas, aspectRatio) {}\n }, {\n key: \"releaseContext\",\n value: function releaseContext(context) {\n return false;\n }\n }, {\n key: \"addEventListener\",\n value: function addEventListener(chart, type, listener) {}\n }, {\n key: \"removeEventListener\",\n value: function removeEventListener(chart, type, listener) {}\n }, {\n key: \"getDevicePixelRatio\",\n value: function getDevicePixelRatio() {\n return 1;\n }\n }, {\n key: \"getMaximumSize\",\n value: function getMaximumSize(element, width, height, aspectRatio) {\n width = Math.max(0, width || element.width);\n height = height || element.height;\n return {\n width: width,\n height: Math.max(0, aspectRatio ? Math.floor(width / aspectRatio) : height)\n };\n }\n }, {\n key: \"isAttached\",\n value: function isAttached(canvas) {\n return true;\n }\n }, {\n key: \"updateConfig\",\n value: function updateConfig(config) {}\n }]);\n return BasePlatform;\n }();\n var BasicPlatform = /*#__PURE__*/function (_BasePlatform) {\n _inherits$1(BasicPlatform, _BasePlatform);\n var _super9 = _createSuper$1(BasicPlatform);\n function BasicPlatform() {\n _classCallCheck$1(this, BasicPlatform);\n return _super9.apply(this, arguments);\n }\n _createClass$1(BasicPlatform, [{\n key: \"acquireContext\",\n value: function acquireContext(item) {\n return item && item.getContext && item.getContext('2d') || null;\n }\n }, {\n key: \"updateConfig\",\n value: function updateConfig(config) {\n config.options.animation = false;\n }\n }]);\n return BasicPlatform;\n }(BasePlatform);\n var EXPANDO_KEY = '$chartjs';\n var EVENT_TYPES = {\n touchstart: 'mousedown',\n touchmove: 'mousemove',\n touchend: 'mouseup',\n pointerenter: 'mouseenter',\n pointerdown: 'mousedown',\n pointermove: 'mousemove',\n pointerup: 'mouseup',\n pointerleave: 'mouseout',\n pointerout: 'mouseout'\n };\n var isNullOrEmpty = function isNullOrEmpty(value) {\n return value === null || value === '';\n };\n function initCanvas(canvas, aspectRatio) {\n var style = canvas.style;\n var renderHeight = canvas.getAttribute('height');\n var renderWidth = canvas.getAttribute('width');\n canvas[EXPANDO_KEY] = {\n initial: {\n height: renderHeight,\n width: renderWidth,\n style: {\n display: style.display,\n height: style.height,\n width: style.width\n }\n }\n };\n style.display = style.display || 'block';\n style.boxSizing = style.boxSizing || 'border-box';\n if (isNullOrEmpty(renderWidth)) {\n var displayWidth = readUsedSize(canvas, 'width');\n if (displayWidth !== undefined) {\n canvas.width = displayWidth;\n }\n }\n if (isNullOrEmpty(renderHeight)) {\n if (canvas.style.height === '') {\n canvas.height = canvas.width / (aspectRatio || 2);\n } else {\n var displayHeight = readUsedSize(canvas, 'height');\n if (displayHeight !== undefined) {\n canvas.height = displayHeight;\n }\n }\n }\n return canvas;\n }\n var eventListenerOptions = supportsEventListenerOptions ? {\n passive: true\n } : false;\n function addListener(node, type, listener) {\n node.addEventListener(type, listener, eventListenerOptions);\n }\n function removeListener(chart, type, listener) {\n chart.canvas.removeEventListener(type, listener, eventListenerOptions);\n }\n function fromNativeEvent(event, chart) {\n var type = EVENT_TYPES[event.type] || event.type;\n var _getRelativePosition = getRelativePosition(event, chart),\n x = _getRelativePosition.x,\n y = _getRelativePosition.y;\n return {\n type: type,\n chart: chart,\n \"native\": event,\n x: x !== undefined ? x : null,\n y: y !== undefined ? y : null\n };\n }\n function nodeListContains(nodeList, canvas) {\n var _iterator7 = _createForOfIteratorHelper$1(nodeList),\n _step7;\n try {\n for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {\n var node = _step7.value;\n if (node === canvas || node.contains(canvas)) {\n return true;\n }\n }\n } catch (err) {\n _iterator7.e(err);\n } finally {\n _iterator7.f();\n }\n }\n function createAttachObserver(chart, type, listener) {\n var canvas = chart.canvas;\n var observer = new MutationObserver(function (entries) {\n var trigger = false;\n var _iterator8 = _createForOfIteratorHelper$1(entries),\n _step8;\n try {\n for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {\n var entry = _step8.value;\n trigger = trigger || nodeListContains(entry.addedNodes, canvas);\n trigger = trigger && !nodeListContains(entry.removedNodes, canvas);\n }\n } catch (err) {\n _iterator8.e(err);\n } finally {\n _iterator8.f();\n }\n if (trigger) {\n listener();\n }\n });\n observer.observe(document, {\n childList: true,\n subtree: true\n });\n return observer;\n }\n function createDetachObserver(chart, type, listener) {\n var canvas = chart.canvas;\n var observer = new MutationObserver(function (entries) {\n var trigger = false;\n var _iterator9 = _createForOfIteratorHelper$1(entries),\n _step9;\n try {\n for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {\n var entry = _step9.value;\n trigger = trigger || nodeListContains(entry.removedNodes, canvas);\n trigger = trigger && !nodeListContains(entry.addedNodes, canvas);\n }\n } catch (err) {\n _iterator9.e(err);\n } finally {\n _iterator9.f();\n }\n if (trigger) {\n listener();\n }\n });\n observer.observe(document, {\n childList: true,\n subtree: true\n });\n return observer;\n }\n var drpListeningCharts = new Map();\n var oldDevicePixelRatio = 0;\n function onWindowResize() {\n var dpr = window.devicePixelRatio;\n if (dpr === oldDevicePixelRatio) {\n return;\n }\n oldDevicePixelRatio = dpr;\n drpListeningCharts.forEach(function (resize, chart) {\n if (chart.currentDevicePixelRatio !== dpr) {\n resize();\n }\n });\n }\n function listenDevicePixelRatioChanges(chart, resize) {\n if (!drpListeningCharts.size) {\n window.addEventListener('resize', onWindowResize);\n }\n drpListeningCharts.set(chart, resize);\n }\n function unlistenDevicePixelRatioChanges(chart) {\n drpListeningCharts[\"delete\"](chart);\n if (!drpListeningCharts.size) {\n window.removeEventListener('resize', onWindowResize);\n }\n }\n function createResizeObserver(chart, type, listener) {\n var canvas = chart.canvas;\n var container = canvas && _getParentNode(canvas);\n if (!container) {\n return;\n }\n var resize = throttled(function (width, height) {\n var w = container.clientWidth;\n listener(width, height);\n if (w < container.clientWidth) {\n listener();\n }\n }, window);\n var observer = new ResizeObserver(function (entries) {\n var entry = entries[0];\n var width = entry.contentRect.width;\n var height = entry.contentRect.height;\n if (width === 0 && height === 0) {\n return;\n }\n resize(width, height);\n });\n observer.observe(container);\n listenDevicePixelRatioChanges(chart, resize);\n return observer;\n }\n function releaseObserver(chart, type, observer) {\n if (observer) {\n observer.disconnect();\n }\n if (type === 'resize') {\n unlistenDevicePixelRatioChanges(chart);\n }\n }\n function createProxyAndListen(chart, type, listener) {\n var canvas = chart.canvas;\n var proxy = throttled(function (event) {\n if (chart.ctx !== null) {\n listener(fromNativeEvent(event, chart));\n }\n }, chart);\n addListener(canvas, type, proxy);\n return proxy;\n }\n var DomPlatform = /*#__PURE__*/function (_BasePlatform2) {\n _inherits$1(DomPlatform, _BasePlatform2);\n var _super10 = _createSuper$1(DomPlatform);\n function DomPlatform() {\n _classCallCheck$1(this, DomPlatform);\n return _super10.apply(this, arguments);\n }\n _createClass$1(DomPlatform, [{\n key: \"acquireContext\",\n value: function acquireContext(canvas, aspectRatio) {\n var context = canvas && canvas.getContext && canvas.getContext('2d');\n if (context && context.canvas === canvas) {\n initCanvas(canvas, aspectRatio);\n return context;\n }\n return null;\n }\n }, {\n key: \"releaseContext\",\n value: function releaseContext(context) {\n var canvas = context.canvas;\n if (!canvas[EXPANDO_KEY]) {\n return false;\n }\n var initial = canvas[EXPANDO_KEY].initial;\n ['height', 'width'].forEach(function (prop) {\n var value = initial[prop];\n if (isNullOrUndef(value)) {\n canvas.removeAttribute(prop);\n } else {\n canvas.setAttribute(prop, value);\n }\n });\n var style = initial.style || {};\n Object.keys(style).forEach(function (key) {\n canvas.style[key] = style[key];\n });\n canvas.width = canvas.width;\n delete canvas[EXPANDO_KEY];\n return true;\n }\n }, {\n key: \"addEventListener\",\n value: function addEventListener(chart, type, listener) {\n this.removeEventListener(chart, type);\n var proxies = chart.$proxies || (chart.$proxies = {});\n var handlers = {\n attach: createAttachObserver,\n detach: createDetachObserver,\n resize: createResizeObserver\n };\n var handler = handlers[type] || createProxyAndListen;\n proxies[type] = handler(chart, type, listener);\n }\n }, {\n key: \"removeEventListener\",\n value: function removeEventListener(chart, type) {\n var proxies = chart.$proxies || (chart.$proxies = {});\n var proxy = proxies[type];\n if (!proxy) {\n return;\n }\n var handlers = {\n attach: releaseObserver,\n detach: releaseObserver,\n resize: releaseObserver\n };\n var handler = handlers[type] || removeListener;\n handler(chart, type, proxy);\n proxies[type] = undefined;\n }\n }, {\n key: \"getDevicePixelRatio\",\n value: function getDevicePixelRatio() {\n return window.devicePixelRatio;\n }\n }, {\n key: \"getMaximumSize\",\n value: function getMaximumSize$1(canvas, width, height, aspectRatio) {\n return getMaximumSize(canvas, width, height, aspectRatio);\n }\n }, {\n key: \"isAttached\",\n value: function isAttached(canvas) {\n var container = _getParentNode(canvas);\n return !!(container && container.isConnected);\n }\n }]);\n return DomPlatform;\n }(BasePlatform);\n function _detectPlatform(canvas) {\n if (!_isDomSupported() || typeof OffscreenCanvas !== 'undefined' && canvas instanceof OffscreenCanvas) {\n return BasicPlatform;\n }\n return DomPlatform;\n }\n var Element = /*#__PURE__*/function () {\n function Element() {\n _classCallCheck$1(this, Element);\n _defineProperty$1(this, \"x\", void 0);\n _defineProperty$1(this, \"y\", void 0);\n _defineProperty$1(this, \"active\", false);\n _defineProperty$1(this, \"options\", void 0);\n _defineProperty$1(this, \"$animations\", void 0);\n }\n _createClass$1(Element, [{\n key: \"tooltipPosition\",\n value: function tooltipPosition(useFinalPosition) {\n var _this$getProps = this.getProps(['x', 'y'], useFinalPosition),\n x = _this$getProps.x,\n y = _this$getProps.y;\n return {\n x: x,\n y: y\n };\n }\n }, {\n key: \"hasValue\",\n value: function hasValue() {\n return isNumber(this.x) && isNumber(this.y);\n }\n }, {\n key: \"getProps\",\n value: function getProps(props, _final) {\n var _this8 = this;\n var anims = this.$animations;\n if (!_final || !anims) {\n // let's not create an object, if not needed\n return this;\n }\n var ret = {};\n props.forEach(function (prop) {\n ret[prop] = anims[prop] && anims[prop].active() ? anims[prop]._to : _this8[prop];\n });\n return ret;\n }\n }]);\n return Element;\n }();\n _defineProperty$1(Element, \"defaults\", {});\n _defineProperty$1(Element, \"defaultRoutes\", undefined);\n function autoSkip(scale, ticks) {\n var tickOpts = scale.options.ticks;\n var determinedMaxTicks = determineMaxTicks(scale);\n var ticksLimit = Math.min(tickOpts.maxTicksLimit || determinedMaxTicks, determinedMaxTicks);\n var majorIndices = tickOpts.major.enabled ? getMajorIndices(ticks) : [];\n var numMajorIndices = majorIndices.length;\n var first = majorIndices[0];\n var last = majorIndices[numMajorIndices - 1];\n var newTicks = [];\n if (numMajorIndices > ticksLimit) {\n skipMajors(ticks, newTicks, majorIndices, numMajorIndices / ticksLimit);\n return newTicks;\n }\n var spacing = calculateSpacing(majorIndices, ticks, ticksLimit);\n if (numMajorIndices > 0) {\n var i, ilen;\n var avgMajorSpacing = numMajorIndices > 1 ? Math.round((last - first) / (numMajorIndices - 1)) : null;\n skip(ticks, newTicks, spacing, isNullOrUndef(avgMajorSpacing) ? 0 : first - avgMajorSpacing, first);\n for (i = 0, ilen = numMajorIndices - 1; i < ilen; i++) {\n skip(ticks, newTicks, spacing, majorIndices[i], majorIndices[i + 1]);\n }\n skip(ticks, newTicks, spacing, last, isNullOrUndef(avgMajorSpacing) ? ticks.length : last + avgMajorSpacing);\n return newTicks;\n }\n skip(ticks, newTicks, spacing);\n return newTicks;\n }\n function determineMaxTicks(scale) {\n var offset = scale.options.offset;\n var tickLength = scale._tickSize();\n var maxScale = scale._length / tickLength + (offset ? 0 : 1);\n var maxChart = scale._maxLength / tickLength;\n return Math.floor(Math.min(maxScale, maxChart));\n }\n function calculateSpacing(majorIndices, ticks, ticksLimit) {\n var evenMajorSpacing = getEvenSpacing(majorIndices);\n var spacing = ticks.length / ticksLimit;\n if (!evenMajorSpacing) {\n return Math.max(spacing, 1);\n }\n var factors = _factorize(evenMajorSpacing);\n for (var i = 0, ilen = factors.length - 1; i < ilen; i++) {\n var factor = factors[i];\n if (factor > spacing) {\n return factor;\n }\n }\n return Math.max(spacing, 1);\n }\n function getMajorIndices(ticks) {\n var result = [];\n var i, ilen;\n for (i = 0, ilen = ticks.length; i < ilen; i++) {\n if (ticks[i].major) {\n result.push(i);\n }\n }\n return result;\n }\n function skipMajors(ticks, newTicks, majorIndices, spacing) {\n var count = 0;\n var next = majorIndices[0];\n var i;\n spacing = Math.ceil(spacing);\n for (i = 0; i < ticks.length; i++) {\n if (i === next) {\n newTicks.push(ticks[i]);\n count++;\n next = majorIndices[count * spacing];\n }\n }\n }\n function skip(ticks, newTicks, spacing, majorStart, majorEnd) {\n var start = valueOrDefault(majorStart, 0);\n var end = Math.min(valueOrDefault(majorEnd, ticks.length), ticks.length);\n var count = 0;\n var length, i, next;\n spacing = Math.ceil(spacing);\n if (majorEnd) {\n length = majorEnd - majorStart;\n spacing = length / Math.floor(length / spacing);\n }\n next = start;\n while (next < 0) {\n count++;\n next = Math.round(start + count * spacing);\n }\n for (i = Math.max(start, 0); i < end; i++) {\n if (i === next) {\n newTicks.push(ticks[i]);\n count++;\n next = Math.round(start + count * spacing);\n }\n }\n }\n function getEvenSpacing(arr) {\n var len = arr.length;\n var i, diff;\n if (len < 2) {\n return false;\n }\n for (diff = arr[0], i = 1; i < len; ++i) {\n if (arr[i] - arr[i - 1] !== diff) {\n return false;\n }\n }\n return diff;\n }\n var reverseAlign = function reverseAlign(align) {\n return align === 'left' ? 'right' : align === 'right' ? 'left' : align;\n };\n var offsetFromEdge = function offsetFromEdge(scale, edge, offset) {\n return edge === 'top' || edge === 'left' ? scale[edge] + offset : scale[edge] - offset;\n };\n var getTicksLimit = function getTicksLimit(ticksLength, maxTicksLimit) {\n return Math.min(maxTicksLimit || ticksLength, ticksLength);\n };\n function sample(arr, numItems) {\n var result = [];\n var increment = arr.length / numItems;\n var len = arr.length;\n var i = 0;\n for (; i < len; i += increment) {\n result.push(arr[Math.floor(i)]);\n }\n return result;\n }\n function getPixelForGridLine(scale, index, offsetGridLines) {\n var length = scale.ticks.length;\n var validIndex = Math.min(index, length - 1);\n var start = scale._startPixel;\n var end = scale._endPixel;\n var epsilon = 1e-6;\n var lineValue = scale.getPixelForTick(validIndex);\n var offset;\n if (offsetGridLines) {\n if (length === 1) {\n offset = Math.max(lineValue - start, end - lineValue);\n } else if (index === 0) {\n offset = (scale.getPixelForTick(1) - lineValue) / 2;\n } else {\n offset = (lineValue - scale.getPixelForTick(validIndex - 1)) / 2;\n }\n lineValue += validIndex < index ? offset : -offset;\n if (lineValue < start - epsilon || lineValue > end + epsilon) {\n return;\n }\n }\n return lineValue;\n }\n function garbageCollect(caches, length) {\n each(caches, function (cache) {\n var gc = cache.gc;\n var gcLen = gc.length / 2;\n var i;\n if (gcLen > length) {\n for (i = 0; i < gcLen; ++i) {\n delete cache.data[gc[i]];\n }\n gc.splice(0, gcLen);\n }\n });\n }\n function getTickMarkLength(options) {\n return options.drawTicks ? options.tickLength : 0;\n }\n function getTitleHeight(options, fallback) {\n if (!options.display) {\n return 0;\n }\n var font = toFont(options.font, fallback);\n var padding = toPadding(options.padding);\n var lines = isArray(options.text) ? options.text.length : 1;\n return lines * font.lineHeight + padding.height;\n }\n function createScaleContext(parent, scale) {\n return createContext(parent, {\n scale: scale,\n type: 'scale'\n });\n }\n function createTickContext(parent, index, tick) {\n return createContext(parent, {\n tick: tick,\n index: index,\n type: 'tick'\n });\n }\n function titleAlign(align, position, reverse) {\n var ret = _toLeftRightCenter(align);\n if (reverse && position !== 'right' || !reverse && position === 'right') {\n ret = reverseAlign(ret);\n }\n return ret;\n }\n function titleArgs(scale, offset, position, align) {\n var top = scale.top,\n left = scale.left,\n bottom = scale.bottom,\n right = scale.right,\n chart = scale.chart;\n var chartArea = chart.chartArea,\n scales = chart.scales;\n var rotation = 0;\n var maxWidth, titleX, titleY;\n var height = bottom - top;\n var width = right - left;\n if (scale.isHorizontal()) {\n titleX = _alignStartEnd(align, left, right);\n if (isObject(position)) {\n var positionAxisID = Object.keys(position)[0];\n var value = position[positionAxisID];\n titleY = scales[positionAxisID].getPixelForValue(value) + height - offset;\n } else if (position === 'center') {\n titleY = (chartArea.bottom + chartArea.top) / 2 + height - offset;\n } else {\n titleY = offsetFromEdge(scale, position, offset);\n }\n maxWidth = right - left;\n } else {\n if (isObject(position)) {\n var _positionAxisID = Object.keys(position)[0];\n var _value = position[_positionAxisID];\n titleX = scales[_positionAxisID].getPixelForValue(_value) - width + offset;\n } else if (position === 'center') {\n titleX = (chartArea.left + chartArea.right) / 2 - width + offset;\n } else {\n titleX = offsetFromEdge(scale, position, offset);\n }\n titleY = _alignStartEnd(align, bottom, top);\n rotation = position === 'left' ? -HALF_PI : HALF_PI;\n }\n return {\n titleX: titleX,\n titleY: titleY,\n maxWidth: maxWidth,\n rotation: rotation\n };\n }\n var Scale = /*#__PURE__*/function (_Element) {\n _inherits$1(Scale, _Element);\n var _super11 = _createSuper$1(Scale);\n function Scale(cfg) {\n var _this9;\n _classCallCheck$1(this, Scale);\n _this9 = _super11.call(this);\n _this9.id = cfg.id;\n _this9.type = cfg.type;\n _this9.options = undefined;\n _this9.ctx = cfg.ctx;\n _this9.chart = cfg.chart;\n _this9.top = undefined;\n _this9.bottom = undefined;\n _this9.left = undefined;\n _this9.right = undefined;\n _this9.width = undefined;\n _this9.height = undefined;\n _this9._margins = {\n left: 0,\n right: 0,\n top: 0,\n bottom: 0\n };\n _this9.maxWidth = undefined;\n _this9.maxHeight = undefined;\n _this9.paddingTop = undefined;\n _this9.paddingBottom = undefined;\n _this9.paddingLeft = undefined;\n _this9.paddingRight = undefined;\n _this9.axis = undefined;\n _this9.labelRotation = undefined;\n _this9.min = undefined;\n _this9.max = undefined;\n _this9._range = undefined;\n _this9.ticks = [];\n _this9._gridLineItems = null;\n _this9._labelItems = null;\n _this9._labelSizes = null;\n _this9._length = 0;\n _this9._maxLength = 0;\n _this9._longestTextCache = {};\n _this9._startPixel = undefined;\n _this9._endPixel = undefined;\n _this9._reversePixels = false;\n _this9._userMax = undefined;\n _this9._userMin = undefined;\n _this9._suggestedMax = undefined;\n _this9._suggestedMin = undefined;\n _this9._ticksLength = 0;\n _this9._borderValue = 0;\n _this9._cache = {};\n _this9._dataLimitsCached = false;\n _this9.$context = undefined;\n return _this9;\n }\n _createClass$1(Scale, [{\n key: \"init\",\n value: function init(options) {\n this.options = options.setContext(this.getContext());\n this.axis = options.axis;\n this._userMin = this.parse(options.min);\n this._userMax = this.parse(options.max);\n this._suggestedMin = this.parse(options.suggestedMin);\n this._suggestedMax = this.parse(options.suggestedMax);\n }\n }, {\n key: \"parse\",\n value: function parse(raw, index) {\n return raw;\n }\n }, {\n key: \"getUserBounds\",\n value: function getUserBounds() {\n var _userMin = this._userMin,\n _userMax = this._userMax,\n _suggestedMin = this._suggestedMin,\n _suggestedMax = this._suggestedMax;\n _userMin = finiteOrDefault(_userMin, Number.POSITIVE_INFINITY);\n _userMax = finiteOrDefault(_userMax, Number.NEGATIVE_INFINITY);\n _suggestedMin = finiteOrDefault(_suggestedMin, Number.POSITIVE_INFINITY);\n _suggestedMax = finiteOrDefault(_suggestedMax, Number.NEGATIVE_INFINITY);\n return {\n min: finiteOrDefault(_userMin, _suggestedMin),\n max: finiteOrDefault(_userMax, _suggestedMax),\n minDefined: isNumberFinite(_userMin),\n maxDefined: isNumberFinite(_userMax)\n };\n }\n }, {\n key: \"getMinMax\",\n value: function getMinMax(canStack) {\n var _this$getUserBounds = this.getUserBounds(),\n min = _this$getUserBounds.min,\n max = _this$getUserBounds.max,\n minDefined = _this$getUserBounds.minDefined,\n maxDefined = _this$getUserBounds.maxDefined;\n var range;\n if (minDefined && maxDefined) {\n return {\n min: min,\n max: max\n };\n }\n var metas = this.getMatchingVisibleMetas();\n for (var i = 0, ilen = metas.length; i < ilen; ++i) {\n range = metas[i].controller.getMinMax(this, canStack);\n if (!minDefined) {\n min = Math.min(min, range.min);\n }\n if (!maxDefined) {\n max = Math.max(max, range.max);\n }\n }\n min = maxDefined && min > max ? max : min;\n max = minDefined && min > max ? min : max;\n return {\n min: finiteOrDefault(min, finiteOrDefault(max, min)),\n max: finiteOrDefault(max, finiteOrDefault(min, max))\n };\n }\n }, {\n key: \"getPadding\",\n value: function getPadding() {\n return {\n left: this.paddingLeft || 0,\n top: this.paddingTop || 0,\n right: this.paddingRight || 0,\n bottom: this.paddingBottom || 0\n };\n }\n }, {\n key: \"getTicks\",\n value: function getTicks() {\n return this.ticks;\n }\n }, {\n key: \"getLabels\",\n value: function getLabels() {\n var data = this.chart.data;\n return this.options.labels || (this.isHorizontal() ? data.xLabels : data.yLabels) || data.labels || [];\n }\n }, {\n key: \"getLabelItems\",\n value: function getLabelItems() {\n var chartArea = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.chart.chartArea;\n var items = this._labelItems || (this._labelItems = this._computeLabelItems(chartArea));\n return items;\n }\n }, {\n key: \"beforeLayout\",\n value: function beforeLayout() {\n this._cache = {};\n this._dataLimitsCached = false;\n }\n }, {\n key: \"beforeUpdate\",\n value: function beforeUpdate() {\n callback(this.options.beforeUpdate, [this]);\n }\n }, {\n key: \"update\",\n value: function update(maxWidth, maxHeight, margins) {\n var _this$options4 = this.options,\n beginAtZero = _this$options4.beginAtZero,\n grace = _this$options4.grace,\n tickOpts = _this$options4.ticks;\n var sampleSize = tickOpts.sampleSize;\n this.beforeUpdate();\n this.maxWidth = maxWidth;\n this.maxHeight = maxHeight;\n this._margins = margins = Object.assign({\n left: 0,\n right: 0,\n top: 0,\n bottom: 0\n }, margins);\n this.ticks = null;\n this._labelSizes = null;\n this._gridLineItems = null;\n this._labelItems = null;\n this.beforeSetDimensions();\n this.setDimensions();\n this.afterSetDimensions();\n this._maxLength = this.isHorizontal() ? this.width + margins.left + margins.right : this.height + margins.top + margins.bottom;\n if (!this._dataLimitsCached) {\n this.beforeDataLimits();\n this.determineDataLimits();\n this.afterDataLimits();\n this._range = _addGrace(this, grace, beginAtZero);\n this._dataLimitsCached = true;\n }\n this.beforeBuildTicks();\n this.ticks = this.buildTicks() || [];\n this.afterBuildTicks();\n var samplingEnabled = sampleSize < this.ticks.length;\n this._convertTicksToLabels(samplingEnabled ? sample(this.ticks, sampleSize) : this.ticks);\n this.configure();\n this.beforeCalculateLabelRotation();\n this.calculateLabelRotation();\n this.afterCalculateLabelRotation();\n if (tickOpts.display && (tickOpts.autoSkip || tickOpts.source === 'auto')) {\n this.ticks = autoSkip(this, this.ticks);\n this._labelSizes = null;\n this.afterAutoSkip();\n }\n if (samplingEnabled) {\n this._convertTicksToLabels(this.ticks);\n }\n this.beforeFit();\n this.fit();\n this.afterFit();\n this.afterUpdate();\n }\n }, {\n key: \"configure\",\n value: function configure() {\n var reversePixels = this.options.reverse;\n var startPixel, endPixel;\n if (this.isHorizontal()) {\n startPixel = this.left;\n endPixel = this.right;\n } else {\n startPixel = this.top;\n endPixel = this.bottom;\n reversePixels = !reversePixels;\n }\n this._startPixel = startPixel;\n this._endPixel = endPixel;\n this._reversePixels = reversePixels;\n this._length = endPixel - startPixel;\n this._alignToPixels = this.options.alignToPixels;\n }\n }, {\n key: \"afterUpdate\",\n value: function afterUpdate() {\n callback(this.options.afterUpdate, [this]);\n }\n }, {\n key: \"beforeSetDimensions\",\n value: function beforeSetDimensions() {\n callback(this.options.beforeSetDimensions, [this]);\n }\n }, {\n key: \"setDimensions\",\n value: function setDimensions() {\n if (this.isHorizontal()) {\n this.width = this.maxWidth;\n this.left = 0;\n this.right = this.width;\n } else {\n this.height = this.maxHeight;\n this.top = 0;\n this.bottom = this.height;\n }\n this.paddingLeft = 0;\n this.paddingTop = 0;\n this.paddingRight = 0;\n this.paddingBottom = 0;\n }\n }, {\n key: \"afterSetDimensions\",\n value: function afterSetDimensions() {\n callback(this.options.afterSetDimensions, [this]);\n }\n }, {\n key: \"_callHooks\",\n value: function _callHooks(name) {\n this.chart.notifyPlugins(name, this.getContext());\n callback(this.options[name], [this]);\n }\n }, {\n key: \"beforeDataLimits\",\n value: function beforeDataLimits() {\n this._callHooks('beforeDataLimits');\n }\n }, {\n key: \"determineDataLimits\",\n value: function determineDataLimits() {}\n }, {\n key: \"afterDataLimits\",\n value: function afterDataLimits() {\n this._callHooks('afterDataLimits');\n }\n }, {\n key: \"beforeBuildTicks\",\n value: function beforeBuildTicks() {\n this._callHooks('beforeBuildTicks');\n }\n }, {\n key: \"buildTicks\",\n value: function buildTicks() {\n return [];\n }\n }, {\n key: \"afterBuildTicks\",\n value: function afterBuildTicks() {\n this._callHooks('afterBuildTicks');\n }\n }, {\n key: \"beforeTickToLabelConversion\",\n value: function beforeTickToLabelConversion() {\n callback(this.options.beforeTickToLabelConversion, [this]);\n }\n }, {\n key: \"generateTickLabels\",\n value: function generateTickLabels(ticks) {\n var tickOpts = this.options.ticks;\n var i, ilen, tick;\n for (i = 0, ilen = ticks.length; i < ilen; i++) {\n tick = ticks[i];\n tick.label = callback(tickOpts.callback, [tick.value, i, ticks], this);\n }\n }\n }, {\n key: \"afterTickToLabelConversion\",\n value: function afterTickToLabelConversion() {\n callback(this.options.afterTickToLabelConversion, [this]);\n }\n }, {\n key: \"beforeCalculateLabelRotation\",\n value: function beforeCalculateLabelRotation() {\n callback(this.options.beforeCalculateLabelRotation, [this]);\n }\n }, {\n key: \"calculateLabelRotation\",\n value: function calculateLabelRotation() {\n var options = this.options;\n var tickOpts = options.ticks;\n var numTicks = getTicksLimit(this.ticks.length, options.ticks.maxTicksLimit);\n var minRotation = tickOpts.minRotation || 0;\n var maxRotation = tickOpts.maxRotation;\n var labelRotation = minRotation;\n var tickWidth, maxHeight, maxLabelDiagonal;\n if (!this._isVisible() || !tickOpts.display || minRotation >= maxRotation || numTicks <= 1 || !this.isHorizontal()) {\n this.labelRotation = minRotation;\n return;\n }\n var labelSizes = this._getLabelSizes();\n var maxLabelWidth = labelSizes.widest.width;\n var maxLabelHeight = labelSizes.highest.height;\n var maxWidth = _limitValue(this.chart.width - maxLabelWidth, 0, this.maxWidth);\n tickWidth = options.offset ? this.maxWidth / numTicks : maxWidth / (numTicks - 1);\n if (maxLabelWidth + 6 > tickWidth) {\n tickWidth = maxWidth / (numTicks - (options.offset ? 0.5 : 1));\n maxHeight = this.maxHeight - getTickMarkLength(options.grid) - tickOpts.padding - getTitleHeight(options.title, this.chart.options.font);\n maxLabelDiagonal = Math.sqrt(maxLabelWidth * maxLabelWidth + maxLabelHeight * maxLabelHeight);\n labelRotation = toDegrees(Math.min(Math.asin(_limitValue((labelSizes.highest.height + 6) / tickWidth, -1, 1)), Math.asin(_limitValue(maxHeight / maxLabelDiagonal, -1, 1)) - Math.asin(_limitValue(maxLabelHeight / maxLabelDiagonal, -1, 1))));\n labelRotation = Math.max(minRotation, Math.min(maxRotation, labelRotation));\n }\n this.labelRotation = labelRotation;\n }\n }, {\n key: \"afterCalculateLabelRotation\",\n value: function afterCalculateLabelRotation() {\n callback(this.options.afterCalculateLabelRotation, [this]);\n }\n }, {\n key: \"afterAutoSkip\",\n value: function afterAutoSkip() {}\n }, {\n key: \"beforeFit\",\n value: function beforeFit() {\n callback(this.options.beforeFit, [this]);\n }\n }, {\n key: \"fit\",\n value: function fit() {\n var minSize = {\n width: 0,\n height: 0\n };\n var chart = this.chart,\n _this$options5 = this.options,\n tickOpts = _this$options5.ticks,\n titleOpts = _this$options5.title,\n gridOpts = _this$options5.grid;\n var display = this._isVisible();\n var isHorizontal = this.isHorizontal();\n if (display) {\n var titleHeight = getTitleHeight(titleOpts, chart.options.font);\n if (isHorizontal) {\n minSize.width = this.maxWidth;\n minSize.height = getTickMarkLength(gridOpts) + titleHeight;\n } else {\n minSize.height = this.maxHeight;\n minSize.width = getTickMarkLength(gridOpts) + titleHeight;\n }\n if (tickOpts.display && this.ticks.length) {\n var _this$_getLabelSizes = this._getLabelSizes(),\n first = _this$_getLabelSizes.first,\n last = _this$_getLabelSizes.last,\n widest = _this$_getLabelSizes.widest,\n highest = _this$_getLabelSizes.highest;\n var tickPadding = tickOpts.padding * 2;\n var angleRadians = toRadians(this.labelRotation);\n var cos = Math.cos(angleRadians);\n var sin = Math.sin(angleRadians);\n if (isHorizontal) {\n var labelHeight = tickOpts.mirror ? 0 : sin * widest.width + cos * highest.height;\n minSize.height = Math.min(this.maxHeight, minSize.height + labelHeight + tickPadding);\n } else {\n var labelWidth = tickOpts.mirror ? 0 : cos * widest.width + sin * highest.height;\n minSize.width = Math.min(this.maxWidth, minSize.width + labelWidth + tickPadding);\n }\n this._calculatePadding(first, last, sin, cos);\n }\n }\n this._handleMargins();\n if (isHorizontal) {\n this.width = this._length = chart.width - this._margins.left - this._margins.right;\n this.height = minSize.height;\n } else {\n this.width = minSize.width;\n this.height = this._length = chart.height - this._margins.top - this._margins.bottom;\n }\n }\n }, {\n key: \"_calculatePadding\",\n value: function _calculatePadding(first, last, sin, cos) {\n var _this$options6 = this.options,\n _this$options6$ticks = _this$options6.ticks,\n align = _this$options6$ticks.align,\n padding = _this$options6$ticks.padding,\n position = _this$options6.position;\n var isRotated = this.labelRotation !== 0;\n var labelsBelowTicks = position !== 'top' && this.axis === 'x';\n if (this.isHorizontal()) {\n var offsetLeft = this.getPixelForTick(0) - this.left;\n var offsetRight = this.right - this.getPixelForTick(this.ticks.length - 1);\n var paddingLeft = 0;\n var paddingRight = 0;\n if (isRotated) {\n if (labelsBelowTicks) {\n paddingLeft = cos * first.width;\n paddingRight = sin * last.height;\n } else {\n paddingLeft = sin * first.height;\n paddingRight = cos * last.width;\n }\n } else if (align === 'start') {\n paddingRight = last.width;\n } else if (align === 'end') {\n paddingLeft = first.width;\n } else if (align !== 'inner') {\n paddingLeft = first.width / 2;\n paddingRight = last.width / 2;\n }\n this.paddingLeft = Math.max((paddingLeft - offsetLeft + padding) * this.width / (this.width - offsetLeft), 0);\n this.paddingRight = Math.max((paddingRight - offsetRight + padding) * this.width / (this.width - offsetRight), 0);\n } else {\n var paddingTop = last.height / 2;\n var paddingBottom = first.height / 2;\n if (align === 'start') {\n paddingTop = 0;\n paddingBottom = first.height;\n } else if (align === 'end') {\n paddingTop = last.height;\n paddingBottom = 0;\n }\n this.paddingTop = paddingTop + padding;\n this.paddingBottom = paddingBottom + padding;\n }\n }\n }, {\n key: \"_handleMargins\",\n value: function _handleMargins() {\n if (this._margins) {\n this._margins.left = Math.max(this.paddingLeft, this._margins.left);\n this._margins.top = Math.max(this.paddingTop, this._margins.top);\n this._margins.right = Math.max(this.paddingRight, this._margins.right);\n this._margins.bottom = Math.max(this.paddingBottom, this._margins.bottom);\n }\n }\n }, {\n key: \"afterFit\",\n value: function afterFit() {\n callback(this.options.afterFit, [this]);\n }\n }, {\n key: \"isHorizontal\",\n value: function isHorizontal() {\n var _this$options7 = this.options,\n axis = _this$options7.axis,\n position = _this$options7.position;\n return position === 'top' || position === 'bottom' || axis === 'x';\n }\n }, {\n key: \"isFullSize\",\n value: function isFullSize() {\n return this.options.fullSize;\n }\n }, {\n key: \"_convertTicksToLabels\",\n value: function _convertTicksToLabels(ticks) {\n this.beforeTickToLabelConversion();\n this.generateTickLabels(ticks);\n var i, ilen;\n for (i = 0, ilen = ticks.length; i < ilen; i++) {\n if (isNullOrUndef(ticks[i].label)) {\n ticks.splice(i, 1);\n ilen--;\n i--;\n }\n }\n this.afterTickToLabelConversion();\n }\n }, {\n key: \"_getLabelSizes\",\n value: function _getLabelSizes() {\n var labelSizes = this._labelSizes;\n if (!labelSizes) {\n var sampleSize = this.options.ticks.sampleSize;\n var ticks = this.ticks;\n if (sampleSize < ticks.length) {\n ticks = sample(ticks, sampleSize);\n }\n this._labelSizes = labelSizes = this._computeLabelSizes(ticks, ticks.length, this.options.ticks.maxTicksLimit);\n }\n return labelSizes;\n }\n }, {\n key: \"_computeLabelSizes\",\n value: function _computeLabelSizes(ticks, length, maxTicksLimit) {\n var ctx = this.ctx,\n caches = this._longestTextCache;\n var widths = [];\n var heights = [];\n var increment = Math.floor(length / getTicksLimit(length, maxTicksLimit));\n var widestLabelSize = 0;\n var highestLabelSize = 0;\n var i, j, jlen, label, tickFont, fontString, cache, lineHeight, width, height, nestedLabel;\n for (i = 0; i < length; i += increment) {\n label = ticks[i].label;\n tickFont = this._resolveTickFontOptions(i);\n ctx.font = fontString = tickFont.string;\n cache = caches[fontString] = caches[fontString] || {\n data: {},\n gc: []\n };\n lineHeight = tickFont.lineHeight;\n width = height = 0;\n if (!isNullOrUndef(label) && !isArray(label)) {\n width = _measureText(ctx, cache.data, cache.gc, width, label);\n height = lineHeight;\n } else if (isArray(label)) {\n for (j = 0, jlen = label.length; j < jlen; ++j) {\n nestedLabel = label[j];\n if (!isNullOrUndef(nestedLabel) && !isArray(nestedLabel)) {\n width = _measureText(ctx, cache.data, cache.gc, width, nestedLabel);\n height += lineHeight;\n }\n }\n }\n widths.push(width);\n heights.push(height);\n widestLabelSize = Math.max(width, widestLabelSize);\n highestLabelSize = Math.max(height, highestLabelSize);\n }\n garbageCollect(caches, length);\n var widest = widths.indexOf(widestLabelSize);\n var highest = heights.indexOf(highestLabelSize);\n var valueAt = function valueAt(idx) {\n return {\n width: widths[idx] || 0,\n height: heights[idx] || 0\n };\n };\n return {\n first: valueAt(0),\n last: valueAt(length - 1),\n widest: valueAt(widest),\n highest: valueAt(highest),\n widths: widths,\n heights: heights\n };\n }\n }, {\n key: \"getLabelForValue\",\n value: function getLabelForValue(value) {\n return value;\n }\n }, {\n key: \"getPixelForValue\",\n value: function getPixelForValue(value, index) {\n return NaN;\n }\n }, {\n key: \"getValueForPixel\",\n value: function getValueForPixel(pixel) {}\n }, {\n key: \"getPixelForTick\",\n value: function getPixelForTick(index) {\n var ticks = this.ticks;\n if (index < 0 || index > ticks.length - 1) {\n return null;\n }\n return this.getPixelForValue(ticks[index].value);\n }\n }, {\n key: \"getPixelForDecimal\",\n value: function getPixelForDecimal(decimal) {\n if (this._reversePixels) {\n decimal = 1 - decimal;\n }\n var pixel = this._startPixel + decimal * this._length;\n return _int16Range(this._alignToPixels ? _alignPixel(this.chart, pixel, 0) : pixel);\n }\n }, {\n key: \"getDecimalForPixel\",\n value: function getDecimalForPixel(pixel) {\n var decimal = (pixel - this._startPixel) / this._length;\n return this._reversePixels ? 1 - decimal : decimal;\n }\n }, {\n key: \"getBasePixel\",\n value: function getBasePixel() {\n return this.getPixelForValue(this.getBaseValue());\n }\n }, {\n key: \"getBaseValue\",\n value: function getBaseValue() {\n var min = this.min,\n max = this.max;\n return min < 0 && max < 0 ? max : min > 0 && max > 0 ? min : 0;\n }\n }, {\n key: \"getContext\",\n value: function getContext(index) {\n var ticks = this.ticks || [];\n if (index >= 0 && index < ticks.length) {\n var tick = ticks[index];\n return tick.$context || (tick.$context = createTickContext(this.getContext(), index, tick));\n }\n return this.$context || (this.$context = createScaleContext(this.chart.getContext(), this));\n }\n }, {\n key: \"_tickSize\",\n value: function _tickSize() {\n var optionTicks = this.options.ticks;\n var rot = toRadians(this.labelRotation);\n var cos = Math.abs(Math.cos(rot));\n var sin = Math.abs(Math.sin(rot));\n var labelSizes = this._getLabelSizes();\n var padding = optionTicks.autoSkipPadding || 0;\n var w = labelSizes ? labelSizes.widest.width + padding : 0;\n var h = labelSizes ? labelSizes.highest.height + padding : 0;\n return this.isHorizontal() ? h * cos > w * sin ? w / cos : h / sin : h * sin < w * cos ? h / cos : w / sin;\n }\n }, {\n key: \"_isVisible\",\n value: function _isVisible() {\n var display = this.options.display;\n if (display !== 'auto') {\n return !!display;\n }\n return this.getMatchingVisibleMetas().length > 0;\n }\n }, {\n key: \"_computeGridLineItems\",\n value: function _computeGridLineItems(chartArea) {\n var axis = this.axis;\n var chart = this.chart;\n var options = this.options;\n var grid = options.grid,\n position = options.position,\n border = options.border;\n var offset = grid.offset;\n var isHorizontal = this.isHorizontal();\n var ticks = this.ticks;\n var ticksLength = ticks.length + (offset ? 1 : 0);\n var tl = getTickMarkLength(grid);\n var items = [];\n var borderOpts = border.setContext(this.getContext());\n var axisWidth = borderOpts.display ? borderOpts.width : 0;\n var axisHalfWidth = axisWidth / 2;\n var alignBorderValue = function alignBorderValue(pixel) {\n return _alignPixel(chart, pixel, axisWidth);\n };\n var borderValue, i, lineValue, alignedLineValue;\n var tx1, ty1, tx2, ty2, x1, y1, x2, y2;\n if (position === 'top') {\n borderValue = alignBorderValue(this.bottom);\n ty1 = this.bottom - tl;\n ty2 = borderValue - axisHalfWidth;\n y1 = alignBorderValue(chartArea.top) + axisHalfWidth;\n y2 = chartArea.bottom;\n } else if (position === 'bottom') {\n borderValue = alignBorderValue(this.top);\n y1 = chartArea.top;\n y2 = alignBorderValue(chartArea.bottom) - axisHalfWidth;\n ty1 = borderValue + axisHalfWidth;\n ty2 = this.top + tl;\n } else if (position === 'left') {\n borderValue = alignBorderValue(this.right);\n tx1 = this.right - tl;\n tx2 = borderValue - axisHalfWidth;\n x1 = alignBorderValue(chartArea.left) + axisHalfWidth;\n x2 = chartArea.right;\n } else if (position === 'right') {\n borderValue = alignBorderValue(this.left);\n x1 = chartArea.left;\n x2 = alignBorderValue(chartArea.right) - axisHalfWidth;\n tx1 = borderValue + axisHalfWidth;\n tx2 = this.left + tl;\n } else if (axis === 'x') {\n if (position === 'center') {\n borderValue = alignBorderValue((chartArea.top + chartArea.bottom) / 2 + 0.5);\n } else if (isObject(position)) {\n var positionAxisID = Object.keys(position)[0];\n var value = position[positionAxisID];\n borderValue = alignBorderValue(this.chart.scales[positionAxisID].getPixelForValue(value));\n }\n y1 = chartArea.top;\n y2 = chartArea.bottom;\n ty1 = borderValue + axisHalfWidth;\n ty2 = ty1 + tl;\n } else if (axis === 'y') {\n if (position === 'center') {\n borderValue = alignBorderValue((chartArea.left + chartArea.right) / 2);\n } else if (isObject(position)) {\n var _positionAxisID2 = Object.keys(position)[0];\n var _value2 = position[_positionAxisID2];\n borderValue = alignBorderValue(this.chart.scales[_positionAxisID2].getPixelForValue(_value2));\n }\n tx1 = borderValue - axisHalfWidth;\n tx2 = tx1 - tl;\n x1 = chartArea.left;\n x2 = chartArea.right;\n }\n var limit = valueOrDefault(options.ticks.maxTicksLimit, ticksLength);\n var step = Math.max(1, Math.ceil(ticksLength / limit));\n for (i = 0; i < ticksLength; i += step) {\n var context = this.getContext(i);\n var optsAtIndex = grid.setContext(context);\n var optsAtIndexBorder = border.setContext(context);\n var lineWidth = optsAtIndex.lineWidth;\n var lineColor = optsAtIndex.color;\n var borderDash = optsAtIndexBorder.dash || [];\n var borderDashOffset = optsAtIndexBorder.dashOffset;\n var tickWidth = optsAtIndex.tickWidth;\n var tickColor = optsAtIndex.tickColor;\n var tickBorderDash = optsAtIndex.tickBorderDash || [];\n var tickBorderDashOffset = optsAtIndex.tickBorderDashOffset;\n lineValue = getPixelForGridLine(this, i, offset);\n if (lineValue === undefined) {\n continue;\n }\n alignedLineValue = _alignPixel(chart, lineValue, lineWidth);\n if (isHorizontal) {\n tx1 = tx2 = x1 = x2 = alignedLineValue;\n } else {\n ty1 = ty2 = y1 = y2 = alignedLineValue;\n }\n items.push({\n tx1: tx1,\n ty1: ty1,\n tx2: tx2,\n ty2: ty2,\n x1: x1,\n y1: y1,\n x2: x2,\n y2: y2,\n width: lineWidth,\n color: lineColor,\n borderDash: borderDash,\n borderDashOffset: borderDashOffset,\n tickWidth: tickWidth,\n tickColor: tickColor,\n tickBorderDash: tickBorderDash,\n tickBorderDashOffset: tickBorderDashOffset\n });\n }\n this._ticksLength = ticksLength;\n this._borderValue = borderValue;\n return items;\n }\n }, {\n key: \"_computeLabelItems\",\n value: function _computeLabelItems(chartArea) {\n var axis = this.axis;\n var options = this.options;\n var position = options.position,\n optionTicks = options.ticks;\n var isHorizontal = this.isHorizontal();\n var ticks = this.ticks;\n var align = optionTicks.align,\n crossAlign = optionTicks.crossAlign,\n padding = optionTicks.padding,\n mirror = optionTicks.mirror;\n var tl = getTickMarkLength(options.grid);\n var tickAndPadding = tl + padding;\n var hTickAndPadding = mirror ? -padding : tickAndPadding;\n var rotation = -toRadians(this.labelRotation);\n var items = [];\n var i, ilen, tick, label, x, y, textAlign, pixel, font, lineHeight, lineCount, textOffset;\n var textBaseline = 'middle';\n if (position === 'top') {\n y = this.bottom - hTickAndPadding;\n textAlign = this._getXAxisLabelAlignment();\n } else if (position === 'bottom') {\n y = this.top + hTickAndPadding;\n textAlign = this._getXAxisLabelAlignment();\n } else if (position === 'left') {\n var ret = this._getYAxisLabelAlignment(tl);\n textAlign = ret.textAlign;\n x = ret.x;\n } else if (position === 'right') {\n var _ret = this._getYAxisLabelAlignment(tl);\n textAlign = _ret.textAlign;\n x = _ret.x;\n } else if (axis === 'x') {\n if (position === 'center') {\n y = (chartArea.top + chartArea.bottom) / 2 + tickAndPadding;\n } else if (isObject(position)) {\n var positionAxisID = Object.keys(position)[0];\n var value = position[positionAxisID];\n y = this.chart.scales[positionAxisID].getPixelForValue(value) + tickAndPadding;\n }\n textAlign = this._getXAxisLabelAlignment();\n } else if (axis === 'y') {\n if (position === 'center') {\n x = (chartArea.left + chartArea.right) / 2 - tickAndPadding;\n } else if (isObject(position)) {\n var _positionAxisID3 = Object.keys(position)[0];\n var _value3 = position[_positionAxisID3];\n x = this.chart.scales[_positionAxisID3].getPixelForValue(_value3);\n }\n textAlign = this._getYAxisLabelAlignment(tl).textAlign;\n }\n if (axis === 'y') {\n if (align === 'start') {\n textBaseline = 'top';\n } else if (align === 'end') {\n textBaseline = 'bottom';\n }\n }\n var labelSizes = this._getLabelSizes();\n for (i = 0, ilen = ticks.length; i < ilen; ++i) {\n tick = ticks[i];\n label = tick.label;\n var optsAtIndex = optionTicks.setContext(this.getContext(i));\n pixel = this.getPixelForTick(i) + optionTicks.labelOffset;\n font = this._resolveTickFontOptions(i);\n lineHeight = font.lineHeight;\n lineCount = isArray(label) ? label.length : 1;\n var halfCount = lineCount / 2;\n var color = optsAtIndex.color;\n var strokeColor = optsAtIndex.textStrokeColor;\n var strokeWidth = optsAtIndex.textStrokeWidth;\n var tickTextAlign = textAlign;\n if (isHorizontal) {\n x = pixel;\n if (textAlign === 'inner') {\n if (i === ilen - 1) {\n tickTextAlign = !this.options.reverse ? 'right' : 'left';\n } else if (i === 0) {\n tickTextAlign = !this.options.reverse ? 'left' : 'right';\n } else {\n tickTextAlign = 'center';\n }\n }\n if (position === 'top') {\n if (crossAlign === 'near' || rotation !== 0) {\n textOffset = -lineCount * lineHeight + lineHeight / 2;\n } else if (crossAlign === 'center') {\n textOffset = -labelSizes.highest.height / 2 - halfCount * lineHeight + lineHeight;\n } else {\n textOffset = -labelSizes.highest.height + lineHeight / 2;\n }\n } else {\n if (crossAlign === 'near' || rotation !== 0) {\n textOffset = lineHeight / 2;\n } else if (crossAlign === 'center') {\n textOffset = labelSizes.highest.height / 2 - halfCount * lineHeight;\n } else {\n textOffset = labelSizes.highest.height - lineCount * lineHeight;\n }\n }\n if (mirror) {\n textOffset *= -1;\n }\n if (rotation !== 0 && !optsAtIndex.showLabelBackdrop) {\n x += lineHeight / 2 * Math.sin(rotation);\n }\n } else {\n y = pixel;\n textOffset = (1 - lineCount) * lineHeight / 2;\n }\n var backdrop = void 0;\n if (optsAtIndex.showLabelBackdrop) {\n var labelPadding = toPadding(optsAtIndex.backdropPadding);\n var height = labelSizes.heights[i];\n var width = labelSizes.widths[i];\n var top = textOffset - labelPadding.top;\n var left = 0 - labelPadding.left;\n switch (textBaseline) {\n case 'middle':\n top -= height / 2;\n break;\n case 'bottom':\n top -= height;\n break;\n }\n switch (textAlign) {\n case 'center':\n left -= width / 2;\n break;\n case 'right':\n left -= width;\n break;\n }\n backdrop = {\n left: left,\n top: top,\n width: width + labelPadding.width,\n height: height + labelPadding.height,\n color: optsAtIndex.backdropColor\n };\n }\n items.push({\n label: label,\n font: font,\n textOffset: textOffset,\n options: {\n rotation: rotation,\n color: color,\n strokeColor: strokeColor,\n strokeWidth: strokeWidth,\n textAlign: tickTextAlign,\n textBaseline: textBaseline,\n translation: [x, y],\n backdrop: backdrop\n }\n });\n }\n return items;\n }\n }, {\n key: \"_getXAxisLabelAlignment\",\n value: function _getXAxisLabelAlignment() {\n var _this$options8 = this.options,\n position = _this$options8.position,\n ticks = _this$options8.ticks;\n var rotation = -toRadians(this.labelRotation);\n if (rotation) {\n return position === 'top' ? 'left' : 'right';\n }\n var align = 'center';\n if (ticks.align === 'start') {\n align = 'left';\n } else if (ticks.align === 'end') {\n align = 'right';\n } else if (ticks.align === 'inner') {\n align = 'inner';\n }\n return align;\n }\n }, {\n key: \"_getYAxisLabelAlignment\",\n value: function _getYAxisLabelAlignment(tl) {\n var _this$options9 = this.options,\n position = _this$options9.position,\n _this$options9$ticks = _this$options9.ticks,\n crossAlign = _this$options9$ticks.crossAlign,\n mirror = _this$options9$ticks.mirror,\n padding = _this$options9$ticks.padding;\n var labelSizes = this._getLabelSizes();\n var tickAndPadding = tl + padding;\n var widest = labelSizes.widest.width;\n var textAlign;\n var x;\n if (position === 'left') {\n if (mirror) {\n x = this.right + padding;\n if (crossAlign === 'near') {\n textAlign = 'left';\n } else if (crossAlign === 'center') {\n textAlign = 'center';\n x += widest / 2;\n } else {\n textAlign = 'right';\n x += widest;\n }\n } else {\n x = this.right - tickAndPadding;\n if (crossAlign === 'near') {\n textAlign = 'right';\n } else if (crossAlign === 'center') {\n textAlign = 'center';\n x -= widest / 2;\n } else {\n textAlign = 'left';\n x = this.left;\n }\n }\n } else if (position === 'right') {\n if (mirror) {\n x = this.left + padding;\n if (crossAlign === 'near') {\n textAlign = 'right';\n } else if (crossAlign === 'center') {\n textAlign = 'center';\n x -= widest / 2;\n } else {\n textAlign = 'left';\n x -= widest;\n }\n } else {\n x = this.left + tickAndPadding;\n if (crossAlign === 'near') {\n textAlign = 'left';\n } else if (crossAlign === 'center') {\n textAlign = 'center';\n x += widest / 2;\n } else {\n textAlign = 'right';\n x = this.right;\n }\n }\n } else {\n textAlign = 'right';\n }\n return {\n textAlign: textAlign,\n x: x\n };\n }\n }, {\n key: \"_computeLabelArea\",\n value: function _computeLabelArea() {\n if (this.options.ticks.mirror) {\n return;\n }\n var chart = this.chart;\n var position = this.options.position;\n if (position === 'left' || position === 'right') {\n return {\n top: 0,\n left: this.left,\n bottom: chart.height,\n right: this.right\n };\n }\n if (position === 'top' || position === 'bottom') {\n return {\n top: this.top,\n left: 0,\n bottom: this.bottom,\n right: chart.width\n };\n }\n }\n }, {\n key: \"drawBackground\",\n value: function drawBackground() {\n var ctx = this.ctx,\n backgroundColor = this.options.backgroundColor,\n left = this.left,\n top = this.top,\n width = this.width,\n height = this.height;\n if (backgroundColor) {\n ctx.save();\n ctx.fillStyle = backgroundColor;\n ctx.fillRect(left, top, width, height);\n ctx.restore();\n }\n }\n }, {\n key: \"getLineWidthForValue\",\n value: function getLineWidthForValue(value) {\n var grid = this.options.grid;\n if (!this._isVisible() || !grid.display) {\n return 0;\n }\n var ticks = this.ticks;\n var index = ticks.findIndex(function (t) {\n return t.value === value;\n });\n if (index >= 0) {\n var opts = grid.setContext(this.getContext(index));\n return opts.lineWidth;\n }\n return 0;\n }\n }, {\n key: \"drawGrid\",\n value: function drawGrid(chartArea) {\n var grid = this.options.grid;\n var ctx = this.ctx;\n var items = this._gridLineItems || (this._gridLineItems = this._computeGridLineItems(chartArea));\n var i, ilen;\n var drawLine = function drawLine(p1, p2, style) {\n if (!style.width || !style.color) {\n return;\n }\n ctx.save();\n ctx.lineWidth = style.width;\n ctx.strokeStyle = style.color;\n ctx.setLineDash(style.borderDash || []);\n ctx.lineDashOffset = style.borderDashOffset;\n ctx.beginPath();\n ctx.moveTo(p1.x, p1.y);\n ctx.lineTo(p2.x, p2.y);\n ctx.stroke();\n ctx.restore();\n };\n if (grid.display) {\n for (i = 0, ilen = items.length; i < ilen; ++i) {\n var item = items[i];\n if (grid.drawOnChartArea) {\n drawLine({\n x: item.x1,\n y: item.y1\n }, {\n x: item.x2,\n y: item.y2\n }, item);\n }\n if (grid.drawTicks) {\n drawLine({\n x: item.tx1,\n y: item.ty1\n }, {\n x: item.tx2,\n y: item.ty2\n }, {\n color: item.tickColor,\n width: item.tickWidth,\n borderDash: item.tickBorderDash,\n borderDashOffset: item.tickBorderDashOffset\n });\n }\n }\n }\n }\n }, {\n key: \"drawBorder\",\n value: function drawBorder() {\n var chart = this.chart,\n ctx = this.ctx,\n _this$options10 = this.options,\n border = _this$options10.border,\n grid = _this$options10.grid;\n var borderOpts = border.setContext(this.getContext());\n var axisWidth = border.display ? borderOpts.width : 0;\n if (!axisWidth) {\n return;\n }\n var lastLineWidth = grid.setContext(this.getContext(0)).lineWidth;\n var borderValue = this._borderValue;\n var x1, x2, y1, y2;\n if (this.isHorizontal()) {\n x1 = _alignPixel(chart, this.left, axisWidth) - axisWidth / 2;\n x2 = _alignPixel(chart, this.right, lastLineWidth) + lastLineWidth / 2;\n y1 = y2 = borderValue;\n } else {\n y1 = _alignPixel(chart, this.top, axisWidth) - axisWidth / 2;\n y2 = _alignPixel(chart, this.bottom, lastLineWidth) + lastLineWidth / 2;\n x1 = x2 = borderValue;\n }\n ctx.save();\n ctx.lineWidth = borderOpts.width;\n ctx.strokeStyle = borderOpts.color;\n ctx.beginPath();\n ctx.moveTo(x1, y1);\n ctx.lineTo(x2, y2);\n ctx.stroke();\n ctx.restore();\n }\n }, {\n key: \"drawLabels\",\n value: function drawLabels(chartArea) {\n var optionTicks = this.options.ticks;\n if (!optionTicks.display) {\n return;\n }\n var ctx = this.ctx;\n var area = this._computeLabelArea();\n if (area) {\n clipArea(ctx, area);\n }\n var items = this.getLabelItems(chartArea);\n var _iterator10 = _createForOfIteratorHelper$1(items),\n _step10;\n try {\n for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {\n var item = _step10.value;\n var renderTextOptions = item.options;\n var tickFont = item.font;\n var label = item.label;\n var y = item.textOffset;\n renderText(ctx, label, 0, y, tickFont, renderTextOptions);\n }\n } catch (err) {\n _iterator10.e(err);\n } finally {\n _iterator10.f();\n }\n if (area) {\n unclipArea(ctx);\n }\n }\n }, {\n key: \"drawTitle\",\n value: function drawTitle() {\n var ctx = this.ctx,\n _this$options11 = this.options,\n position = _this$options11.position,\n title = _this$options11.title,\n reverse = _this$options11.reverse;\n if (!title.display) {\n return;\n }\n var font = toFont(title.font);\n var padding = toPadding(title.padding);\n var align = title.align;\n var offset = font.lineHeight / 2;\n if (position === 'bottom' || position === 'center' || isObject(position)) {\n offset += padding.bottom;\n if (isArray(title.text)) {\n offset += font.lineHeight * (title.text.length - 1);\n }\n } else {\n offset += padding.top;\n }\n var _titleArgs = titleArgs(this, offset, position, align),\n titleX = _titleArgs.titleX,\n titleY = _titleArgs.titleY,\n maxWidth = _titleArgs.maxWidth,\n rotation = _titleArgs.rotation;\n renderText(ctx, title.text, 0, 0, font, {\n color: title.color,\n maxWidth: maxWidth,\n rotation: rotation,\n textAlign: titleAlign(align, position, reverse),\n textBaseline: 'middle',\n translation: [titleX, titleY]\n });\n }\n }, {\n key: \"draw\",\n value: function draw(chartArea) {\n if (!this._isVisible()) {\n return;\n }\n this.drawBackground();\n this.drawGrid(chartArea);\n this.drawBorder();\n this.drawTitle();\n this.drawLabels(chartArea);\n }\n }, {\n key: \"_layers\",\n value: function _layers() {\n var _this10 = this;\n var opts = this.options;\n var tz = opts.ticks && opts.ticks.z || 0;\n var gz = valueOrDefault(opts.grid && opts.grid.z, -1);\n var bz = valueOrDefault(opts.border && opts.border.z, 0);\n if (!this._isVisible() || this.draw !== Scale.prototype.draw) {\n return [{\n z: tz,\n draw: function draw(chartArea) {\n _this10.draw(chartArea);\n }\n }];\n }\n return [{\n z: gz,\n draw: function draw(chartArea) {\n _this10.drawBackground();\n _this10.drawGrid(chartArea);\n _this10.drawTitle();\n }\n }, {\n z: bz,\n draw: function draw() {\n _this10.drawBorder();\n }\n }, {\n z: tz,\n draw: function draw(chartArea) {\n _this10.drawLabels(chartArea);\n }\n }];\n }\n }, {\n key: \"getMatchingVisibleMetas\",\n value: function getMatchingVisibleMetas(type) {\n var metas = this.chart.getSortedVisibleDatasetMetas();\n var axisID = this.axis + 'AxisID';\n var result = [];\n var i, ilen;\n for (i = 0, ilen = metas.length; i < ilen; ++i) {\n var meta = metas[i];\n if (meta[axisID] === this.id && (!type || meta.type === type)) {\n result.push(meta);\n }\n }\n return result;\n }\n }, {\n key: \"_resolveTickFontOptions\",\n value: function _resolveTickFontOptions(index) {\n var opts = this.options.ticks.setContext(this.getContext(index));\n return toFont(opts.font);\n }\n }, {\n key: \"_maxDigits\",\n value: function _maxDigits() {\n var fontSize = this._resolveTickFontOptions(0).lineHeight;\n return (this.isHorizontal() ? this.width : this.height) / fontSize;\n }\n }]);\n return Scale;\n }(Element);\n var TypedRegistry = /*#__PURE__*/function () {\n function TypedRegistry(type, scope, override) {\n _classCallCheck$1(this, TypedRegistry);\n this.type = type;\n this.scope = scope;\n this.override = override;\n this.items = Object.create(null);\n }\n _createClass$1(TypedRegistry, [{\n key: \"isForType\",\n value: function isForType(type) {\n return Object.prototype.isPrototypeOf.call(this.type.prototype, type.prototype);\n }\n }, {\n key: \"register\",\n value: function register(item) {\n var proto = Object.getPrototypeOf(item);\n var parentScope;\n if (isIChartComponent(proto)) {\n parentScope = this.register(proto);\n }\n var items = this.items;\n var id = item.id;\n var scope = this.scope + '.' + id;\n if (!id) {\n throw new Error('class does not have id: ' + item);\n }\n if (id in items) {\n return scope;\n }\n items[id] = item;\n registerDefaults(item, scope, parentScope);\n if (this.override) {\n defaults.override(item.id, item.overrides);\n }\n return scope;\n }\n }, {\n key: \"get\",\n value: function get(id) {\n return this.items[id];\n }\n }, {\n key: \"unregister\",\n value: function unregister(item) {\n var items = this.items;\n var id = item.id;\n var scope = this.scope;\n if (id in items) {\n delete items[id];\n }\n if (scope && id in defaults[scope]) {\n delete defaults[scope][id];\n if (this.override) {\n delete overrides[id];\n }\n }\n }\n }]);\n return TypedRegistry;\n }();\n function registerDefaults(item, scope, parentScope) {\n var itemDefaults = merge(Object.create(null), [parentScope ? defaults.get(parentScope) : {}, defaults.get(scope), item.defaults]);\n defaults.set(scope, itemDefaults);\n if (item.defaultRoutes) {\n routeDefaults(scope, item.defaultRoutes);\n }\n if (item.descriptors) {\n defaults.describe(scope, item.descriptors);\n }\n }\n function routeDefaults(scope, routes) {\n Object.keys(routes).forEach(function (property) {\n var propertyParts = property.split('.');\n var sourceName = propertyParts.pop();\n var sourceScope = [scope].concat(propertyParts).join('.');\n var parts = routes[property].split('.');\n var targetName = parts.pop();\n var targetScope = parts.join('.');\n defaults.route(sourceScope, sourceName, targetScope, targetName);\n });\n }\n function isIChartComponent(proto) {\n return 'id' in proto && 'defaults' in proto;\n }\n var Registry = /*#__PURE__*/function () {\n function Registry() {\n _classCallCheck$1(this, Registry);\n this.controllers = new TypedRegistry(DatasetController, 'datasets', true);\n this.elements = new TypedRegistry(Element, 'elements');\n this.plugins = new TypedRegistry(Object, 'plugins');\n this.scales = new TypedRegistry(Scale, 'scales');\n this._typedRegistries = [this.controllers, this.scales, this.elements];\n }\n _createClass$1(Registry, [{\n key: \"add\",\n value: function add() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n this._each('register', args);\n }\n }, {\n key: \"remove\",\n value: function remove() {\n for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n args[_key2] = arguments[_key2];\n }\n this._each('unregister', args);\n }\n }, {\n key: \"addControllers\",\n value: function addControllers() {\n for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n args[_key3] = arguments[_key3];\n }\n this._each('register', args, this.controllers);\n }\n }, {\n key: \"addElements\",\n value: function addElements() {\n for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n args[_key4] = arguments[_key4];\n }\n this._each('register', args, this.elements);\n }\n }, {\n key: \"addPlugins\",\n value: function addPlugins() {\n for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {\n args[_key5] = arguments[_key5];\n }\n this._each('register', args, this.plugins);\n }\n }, {\n key: \"addScales\",\n value: function addScales() {\n for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {\n args[_key6] = arguments[_key6];\n }\n this._each('register', args, this.scales);\n }\n }, {\n key: \"getController\",\n value: function getController(id) {\n return this._get(id, this.controllers, 'controller');\n }\n }, {\n key: \"getElement\",\n value: function getElement(id) {\n return this._get(id, this.elements, 'element');\n }\n }, {\n key: \"getPlugin\",\n value: function getPlugin(id) {\n return this._get(id, this.plugins, 'plugin');\n }\n }, {\n key: \"getScale\",\n value: function getScale(id) {\n return this._get(id, this.scales, 'scale');\n }\n }, {\n key: \"removeControllers\",\n value: function removeControllers() {\n for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {\n args[_key7] = arguments[_key7];\n }\n this._each('unregister', args, this.controllers);\n }\n }, {\n key: \"removeElements\",\n value: function removeElements() {\n for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {\n args[_key8] = arguments[_key8];\n }\n this._each('unregister', args, this.elements);\n }\n }, {\n key: \"removePlugins\",\n value: function removePlugins() {\n for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {\n args[_key9] = arguments[_key9];\n }\n this._each('unregister', args, this.plugins);\n }\n }, {\n key: \"removeScales\",\n value: function removeScales() {\n for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {\n args[_key10] = arguments[_key10];\n }\n this._each('unregister', args, this.scales);\n }\n }, {\n key: \"_each\",\n value: function _each(method, args, typedRegistry) {\n var _this11 = this;\n _toConsumableArray(args).forEach(function (arg) {\n var reg = typedRegistry || _this11._getRegistryForType(arg);\n if (typedRegistry || reg.isForType(arg) || reg === _this11.plugins && arg.id) {\n _this11._exec(method, reg, arg);\n } else {\n each(arg, function (item) {\n var itemReg = typedRegistry || _this11._getRegistryForType(item);\n _this11._exec(method, itemReg, item);\n });\n }\n });\n }\n }, {\n key: \"_exec\",\n value: function _exec(method, registry, component) {\n var camelMethod = _capitalize(method);\n callback(component['before' + camelMethod], [], component);\n registry[method](component);\n callback(component['after' + camelMethod], [], component);\n }\n }, {\n key: \"_getRegistryForType\",\n value: function _getRegistryForType(type) {\n for (var i = 0; i < this._typedRegistries.length; i++) {\n var reg = this._typedRegistries[i];\n if (reg.isForType(type)) {\n return reg;\n }\n }\n return this.plugins;\n }\n }, {\n key: \"_get\",\n value: function _get(id, typedRegistry, type) {\n var item = typedRegistry.get(id);\n if (item === undefined) {\n throw new Error('\"' + id + '\" is not a registered ' + type + '.');\n }\n return item;\n }\n }]);\n return Registry;\n }();\n var registry = /* #__PURE__ */new Registry();\n var PluginService = /*#__PURE__*/function () {\n function PluginService() {\n _classCallCheck$1(this, PluginService);\n this._init = [];\n }\n _createClass$1(PluginService, [{\n key: \"notify\",\n value: function notify(chart, hook, args, filter) {\n if (hook === 'beforeInit') {\n this._init = this._createDescriptors(chart, true);\n this._notify(this._init, chart, 'install');\n }\n var descriptors = filter ? this._descriptors(chart).filter(filter) : this._descriptors(chart);\n var result = this._notify(descriptors, chart, hook, args);\n if (hook === 'afterDestroy') {\n this._notify(descriptors, chart, 'stop');\n this._notify(this._init, chart, 'uninstall');\n }\n return result;\n }\n }, {\n key: \"_notify\",\n value: function _notify(descriptors, chart, hook, args) {\n args = args || {};\n var _iterator11 = _createForOfIteratorHelper$1(descriptors),\n _step11;\n try {\n for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {\n var descriptor = _step11.value;\n var plugin = descriptor.plugin;\n var method = plugin[hook];\n var params = [chart, args, descriptor.options];\n if (callback(method, params, plugin) === false && args.cancelable) {\n return false;\n }\n }\n } catch (err) {\n _iterator11.e(err);\n } finally {\n _iterator11.f();\n }\n return true;\n }\n }, {\n key: \"invalidate\",\n value: function invalidate() {\n if (!isNullOrUndef(this._cache)) {\n this._oldCache = this._cache;\n this._cache = undefined;\n }\n }\n }, {\n key: \"_descriptors\",\n value: function _descriptors(chart) {\n if (this._cache) {\n return this._cache;\n }\n var descriptors = this._cache = this._createDescriptors(chart);\n this._notifyStateChanges(chart);\n return descriptors;\n }\n }, {\n key: \"_createDescriptors\",\n value: function _createDescriptors(chart, all) {\n var config = chart && chart.config;\n var options = valueOrDefault(config.options && config.options.plugins, {});\n var plugins = allPlugins(config);\n return options === false && !all ? [] : createDescriptors(chart, plugins, options, all);\n }\n }, {\n key: \"_notifyStateChanges\",\n value: function _notifyStateChanges(chart) {\n var previousDescriptors = this._oldCache || [];\n var descriptors = this._cache;\n var diff = function diff(a, b) {\n return a.filter(function (x) {\n return !b.some(function (y) {\n return x.plugin.id === y.plugin.id;\n });\n });\n };\n this._notify(diff(previousDescriptors, descriptors), chart, 'stop');\n this._notify(diff(descriptors, previousDescriptors), chart, 'start');\n }\n }]);\n return PluginService;\n }();\n function allPlugins(config) {\n var localIds = {};\n var plugins = [];\n var keys = Object.keys(registry.plugins.items);\n for (var i = 0; i < keys.length; i++) {\n plugins.push(registry.getPlugin(keys[i]));\n }\n var local = config.plugins || [];\n for (var _i2 = 0; _i2 < local.length; _i2++) {\n var plugin = local[_i2];\n if (plugins.indexOf(plugin) === -1) {\n plugins.push(plugin);\n localIds[plugin.id] = true;\n }\n }\n return {\n plugins: plugins,\n localIds: localIds\n };\n }\n function getOpts(options, all) {\n if (!all && options === false) {\n return null;\n }\n if (options === true) {\n return {};\n }\n return options;\n }\n function createDescriptors(chart, _ref2, options, all) {\n var plugins = _ref2.plugins,\n localIds = _ref2.localIds;\n var result = [];\n var context = chart.getContext();\n var _iterator12 = _createForOfIteratorHelper$1(plugins),\n _step12;\n try {\n for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {\n var plugin = _step12.value;\n var id = plugin.id;\n var opts = getOpts(options[id], all);\n if (opts === null) {\n continue;\n }\n result.push({\n plugin: plugin,\n options: pluginOpts(chart.config, {\n plugin: plugin,\n local: localIds[id]\n }, opts, context)\n });\n }\n } catch (err) {\n _iterator12.e(err);\n } finally {\n _iterator12.f();\n }\n return result;\n }\n function pluginOpts(config, _ref3, opts, context) {\n var plugin = _ref3.plugin,\n local = _ref3.local;\n var keys = config.pluginScopeKeys(plugin);\n var scopes = config.getOptionScopes(opts, keys);\n if (local && plugin.defaults) {\n scopes.push(plugin.defaults);\n }\n return config.createResolver(scopes, context, [''], {\n scriptable: false,\n indexable: false,\n allKeys: true\n });\n }\n function getIndexAxis(type, options) {\n var datasetDefaults = defaults.datasets[type] || {};\n var datasetOptions = (options.datasets || {})[type] || {};\n return datasetOptions.indexAxis || options.indexAxis || datasetDefaults.indexAxis || 'x';\n }\n function getAxisFromDefaultScaleID(id, indexAxis) {\n var axis = id;\n if (id === '_index_') {\n axis = indexAxis;\n } else if (id === '_value_') {\n axis = indexAxis === 'x' ? 'y' : 'x';\n }\n return axis;\n }\n function getDefaultScaleIDFromAxis(axis, indexAxis) {\n return axis === indexAxis ? '_index_' : '_value_';\n }\n function idMatchesAxis(id) {\n if (id === 'x' || id === 'y' || id === 'r') {\n return id;\n }\n }\n function axisFromPosition(position) {\n if (position === 'top' || position === 'bottom') {\n return 'x';\n }\n if (position === 'left' || position === 'right') {\n return 'y';\n }\n }\n function determineAxis(id) {\n if (idMatchesAxis(id)) {\n return id;\n }\n for (var _len11 = arguments.length, scaleOptions = new Array(_len11 > 1 ? _len11 - 1 : 0), _key11 = 1; _key11 < _len11; _key11++) {\n scaleOptions[_key11 - 1] = arguments[_key11];\n }\n for (var _i3 = 0, _scaleOptions = scaleOptions; _i3 < _scaleOptions.length; _i3++) {\n var opts = _scaleOptions[_i3];\n var axis = opts.axis || axisFromPosition(opts.position) || id.length > 1 && idMatchesAxis(id[0].toLowerCase());\n if (axis) {\n return axis;\n }\n }\n throw new Error(\"Cannot determine type of '\".concat(id, \"' axis. Please provide 'axis' or 'position' option.\"));\n }\n function getAxisFromDataset(id, axis, dataset) {\n if (dataset[axis + 'AxisID'] === id) {\n return {\n axis: axis\n };\n }\n }\n function retrieveAxisFromDatasets(id, config) {\n if (config.data && config.data.datasets) {\n var boundDs = config.data.datasets.filter(function (d) {\n return d.xAxisID === id || d.yAxisID === id;\n });\n if (boundDs.length) {\n return getAxisFromDataset(id, 'x', boundDs[0]) || getAxisFromDataset(id, 'y', boundDs[0]);\n }\n }\n return {};\n }\n function mergeScaleConfig(config, options) {\n var chartDefaults = overrides[config.type] || {\n scales: {}\n };\n var configScales = options.scales || {};\n var chartIndexAxis = getIndexAxis(config.type, options);\n var scales = Object.create(null);\n Object.keys(configScales).forEach(function (id) {\n var scaleConf = configScales[id];\n if (!isObject(scaleConf)) {\n return console.error(\"Invalid scale configuration for scale: \".concat(id));\n }\n if (scaleConf._proxy) {\n return console.warn(\"Ignoring resolver passed as options for scale: \".concat(id));\n }\n var axis = determineAxis(id, scaleConf, retrieveAxisFromDatasets(id, config), defaults.scales[scaleConf.type]);\n var defaultId = getDefaultScaleIDFromAxis(axis, chartIndexAxis);\n var defaultScaleOptions = chartDefaults.scales || {};\n scales[id] = mergeIf(Object.create(null), [{\n axis: axis\n }, scaleConf, defaultScaleOptions[axis], defaultScaleOptions[defaultId]]);\n });\n config.data.datasets.forEach(function (dataset) {\n var type = dataset.type || config.type;\n var indexAxis = dataset.indexAxis || getIndexAxis(type, options);\n var datasetDefaults = overrides[type] || {};\n var defaultScaleOptions = datasetDefaults.scales || {};\n Object.keys(defaultScaleOptions).forEach(function (defaultID) {\n var axis = getAxisFromDefaultScaleID(defaultID, indexAxis);\n var id = dataset[axis + 'AxisID'] || axis;\n scales[id] = scales[id] || Object.create(null);\n mergeIf(scales[id], [{\n axis: axis\n }, configScales[id], defaultScaleOptions[defaultID]]);\n });\n });\n Object.keys(scales).forEach(function (key) {\n var scale = scales[key];\n mergeIf(scale, [defaults.scales[scale.type], defaults.scale]);\n });\n return scales;\n }\n function initOptions(config) {\n var options = config.options || (config.options = {});\n options.plugins = valueOrDefault(options.plugins, {});\n options.scales = mergeScaleConfig(config, options);\n }\n function initData(data) {\n data = data || {};\n data.datasets = data.datasets || [];\n data.labels = data.labels || [];\n return data;\n }\n function initConfig(config) {\n config = config || {};\n config.data = initData(config.data);\n initOptions(config);\n return config;\n }\n var keyCache = new Map();\n var keysCached = new Set();\n function cachedKeys(cacheKey, generate) {\n var keys = keyCache.get(cacheKey);\n if (!keys) {\n keys = generate();\n keyCache.set(cacheKey, keys);\n keysCached.add(keys);\n }\n return keys;\n }\n var addIfFound = function addIfFound(set, obj, key) {\n var opts = resolveObjectKey(obj, key);\n if (opts !== undefined) {\n set.add(opts);\n }\n };\n var Config = /*#__PURE__*/function () {\n function Config(config) {\n _classCallCheck$1(this, Config);\n this._config = initConfig(config);\n this._scopeCache = new Map();\n this._resolverCache = new Map();\n }\n _createClass$1(Config, [{\n key: \"platform\",\n get: function get() {\n return this._config.platform;\n }\n }, {\n key: \"type\",\n get: function get() {\n return this._config.type;\n },\n set: function set(type) {\n this._config.type = type;\n }\n }, {\n key: \"data\",\n get: function get() {\n return this._config.data;\n },\n set: function set(data) {\n this._config.data = initData(data);\n }\n }, {\n key: \"options\",\n get: function get() {\n return this._config.options;\n },\n set: function set(options) {\n this._config.options = options;\n }\n }, {\n key: \"plugins\",\n get: function get() {\n return this._config.plugins;\n }\n }, {\n key: \"update\",\n value: function update() {\n var config = this._config;\n this.clearCache();\n initOptions(config);\n }\n }, {\n key: \"clearCache\",\n value: function clearCache() {\n this._scopeCache.clear();\n this._resolverCache.clear();\n }\n }, {\n key: \"datasetScopeKeys\",\n value: function datasetScopeKeys(datasetType) {\n return cachedKeys(datasetType, function () {\n return [[\"datasets.\".concat(datasetType), '']];\n });\n }\n }, {\n key: \"datasetAnimationScopeKeys\",\n value: function datasetAnimationScopeKeys(datasetType, transition) {\n return cachedKeys(\"\".concat(datasetType, \".transition.\").concat(transition), function () {\n return [[\"datasets.\".concat(datasetType, \".transitions.\").concat(transition), \"transitions.\".concat(transition)], [\"datasets.\".concat(datasetType), '']];\n });\n }\n }, {\n key: \"datasetElementScopeKeys\",\n value: function datasetElementScopeKeys(datasetType, elementType) {\n return cachedKeys(\"\".concat(datasetType, \"-\").concat(elementType), function () {\n return [[\"datasets.\".concat(datasetType, \".elements.\").concat(elementType), \"datasets.\".concat(datasetType), \"elements.\".concat(elementType), '']];\n });\n }\n }, {\n key: \"pluginScopeKeys\",\n value: function pluginScopeKeys(plugin) {\n var id = plugin.id;\n var type = this.type;\n return cachedKeys(\"\".concat(type, \"-plugin-\").concat(id), function () {\n return [[\"plugins.\".concat(id)].concat(_toConsumableArray(plugin.additionalOptionScopes || []))];\n });\n }\n }, {\n key: \"_cachedScopes\",\n value: function _cachedScopes(mainScope, resetCache) {\n var _scopeCache = this._scopeCache;\n var cache = _scopeCache.get(mainScope);\n if (!cache || resetCache) {\n cache = new Map();\n _scopeCache.set(mainScope, cache);\n }\n return cache;\n }\n }, {\n key: \"getOptionScopes\",\n value: function getOptionScopes(mainScope, keyLists, resetCache) {\n var options = this.options,\n type = this.type;\n var cache = this._cachedScopes(mainScope, resetCache);\n var cached = cache.get(keyLists);\n if (cached) {\n return cached;\n }\n var scopes = new Set();\n keyLists.forEach(function (keys) {\n if (mainScope) {\n scopes.add(mainScope);\n keys.forEach(function (key) {\n return addIfFound(scopes, mainScope, key);\n });\n }\n keys.forEach(function (key) {\n return addIfFound(scopes, options, key);\n });\n keys.forEach(function (key) {\n return addIfFound(scopes, overrides[type] || {}, key);\n });\n keys.forEach(function (key) {\n return addIfFound(scopes, defaults, key);\n });\n keys.forEach(function (key) {\n return addIfFound(scopes, descriptors, key);\n });\n });\n var array = Array.from(scopes);\n if (array.length === 0) {\n array.push(Object.create(null));\n }\n if (keysCached.has(keyLists)) {\n cache.set(keyLists, array);\n }\n return array;\n }\n }, {\n key: \"chartOptionScopes\",\n value: function chartOptionScopes() {\n var options = this.options,\n type = this.type;\n return [options, overrides[type] || {}, defaults.datasets[type] || {}, {\n type: type\n }, defaults, descriptors];\n }\n }, {\n key: \"resolveNamedOptions\",\n value: function resolveNamedOptions(scopes, names, context) {\n var prefixes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [''];\n var result = {\n $shared: true\n };\n var _getResolver = getResolver(this._resolverCache, scopes, prefixes),\n resolver = _getResolver.resolver,\n subPrefixes = _getResolver.subPrefixes;\n var options = resolver;\n if (needContext(resolver, names)) {\n result.$shared = false;\n context = isFunction(context) ? context() : context;\n var subResolver = this.createResolver(scopes, context, subPrefixes);\n options = _attachContext(resolver, context, subResolver);\n }\n var _iterator13 = _createForOfIteratorHelper$1(names),\n _step13;\n try {\n for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {\n var prop = _step13.value;\n result[prop] = options[prop];\n }\n } catch (err) {\n _iterator13.e(err);\n } finally {\n _iterator13.f();\n }\n return result;\n }\n }, {\n key: \"createResolver\",\n value: function createResolver(scopes, context) {\n var prefixes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [''];\n var descriptorDefaults = arguments.length > 3 ? arguments[3] : undefined;\n var _getResolver2 = getResolver(this._resolverCache, scopes, prefixes),\n resolver = _getResolver2.resolver;\n return isObject(context) ? _attachContext(resolver, context, undefined, descriptorDefaults) : resolver;\n }\n }]);\n return Config;\n }();\n function getResolver(resolverCache, scopes, prefixes) {\n var cache = resolverCache.get(scopes);\n if (!cache) {\n cache = new Map();\n resolverCache.set(scopes, cache);\n }\n var cacheKey = prefixes.join();\n var cached = cache.get(cacheKey);\n if (!cached) {\n var resolver = _createResolver(scopes, prefixes);\n cached = {\n resolver: resolver,\n subPrefixes: prefixes.filter(function (p) {\n return !p.toLowerCase().includes('hover');\n })\n };\n cache.set(cacheKey, cached);\n }\n return cached;\n }\n var hasFunction = function hasFunction(value) {\n return isObject(value) && Object.getOwnPropertyNames(value).reduce(function (acc, key) {\n return acc || isFunction(value[key]);\n }, false);\n };\n function needContext(proxy, names) {\n var _descriptors2 = _descriptors(proxy),\n isScriptable = _descriptors2.isScriptable,\n isIndexable = _descriptors2.isIndexable;\n var _iterator14 = _createForOfIteratorHelper$1(names),\n _step14;\n try {\n for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {\n var prop = _step14.value;\n var scriptable = isScriptable(prop);\n var indexable = isIndexable(prop);\n var value = (indexable || scriptable) && proxy[prop];\n if (scriptable && (isFunction(value) || hasFunction(value)) || indexable && isArray(value)) {\n return true;\n }\n }\n } catch (err) {\n _iterator14.e(err);\n } finally {\n _iterator14.f();\n }\n return false;\n }\n var version = \"4.4.0\";\n var KNOWN_POSITIONS = ['top', 'bottom', 'left', 'right', 'chartArea'];\n function positionIsHorizontal(position, axis) {\n return position === 'top' || position === 'bottom' || KNOWN_POSITIONS.indexOf(position) === -1 && axis === 'x';\n }\n function compare2Level(l1, l2) {\n return function (a, b) {\n return a[l1] === b[l1] ? a[l2] - b[l2] : a[l1] - b[l1];\n };\n }\n function onAnimationsComplete(context) {\n var chart = context.chart;\n var animationOptions = chart.options.animation;\n chart.notifyPlugins('afterRender');\n callback(animationOptions && animationOptions.onComplete, [context], chart);\n }\n function onAnimationProgress(context) {\n var chart = context.chart;\n var animationOptions = chart.options.animation;\n callback(animationOptions && animationOptions.onProgress, [context], chart);\n }\n function getCanvas(item) {\n if (_isDomSupported() && typeof item === 'string') {\n item = document.getElementById(item);\n } else if (item && item.length) {\n item = item[0];\n }\n if (item && item.canvas) {\n item = item.canvas;\n }\n return item;\n }\n var instances = {};\n var getChart = function getChart(key) {\n var canvas = getCanvas(key);\n return Object.values(instances).filter(function (c) {\n return c.canvas === canvas;\n }).pop();\n };\n function moveNumericKeys(obj, start, move) {\n var keys = Object.keys(obj);\n for (var _i4 = 0, _keys = keys; _i4 < _keys.length; _i4++) {\n var key = _keys[_i4];\n var intKey = +key;\n if (intKey >= start) {\n var value = obj[key];\n delete obj[key];\n if (move > 0 || intKey > start) {\n obj[intKey + move] = value;\n }\n }\n }\n }\n function determineLastEvent(e, lastEvent, inChartArea, isClick) {\n if (!inChartArea || e.type === 'mouseout') {\n return null;\n }\n if (isClick) {\n return lastEvent;\n }\n return e;\n }\n function getSizeForArea(scale, chartArea, field) {\n return scale.options.clip ? scale[field] : chartArea[field];\n }\n function getDatasetArea(meta, chartArea) {\n var xScale = meta.xScale,\n yScale = meta.yScale;\n if (xScale && yScale) {\n return {\n left: getSizeForArea(xScale, chartArea, 'left'),\n right: getSizeForArea(xScale, chartArea, 'right'),\n top: getSizeForArea(yScale, chartArea, 'top'),\n bottom: getSizeForArea(yScale, chartArea, 'bottom')\n };\n }\n return chartArea;\n }\n var Chart = /*#__PURE__*/function () {\n function Chart(item, userConfig) {\n var _this12 = this;\n _classCallCheck$1(this, Chart);\n var config = this.config = new Config(userConfig);\n var initialCanvas = getCanvas(item);\n var existingChart = getChart(initialCanvas);\n if (existingChart) {\n throw new Error('Canvas is already in use. Chart with ID \\'' + existingChart.id + '\\'' + ' must be destroyed before the canvas with ID \\'' + existingChart.canvas.id + '\\' can be reused.');\n }\n var options = config.createResolver(config.chartOptionScopes(), this.getContext());\n this.platform = new (config.platform || _detectPlatform(initialCanvas))();\n this.platform.updateConfig(config);\n var context = this.platform.acquireContext(initialCanvas, options.aspectRatio);\n var canvas = context && context.canvas;\n var height = canvas && canvas.height;\n var width = canvas && canvas.width;\n this.id = uid();\n this.ctx = context;\n this.canvas = canvas;\n this.width = width;\n this.height = height;\n this._options = options;\n this._aspectRatio = this.aspectRatio;\n this._layers = [];\n this._metasets = [];\n this._stacks = undefined;\n this.boxes = [];\n this.currentDevicePixelRatio = undefined;\n this.chartArea = undefined;\n this._active = [];\n this._lastEvent = undefined;\n this._listeners = {};\n this._responsiveListeners = undefined;\n this._sortedMetasets = [];\n this.scales = {};\n this._plugins = new PluginService();\n this.$proxies = {};\n this._hiddenIndices = {};\n this.attached = false;\n this._animationsDisabled = undefined;\n this.$context = undefined;\n this._doResize = debounce(function (mode) {\n return _this12.update(mode);\n }, options.resizeDelay || 0);\n this._dataChanges = [];\n instances[this.id] = this;\n if (!context || !canvas) {\n console.error(\"Failed to create chart: can't acquire context from the given item\");\n return;\n }\n animator.listen(this, 'complete', onAnimationsComplete);\n animator.listen(this, 'progress', onAnimationProgress);\n this._initialize();\n if (this.attached) {\n this.update();\n }\n }\n _createClass$1(Chart, [{\n key: \"aspectRatio\",\n get: function get() {\n var _this$options12 = this.options,\n aspectRatio = _this$options12.aspectRatio,\n maintainAspectRatio = _this$options12.maintainAspectRatio,\n width = this.width,\n height = this.height,\n _aspectRatio = this._aspectRatio;\n if (!isNullOrUndef(aspectRatio)) {\n return aspectRatio;\n }\n if (maintainAspectRatio && _aspectRatio) {\n return _aspectRatio;\n }\n return height ? width / height : null;\n }\n }, {\n key: \"data\",\n get: function get() {\n return this.config.data;\n },\n set: function set(data) {\n this.config.data = data;\n }\n }, {\n key: \"options\",\n get: function get() {\n return this._options;\n },\n set: function set(options) {\n this.config.options = options;\n }\n }, {\n key: \"registry\",\n get: function get() {\n return registry;\n }\n }, {\n key: \"_initialize\",\n value: function _initialize() {\n this.notifyPlugins('beforeInit');\n if (this.options.responsive) {\n this.resize();\n } else {\n retinaScale(this, this.options.devicePixelRatio);\n }\n this.bindEvents();\n this.notifyPlugins('afterInit');\n return this;\n }\n }, {\n key: \"clear\",\n value: function clear() {\n clearCanvas(this.canvas, this.ctx);\n return this;\n }\n }, {\n key: \"stop\",\n value: function stop() {\n animator.stop(this);\n return this;\n }\n }, {\n key: \"resize\",\n value: function resize(width, height) {\n if (!animator.running(this)) {\n this._resize(width, height);\n } else {\n this._resizeBeforeDraw = {\n width: width,\n height: height\n };\n }\n }\n }, {\n key: \"_resize\",\n value: function _resize(width, height) {\n var options = this.options;\n var canvas = this.canvas;\n var aspectRatio = options.maintainAspectRatio && this.aspectRatio;\n var newSize = this.platform.getMaximumSize(canvas, width, height, aspectRatio);\n var newRatio = options.devicePixelRatio || this.platform.getDevicePixelRatio();\n var mode = this.width ? 'resize' : 'attach';\n this.width = newSize.width;\n this.height = newSize.height;\n this._aspectRatio = this.aspectRatio;\n if (!retinaScale(this, newRatio, true)) {\n return;\n }\n this.notifyPlugins('resize', {\n size: newSize\n });\n callback(options.onResize, [this, newSize], this);\n if (this.attached) {\n if (this._doResize(mode)) {\n this.render();\n }\n }\n }\n }, {\n key: \"ensureScalesHaveIDs\",\n value: function ensureScalesHaveIDs() {\n var options = this.options;\n var scalesOptions = options.scales || {};\n each(scalesOptions, function (axisOptions, axisID) {\n axisOptions.id = axisID;\n });\n }\n }, {\n key: \"buildOrUpdateScales\",\n value: function buildOrUpdateScales() {\n var _this13 = this;\n var options = this.options;\n var scaleOpts = options.scales;\n var scales = this.scales;\n var updated = Object.keys(scales).reduce(function (obj, id) {\n obj[id] = false;\n return obj;\n }, {});\n var items = [];\n if (scaleOpts) {\n items = items.concat(Object.keys(scaleOpts).map(function (id) {\n var scaleOptions = scaleOpts[id];\n var axis = determineAxis(id, scaleOptions);\n var isRadial = axis === 'r';\n var isHorizontal = axis === 'x';\n return {\n options: scaleOptions,\n dposition: isRadial ? 'chartArea' : isHorizontal ? 'bottom' : 'left',\n dtype: isRadial ? 'radialLinear' : isHorizontal ? 'category' : 'linear'\n };\n }));\n }\n each(items, function (item) {\n var scaleOptions = item.options;\n var id = scaleOptions.id;\n var axis = determineAxis(id, scaleOptions);\n var scaleType = valueOrDefault(scaleOptions.type, item.dtype);\n if (scaleOptions.position === undefined || positionIsHorizontal(scaleOptions.position, axis) !== positionIsHorizontal(item.dposition)) {\n scaleOptions.position = item.dposition;\n }\n updated[id] = true;\n var scale = null;\n if (id in scales && scales[id].type === scaleType) {\n scale = scales[id];\n } else {\n var scaleClass = registry.getScale(scaleType);\n scale = new scaleClass({\n id: id,\n type: scaleType,\n ctx: _this13.ctx,\n chart: _this13\n });\n scales[scale.id] = scale;\n }\n scale.init(scaleOptions, options);\n });\n each(updated, function (hasUpdated, id) {\n if (!hasUpdated) {\n delete scales[id];\n }\n });\n each(scales, function (scale) {\n layouts.configure(_this13, scale, scale.options);\n layouts.addBox(_this13, scale);\n });\n }\n }, {\n key: \"_updateMetasets\",\n value: function _updateMetasets() {\n var metasets = this._metasets;\n var numData = this.data.datasets.length;\n var numMeta = metasets.length;\n metasets.sort(function (a, b) {\n return a.index - b.index;\n });\n if (numMeta > numData) {\n for (var i = numData; i < numMeta; ++i) {\n this._destroyDatasetMeta(i);\n }\n metasets.splice(numData, numMeta - numData);\n }\n this._sortedMetasets = metasets.slice(0).sort(compare2Level('order', 'index'));\n }\n }, {\n key: \"_removeUnreferencedMetasets\",\n value: function _removeUnreferencedMetasets() {\n var _this14 = this;\n var metasets = this._metasets,\n datasets = this.data.datasets;\n if (metasets.length > datasets.length) {\n delete this._stacks;\n }\n metasets.forEach(function (meta, index) {\n if (datasets.filter(function (x) {\n return x === meta._dataset;\n }).length === 0) {\n _this14._destroyDatasetMeta(index);\n }\n });\n }\n }, {\n key: \"buildOrUpdateControllers\",\n value: function buildOrUpdateControllers() {\n var newControllers = [];\n var datasets = this.data.datasets;\n var i, ilen;\n this._removeUnreferencedMetasets();\n for (i = 0, ilen = datasets.length; i < ilen; i++) {\n var dataset = datasets[i];\n var meta = this.getDatasetMeta(i);\n var type = dataset.type || this.config.type;\n if (meta.type && meta.type !== type) {\n this._destroyDatasetMeta(i);\n meta = this.getDatasetMeta(i);\n }\n meta.type = type;\n meta.indexAxis = dataset.indexAxis || getIndexAxis(type, this.options);\n meta.order = dataset.order || 0;\n meta.index = i;\n meta.label = '' + dataset.label;\n meta.visible = this.isDatasetVisible(i);\n if (meta.controller) {\n meta.controller.updateIndex(i);\n meta.controller.linkScales();\n } else {\n var ControllerClass = registry.getController(type);\n var _defaults$datasets$ty = defaults.datasets[type],\n datasetElementType = _defaults$datasets$ty.datasetElementType,\n dataElementType = _defaults$datasets$ty.dataElementType;\n Object.assign(ControllerClass, {\n dataElementType: registry.getElement(dataElementType),\n datasetElementType: datasetElementType && registry.getElement(datasetElementType)\n });\n meta.controller = new ControllerClass(this, i);\n newControllers.push(meta.controller);\n }\n }\n this._updateMetasets();\n return newControllers;\n }\n }, {\n key: \"_resetElements\",\n value: function _resetElements() {\n var _this15 = this;\n each(this.data.datasets, function (dataset, datasetIndex) {\n _this15.getDatasetMeta(datasetIndex).controller.reset();\n }, this);\n }\n }, {\n key: \"reset\",\n value: function reset() {\n this._resetElements();\n this.notifyPlugins('reset');\n }\n }, {\n key: \"update\",\n value: function update(mode) {\n var config = this.config;\n config.update();\n var options = this._options = config.createResolver(config.chartOptionScopes(), this.getContext());\n var animsDisabled = this._animationsDisabled = !options.animation;\n this._updateScales();\n this._checkEventBindings();\n this._updateHiddenIndices();\n this._plugins.invalidate();\n if (this.notifyPlugins('beforeUpdate', {\n mode: mode,\n cancelable: true\n }) === false) {\n return;\n }\n var newControllers = this.buildOrUpdateControllers();\n this.notifyPlugins('beforeElementsUpdate');\n var minPadding = 0;\n for (var i = 0, ilen = this.data.datasets.length; i < ilen; i++) {\n var _this$getDatasetMeta = this.getDatasetMeta(i),\n controller = _this$getDatasetMeta.controller;\n var reset = !animsDisabled && newControllers.indexOf(controller) === -1;\n controller.buildOrUpdateElements(reset);\n minPadding = Math.max(+controller.getMaxOverflow(), minPadding);\n }\n minPadding = this._minPadding = options.layout.autoPadding ? minPadding : 0;\n this._updateLayout(minPadding);\n if (!animsDisabled) {\n each(newControllers, function (controller) {\n controller.reset();\n });\n }\n this._updateDatasets(mode);\n this.notifyPlugins('afterUpdate', {\n mode: mode\n });\n this._layers.sort(compare2Level('z', '_idx'));\n var _active = this._active,\n _lastEvent = this._lastEvent;\n if (_lastEvent) {\n this._eventHandler(_lastEvent, true);\n } else if (_active.length) {\n this._updateHoverStyles(_active, _active, true);\n }\n this.render();\n }\n }, {\n key: \"_updateScales\",\n value: function _updateScales() {\n var _this16 = this;\n each(this.scales, function (scale) {\n layouts.removeBox(_this16, scale);\n });\n this.ensureScalesHaveIDs();\n this.buildOrUpdateScales();\n }\n }, {\n key: \"_checkEventBindings\",\n value: function _checkEventBindings() {\n var options = this.options;\n var existingEvents = new Set(Object.keys(this._listeners));\n var newEvents = new Set(options.events);\n if (!setsEqual(existingEvents, newEvents) || !!this._responsiveListeners !== options.responsive) {\n this.unbindEvents();\n this.bindEvents();\n }\n }\n }, {\n key: \"_updateHiddenIndices\",\n value: function _updateHiddenIndices() {\n var _hiddenIndices = this._hiddenIndices;\n var changes = this._getUniformDataChanges() || [];\n var _iterator15 = _createForOfIteratorHelper$1(changes),\n _step15;\n try {\n for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {\n var _step15$value = _step15.value,\n method = _step15$value.method,\n start = _step15$value.start,\n count = _step15$value.count;\n var move = method === '_removeElements' ? -count : count;\n moveNumericKeys(_hiddenIndices, start, move);\n }\n } catch (err) {\n _iterator15.e(err);\n } finally {\n _iterator15.f();\n }\n }\n }, {\n key: \"_getUniformDataChanges\",\n value: function _getUniformDataChanges() {\n var _dataChanges = this._dataChanges;\n if (!_dataChanges || !_dataChanges.length) {\n return;\n }\n this._dataChanges = [];\n var datasetCount = this.data.datasets.length;\n var makeSet = function makeSet(idx) {\n return new Set(_dataChanges.filter(function (c) {\n return c[0] === idx;\n }).map(function (c, i) {\n return i + ',' + c.splice(1).join(',');\n }));\n };\n var changeSet = makeSet(0);\n for (var i = 1; i < datasetCount; i++) {\n if (!setsEqual(changeSet, makeSet(i))) {\n return;\n }\n }\n return Array.from(changeSet).map(function (c) {\n return c.split(',');\n }).map(function (a) {\n return {\n method: a[1],\n start: +a[2],\n count: +a[3]\n };\n });\n }\n }, {\n key: \"_updateLayout\",\n value: function _updateLayout(minPadding) {\n var _this17 = this;\n if (this.notifyPlugins('beforeLayout', {\n cancelable: true\n }) === false) {\n return;\n }\n layouts.update(this, this.width, this.height, minPadding);\n var area = this.chartArea;\n var noArea = area.width <= 0 || area.height <= 0;\n this._layers = [];\n each(this.boxes, function (box) {\n var _this17$_layers;\n if (noArea && box.position === 'chartArea') {\n return;\n }\n if (box.configure) {\n box.configure();\n }\n (_this17$_layers = _this17._layers).push.apply(_this17$_layers, _toConsumableArray(box._layers()));\n }, this);\n this._layers.forEach(function (item, index) {\n item._idx = index;\n });\n this.notifyPlugins('afterLayout');\n }\n }, {\n key: \"_updateDatasets\",\n value: function _updateDatasets(mode) {\n if (this.notifyPlugins('beforeDatasetsUpdate', {\n mode: mode,\n cancelable: true\n }) === false) {\n return;\n }\n for (var i = 0, ilen = this.data.datasets.length; i < ilen; ++i) {\n this.getDatasetMeta(i).controller.configure();\n }\n for (var _i5 = 0, _ilen = this.data.datasets.length; _i5 < _ilen; ++_i5) {\n this._updateDataset(_i5, isFunction(mode) ? mode({\n datasetIndex: _i5\n }) : mode);\n }\n this.notifyPlugins('afterDatasetsUpdate', {\n mode: mode\n });\n }\n }, {\n key: \"_updateDataset\",\n value: function _updateDataset(index, mode) {\n var meta = this.getDatasetMeta(index);\n var args = {\n meta: meta,\n index: index,\n mode: mode,\n cancelable: true\n };\n if (this.notifyPlugins('beforeDatasetUpdate', args) === false) {\n return;\n }\n meta.controller._update(mode);\n args.cancelable = false;\n this.notifyPlugins('afterDatasetUpdate', args);\n }\n }, {\n key: \"render\",\n value: function render() {\n if (this.notifyPlugins('beforeRender', {\n cancelable: true\n }) === false) {\n return;\n }\n if (animator.has(this)) {\n if (this.attached && !animator.running(this)) {\n animator.start(this);\n }\n } else {\n this.draw();\n onAnimationsComplete({\n chart: this\n });\n }\n }\n }, {\n key: \"draw\",\n value: function draw() {\n var i;\n if (this._resizeBeforeDraw) {\n var _this$_resizeBeforeDr = this._resizeBeforeDraw,\n width = _this$_resizeBeforeDr.width,\n height = _this$_resizeBeforeDr.height;\n this._resize(width, height);\n this._resizeBeforeDraw = null;\n }\n this.clear();\n if (this.width <= 0 || this.height <= 0) {\n return;\n }\n if (this.notifyPlugins('beforeDraw', {\n cancelable: true\n }) === false) {\n return;\n }\n var layers = this._layers;\n for (i = 0; i < layers.length && layers[i].z <= 0; ++i) {\n layers[i].draw(this.chartArea);\n }\n this._drawDatasets();\n for (; i < layers.length; ++i) {\n layers[i].draw(this.chartArea);\n }\n this.notifyPlugins('afterDraw');\n }\n }, {\n key: \"_getSortedDatasetMetas\",\n value: function _getSortedDatasetMetas(filterVisible) {\n var metasets = this._sortedMetasets;\n var result = [];\n var i, ilen;\n for (i = 0, ilen = metasets.length; i < ilen; ++i) {\n var meta = metasets[i];\n if (!filterVisible || meta.visible) {\n result.push(meta);\n }\n }\n return result;\n }\n }, {\n key: \"getSortedVisibleDatasetMetas\",\n value: function getSortedVisibleDatasetMetas() {\n return this._getSortedDatasetMetas(true);\n }\n }, {\n key: \"_drawDatasets\",\n value: function _drawDatasets() {\n if (this.notifyPlugins('beforeDatasetsDraw', {\n cancelable: true\n }) === false) {\n return;\n }\n var metasets = this.getSortedVisibleDatasetMetas();\n for (var i = metasets.length - 1; i >= 0; --i) {\n this._drawDataset(metasets[i]);\n }\n this.notifyPlugins('afterDatasetsDraw');\n }\n }, {\n key: \"_drawDataset\",\n value: function _drawDataset(meta) {\n var ctx = this.ctx;\n var clip = meta._clip;\n var useClip = !clip.disabled;\n var area = getDatasetArea(meta, this.chartArea);\n var args = {\n meta: meta,\n index: meta.index,\n cancelable: true\n };\n if (this.notifyPlugins('beforeDatasetDraw', args) === false) {\n return;\n }\n if (useClip) {\n clipArea(ctx, {\n left: clip.left === false ? 0 : area.left - clip.left,\n right: clip.right === false ? this.width : area.right + clip.right,\n top: clip.top === false ? 0 : area.top - clip.top,\n bottom: clip.bottom === false ? this.height : area.bottom + clip.bottom\n });\n }\n meta.controller.draw();\n if (useClip) {\n unclipArea(ctx);\n }\n args.cancelable = false;\n this.notifyPlugins('afterDatasetDraw', args);\n }\n }, {\n key: \"isPointInArea\",\n value: function isPointInArea(point) {\n return _isPointInArea(point, this.chartArea, this._minPadding);\n }\n }, {\n key: \"getElementsAtEventForMode\",\n value: function getElementsAtEventForMode(e, mode, options, useFinalPosition) {\n var method = Interaction.modes[mode];\n if (typeof method === 'function') {\n return method(this, e, options, useFinalPosition);\n }\n return [];\n }\n }, {\n key: \"getDatasetMeta\",\n value: function getDatasetMeta(datasetIndex) {\n var dataset = this.data.datasets[datasetIndex];\n var metasets = this._metasets;\n var meta = metasets.filter(function (x) {\n return x && x._dataset === dataset;\n }).pop();\n if (!meta) {\n meta = {\n type: null,\n data: [],\n dataset: null,\n controller: null,\n hidden: null,\n xAxisID: null,\n yAxisID: null,\n order: dataset && dataset.order || 0,\n index: datasetIndex,\n _dataset: dataset,\n _parsed: [],\n _sorted: false\n };\n metasets.push(meta);\n }\n return meta;\n }\n }, {\n key: \"getContext\",\n value: function getContext() {\n return this.$context || (this.$context = createContext(null, {\n chart: this,\n type: 'chart'\n }));\n }\n }, {\n key: \"getVisibleDatasetCount\",\n value: function getVisibleDatasetCount() {\n return this.getSortedVisibleDatasetMetas().length;\n }\n }, {\n key: \"isDatasetVisible\",\n value: function isDatasetVisible(datasetIndex) {\n var dataset = this.data.datasets[datasetIndex];\n if (!dataset) {\n return false;\n }\n var meta = this.getDatasetMeta(datasetIndex);\n return typeof meta.hidden === 'boolean' ? !meta.hidden : !dataset.hidden;\n }\n }, {\n key: \"setDatasetVisibility\",\n value: function setDatasetVisibility(datasetIndex, visible) {\n var meta = this.getDatasetMeta(datasetIndex);\n meta.hidden = !visible;\n }\n }, {\n key: \"toggleDataVisibility\",\n value: function toggleDataVisibility(index) {\n this._hiddenIndices[index] = !this._hiddenIndices[index];\n }\n }, {\n key: \"getDataVisibility\",\n value: function getDataVisibility(index) {\n return !this._hiddenIndices[index];\n }\n }, {\n key: \"_updateVisibility\",\n value: function _updateVisibility(datasetIndex, dataIndex, visible) {\n var mode = visible ? 'show' : 'hide';\n var meta = this.getDatasetMeta(datasetIndex);\n var anims = meta.controller._resolveAnimations(undefined, mode);\n if (defined(dataIndex)) {\n meta.data[dataIndex].hidden = !visible;\n this.update();\n } else {\n this.setDatasetVisibility(datasetIndex, visible);\n anims.update(meta, {\n visible: visible\n });\n this.update(function (ctx) {\n return ctx.datasetIndex === datasetIndex ? mode : undefined;\n });\n }\n }\n }, {\n key: \"hide\",\n value: function hide(datasetIndex, dataIndex) {\n this._updateVisibility(datasetIndex, dataIndex, false);\n }\n }, {\n key: \"show\",\n value: function show(datasetIndex, dataIndex) {\n this._updateVisibility(datasetIndex, dataIndex, true);\n }\n }, {\n key: \"_destroyDatasetMeta\",\n value: function _destroyDatasetMeta(datasetIndex) {\n var meta = this._metasets[datasetIndex];\n if (meta && meta.controller) {\n meta.controller._destroy();\n }\n delete this._metasets[datasetIndex];\n }\n }, {\n key: \"_stop\",\n value: function _stop() {\n var i, ilen;\n this.stop();\n animator.remove(this);\n for (i = 0, ilen = this.data.datasets.length; i < ilen; ++i) {\n this._destroyDatasetMeta(i);\n }\n }\n }, {\n key: \"destroy\",\n value: function destroy() {\n this.notifyPlugins('beforeDestroy');\n var canvas = this.canvas,\n ctx = this.ctx;\n this._stop();\n this.config.clearCache();\n if (canvas) {\n this.unbindEvents();\n clearCanvas(canvas, ctx);\n this.platform.releaseContext(ctx);\n this.canvas = null;\n this.ctx = null;\n }\n delete instances[this.id];\n this.notifyPlugins('afterDestroy');\n }\n }, {\n key: \"toBase64Image\",\n value: function toBase64Image() {\n var _this$canvas;\n return (_this$canvas = this.canvas).toDataURL.apply(_this$canvas, arguments);\n }\n }, {\n key: \"bindEvents\",\n value: function bindEvents() {\n this.bindUserEvents();\n if (this.options.responsive) {\n this.bindResponsiveEvents();\n } else {\n this.attached = true;\n }\n }\n }, {\n key: \"bindUserEvents\",\n value: function bindUserEvents() {\n var _this18 = this;\n var listeners = this._listeners;\n var platform = this.platform;\n var _add = function _add(type, listener) {\n platform.addEventListener(_this18, type, listener);\n listeners[type] = listener;\n };\n var listener = function listener(e, x, y) {\n e.offsetX = x;\n e.offsetY = y;\n _this18._eventHandler(e);\n };\n each(this.options.events, function (type) {\n return _add(type, listener);\n });\n }\n }, {\n key: \"bindResponsiveEvents\",\n value: function bindResponsiveEvents() {\n var _this19 = this;\n if (!this._responsiveListeners) {\n this._responsiveListeners = {};\n }\n var listeners = this._responsiveListeners;\n var platform = this.platform;\n var _add = function _add(type, listener) {\n platform.addEventListener(_this19, type, listener);\n listeners[type] = listener;\n };\n var _remove = function _remove(type, listener) {\n if (listeners[type]) {\n platform.removeEventListener(_this19, type, listener);\n delete listeners[type];\n }\n };\n var listener = function listener(width, height) {\n if (_this19.canvas) {\n _this19.resize(width, height);\n }\n };\n var detached;\n var attached = function attached() {\n _remove('attach', attached);\n _this19.attached = true;\n _this19.resize();\n _add('resize', listener);\n _add('detach', detached);\n };\n detached = function detached() {\n _this19.attached = false;\n _remove('resize', listener);\n _this19._stop();\n _this19._resize(0, 0);\n _add('attach', attached);\n };\n if (platform.isAttached(this.canvas)) {\n attached();\n } else {\n detached();\n }\n }\n }, {\n key: \"unbindEvents\",\n value: function unbindEvents() {\n var _this20 = this;\n each(this._listeners, function (listener, type) {\n _this20.platform.removeEventListener(_this20, type, listener);\n });\n this._listeners = {};\n each(this._responsiveListeners, function (listener, type) {\n _this20.platform.removeEventListener(_this20, type, listener);\n });\n this._responsiveListeners = undefined;\n }\n }, {\n key: \"updateHoverStyle\",\n value: function updateHoverStyle(items, mode, enabled) {\n var prefix = enabled ? 'set' : 'remove';\n var meta, item, i, ilen;\n if (mode === 'dataset') {\n meta = this.getDatasetMeta(items[0].datasetIndex);\n meta.controller['_' + prefix + 'DatasetHoverStyle']();\n }\n for (i = 0, ilen = items.length; i < ilen; ++i) {\n item = items[i];\n var controller = item && this.getDatasetMeta(item.datasetIndex).controller;\n if (controller) {\n controller[prefix + 'HoverStyle'](item.element, item.datasetIndex, item.index);\n }\n }\n }\n }, {\n key: \"getActiveElements\",\n value: function getActiveElements() {\n return this._active || [];\n }\n }, {\n key: \"setActiveElements\",\n value: function setActiveElements(activeElements) {\n var _this21 = this;\n var lastActive = this._active || [];\n var active = activeElements.map(function (_ref4) {\n var datasetIndex = _ref4.datasetIndex,\n index = _ref4.index;\n var meta = _this21.getDatasetMeta(datasetIndex);\n if (!meta) {\n throw new Error('No dataset found at index ' + datasetIndex);\n }\n return {\n datasetIndex: datasetIndex,\n element: meta.data[index],\n index: index\n };\n });\n var changed = !_elementsEqual(active, lastActive);\n if (changed) {\n this._active = active;\n this._lastEvent = null;\n this._updateHoverStyles(active, lastActive);\n }\n }\n }, {\n key: \"notifyPlugins\",\n value: function notifyPlugins(hook, args, filter) {\n return this._plugins.notify(this, hook, args, filter);\n }\n }, {\n key: \"isPluginEnabled\",\n value: function isPluginEnabled(pluginId) {\n return this._plugins._cache.filter(function (p) {\n return p.plugin.id === pluginId;\n }).length === 1;\n }\n }, {\n key: \"_updateHoverStyles\",\n value: function _updateHoverStyles(active, lastActive, replay) {\n var hoverOptions = this.options.hover;\n var diff = function diff(a, b) {\n return a.filter(function (x) {\n return !b.some(function (y) {\n return x.datasetIndex === y.datasetIndex && x.index === y.index;\n });\n });\n };\n var deactivated = diff(lastActive, active);\n var activated = replay ? active : diff(active, lastActive);\n if (deactivated.length) {\n this.updateHoverStyle(deactivated, hoverOptions.mode, false);\n }\n if (activated.length && hoverOptions.mode) {\n this.updateHoverStyle(activated, hoverOptions.mode, true);\n }\n }\n }, {\n key: \"_eventHandler\",\n value: function _eventHandler(e, replay) {\n var _this22 = this;\n var args = {\n event: e,\n replay: replay,\n cancelable: true,\n inChartArea: this.isPointInArea(e)\n };\n var eventFilter = function eventFilter(plugin) {\n return (plugin.options.events || _this22.options.events).includes(e[\"native\"].type);\n };\n if (this.notifyPlugins('beforeEvent', args, eventFilter) === false) {\n return;\n }\n var changed = this._handleEvent(e, replay, args.inChartArea);\n args.cancelable = false;\n this.notifyPlugins('afterEvent', args, eventFilter);\n if (changed || args.changed) {\n this.render();\n }\n return this;\n }\n }, {\n key: \"_handleEvent\",\n value: function _handleEvent(e, replay, inChartArea) {\n var _this$_active = this._active,\n lastActive = _this$_active === void 0 ? [] : _this$_active,\n options = this.options;\n var useFinalPosition = replay;\n var active = this._getActiveElements(e, lastActive, inChartArea, useFinalPosition);\n var isClick = _isClickEvent(e);\n var lastEvent = determineLastEvent(e, this._lastEvent, inChartArea, isClick);\n if (inChartArea) {\n this._lastEvent = null;\n callback(options.onHover, [e, active, this], this);\n if (isClick) {\n callback(options.onClick, [e, active, this], this);\n }\n }\n var changed = !_elementsEqual(active, lastActive);\n if (changed || replay) {\n this._active = active;\n this._updateHoverStyles(active, lastActive, replay);\n }\n this._lastEvent = lastEvent;\n return changed;\n }\n }, {\n key: \"_getActiveElements\",\n value: function _getActiveElements(e, lastActive, inChartArea, useFinalPosition) {\n if (e.type === 'mouseout') {\n return [];\n }\n if (!inChartArea) {\n return lastActive;\n }\n var hoverOptions = this.options.hover;\n return this.getElementsAtEventForMode(e, hoverOptions.mode, hoverOptions, useFinalPosition);\n }\n }], [{\n key: \"register\",\n value: function register() {\n registry.add.apply(registry, arguments);\n invalidatePlugins();\n }\n }, {\n key: \"unregister\",\n value: function unregister() {\n registry.remove.apply(registry, arguments);\n invalidatePlugins();\n }\n }]);\n return Chart;\n }();\n _defineProperty$1(Chart, \"defaults\", defaults);\n _defineProperty$1(Chart, \"instances\", instances);\n _defineProperty$1(Chart, \"overrides\", overrides);\n _defineProperty$1(Chart, \"registry\", registry);\n _defineProperty$1(Chart, \"version\", version);\n _defineProperty$1(Chart, \"getChart\", getChart);\n function invalidatePlugins() {\n return each(Chart.instances, function (chart) {\n return chart._plugins.invalidate();\n });\n }\n function clipArc(ctx, element, endAngle) {\n var startAngle = element.startAngle,\n pixelMargin = element.pixelMargin,\n x = element.x,\n y = element.y,\n outerRadius = element.outerRadius,\n innerRadius = element.innerRadius;\n var angleMargin = pixelMargin / outerRadius;\n // Draw an inner border by clipping the arc and drawing a double-width border\n // Enlarge the clipping arc by 0.33 pixels to eliminate glitches between borders\n ctx.beginPath();\n ctx.arc(x, y, outerRadius, startAngle - angleMargin, endAngle + angleMargin);\n if (innerRadius > pixelMargin) {\n angleMargin = pixelMargin / innerRadius;\n ctx.arc(x, y, innerRadius, endAngle + angleMargin, startAngle - angleMargin, true);\n } else {\n ctx.arc(x, y, pixelMargin, endAngle + HALF_PI, startAngle - HALF_PI);\n }\n ctx.closePath();\n ctx.clip();\n }\n function toRadiusCorners(value) {\n return _readValueToProps(value, ['outerStart', 'outerEnd', 'innerStart', 'innerEnd']);\n }\n /**\n * Parse border radius from the provided options\n */\n function parseBorderRadius$1(arc, innerRadius, outerRadius, angleDelta) {\n var o = toRadiusCorners(arc.options.borderRadius);\n var halfThickness = (outerRadius - innerRadius) / 2;\n var innerLimit = Math.min(halfThickness, angleDelta * innerRadius / 2);\n // Outer limits are complicated. We want to compute the available angular distance at\n // a radius of outerRadius - borderRadius because for small angular distances, this term limits.\n // We compute at r = outerRadius - borderRadius because this circle defines the center of the border corners.\n //\n // If the borderRadius is large, that value can become negative.\n // This causes the outer borders to lose their radius entirely, which is rather unexpected. To solve that, if borderRadius > outerRadius\n // we know that the thickness term will dominate and compute the limits at that point\n var computeOuterLimit = function computeOuterLimit(val) {\n var outerArcLimit = (outerRadius - Math.min(halfThickness, val)) * angleDelta / 2;\n return _limitValue(val, 0, Math.min(halfThickness, outerArcLimit));\n };\n return {\n outerStart: computeOuterLimit(o.outerStart),\n outerEnd: computeOuterLimit(o.outerEnd),\n innerStart: _limitValue(o.innerStart, 0, innerLimit),\n innerEnd: _limitValue(o.innerEnd, 0, innerLimit)\n };\n }\n /**\n * Convert (r, 𝜃) to (x, y)\n */\n function rThetaToXY(r, theta, x, y) {\n return {\n x: x + r * Math.cos(theta),\n y: y + r * Math.sin(theta)\n };\n }\n /**\n * Path the arc, respecting border radius by separating into left and right halves.\n *\n * Start End\n *\n * 1--->a--->2 Outer\n * / \\\n * 8 3\n * | |\n * | |\n * 7 4\n * \\ /\n * 6<---b<---5 Inner\n */\n function pathArc(ctx, element, offset, spacing, end, circular) {\n var x = element.x,\n y = element.y,\n start = element.startAngle,\n pixelMargin = element.pixelMargin,\n innerR = element.innerRadius;\n var outerRadius = Math.max(element.outerRadius + spacing + offset - pixelMargin, 0);\n var innerRadius = innerR > 0 ? innerR + spacing + offset + pixelMargin : 0;\n var spacingOffset = 0;\n var alpha = end - start;\n if (spacing) {\n // When spacing is present, it is the same for all items\n // So we adjust the start and end angle of the arc such that\n // the distance is the same as it would be without the spacing\n var noSpacingInnerRadius = innerR > 0 ? innerR - spacing : 0;\n var noSpacingOuterRadius = outerRadius > 0 ? outerRadius - spacing : 0;\n var avNogSpacingRadius = (noSpacingInnerRadius + noSpacingOuterRadius) / 2;\n var adjustedAngle = avNogSpacingRadius !== 0 ? alpha * avNogSpacingRadius / (avNogSpacingRadius + spacing) : alpha;\n spacingOffset = (alpha - adjustedAngle) / 2;\n }\n var beta = Math.max(0.001, alpha * outerRadius - offset / PI) / outerRadius;\n var angleOffset = (alpha - beta) / 2;\n var startAngle = start + angleOffset + spacingOffset;\n var endAngle = end - angleOffset - spacingOffset;\n var _parseBorderRadius$ = parseBorderRadius$1(element, innerRadius, outerRadius, endAngle - startAngle),\n outerStart = _parseBorderRadius$.outerStart,\n outerEnd = _parseBorderRadius$.outerEnd,\n innerStart = _parseBorderRadius$.innerStart,\n innerEnd = _parseBorderRadius$.innerEnd;\n var outerStartAdjustedRadius = outerRadius - outerStart;\n var outerEndAdjustedRadius = outerRadius - outerEnd;\n var outerStartAdjustedAngle = startAngle + outerStart / outerStartAdjustedRadius;\n var outerEndAdjustedAngle = endAngle - outerEnd / outerEndAdjustedRadius;\n var innerStartAdjustedRadius = innerRadius + innerStart;\n var innerEndAdjustedRadius = innerRadius + innerEnd;\n var innerStartAdjustedAngle = startAngle + innerStart / innerStartAdjustedRadius;\n var innerEndAdjustedAngle = endAngle - innerEnd / innerEndAdjustedRadius;\n ctx.beginPath();\n if (circular) {\n // The first arc segments from point 1 to point a to point 2\n var outerMidAdjustedAngle = (outerStartAdjustedAngle + outerEndAdjustedAngle) / 2;\n ctx.arc(x, y, outerRadius, outerStartAdjustedAngle, outerMidAdjustedAngle);\n ctx.arc(x, y, outerRadius, outerMidAdjustedAngle, outerEndAdjustedAngle);\n // The corner segment from point 2 to point 3\n if (outerEnd > 0) {\n var pCenter = rThetaToXY(outerEndAdjustedRadius, outerEndAdjustedAngle, x, y);\n ctx.arc(pCenter.x, pCenter.y, outerEnd, outerEndAdjustedAngle, endAngle + HALF_PI);\n }\n // The line from point 3 to point 4\n var p4 = rThetaToXY(innerEndAdjustedRadius, endAngle, x, y);\n ctx.lineTo(p4.x, p4.y);\n // The corner segment from point 4 to point 5\n if (innerEnd > 0) {\n var _pCenter = rThetaToXY(innerEndAdjustedRadius, innerEndAdjustedAngle, x, y);\n ctx.arc(_pCenter.x, _pCenter.y, innerEnd, endAngle + HALF_PI, innerEndAdjustedAngle + Math.PI);\n }\n // The inner arc from point 5 to point b to point 6\n var innerMidAdjustedAngle = (endAngle - innerEnd / innerRadius + (startAngle + innerStart / innerRadius)) / 2;\n ctx.arc(x, y, innerRadius, endAngle - innerEnd / innerRadius, innerMidAdjustedAngle, true);\n ctx.arc(x, y, innerRadius, innerMidAdjustedAngle, startAngle + innerStart / innerRadius, true);\n // The corner segment from point 6 to point 7\n if (innerStart > 0) {\n var _pCenter2 = rThetaToXY(innerStartAdjustedRadius, innerStartAdjustedAngle, x, y);\n ctx.arc(_pCenter2.x, _pCenter2.y, innerStart, innerStartAdjustedAngle + Math.PI, startAngle - HALF_PI);\n }\n // The line from point 7 to point 8\n var p8 = rThetaToXY(outerStartAdjustedRadius, startAngle, x, y);\n ctx.lineTo(p8.x, p8.y);\n // The corner segment from point 8 to point 1\n if (outerStart > 0) {\n var _pCenter3 = rThetaToXY(outerStartAdjustedRadius, outerStartAdjustedAngle, x, y);\n ctx.arc(_pCenter3.x, _pCenter3.y, outerStart, startAngle - HALF_PI, outerStartAdjustedAngle);\n }\n } else {\n ctx.moveTo(x, y);\n var outerStartX = Math.cos(outerStartAdjustedAngle) * outerRadius + x;\n var outerStartY = Math.sin(outerStartAdjustedAngle) * outerRadius + y;\n ctx.lineTo(outerStartX, outerStartY);\n var outerEndX = Math.cos(outerEndAdjustedAngle) * outerRadius + x;\n var outerEndY = Math.sin(outerEndAdjustedAngle) * outerRadius + y;\n ctx.lineTo(outerEndX, outerEndY);\n }\n ctx.closePath();\n }\n function drawArc(ctx, element, offset, spacing, circular) {\n var fullCircles = element.fullCircles,\n startAngle = element.startAngle,\n circumference = element.circumference;\n var endAngle = element.endAngle;\n if (fullCircles) {\n pathArc(ctx, element, offset, spacing, endAngle, circular);\n for (var i = 0; i < fullCircles; ++i) {\n ctx.fill();\n }\n if (!isNaN(circumference)) {\n endAngle = startAngle + (circumference % TAU || TAU);\n }\n }\n pathArc(ctx, element, offset, spacing, endAngle, circular);\n ctx.fill();\n return endAngle;\n }\n function drawBorder(ctx, element, offset, spacing, circular) {\n var fullCircles = element.fullCircles,\n startAngle = element.startAngle,\n circumference = element.circumference,\n options = element.options;\n var borderWidth = options.borderWidth,\n borderJoinStyle = options.borderJoinStyle,\n borderDash = options.borderDash,\n borderDashOffset = options.borderDashOffset;\n var inner = options.borderAlign === 'inner';\n if (!borderWidth) {\n return;\n }\n ctx.setLineDash(borderDash || []);\n ctx.lineDashOffset = borderDashOffset;\n if (inner) {\n ctx.lineWidth = borderWidth * 2;\n ctx.lineJoin = borderJoinStyle || 'round';\n } else {\n ctx.lineWidth = borderWidth;\n ctx.lineJoin = borderJoinStyle || 'bevel';\n }\n var endAngle = element.endAngle;\n if (fullCircles) {\n pathArc(ctx, element, offset, spacing, endAngle, circular);\n for (var i = 0; i < fullCircles; ++i) {\n ctx.stroke();\n }\n if (!isNaN(circumference)) {\n endAngle = startAngle + (circumference % TAU || TAU);\n }\n }\n if (inner) {\n clipArc(ctx, element, endAngle);\n }\n if (!fullCircles) {\n pathArc(ctx, element, offset, spacing, endAngle, circular);\n ctx.stroke();\n }\n }\n var ArcElement = /*#__PURE__*/function (_Element2) {\n _inherits$1(ArcElement, _Element2);\n var _super12 = _createSuper$1(ArcElement);\n function ArcElement(cfg) {\n var _this23;\n _classCallCheck$1(this, ArcElement);\n _this23 = _super12.call(this);\n _defineProperty$1(_assertThisInitialized$1(_this23), \"circumference\", void 0);\n _defineProperty$1(_assertThisInitialized$1(_this23), \"endAngle\", void 0);\n _defineProperty$1(_assertThisInitialized$1(_this23), \"fullCircles\", void 0);\n _defineProperty$1(_assertThisInitialized$1(_this23), \"innerRadius\", void 0);\n _defineProperty$1(_assertThisInitialized$1(_this23), \"outerRadius\", void 0);\n _defineProperty$1(_assertThisInitialized$1(_this23), \"pixelMargin\", void 0);\n _defineProperty$1(_assertThisInitialized$1(_this23), \"startAngle\", void 0);\n _this23.options = undefined;\n _this23.circumference = undefined;\n _this23.startAngle = undefined;\n _this23.endAngle = undefined;\n _this23.innerRadius = undefined;\n _this23.outerRadius = undefined;\n _this23.pixelMargin = 0;\n _this23.fullCircles = 0;\n if (cfg) {\n Object.assign(_assertThisInitialized$1(_this23), cfg);\n }\n return _this23;\n }\n _createClass$1(ArcElement, [{\n key: \"inRange\",\n value: function inRange(chartX, chartY, useFinalPosition) {\n var point = this.getProps(['x', 'y'], useFinalPosition);\n var _getAngleFromPoint2 = getAngleFromPoint(point, {\n x: chartX,\n y: chartY\n }),\n angle = _getAngleFromPoint2.angle,\n distance = _getAngleFromPoint2.distance;\n var _this$getProps2 = this.getProps(['startAngle', 'endAngle', 'innerRadius', 'outerRadius', 'circumference'], useFinalPosition),\n startAngle = _this$getProps2.startAngle,\n endAngle = _this$getProps2.endAngle,\n innerRadius = _this$getProps2.innerRadius,\n outerRadius = _this$getProps2.outerRadius,\n circumference = _this$getProps2.circumference;\n var rAdjust = (this.options.spacing + this.options.borderWidth) / 2;\n var _circumference = valueOrDefault(circumference, endAngle - startAngle);\n var betweenAngles = _circumference >= TAU || _angleBetween(angle, startAngle, endAngle);\n var withinRadius = _isBetween(distance, innerRadius + rAdjust, outerRadius + rAdjust);\n return betweenAngles && withinRadius;\n }\n }, {\n key: \"getCenterPoint\",\n value: function getCenterPoint(useFinalPosition) {\n var _this$getProps3 = this.getProps(['x', 'y', 'startAngle', 'endAngle', 'innerRadius', 'outerRadius'], useFinalPosition),\n x = _this$getProps3.x,\n y = _this$getProps3.y,\n startAngle = _this$getProps3.startAngle,\n endAngle = _this$getProps3.endAngle,\n innerRadius = _this$getProps3.innerRadius,\n outerRadius = _this$getProps3.outerRadius;\n var _this$options13 = this.options,\n offset = _this$options13.offset,\n spacing = _this$options13.spacing;\n var halfAngle = (startAngle + endAngle) / 2;\n var halfRadius = (innerRadius + outerRadius + spacing + offset) / 2;\n return {\n x: x + Math.cos(halfAngle) * halfRadius,\n y: y + Math.sin(halfAngle) * halfRadius\n };\n }\n }, {\n key: \"tooltipPosition\",\n value: function tooltipPosition(useFinalPosition) {\n return this.getCenterPoint(useFinalPosition);\n }\n }, {\n key: \"draw\",\n value: function draw(ctx) {\n var options = this.options,\n circumference = this.circumference;\n var offset = (options.offset || 0) / 4;\n var spacing = (options.spacing || 0) / 2;\n var circular = options.circular;\n this.pixelMargin = options.borderAlign === 'inner' ? 0.33 : 0;\n this.fullCircles = circumference > TAU ? Math.floor(circumference / TAU) : 0;\n if (circumference === 0 || this.innerRadius < 0 || this.outerRadius < 0) {\n return;\n }\n ctx.save();\n var halfAngle = (this.startAngle + this.endAngle) / 2;\n ctx.translate(Math.cos(halfAngle) * offset, Math.sin(halfAngle) * offset);\n var fix = 1 - Math.sin(Math.min(PI, circumference || 0));\n var radiusOffset = offset * fix;\n ctx.fillStyle = options.backgroundColor;\n ctx.strokeStyle = options.borderColor;\n drawArc(ctx, this, radiusOffset, spacing, circular);\n drawBorder(ctx, this, radiusOffset, spacing, circular);\n ctx.restore();\n }\n }]);\n return ArcElement;\n }(Element);\n _defineProperty$1(ArcElement, \"id\", 'arc');\n _defineProperty$1(ArcElement, \"defaults\", {\n borderAlign: 'center',\n borderColor: '#fff',\n borderDash: [],\n borderDashOffset: 0,\n borderJoinStyle: undefined,\n borderRadius: 0,\n borderWidth: 2,\n offset: 0,\n spacing: 0,\n angle: undefined,\n circular: true\n });\n _defineProperty$1(ArcElement, \"defaultRoutes\", {\n backgroundColor: 'backgroundColor'\n });\n _defineProperty$1(ArcElement, \"descriptors\", {\n _scriptable: true,\n _indexable: function _indexable(name) {\n return name !== 'borderDash';\n }\n });\n function setStyle(ctx, options) {\n var style = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : options;\n ctx.lineCap = valueOrDefault(style.borderCapStyle, options.borderCapStyle);\n ctx.setLineDash(valueOrDefault(style.borderDash, options.borderDash));\n ctx.lineDashOffset = valueOrDefault(style.borderDashOffset, options.borderDashOffset);\n ctx.lineJoin = valueOrDefault(style.borderJoinStyle, options.borderJoinStyle);\n ctx.lineWidth = valueOrDefault(style.borderWidth, options.borderWidth);\n ctx.strokeStyle = valueOrDefault(style.borderColor, options.borderColor);\n }\n function lineTo(ctx, previous, target) {\n ctx.lineTo(target.x, target.y);\n }\n function getLineMethod(options) {\n if (options.stepped) {\n return _steppedLineTo;\n }\n if (options.tension || options.cubicInterpolationMode === 'monotone') {\n return _bezierCurveTo;\n }\n return lineTo;\n }\n function pathVars(points, segment) {\n var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var count = points.length;\n var _params$start = params.start,\n paramsStart = _params$start === void 0 ? 0 : _params$start,\n _params$end = params.end,\n paramsEnd = _params$end === void 0 ? count - 1 : _params$end;\n var segmentStart = segment.start,\n segmentEnd = segment.end;\n var start = Math.max(paramsStart, segmentStart);\n var end = Math.min(paramsEnd, segmentEnd);\n var outside = paramsStart < segmentStart && paramsEnd < segmentStart || paramsStart > segmentEnd && paramsEnd > segmentEnd;\n return {\n count: count,\n start: start,\n loop: segment.loop,\n ilen: end < start && !outside ? count + end - start : end - start\n };\n }\n function pathSegment(ctx, line, segment, params) {\n var points = line.points,\n options = line.options;\n var _pathVars = pathVars(points, segment, params),\n count = _pathVars.count,\n start = _pathVars.start,\n loop = _pathVars.loop,\n ilen = _pathVars.ilen;\n var lineMethod = getLineMethod(options);\n var _ref5 = params || {},\n _ref5$move = _ref5.move,\n move = _ref5$move === void 0 ? true : _ref5$move,\n reverse = _ref5.reverse;\n var i, point, prev;\n for (i = 0; i <= ilen; ++i) {\n point = points[(start + (reverse ? ilen - i : i)) % count];\n if (point.skip) {\n continue;\n } else if (move) {\n ctx.moveTo(point.x, point.y);\n move = false;\n } else {\n lineMethod(ctx, prev, point, reverse, options.stepped);\n }\n prev = point;\n }\n if (loop) {\n point = points[(start + (reverse ? ilen : 0)) % count];\n lineMethod(ctx, prev, point, reverse, options.stepped);\n }\n return !!loop;\n }\n function fastPathSegment(ctx, line, segment, params) {\n var points = line.points;\n var _pathVars2 = pathVars(points, segment, params),\n count = _pathVars2.count,\n start = _pathVars2.start,\n ilen = _pathVars2.ilen;\n var _ref6 = params || {},\n _ref6$move = _ref6.move,\n move = _ref6$move === void 0 ? true : _ref6$move,\n reverse = _ref6.reverse;\n var avgX = 0;\n var countX = 0;\n var i, point, prevX, minY, maxY, lastY;\n var pointIndex = function pointIndex(index) {\n return (start + (reverse ? ilen - index : index)) % count;\n };\n var drawX = function drawX() {\n if (minY !== maxY) {\n ctx.lineTo(avgX, maxY);\n ctx.lineTo(avgX, minY);\n ctx.lineTo(avgX, lastY);\n }\n };\n if (move) {\n point = points[pointIndex(0)];\n ctx.moveTo(point.x, point.y);\n }\n for (i = 0; i <= ilen; ++i) {\n point = points[pointIndex(i)];\n if (point.skip) {\n continue;\n }\n var x = point.x;\n var y = point.y;\n var truncX = x | 0;\n if (truncX === prevX) {\n if (y < minY) {\n minY = y;\n } else if (y > maxY) {\n maxY = y;\n }\n avgX = (countX * avgX + x) / ++countX;\n } else {\n drawX();\n ctx.lineTo(x, y);\n prevX = truncX;\n countX = 0;\n minY = maxY = y;\n }\n lastY = y;\n }\n drawX();\n }\n function _getSegmentMethod(line) {\n var opts = line.options;\n var borderDash = opts.borderDash && opts.borderDash.length;\n var useFastPath = !line._decimated && !line._loop && !opts.tension && opts.cubicInterpolationMode !== 'monotone' && !opts.stepped && !borderDash;\n return useFastPath ? fastPathSegment : pathSegment;\n }\n function _getInterpolationMethod(options) {\n if (options.stepped) {\n return _steppedInterpolation;\n }\n if (options.tension || options.cubicInterpolationMode === 'monotone') {\n return _bezierInterpolation;\n }\n return _pointInLine;\n }\n function strokePathWithCache(ctx, line, start, count) {\n var path = line._path;\n if (!path) {\n path = line._path = new Path2D();\n if (line.path(path, start, count)) {\n path.closePath();\n }\n }\n setStyle(ctx, line.options);\n ctx.stroke(path);\n }\n function strokePathDirect(ctx, line, start, count) {\n var segments = line.segments,\n options = line.options;\n var segmentMethod = _getSegmentMethod(line);\n var _iterator16 = _createForOfIteratorHelper$1(segments),\n _step16;\n try {\n for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {\n var segment = _step16.value;\n setStyle(ctx, options, segment.style);\n ctx.beginPath();\n if (segmentMethod(ctx, line, segment, {\n start: start,\n end: start + count - 1\n })) {\n ctx.closePath();\n }\n ctx.stroke();\n }\n } catch (err) {\n _iterator16.e(err);\n } finally {\n _iterator16.f();\n }\n }\n var usePath2D = typeof Path2D === 'function';\n function _draw(ctx, line, start, count) {\n if (usePath2D && !line.options.segment) {\n strokePathWithCache(ctx, line, start, count);\n } else {\n strokePathDirect(ctx, line, start, count);\n }\n }\n var LineElement = /*#__PURE__*/function (_Element3) {\n _inherits$1(LineElement, _Element3);\n var _super13 = _createSuper$1(LineElement);\n function LineElement(cfg) {\n var _this24;\n _classCallCheck$1(this, LineElement);\n _this24 = _super13.call(this);\n _this24.animated = true;\n _this24.options = undefined;\n _this24._chart = undefined;\n _this24._loop = undefined;\n _this24._fullLoop = undefined;\n _this24._path = undefined;\n _this24._points = undefined;\n _this24._segments = undefined;\n _this24._decimated = false;\n _this24._pointsUpdated = false;\n _this24._datasetIndex = undefined;\n if (cfg) {\n Object.assign(_assertThisInitialized$1(_this24), cfg);\n }\n return _this24;\n }\n _createClass$1(LineElement, [{\n key: \"updateControlPoints\",\n value: function updateControlPoints(chartArea, indexAxis) {\n var options = this.options;\n if ((options.tension || options.cubicInterpolationMode === 'monotone') && !options.stepped && !this._pointsUpdated) {\n var loop = options.spanGaps ? this._loop : this._fullLoop;\n _updateBezierControlPoints(this._points, options, chartArea, loop, indexAxis);\n this._pointsUpdated = true;\n }\n }\n }, {\n key: \"points\",\n get: function get() {\n return this._points;\n },\n set: function set(points) {\n this._points = points;\n delete this._segments;\n delete this._path;\n this._pointsUpdated = false;\n }\n }, {\n key: \"segments\",\n get: function get() {\n return this._segments || (this._segments = _computeSegments(this, this.options.segment));\n }\n }, {\n key: \"first\",\n value: function first() {\n var segments = this.segments;\n var points = this.points;\n return segments.length && points[segments[0].start];\n }\n }, {\n key: \"last\",\n value: function last() {\n var segments = this.segments;\n var points = this.points;\n var count = segments.length;\n return count && points[segments[count - 1].end];\n }\n }, {\n key: \"interpolate\",\n value: function interpolate(point, property) {\n var options = this.options;\n var value = point[property];\n var points = this.points;\n var segments = _boundSegments(this, {\n property: property,\n start: value,\n end: value\n });\n if (!segments.length) {\n return;\n }\n var result = [];\n var _interpolate = _getInterpolationMethod(options);\n var i, ilen;\n for (i = 0, ilen = segments.length; i < ilen; ++i) {\n var _segments$i = segments[i],\n start = _segments$i.start,\n end = _segments$i.end;\n var p1 = points[start];\n var p2 = points[end];\n if (p1 === p2) {\n result.push(p1);\n continue;\n }\n var t = Math.abs((value - p1[property]) / (p2[property] - p1[property]));\n var interpolated = _interpolate(p1, p2, t, options.stepped);\n interpolated[property] = point[property];\n result.push(interpolated);\n }\n return result.length === 1 ? result[0] : result;\n }\n }, {\n key: \"pathSegment\",\n value: function pathSegment(ctx, segment, params) {\n var segmentMethod = _getSegmentMethod(this);\n return segmentMethod(ctx, this, segment, params);\n }\n }, {\n key: \"path\",\n value: function path(ctx, start, count) {\n var segments = this.segments;\n var segmentMethod = _getSegmentMethod(this);\n var loop = this._loop;\n start = start || 0;\n count = count || this.points.length - start;\n var _iterator17 = _createForOfIteratorHelper$1(segments),\n _step17;\n try {\n for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {\n var segment = _step17.value;\n loop &= segmentMethod(ctx, this, segment, {\n start: start,\n end: start + count - 1\n });\n }\n } catch (err) {\n _iterator17.e(err);\n } finally {\n _iterator17.f();\n }\n return !!loop;\n }\n }, {\n key: \"draw\",\n value: function draw(ctx, chartArea, start, count) {\n var options = this.options || {};\n var points = this.points || [];\n if (points.length && options.borderWidth) {\n ctx.save();\n _draw(ctx, this, start, count);\n ctx.restore();\n }\n if (this.animated) {\n this._pointsUpdated = false;\n this._path = undefined;\n }\n }\n }]);\n return LineElement;\n }(Element);\n _defineProperty$1(LineElement, \"id\", 'line');\n _defineProperty$1(LineElement, \"defaults\", {\n borderCapStyle: 'butt',\n borderDash: [],\n borderDashOffset: 0,\n borderJoinStyle: 'miter',\n borderWidth: 3,\n capBezierPoints: true,\n cubicInterpolationMode: 'default',\n fill: false,\n spanGaps: false,\n stepped: false,\n tension: 0\n });\n _defineProperty$1(LineElement, \"defaultRoutes\", {\n backgroundColor: 'backgroundColor',\n borderColor: 'borderColor'\n });\n _defineProperty$1(LineElement, \"descriptors\", {\n _scriptable: true,\n _indexable: function _indexable(name) {\n return name !== 'borderDash' && name !== 'fill';\n }\n });\n function inRange$1(el, pos, axis, useFinalPosition) {\n var options = el.options;\n var _el$getProps = el.getProps([axis], useFinalPosition),\n value = _el$getProps[axis];\n return Math.abs(pos - value) < options.radius + options.hitRadius;\n }\n var PointElement = /*#__PURE__*/function (_Element4) {\n _inherits$1(PointElement, _Element4);\n var _super14 = _createSuper$1(PointElement);\n function PointElement(cfg) {\n var _this25;\n _classCallCheck$1(this, PointElement);\n _this25 = _super14.call(this);\n _defineProperty$1(_assertThisInitialized$1(_this25), \"parsed\", void 0);\n _defineProperty$1(_assertThisInitialized$1(_this25), \"skip\", void 0);\n _defineProperty$1(_assertThisInitialized$1(_this25), \"stop\", void 0);\n _this25.options = undefined;\n _this25.parsed = undefined;\n _this25.skip = undefined;\n _this25.stop = undefined;\n if (cfg) {\n Object.assign(_assertThisInitialized$1(_this25), cfg);\n }\n return _this25;\n }\n _createClass$1(PointElement, [{\n key: \"inRange\",\n value: function inRange(mouseX, mouseY, useFinalPosition) {\n var options = this.options;\n var _this$getProps4 = this.getProps(['x', 'y'], useFinalPosition),\n x = _this$getProps4.x,\n y = _this$getProps4.y;\n return Math.pow(mouseX - x, 2) + Math.pow(mouseY - y, 2) < Math.pow(options.hitRadius + options.radius, 2);\n }\n }, {\n key: \"inXRange\",\n value: function inXRange(mouseX, useFinalPosition) {\n return inRange$1(this, mouseX, 'x', useFinalPosition);\n }\n }, {\n key: \"inYRange\",\n value: function inYRange(mouseY, useFinalPosition) {\n return inRange$1(this, mouseY, 'y', useFinalPosition);\n }\n }, {\n key: \"getCenterPoint\",\n value: function getCenterPoint(useFinalPosition) {\n var _this$getProps5 = this.getProps(['x', 'y'], useFinalPosition),\n x = _this$getProps5.x,\n y = _this$getProps5.y;\n return {\n x: x,\n y: y\n };\n }\n }, {\n key: \"size\",\n value: function size(options) {\n options = options || this.options || {};\n var radius = options.radius || 0;\n radius = Math.max(radius, radius && options.hoverRadius || 0);\n var borderWidth = radius && options.borderWidth || 0;\n return (radius + borderWidth) * 2;\n }\n }, {\n key: \"draw\",\n value: function draw(ctx, area) {\n var options = this.options;\n if (this.skip || options.radius < 0.1 || !_isPointInArea(this, area, this.size(options) / 2)) {\n return;\n }\n ctx.strokeStyle = options.borderColor;\n ctx.lineWidth = options.borderWidth;\n ctx.fillStyle = options.backgroundColor;\n drawPoint(ctx, options, this.x, this.y);\n }\n }, {\n key: \"getRange\",\n value: function getRange() {\n var options = this.options || {};\n // @ts-expect-error Fallbacks should never be hit in practice\n return options.radius + options.hitRadius;\n }\n }]);\n return PointElement;\n }(Element);\n _defineProperty$1(PointElement, \"id\", 'point');\n /**\n * @type {any}\n */\n _defineProperty$1(PointElement, \"defaults\", {\n borderWidth: 1,\n hitRadius: 1,\n hoverBorderWidth: 1,\n hoverRadius: 4,\n pointStyle: 'circle',\n radius: 3,\n rotation: 0\n });\n /**\n * @type {any}\n */\n _defineProperty$1(PointElement, \"defaultRoutes\", {\n backgroundColor: 'backgroundColor',\n borderColor: 'borderColor'\n });\n function getBarBounds(bar, useFinalPosition) {\n var _bar$getProps = bar.getProps(['x', 'y', 'base', 'width', 'height'], useFinalPosition),\n x = _bar$getProps.x,\n y = _bar$getProps.y,\n base = _bar$getProps.base,\n width = _bar$getProps.width,\n height = _bar$getProps.height;\n var left, right, top, bottom, half;\n if (bar.horizontal) {\n half = height / 2;\n left = Math.min(x, base);\n right = Math.max(x, base);\n top = y - half;\n bottom = y + half;\n } else {\n half = width / 2;\n left = x - half;\n right = x + half;\n top = Math.min(y, base);\n bottom = Math.max(y, base);\n }\n return {\n left: left,\n top: top,\n right: right,\n bottom: bottom\n };\n }\n function skipOrLimit(skip, value, min, max) {\n return skip ? 0 : _limitValue(value, min, max);\n }\n function parseBorderWidth(bar, maxW, maxH) {\n var value = bar.options.borderWidth;\n var skip = bar.borderSkipped;\n var o = toTRBL(value);\n return {\n t: skipOrLimit(skip.top, o.top, 0, maxH),\n r: skipOrLimit(skip.right, o.right, 0, maxW),\n b: skipOrLimit(skip.bottom, o.bottom, 0, maxH),\n l: skipOrLimit(skip.left, o.left, 0, maxW)\n };\n }\n function parseBorderRadius(bar, maxW, maxH) {\n var _bar$getProps2 = bar.getProps(['enableBorderRadius']),\n enableBorderRadius = _bar$getProps2.enableBorderRadius;\n var value = bar.options.borderRadius;\n var o = toTRBLCorners(value);\n var maxR = Math.min(maxW, maxH);\n var skip = bar.borderSkipped;\n var enableBorder = enableBorderRadius || isObject(value);\n return {\n topLeft: skipOrLimit(!enableBorder || skip.top || skip.left, o.topLeft, 0, maxR),\n topRight: skipOrLimit(!enableBorder || skip.top || skip.right, o.topRight, 0, maxR),\n bottomLeft: skipOrLimit(!enableBorder || skip.bottom || skip.left, o.bottomLeft, 0, maxR),\n bottomRight: skipOrLimit(!enableBorder || skip.bottom || skip.right, o.bottomRight, 0, maxR)\n };\n }\n function boundingRects(bar) {\n var bounds = getBarBounds(bar);\n var width = bounds.right - bounds.left;\n var height = bounds.bottom - bounds.top;\n var border = parseBorderWidth(bar, width / 2, height / 2);\n var radius = parseBorderRadius(bar, width / 2, height / 2);\n return {\n outer: {\n x: bounds.left,\n y: bounds.top,\n w: width,\n h: height,\n radius: radius\n },\n inner: {\n x: bounds.left + border.l,\n y: bounds.top + border.t,\n w: width - border.l - border.r,\n h: height - border.t - border.b,\n radius: {\n topLeft: Math.max(0, radius.topLeft - Math.max(border.t, border.l)),\n topRight: Math.max(0, radius.topRight - Math.max(border.t, border.r)),\n bottomLeft: Math.max(0, radius.bottomLeft - Math.max(border.b, border.l)),\n bottomRight: Math.max(0, radius.bottomRight - Math.max(border.b, border.r))\n }\n }\n };\n }\n function _inRange(bar, x, y, useFinalPosition) {\n var skipX = x === null;\n var skipY = y === null;\n var skipBoth = skipX && skipY;\n var bounds = bar && !skipBoth && getBarBounds(bar, useFinalPosition);\n return bounds && (skipX || _isBetween(x, bounds.left, bounds.right)) && (skipY || _isBetween(y, bounds.top, bounds.bottom));\n }\n function hasRadius(radius) {\n return radius.topLeft || radius.topRight || radius.bottomLeft || radius.bottomRight;\n }\n function addNormalRectPath(ctx, rect) {\n ctx.rect(rect.x, rect.y, rect.w, rect.h);\n }\n function inflateRect(rect, amount) {\n var refRect = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var x = rect.x !== refRect.x ? -amount : 0;\n var y = rect.y !== refRect.y ? -amount : 0;\n var w = (rect.x + rect.w !== refRect.x + refRect.w ? amount : 0) - x;\n var h = (rect.y + rect.h !== refRect.y + refRect.h ? amount : 0) - y;\n return {\n x: rect.x + x,\n y: rect.y + y,\n w: rect.w + w,\n h: rect.h + h,\n radius: rect.radius\n };\n }\n var BarElement = /*#__PURE__*/function (_Element5) {\n _inherits$1(BarElement, _Element5);\n var _super15 = _createSuper$1(BarElement);\n function BarElement(cfg) {\n var _this26;\n _classCallCheck$1(this, BarElement);\n _this26 = _super15.call(this);\n _this26.options = undefined;\n _this26.horizontal = undefined;\n _this26.base = undefined;\n _this26.width = undefined;\n _this26.height = undefined;\n _this26.inflateAmount = undefined;\n if (cfg) {\n Object.assign(_assertThisInitialized$1(_this26), cfg);\n }\n return _this26;\n }\n _createClass$1(BarElement, [{\n key: \"draw\",\n value: function draw(ctx) {\n var inflateAmount = this.inflateAmount,\n _this$options14 = this.options,\n borderColor = _this$options14.borderColor,\n backgroundColor = _this$options14.backgroundColor;\n var _boundingRects = boundingRects(this),\n inner = _boundingRects.inner,\n outer = _boundingRects.outer;\n var addRectPath = hasRadius(outer.radius) ? addRoundedRectPath : addNormalRectPath;\n ctx.save();\n if (outer.w !== inner.w || outer.h !== inner.h) {\n ctx.beginPath();\n addRectPath(ctx, inflateRect(outer, inflateAmount, inner));\n ctx.clip();\n addRectPath(ctx, inflateRect(inner, -inflateAmount, outer));\n ctx.fillStyle = borderColor;\n ctx.fill('evenodd');\n }\n ctx.beginPath();\n addRectPath(ctx, inflateRect(inner, inflateAmount));\n ctx.fillStyle = backgroundColor;\n ctx.fill();\n ctx.restore();\n }\n }, {\n key: \"inRange\",\n value: function inRange(mouseX, mouseY, useFinalPosition) {\n return _inRange(this, mouseX, mouseY, useFinalPosition);\n }\n }, {\n key: \"inXRange\",\n value: function inXRange(mouseX, useFinalPosition) {\n return _inRange(this, mouseX, null, useFinalPosition);\n }\n }, {\n key: \"inYRange\",\n value: function inYRange(mouseY, useFinalPosition) {\n return _inRange(this, null, mouseY, useFinalPosition);\n }\n }, {\n key: \"getCenterPoint\",\n value: function getCenterPoint(useFinalPosition) {\n var _this$getProps6 = this.getProps(['x', 'y', 'base', 'horizontal'], useFinalPosition),\n x = _this$getProps6.x,\n y = _this$getProps6.y,\n base = _this$getProps6.base,\n horizontal = _this$getProps6.horizontal;\n return {\n x: horizontal ? (x + base) / 2 : x,\n y: horizontal ? y : (y + base) / 2\n };\n }\n }, {\n key: \"getRange\",\n value: function getRange(axis) {\n return axis === 'x' ? this.width / 2 : this.height / 2;\n }\n }]);\n return BarElement;\n }(Element);\n _defineProperty$1(BarElement, \"id\", 'bar');\n _defineProperty$1(BarElement, \"defaults\", {\n borderSkipped: 'start',\n borderWidth: 0,\n borderRadius: 0,\n inflateAmount: 'auto',\n pointStyle: undefined\n });\n _defineProperty$1(BarElement, \"defaultRoutes\", {\n backgroundColor: 'backgroundColor',\n borderColor: 'borderColor'\n });\n var elements = /*#__PURE__*/Object.freeze({\n __proto__: null,\n ArcElement: ArcElement,\n BarElement: BarElement,\n LineElement: LineElement,\n PointElement: PointElement\n });\n var BORDER_COLORS = ['rgb(54, 162, 235)', 'rgb(255, 99, 132)', 'rgb(255, 159, 64)', 'rgb(255, 205, 86)', 'rgb(75, 192, 192)', 'rgb(153, 102, 255)', 'rgb(201, 203, 207)' // grey\n ];\n // Border colors with 50% transparency\n var BACKGROUND_COLORS = /* #__PURE__ */BORDER_COLORS.map(function (color) {\n return color.replace('rgb(', 'rgba(').replace(')', ', 0.5)');\n });\n function getBorderColor(i) {\n return BORDER_COLORS[i % BORDER_COLORS.length];\n }\n function getBackgroundColor(i) {\n return BACKGROUND_COLORS[i % BACKGROUND_COLORS.length];\n }\n function colorizeDefaultDataset(dataset, i) {\n dataset.borderColor = getBorderColor(i);\n dataset.backgroundColor = getBackgroundColor(i);\n return ++i;\n }\n function colorizeDoughnutDataset(dataset, i) {\n dataset.backgroundColor = dataset.data.map(function () {\n return getBorderColor(i++);\n });\n return i;\n }\n function colorizePolarAreaDataset(dataset, i) {\n dataset.backgroundColor = dataset.data.map(function () {\n return getBackgroundColor(i++);\n });\n return i;\n }\n function getColorizer(chart) {\n var i = 0;\n return function (dataset, datasetIndex) {\n var controller = chart.getDatasetMeta(datasetIndex).controller;\n if (controller instanceof DoughnutController) {\n i = colorizeDoughnutDataset(dataset, i);\n } else if (controller instanceof PolarAreaController) {\n i = colorizePolarAreaDataset(dataset, i);\n } else if (controller) {\n i = colorizeDefaultDataset(dataset, i);\n }\n };\n }\n function containsColorsDefinitions(descriptors) {\n var k;\n for (k in descriptors) {\n if (descriptors[k].borderColor || descriptors[k].backgroundColor) {\n return true;\n }\n }\n return false;\n }\n function containsColorsDefinition(descriptor) {\n return descriptor && (descriptor.borderColor || descriptor.backgroundColor);\n }\n var plugin_colors = {\n id: 'colors',\n defaults: {\n enabled: true,\n forceOverride: false\n },\n beforeLayout: function beforeLayout(chart, _args, options) {\n if (!options.enabled) {\n return;\n }\n var _chart$config = chart.config,\n datasets = _chart$config.data.datasets,\n chartOptions = _chart$config.options;\n var elements = chartOptions.elements;\n if (!options.forceOverride && (containsColorsDefinitions(datasets) || containsColorsDefinition(chartOptions) || elements && containsColorsDefinitions(elements))) {\n return;\n }\n var colorizer = getColorizer(chart);\n datasets.forEach(colorizer);\n }\n };\n function lttbDecimation(data, start, count, availableWidth, options) {\n var samples = options.samples || availableWidth;\n if (samples >= count) {\n return data.slice(start, start + count);\n }\n var decimated = [];\n var bucketWidth = (count - 2) / (samples - 2);\n var sampledIndex = 0;\n var endIndex = start + count - 1;\n var a = start;\n var i, maxAreaPoint, maxArea, area, nextA;\n decimated[sampledIndex++] = data[a];\n for (i = 0; i < samples - 2; i++) {\n var avgX = 0;\n var avgY = 0;\n var j = void 0;\n var avgRangeStart = Math.floor((i + 1) * bucketWidth) + 1 + start;\n var avgRangeEnd = Math.min(Math.floor((i + 2) * bucketWidth) + 1, count) + start;\n var avgRangeLength = avgRangeEnd - avgRangeStart;\n for (j = avgRangeStart; j < avgRangeEnd; j++) {\n avgX += data[j].x;\n avgY += data[j].y;\n }\n avgX /= avgRangeLength;\n avgY /= avgRangeLength;\n var rangeOffs = Math.floor(i * bucketWidth) + 1 + start;\n var rangeTo = Math.min(Math.floor((i + 1) * bucketWidth) + 1, count) + start;\n var _data$a = data[a],\n pointAx = _data$a.x,\n pointAy = _data$a.y;\n maxArea = area = -1;\n for (j = rangeOffs; j < rangeTo; j++) {\n area = 0.5 * Math.abs((pointAx - avgX) * (data[j].y - pointAy) - (pointAx - data[j].x) * (avgY - pointAy));\n if (area > maxArea) {\n maxArea = area;\n maxAreaPoint = data[j];\n nextA = j;\n }\n }\n decimated[sampledIndex++] = maxAreaPoint;\n a = nextA;\n }\n decimated[sampledIndex++] = data[endIndex];\n return decimated;\n }\n function minMaxDecimation(data, start, count, availableWidth) {\n var avgX = 0;\n var countX = 0;\n var i, point, x, y, prevX, minIndex, maxIndex, startIndex, minY, maxY;\n var decimated = [];\n var endIndex = start + count - 1;\n var xMin = data[start].x;\n var xMax = data[endIndex].x;\n var dx = xMax - xMin;\n for (i = start; i < start + count; ++i) {\n point = data[i];\n x = (point.x - xMin) / dx * availableWidth;\n y = point.y;\n var truncX = x | 0;\n if (truncX === prevX) {\n if (y < minY) {\n minY = y;\n minIndex = i;\n } else if (y > maxY) {\n maxY = y;\n maxIndex = i;\n }\n avgX = (countX * avgX + point.x) / ++countX;\n } else {\n var lastIndex = i - 1;\n if (!isNullOrUndef(minIndex) && !isNullOrUndef(maxIndex)) {\n var intermediateIndex1 = Math.min(minIndex, maxIndex);\n var intermediateIndex2 = Math.max(minIndex, maxIndex);\n if (intermediateIndex1 !== startIndex && intermediateIndex1 !== lastIndex) {\n decimated.push(_objectSpread2(_objectSpread2({}, data[intermediateIndex1]), {}, {\n x: avgX\n }));\n }\n if (intermediateIndex2 !== startIndex && intermediateIndex2 !== lastIndex) {\n decimated.push(_objectSpread2(_objectSpread2({}, data[intermediateIndex2]), {}, {\n x: avgX\n }));\n }\n }\n if (i > 0 && lastIndex !== startIndex) {\n decimated.push(data[lastIndex]);\n }\n decimated.push(point);\n prevX = truncX;\n countX = 0;\n minY = maxY = y;\n minIndex = maxIndex = startIndex = i;\n }\n }\n return decimated;\n }\n function cleanDecimatedDataset(dataset) {\n if (dataset._decimated) {\n var data = dataset._data;\n delete dataset._decimated;\n delete dataset._data;\n Object.defineProperty(dataset, 'data', {\n configurable: true,\n enumerable: true,\n writable: true,\n value: data\n });\n }\n }\n function cleanDecimatedData(chart) {\n chart.data.datasets.forEach(function (dataset) {\n cleanDecimatedDataset(dataset);\n });\n }\n function getStartAndCountOfVisiblePointsSimplified(meta, points) {\n var pointCount = points.length;\n var start = 0;\n var count;\n var iScale = meta.iScale;\n var _iScale$getUserBounds = iScale.getUserBounds(),\n min = _iScale$getUserBounds.min,\n max = _iScale$getUserBounds.max,\n minDefined = _iScale$getUserBounds.minDefined,\n maxDefined = _iScale$getUserBounds.maxDefined;\n if (minDefined) {\n start = _limitValue(_lookupByKey(points, iScale.axis, min).lo, 0, pointCount - 1);\n }\n if (maxDefined) {\n count = _limitValue(_lookupByKey(points, iScale.axis, max).hi + 1, start, pointCount) - start;\n } else {\n count = pointCount - start;\n }\n return {\n start: start,\n count: count\n };\n }\n var plugin_decimation = {\n id: 'decimation',\n defaults: {\n algorithm: 'min-max',\n enabled: false\n },\n beforeElementsUpdate: function beforeElementsUpdate(chart, args, options) {\n if (!options.enabled) {\n cleanDecimatedData(chart);\n return;\n }\n var availableWidth = chart.width;\n chart.data.datasets.forEach(function (dataset, datasetIndex) {\n var _data = dataset._data,\n indexAxis = dataset.indexAxis;\n var meta = chart.getDatasetMeta(datasetIndex);\n var data = _data || dataset.data;\n if (resolve([indexAxis, chart.options.indexAxis]) === 'y') {\n return;\n }\n if (!meta.controller.supportsDecimation) {\n return;\n }\n var xAxis = chart.scales[meta.xAxisID];\n if (xAxis.type !== 'linear' && xAxis.type !== 'time') {\n return;\n }\n if (chart.options.parsing) {\n return;\n }\n var _getStartAndCountOfVi3 = getStartAndCountOfVisiblePointsSimplified(meta, data),\n start = _getStartAndCountOfVi3.start,\n count = _getStartAndCountOfVi3.count;\n var threshold = options.threshold || 4 * availableWidth;\n if (count <= threshold) {\n cleanDecimatedDataset(dataset);\n return;\n }\n if (isNullOrUndef(_data)) {\n dataset._data = data;\n delete dataset.data;\n Object.defineProperty(dataset, 'data', {\n configurable: true,\n enumerable: true,\n get: function get() {\n return this._decimated;\n },\n set: function set(d) {\n this._data = d;\n }\n });\n }\n var decimated;\n switch (options.algorithm) {\n case 'lttb':\n decimated = lttbDecimation(data, start, count, availableWidth, options);\n break;\n case 'min-max':\n decimated = minMaxDecimation(data, start, count, availableWidth);\n break;\n default:\n throw new Error(\"Unsupported decimation algorithm '\".concat(options.algorithm, \"'\"));\n }\n dataset._decimated = decimated;\n });\n },\n destroy: function destroy(chart) {\n cleanDecimatedData(chart);\n }\n };\n function _segments(line, target, property) {\n var segments = line.segments;\n var points = line.points;\n var tpoints = target.points;\n var parts = [];\n var _iterator18 = _createForOfIteratorHelper$1(segments),\n _step18;\n try {\n for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {\n var segment = _step18.value;\n var start = segment.start,\n end = segment.end;\n end = _findSegmentEnd(start, end, points);\n var bounds = _getBounds(property, points[start], points[end], segment.loop);\n if (!target.segments) {\n parts.push({\n source: segment,\n target: bounds,\n start: points[start],\n end: points[end]\n });\n continue;\n }\n var targetSegments = _boundSegments(target, bounds);\n var _iterator19 = _createForOfIteratorHelper$1(targetSegments),\n _step19;\n try {\n for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {\n var tgt = _step19.value;\n var subBounds = _getBounds(property, tpoints[tgt.start], tpoints[tgt.end], tgt.loop);\n var fillSources = _boundSegment(segment, points, subBounds);\n var _iterator20 = _createForOfIteratorHelper$1(fillSources),\n _step20;\n try {\n for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {\n var fillSource = _step20.value;\n parts.push({\n source: fillSource,\n target: tgt,\n start: _defineProperty$1({}, property, _getEdge(bounds, subBounds, 'start', Math.max)),\n end: _defineProperty$1({}, property, _getEdge(bounds, subBounds, 'end', Math.min))\n });\n }\n } catch (err) {\n _iterator20.e(err);\n } finally {\n _iterator20.f();\n }\n }\n } catch (err) {\n _iterator19.e(err);\n } finally {\n _iterator19.f();\n }\n }\n } catch (err) {\n _iterator18.e(err);\n } finally {\n _iterator18.f();\n }\n return parts;\n }\n function _getBounds(property, first, last, loop) {\n if (loop) {\n return;\n }\n var start = first[property];\n var end = last[property];\n if (property === 'angle') {\n start = _normalizeAngle(start);\n end = _normalizeAngle(end);\n }\n return {\n property: property,\n start: start,\n end: end\n };\n }\n function _pointsFromSegments(boundary, line) {\n var _ref7 = boundary || {},\n _ref7$x = _ref7.x,\n x = _ref7$x === void 0 ? null : _ref7$x,\n _ref7$y = _ref7.y,\n y = _ref7$y === void 0 ? null : _ref7$y;\n var linePoints = line.points;\n var points = [];\n line.segments.forEach(function (_ref8) {\n var start = _ref8.start,\n end = _ref8.end;\n end = _findSegmentEnd(start, end, linePoints);\n var first = linePoints[start];\n var last = linePoints[end];\n if (y !== null) {\n points.push({\n x: first.x,\n y: y\n });\n points.push({\n x: last.x,\n y: y\n });\n } else if (x !== null) {\n points.push({\n x: x,\n y: first.y\n });\n points.push({\n x: x,\n y: last.y\n });\n }\n });\n return points;\n }\n function _findSegmentEnd(start, end, points) {\n for (; end > start; end--) {\n var point = points[end];\n if (!isNaN(point.x) && !isNaN(point.y)) {\n break;\n }\n }\n return end;\n }\n function _getEdge(a, b, prop, fn) {\n if (a && b) {\n return fn(a[prop], b[prop]);\n }\n return a ? a[prop] : b ? b[prop] : 0;\n }\n function _createBoundaryLine(boundary, line) {\n var points = [];\n var _loop = false;\n if (isArray(boundary)) {\n _loop = true;\n points = boundary;\n } else {\n points = _pointsFromSegments(boundary, line);\n }\n return points.length ? new LineElement({\n points: points,\n options: {\n tension: 0\n },\n _loop: _loop,\n _fullLoop: _loop\n }) : null;\n }\n function _shouldApplyFill(source) {\n return source && source.fill !== false;\n }\n function _resolveTarget(sources, index, propagate) {\n var source = sources[index];\n var fill = source.fill;\n var visited = [index];\n var target;\n if (!propagate) {\n return fill;\n }\n while (fill !== false && visited.indexOf(fill) === -1) {\n if (!isNumberFinite(fill)) {\n return fill;\n }\n target = sources[fill];\n if (!target) {\n return false;\n }\n if (target.visible) {\n return fill;\n }\n visited.push(fill);\n fill = target.fill;\n }\n return false;\n }\n function _decodeFill(line, index, count) {\n var fill = parseFillOption(line);\n if (isObject(fill)) {\n return isNaN(fill.value) ? false : fill;\n }\n var target = parseFloat(fill);\n if (isNumberFinite(target) && Math.floor(target) === target) {\n return decodeTargetIndex(fill[0], index, target, count);\n }\n return ['origin', 'start', 'end', 'stack', 'shape'].indexOf(fill) >= 0 && fill;\n }\n function decodeTargetIndex(firstCh, index, target, count) {\n if (firstCh === '-' || firstCh === '+') {\n target = index + target;\n }\n if (target === index || target < 0 || target >= count) {\n return false;\n }\n return target;\n }\n function _getTargetPixel(fill, scale) {\n var pixel = null;\n if (fill === 'start') {\n pixel = scale.bottom;\n } else if (fill === 'end') {\n pixel = scale.top;\n } else if (isObject(fill)) {\n pixel = scale.getPixelForValue(fill.value);\n } else if (scale.getBasePixel) {\n pixel = scale.getBasePixel();\n }\n return pixel;\n }\n function _getTargetValue(fill, scale, startValue) {\n var value;\n if (fill === 'start') {\n value = startValue;\n } else if (fill === 'end') {\n value = scale.options.reverse ? scale.min : scale.max;\n } else if (isObject(fill)) {\n value = fill.value;\n } else {\n value = scale.getBaseValue();\n }\n return value;\n }\n function parseFillOption(line) {\n var options = line.options;\n var fillOption = options.fill;\n var fill = valueOrDefault(fillOption && fillOption.target, fillOption);\n if (fill === undefined) {\n fill = !!options.backgroundColor;\n }\n if (fill === false || fill === null) {\n return false;\n }\n if (fill === true) {\n return 'origin';\n }\n return fill;\n }\n function _buildStackLine(source) {\n var scale = source.scale,\n index = source.index,\n line = source.line;\n var points = [];\n var segments = line.segments;\n var sourcePoints = line.points;\n var linesBelow = getLinesBelow(scale, index);\n linesBelow.push(_createBoundaryLine({\n x: null,\n y: scale.bottom\n }, line));\n for (var i = 0; i < segments.length; i++) {\n var segment = segments[i];\n for (var j = segment.start; j <= segment.end; j++) {\n addPointsBelow(points, sourcePoints[j], linesBelow);\n }\n }\n return new LineElement({\n points: points,\n options: {}\n });\n }\n function getLinesBelow(scale, index) {\n var below = [];\n var metas = scale.getMatchingVisibleMetas('line');\n for (var i = 0; i < metas.length; i++) {\n var meta = metas[i];\n if (meta.index === index) {\n break;\n }\n if (!meta.hidden) {\n below.unshift(meta.dataset);\n }\n }\n return below;\n }\n function addPointsBelow(points, sourcePoint, linesBelow) {\n var postponed = [];\n for (var j = 0; j < linesBelow.length; j++) {\n var line = linesBelow[j];\n var _findPoint = findPoint(line, sourcePoint, 'x'),\n first = _findPoint.first,\n last = _findPoint.last,\n point = _findPoint.point;\n if (!point || first && last) {\n continue;\n }\n if (first) {\n postponed.unshift(point);\n } else {\n points.push(point);\n if (!last) {\n break;\n }\n }\n }\n points.push.apply(points, postponed);\n }\n function findPoint(line, sourcePoint, property) {\n var point = line.interpolate(sourcePoint, property);\n if (!point) {\n return {};\n }\n var pointValue = point[property];\n var segments = line.segments;\n var linePoints = line.points;\n var first = false;\n var last = false;\n for (var i = 0; i < segments.length; i++) {\n var segment = segments[i];\n var firstValue = linePoints[segment.start][property];\n var lastValue = linePoints[segment.end][property];\n if (_isBetween(pointValue, firstValue, lastValue)) {\n first = pointValue === firstValue;\n last = pointValue === lastValue;\n break;\n }\n }\n return {\n first: first,\n last: last,\n point: point\n };\n }\n var simpleArc = /*#__PURE__*/function () {\n function simpleArc(opts) {\n _classCallCheck$1(this, simpleArc);\n this.x = opts.x;\n this.y = opts.y;\n this.radius = opts.radius;\n }\n _createClass$1(simpleArc, [{\n key: \"pathSegment\",\n value: function pathSegment(ctx, bounds, opts) {\n var x = this.x,\n y = this.y,\n radius = this.radius;\n bounds = bounds || {\n start: 0,\n end: TAU\n };\n ctx.arc(x, y, radius, bounds.end, bounds.start, true);\n return !opts.bounds;\n }\n }, {\n key: \"interpolate\",\n value: function interpolate(point) {\n var x = this.x,\n y = this.y,\n radius = this.radius;\n var angle = point.angle;\n return {\n x: x + Math.cos(angle) * radius,\n y: y + Math.sin(angle) * radius,\n angle: angle\n };\n }\n }]);\n return simpleArc;\n }();\n function _getTarget(source) {\n var chart = source.chart,\n fill = source.fill,\n line = source.line;\n if (isNumberFinite(fill)) {\n return getLineByIndex(chart, fill);\n }\n if (fill === 'stack') {\n return _buildStackLine(source);\n }\n if (fill === 'shape') {\n return true;\n }\n var boundary = computeBoundary(source);\n if (boundary instanceof simpleArc) {\n return boundary;\n }\n return _createBoundaryLine(boundary, line);\n }\n function getLineByIndex(chart, index) {\n var meta = chart.getDatasetMeta(index);\n var visible = meta && chart.isDatasetVisible(index);\n return visible ? meta.dataset : null;\n }\n function computeBoundary(source) {\n var scale = source.scale || {};\n if (scale.getPointPositionForValue) {\n return computeCircularBoundary(source);\n }\n return computeLinearBoundary(source);\n }\n function computeLinearBoundary(source) {\n var _source$scale = source.scale,\n scale = _source$scale === void 0 ? {} : _source$scale,\n fill = source.fill;\n var pixel = _getTargetPixel(fill, scale);\n if (isNumberFinite(pixel)) {\n var horizontal = scale.isHorizontal();\n return {\n x: horizontal ? pixel : null,\n y: horizontal ? null : pixel\n };\n }\n return null;\n }\n function computeCircularBoundary(source) {\n var scale = source.scale,\n fill = source.fill;\n var options = scale.options;\n var length = scale.getLabels().length;\n var start = options.reverse ? scale.max : scale.min;\n var value = _getTargetValue(fill, scale, start);\n var target = [];\n if (options.grid.circular) {\n var center = scale.getPointPositionForValue(0, start);\n return new simpleArc({\n x: center.x,\n y: center.y,\n radius: scale.getDistanceFromCenterForValue(value)\n });\n }\n for (var i = 0; i < length; ++i) {\n target.push(scale.getPointPositionForValue(i, value));\n }\n return target;\n }\n function _drawfill(ctx, source, area) {\n var target = _getTarget(source);\n var line = source.line,\n scale = source.scale,\n axis = source.axis;\n var lineOpts = line.options;\n var fillOption = lineOpts.fill;\n var color = lineOpts.backgroundColor;\n var _ref9 = fillOption || {},\n _ref9$above = _ref9.above,\n above = _ref9$above === void 0 ? color : _ref9$above,\n _ref9$below = _ref9.below,\n below = _ref9$below === void 0 ? color : _ref9$below;\n if (target && line.points.length) {\n clipArea(ctx, area);\n doFill(ctx, {\n line: line,\n target: target,\n above: above,\n below: below,\n area: area,\n scale: scale,\n axis: axis\n });\n unclipArea(ctx);\n }\n }\n function doFill(ctx, cfg) {\n var line = cfg.line,\n target = cfg.target,\n above = cfg.above,\n below = cfg.below,\n area = cfg.area,\n scale = cfg.scale;\n var property = line._loop ? 'angle' : cfg.axis;\n ctx.save();\n if (property === 'x' && below !== above) {\n clipVertical(ctx, target, area.top);\n fill(ctx, {\n line: line,\n target: target,\n color: above,\n scale: scale,\n property: property\n });\n ctx.restore();\n ctx.save();\n clipVertical(ctx, target, area.bottom);\n }\n fill(ctx, {\n line: line,\n target: target,\n color: below,\n scale: scale,\n property: property\n });\n ctx.restore();\n }\n function clipVertical(ctx, target, clipY) {\n var segments = target.segments,\n points = target.points;\n var first = true;\n var lineLoop = false;\n ctx.beginPath();\n var _iterator21 = _createForOfIteratorHelper$1(segments),\n _step21;\n try {\n for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {\n var segment = _step21.value;\n var start = segment.start,\n end = segment.end;\n var firstPoint = points[start];\n var lastPoint = points[_findSegmentEnd(start, end, points)];\n if (first) {\n ctx.moveTo(firstPoint.x, firstPoint.y);\n first = false;\n } else {\n ctx.lineTo(firstPoint.x, clipY);\n ctx.lineTo(firstPoint.x, firstPoint.y);\n }\n lineLoop = !!target.pathSegment(ctx, segment, {\n move: lineLoop\n });\n if (lineLoop) {\n ctx.closePath();\n } else {\n ctx.lineTo(lastPoint.x, clipY);\n }\n }\n } catch (err) {\n _iterator21.e(err);\n } finally {\n _iterator21.f();\n }\n ctx.lineTo(target.first().x, clipY);\n ctx.closePath();\n ctx.clip();\n }\n function fill(ctx, cfg) {\n var line = cfg.line,\n target = cfg.target,\n property = cfg.property,\n color = cfg.color,\n scale = cfg.scale;\n var segments = _segments(line, target, property);\n var _iterator22 = _createForOfIteratorHelper$1(segments),\n _step22;\n try {\n for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {\n var _step22$value = _step22.value,\n src = _step22$value.source,\n tgt = _step22$value.target,\n start = _step22$value.start,\n end = _step22$value.end;\n var _src$style = src.style,\n _src$style2 = _src$style === void 0 ? {} : _src$style,\n _src$style2$backgroun = _src$style2.backgroundColor,\n backgroundColor = _src$style2$backgroun === void 0 ? color : _src$style2$backgroun;\n var notShape = target !== true;\n ctx.save();\n ctx.fillStyle = backgroundColor;\n clipBounds(ctx, scale, notShape && _getBounds(property, start, end));\n ctx.beginPath();\n var lineLoop = !!line.pathSegment(ctx, src);\n var loop = void 0;\n if (notShape) {\n if (lineLoop) {\n ctx.closePath();\n } else {\n interpolatedLineTo(ctx, target, end, property);\n }\n var targetLoop = !!target.pathSegment(ctx, tgt, {\n move: lineLoop,\n reverse: true\n });\n loop = lineLoop && targetLoop;\n if (!loop) {\n interpolatedLineTo(ctx, target, start, property);\n }\n }\n ctx.closePath();\n ctx.fill(loop ? 'evenodd' : 'nonzero');\n ctx.restore();\n }\n } catch (err) {\n _iterator22.e(err);\n } finally {\n _iterator22.f();\n }\n }\n function clipBounds(ctx, scale, bounds) {\n var _scale$chart$chartAre = scale.chart.chartArea,\n top = _scale$chart$chartAre.top,\n bottom = _scale$chart$chartAre.bottom;\n var _ref10 = bounds || {},\n property = _ref10.property,\n start = _ref10.start,\n end = _ref10.end;\n if (property === 'x') {\n ctx.beginPath();\n ctx.rect(start, top, end - start, bottom - top);\n ctx.clip();\n }\n }\n function interpolatedLineTo(ctx, target, point, property) {\n var interpolatedPoint = target.interpolate(point, property);\n if (interpolatedPoint) {\n ctx.lineTo(interpolatedPoint.x, interpolatedPoint.y);\n }\n }\n var index = {\n id: 'filler',\n afterDatasetsUpdate: function afterDatasetsUpdate(chart, _args, options) {\n var count = (chart.data.datasets || []).length;\n var sources = [];\n var meta, i, line, source;\n for (i = 0; i < count; ++i) {\n meta = chart.getDatasetMeta(i);\n line = meta.dataset;\n source = null;\n if (line && line.options && line instanceof LineElement) {\n source = {\n visible: chart.isDatasetVisible(i),\n index: i,\n fill: _decodeFill(line, i, count),\n chart: chart,\n axis: meta.controller.options.indexAxis,\n scale: meta.vScale,\n line: line\n };\n }\n meta.$filler = source;\n sources.push(source);\n }\n for (i = 0; i < count; ++i) {\n source = sources[i];\n if (!source || source.fill === false) {\n continue;\n }\n source.fill = _resolveTarget(sources, i, options.propagate);\n }\n },\n beforeDraw: function beforeDraw(chart, _args, options) {\n var draw = options.drawTime === 'beforeDraw';\n var metasets = chart.getSortedVisibleDatasetMetas();\n var area = chart.chartArea;\n for (var i = metasets.length - 1; i >= 0; --i) {\n var source = metasets[i].$filler;\n if (!source) {\n continue;\n }\n source.line.updateControlPoints(area, source.axis);\n if (draw && source.fill) {\n _drawfill(chart.ctx, source, area);\n }\n }\n },\n beforeDatasetsDraw: function beforeDatasetsDraw(chart, _args, options) {\n if (options.drawTime !== 'beforeDatasetsDraw') {\n return;\n }\n var metasets = chart.getSortedVisibleDatasetMetas();\n for (var i = metasets.length - 1; i >= 0; --i) {\n var source = metasets[i].$filler;\n if (_shouldApplyFill(source)) {\n _drawfill(chart.ctx, source, chart.chartArea);\n }\n }\n },\n beforeDatasetDraw: function beforeDatasetDraw(chart, args, options) {\n var source = args.meta.$filler;\n if (!_shouldApplyFill(source) || options.drawTime !== 'beforeDatasetDraw') {\n return;\n }\n _drawfill(chart.ctx, source, chart.chartArea);\n },\n defaults: {\n propagate: true,\n drawTime: 'beforeDatasetDraw'\n }\n };\n var getBoxSize = function getBoxSize(labelOpts, fontSize) {\n var _labelOpts$boxHeight = labelOpts.boxHeight,\n boxHeight = _labelOpts$boxHeight === void 0 ? fontSize : _labelOpts$boxHeight,\n _labelOpts$boxWidth = labelOpts.boxWidth,\n boxWidth = _labelOpts$boxWidth === void 0 ? fontSize : _labelOpts$boxWidth;\n if (labelOpts.usePointStyle) {\n boxHeight = Math.min(boxHeight, fontSize);\n boxWidth = labelOpts.pointStyleWidth || Math.min(boxWidth, fontSize);\n }\n return {\n boxWidth: boxWidth,\n boxHeight: boxHeight,\n itemHeight: Math.max(fontSize, boxHeight)\n };\n };\n var itemsEqual = function itemsEqual(a, b) {\n return a !== null && b !== null && a.datasetIndex === b.datasetIndex && a.index === b.index;\n };\n var Legend = /*#__PURE__*/function (_Element6) {\n _inherits$1(Legend, _Element6);\n var _super16 = _createSuper$1(Legend);\n function Legend(config) {\n var _this27;\n _classCallCheck$1(this, Legend);\n _this27 = _super16.call(this);\n _this27._added = false;\n _this27.legendHitBoxes = [];\n _this27._hoveredItem = null;\n _this27.doughnutMode = false;\n _this27.chart = config.chart;\n _this27.options = config.options;\n _this27.ctx = config.ctx;\n _this27.legendItems = undefined;\n _this27.columnSizes = undefined;\n _this27.lineWidths = undefined;\n _this27.maxHeight = undefined;\n _this27.maxWidth = undefined;\n _this27.top = undefined;\n _this27.bottom = undefined;\n _this27.left = undefined;\n _this27.right = undefined;\n _this27.height = undefined;\n _this27.width = undefined;\n _this27._margins = undefined;\n _this27.position = undefined;\n _this27.weight = undefined;\n _this27.fullSize = undefined;\n return _this27;\n }\n _createClass$1(Legend, [{\n key: \"update\",\n value: function update(maxWidth, maxHeight, margins) {\n this.maxWidth = maxWidth;\n this.maxHeight = maxHeight;\n this._margins = margins;\n this.setDimensions();\n this.buildLabels();\n this.fit();\n }\n }, {\n key: \"setDimensions\",\n value: function setDimensions() {\n if (this.isHorizontal()) {\n this.width = this.maxWidth;\n this.left = this._margins.left;\n this.right = this.width;\n } else {\n this.height = this.maxHeight;\n this.top = this._margins.top;\n this.bottom = this.height;\n }\n }\n }, {\n key: \"buildLabels\",\n value: function buildLabels() {\n var _this28 = this;\n var labelOpts = this.options.labels || {};\n var legendItems = callback(labelOpts.generateLabels, [this.chart], this) || [];\n if (labelOpts.filter) {\n legendItems = legendItems.filter(function (item) {\n return labelOpts.filter(item, _this28.chart.data);\n });\n }\n if (labelOpts.sort) {\n legendItems = legendItems.sort(function (a, b) {\n return labelOpts.sort(a, b, _this28.chart.data);\n });\n }\n if (this.options.reverse) {\n legendItems.reverse();\n }\n this.legendItems = legendItems;\n }\n }, {\n key: \"fit\",\n value: function fit() {\n var options = this.options,\n ctx = this.ctx;\n if (!options.display) {\n this.width = this.height = 0;\n return;\n }\n var labelOpts = options.labels;\n var labelFont = toFont(labelOpts.font);\n var fontSize = labelFont.size;\n var titleHeight = this._computeTitleHeight();\n var _getBoxSize = getBoxSize(labelOpts, fontSize),\n boxWidth = _getBoxSize.boxWidth,\n itemHeight = _getBoxSize.itemHeight;\n var width, height;\n ctx.font = labelFont.string;\n if (this.isHorizontal()) {\n width = this.maxWidth;\n height = this._fitRows(titleHeight, fontSize, boxWidth, itemHeight) + 10;\n } else {\n height = this.maxHeight;\n width = this._fitCols(titleHeight, labelFont, boxWidth, itemHeight) + 10;\n }\n this.width = Math.min(width, options.maxWidth || this.maxWidth);\n this.height = Math.min(height, options.maxHeight || this.maxHeight);\n }\n }, {\n key: \"_fitRows\",\n value: function _fitRows(titleHeight, fontSize, boxWidth, itemHeight) {\n var ctx = this.ctx,\n maxWidth = this.maxWidth,\n padding = this.options.labels.padding;\n var hitboxes = this.legendHitBoxes = [];\n var lineWidths = this.lineWidths = [0];\n var lineHeight = itemHeight + padding;\n var totalHeight = titleHeight;\n ctx.textAlign = 'left';\n ctx.textBaseline = 'middle';\n var row = -1;\n var top = -lineHeight;\n this.legendItems.forEach(function (legendItem, i) {\n var itemWidth = boxWidth + fontSize / 2 + ctx.measureText(legendItem.text).width;\n if (i === 0 || lineWidths[lineWidths.length - 1] + itemWidth + 2 * padding > maxWidth) {\n totalHeight += lineHeight;\n lineWidths[lineWidths.length - (i > 0 ? 0 : 1)] = 0;\n top += lineHeight;\n row++;\n }\n hitboxes[i] = {\n left: 0,\n top: top,\n row: row,\n width: itemWidth,\n height: itemHeight\n };\n lineWidths[lineWidths.length - 1] += itemWidth + padding;\n });\n return totalHeight;\n }\n }, {\n key: \"_fitCols\",\n value: function _fitCols(titleHeight, labelFont, boxWidth, _itemHeight) {\n var ctx = this.ctx,\n maxHeight = this.maxHeight,\n padding = this.options.labels.padding;\n var hitboxes = this.legendHitBoxes = [];\n var columnSizes = this.columnSizes = [];\n var heightLimit = maxHeight - titleHeight;\n var totalWidth = padding;\n var currentColWidth = 0;\n var currentColHeight = 0;\n var left = 0;\n var col = 0;\n this.legendItems.forEach(function (legendItem, i) {\n var _calculateItemSize = calculateItemSize(boxWidth, labelFont, ctx, legendItem, _itemHeight),\n itemWidth = _calculateItemSize.itemWidth,\n itemHeight = _calculateItemSize.itemHeight;\n if (i > 0 && currentColHeight + itemHeight + 2 * padding > heightLimit) {\n totalWidth += currentColWidth + padding;\n columnSizes.push({\n width: currentColWidth,\n height: currentColHeight\n });\n left += currentColWidth + padding;\n col++;\n currentColWidth = currentColHeight = 0;\n }\n hitboxes[i] = {\n left: left,\n top: currentColHeight,\n col: col,\n width: itemWidth,\n height: itemHeight\n };\n currentColWidth = Math.max(currentColWidth, itemWidth);\n currentColHeight += itemHeight + padding;\n });\n totalWidth += currentColWidth;\n columnSizes.push({\n width: currentColWidth,\n height: currentColHeight\n });\n return totalWidth;\n }\n }, {\n key: \"adjustHitBoxes\",\n value: function adjustHitBoxes() {\n if (!this.options.display) {\n return;\n }\n var titleHeight = this._computeTitleHeight();\n var hitboxes = this.legendHitBoxes,\n _this$options15 = this.options,\n align = _this$options15.align,\n padding = _this$options15.labels.padding,\n rtl = _this$options15.rtl;\n var rtlHelper = getRtlAdapter(rtl, this.left, this.width);\n if (this.isHorizontal()) {\n var row = 0;\n var left = _alignStartEnd(align, this.left + padding, this.right - this.lineWidths[row]);\n var _iterator23 = _createForOfIteratorHelper$1(hitboxes),\n _step23;\n try {\n for (_iterator23.s(); !(_step23 = _iterator23.n()).done;) {\n var hitbox = _step23.value;\n if (row !== hitbox.row) {\n row = hitbox.row;\n left = _alignStartEnd(align, this.left + padding, this.right - this.lineWidths[row]);\n }\n hitbox.top += this.top + titleHeight + padding;\n hitbox.left = rtlHelper.leftForLtr(rtlHelper.x(left), hitbox.width);\n left += hitbox.width + padding;\n }\n } catch (err) {\n _iterator23.e(err);\n } finally {\n _iterator23.f();\n }\n } else {\n var col = 0;\n var top = _alignStartEnd(align, this.top + titleHeight + padding, this.bottom - this.columnSizes[col].height);\n var _iterator24 = _createForOfIteratorHelper$1(hitboxes),\n _step24;\n try {\n for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {\n var _hitbox = _step24.value;\n if (_hitbox.col !== col) {\n col = _hitbox.col;\n top = _alignStartEnd(align, this.top + titleHeight + padding, this.bottom - this.columnSizes[col].height);\n }\n _hitbox.top = top;\n _hitbox.left += this.left + padding;\n _hitbox.left = rtlHelper.leftForLtr(rtlHelper.x(_hitbox.left), _hitbox.width);\n top += _hitbox.height + padding;\n }\n } catch (err) {\n _iterator24.e(err);\n } finally {\n _iterator24.f();\n }\n }\n }\n }, {\n key: \"isHorizontal\",\n value: function isHorizontal() {\n return this.options.position === 'top' || this.options.position === 'bottom';\n }\n }, {\n key: \"draw\",\n value: function draw() {\n if (this.options.display) {\n var ctx = this.ctx;\n clipArea(ctx, this);\n this._draw();\n unclipArea(ctx);\n }\n }\n }, {\n key: \"_draw\",\n value: function _draw() {\n var _this29 = this;\n var opts = this.options,\n columnSizes = this.columnSizes,\n lineWidths = this.lineWidths,\n ctx = this.ctx;\n var align = opts.align,\n labelOpts = opts.labels;\n var defaultColor = defaults.color;\n var rtlHelper = getRtlAdapter(opts.rtl, this.left, this.width);\n var labelFont = toFont(labelOpts.font);\n var padding = labelOpts.padding;\n var fontSize = labelFont.size;\n var halfFontSize = fontSize / 2;\n var cursor;\n this.drawTitle();\n ctx.textAlign = rtlHelper.textAlign('left');\n ctx.textBaseline = 'middle';\n ctx.lineWidth = 0.5;\n ctx.font = labelFont.string;\n var _getBoxSize2 = getBoxSize(labelOpts, fontSize),\n boxWidth = _getBoxSize2.boxWidth,\n boxHeight = _getBoxSize2.boxHeight,\n itemHeight = _getBoxSize2.itemHeight;\n var drawLegendBox = function drawLegendBox(x, y, legendItem) {\n if (isNaN(boxWidth) || boxWidth <= 0 || isNaN(boxHeight) || boxHeight < 0) {\n return;\n }\n ctx.save();\n var lineWidth = valueOrDefault(legendItem.lineWidth, 1);\n ctx.fillStyle = valueOrDefault(legendItem.fillStyle, defaultColor);\n ctx.lineCap = valueOrDefault(legendItem.lineCap, 'butt');\n ctx.lineDashOffset = valueOrDefault(legendItem.lineDashOffset, 0);\n ctx.lineJoin = valueOrDefault(legendItem.lineJoin, 'miter');\n ctx.lineWidth = lineWidth;\n ctx.strokeStyle = valueOrDefault(legendItem.strokeStyle, defaultColor);\n ctx.setLineDash(valueOrDefault(legendItem.lineDash, []));\n if (labelOpts.usePointStyle) {\n var drawOptions = {\n radius: boxHeight * Math.SQRT2 / 2,\n pointStyle: legendItem.pointStyle,\n rotation: legendItem.rotation,\n borderWidth: lineWidth\n };\n var centerX = rtlHelper.xPlus(x, boxWidth / 2);\n var centerY = y + halfFontSize;\n drawPointLegend(ctx, drawOptions, centerX, centerY, labelOpts.pointStyleWidth && boxWidth);\n } else {\n var yBoxTop = y + Math.max((fontSize - boxHeight) / 2, 0);\n var xBoxLeft = rtlHelper.leftForLtr(x, boxWidth);\n var borderRadius = toTRBLCorners(legendItem.borderRadius);\n ctx.beginPath();\n if (Object.values(borderRadius).some(function (v) {\n return v !== 0;\n })) {\n addRoundedRectPath(ctx, {\n x: xBoxLeft,\n y: yBoxTop,\n w: boxWidth,\n h: boxHeight,\n radius: borderRadius\n });\n } else {\n ctx.rect(xBoxLeft, yBoxTop, boxWidth, boxHeight);\n }\n ctx.fill();\n if (lineWidth !== 0) {\n ctx.stroke();\n }\n }\n ctx.restore();\n };\n var fillText = function fillText(x, y, legendItem) {\n renderText(ctx, legendItem.text, x, y + itemHeight / 2, labelFont, {\n strikethrough: legendItem.hidden,\n textAlign: rtlHelper.textAlign(legendItem.textAlign)\n });\n };\n var isHorizontal = this.isHorizontal();\n var titleHeight = this._computeTitleHeight();\n if (isHorizontal) {\n cursor = {\n x: _alignStartEnd(align, this.left + padding, this.right - lineWidths[0]),\n y: this.top + padding + titleHeight,\n line: 0\n };\n } else {\n cursor = {\n x: this.left + padding,\n y: _alignStartEnd(align, this.top + titleHeight + padding, this.bottom - columnSizes[0].height),\n line: 0\n };\n }\n overrideTextDirection(this.ctx, opts.textDirection);\n var lineHeight = itemHeight + padding;\n this.legendItems.forEach(function (legendItem, i) {\n ctx.strokeStyle = legendItem.fontColor;\n ctx.fillStyle = legendItem.fontColor;\n var textWidth = ctx.measureText(legendItem.text).width;\n var textAlign = rtlHelper.textAlign(legendItem.textAlign || (legendItem.textAlign = labelOpts.textAlign));\n var width = boxWidth + halfFontSize + textWidth;\n var x = cursor.x;\n var y = cursor.y;\n rtlHelper.setWidth(_this29.width);\n if (isHorizontal) {\n if (i > 0 && x + width + padding > _this29.right) {\n y = cursor.y += lineHeight;\n cursor.line++;\n x = cursor.x = _alignStartEnd(align, _this29.left + padding, _this29.right - lineWidths[cursor.line]);\n }\n } else if (i > 0 && y + lineHeight > _this29.bottom) {\n x = cursor.x = x + columnSizes[cursor.line].width + padding;\n cursor.line++;\n y = cursor.y = _alignStartEnd(align, _this29.top + titleHeight + padding, _this29.bottom - columnSizes[cursor.line].height);\n }\n var realX = rtlHelper.x(x);\n drawLegendBox(realX, y, legendItem);\n x = _textX(textAlign, x + boxWidth + halfFontSize, isHorizontal ? x + width : _this29.right, opts.rtl);\n fillText(rtlHelper.x(x), y, legendItem);\n if (isHorizontal) {\n cursor.x += width + padding;\n } else if (typeof legendItem.text !== 'string') {\n var fontLineHeight = labelFont.lineHeight;\n cursor.y += calculateLegendItemHeight(legendItem, fontLineHeight) + padding;\n } else {\n cursor.y += lineHeight;\n }\n });\n restoreTextDirection(this.ctx, opts.textDirection);\n }\n }, {\n key: \"drawTitle\",\n value: function drawTitle() {\n var opts = this.options;\n var titleOpts = opts.title;\n var titleFont = toFont(titleOpts.font);\n var titlePadding = toPadding(titleOpts.padding);\n if (!titleOpts.display) {\n return;\n }\n var rtlHelper = getRtlAdapter(opts.rtl, this.left, this.width);\n var ctx = this.ctx;\n var position = titleOpts.position;\n var halfFontSize = titleFont.size / 2;\n var topPaddingPlusHalfFontSize = titlePadding.top + halfFontSize;\n var y;\n var left = this.left;\n var maxWidth = this.width;\n if (this.isHorizontal()) {\n maxWidth = Math.max.apply(Math, _toConsumableArray(this.lineWidths));\n y = this.top + topPaddingPlusHalfFontSize;\n left = _alignStartEnd(opts.align, left, this.right - maxWidth);\n } else {\n var maxHeight = this.columnSizes.reduce(function (acc, size) {\n return Math.max(acc, size.height);\n }, 0);\n y = topPaddingPlusHalfFontSize + _alignStartEnd(opts.align, this.top, this.bottom - maxHeight - opts.labels.padding - this._computeTitleHeight());\n }\n var x = _alignStartEnd(position, left, left + maxWidth);\n ctx.textAlign = rtlHelper.textAlign(_toLeftRightCenter(position));\n ctx.textBaseline = 'middle';\n ctx.strokeStyle = titleOpts.color;\n ctx.fillStyle = titleOpts.color;\n ctx.font = titleFont.string;\n renderText(ctx, titleOpts.text, x, y, titleFont);\n }\n }, {\n key: \"_computeTitleHeight\",\n value: function _computeTitleHeight() {\n var titleOpts = this.options.title;\n var titleFont = toFont(titleOpts.font);\n var titlePadding = toPadding(titleOpts.padding);\n return titleOpts.display ? titleFont.lineHeight + titlePadding.height : 0;\n }\n }, {\n key: \"_getLegendItemAt\",\n value: function _getLegendItemAt(x, y) {\n var i, hitBox, lh;\n if (_isBetween(x, this.left, this.right) && _isBetween(y, this.top, this.bottom)) {\n lh = this.legendHitBoxes;\n for (i = 0; i < lh.length; ++i) {\n hitBox = lh[i];\n if (_isBetween(x, hitBox.left, hitBox.left + hitBox.width) && _isBetween(y, hitBox.top, hitBox.top + hitBox.height)) {\n return this.legendItems[i];\n }\n }\n }\n return null;\n }\n }, {\n key: \"handleEvent\",\n value: function handleEvent(e) {\n var opts = this.options;\n if (!isListened(e.type, opts)) {\n return;\n }\n var hoveredItem = this._getLegendItemAt(e.x, e.y);\n if (e.type === 'mousemove' || e.type === 'mouseout') {\n var previous = this._hoveredItem;\n var sameItem = itemsEqual(previous, hoveredItem);\n if (previous && !sameItem) {\n callback(opts.onLeave, [e, previous, this], this);\n }\n this._hoveredItem = hoveredItem;\n if (hoveredItem && !sameItem) {\n callback(opts.onHover, [e, hoveredItem, this], this);\n }\n } else if (hoveredItem) {\n callback(opts.onClick, [e, hoveredItem, this], this);\n }\n }\n }]);\n return Legend;\n }(Element);\n function calculateItemSize(boxWidth, labelFont, ctx, legendItem, _itemHeight) {\n var itemWidth = calculateItemWidth(legendItem, boxWidth, labelFont, ctx);\n var itemHeight = calculateItemHeight(_itemHeight, legendItem, labelFont.lineHeight);\n return {\n itemWidth: itemWidth,\n itemHeight: itemHeight\n };\n }\n function calculateItemWidth(legendItem, boxWidth, labelFont, ctx) {\n var legendItemText = legendItem.text;\n if (legendItemText && typeof legendItemText !== 'string') {\n legendItemText = legendItemText.reduce(function (a, b) {\n return a.length > b.length ? a : b;\n });\n }\n return boxWidth + labelFont.size / 2 + ctx.measureText(legendItemText).width;\n }\n function calculateItemHeight(_itemHeight, legendItem, fontLineHeight) {\n var itemHeight = _itemHeight;\n if (typeof legendItem.text !== 'string') {\n itemHeight = calculateLegendItemHeight(legendItem, fontLineHeight);\n }\n return itemHeight;\n }\n function calculateLegendItemHeight(legendItem, fontLineHeight) {\n var labelHeight = legendItem.text ? legendItem.text.length : 0;\n return fontLineHeight * labelHeight;\n }\n function isListened(type, opts) {\n if ((type === 'mousemove' || type === 'mouseout') && (opts.onHover || opts.onLeave)) {\n return true;\n }\n if (opts.onClick && (type === 'click' || type === 'mouseup')) {\n return true;\n }\n return false;\n }\n var plugin_legend = {\n id: 'legend',\n _element: Legend,\n start: function start(chart, _args, options) {\n var legend = chart.legend = new Legend({\n ctx: chart.ctx,\n options: options,\n chart: chart\n });\n layouts.configure(chart, legend, options);\n layouts.addBox(chart, legend);\n },\n stop: function stop(chart) {\n layouts.removeBox(chart, chart.legend);\n delete chart.legend;\n },\n beforeUpdate: function beforeUpdate(chart, _args, options) {\n var legend = chart.legend;\n layouts.configure(chart, legend, options);\n legend.options = options;\n },\n afterUpdate: function afterUpdate(chart) {\n var legend = chart.legend;\n legend.buildLabels();\n legend.adjustHitBoxes();\n },\n afterEvent: function afterEvent(chart, args) {\n if (!args.replay) {\n chart.legend.handleEvent(args.event);\n }\n },\n defaults: {\n display: true,\n position: 'top',\n align: 'center',\n fullSize: true,\n reverse: false,\n weight: 1000,\n onClick: function onClick(e, legendItem, legend) {\n var index = legendItem.datasetIndex;\n var ci = legend.chart;\n if (ci.isDatasetVisible(index)) {\n ci.hide(index);\n legendItem.hidden = true;\n } else {\n ci.show(index);\n legendItem.hidden = false;\n }\n },\n onHover: null,\n onLeave: null,\n labels: {\n color: function color(ctx) {\n return ctx.chart.options.color;\n },\n boxWidth: 40,\n padding: 10,\n generateLabels: function generateLabels(chart) {\n var datasets = chart.data.datasets;\n var _chart$legend$options = chart.legend.options.labels,\n usePointStyle = _chart$legend$options.usePointStyle,\n pointStyle = _chart$legend$options.pointStyle,\n textAlign = _chart$legend$options.textAlign,\n color = _chart$legend$options.color,\n useBorderRadius = _chart$legend$options.useBorderRadius,\n borderRadius = _chart$legend$options.borderRadius;\n return chart._getSortedDatasetMetas().map(function (meta) {\n var style = meta.controller.getStyle(usePointStyle ? 0 : undefined);\n var borderWidth = toPadding(style.borderWidth);\n return {\n text: datasets[meta.index].label,\n fillStyle: style.backgroundColor,\n fontColor: color,\n hidden: !meta.visible,\n lineCap: style.borderCapStyle,\n lineDash: style.borderDash,\n lineDashOffset: style.borderDashOffset,\n lineJoin: style.borderJoinStyle,\n lineWidth: (borderWidth.width + borderWidth.height) / 4,\n strokeStyle: style.borderColor,\n pointStyle: pointStyle || style.pointStyle,\n rotation: style.rotation,\n textAlign: textAlign || style.textAlign,\n borderRadius: useBorderRadius && (borderRadius || style.borderRadius),\n datasetIndex: meta.index\n };\n }, this);\n }\n },\n title: {\n color: function color(ctx) {\n return ctx.chart.options.color;\n },\n display: false,\n position: 'center',\n text: ''\n }\n },\n descriptors: {\n _scriptable: function _scriptable(name) {\n return !name.startsWith('on');\n },\n labels: {\n _scriptable: function _scriptable(name) {\n return !['generateLabels', 'filter', 'sort'].includes(name);\n }\n }\n }\n };\n var Title = /*#__PURE__*/function (_Element7) {\n _inherits$1(Title, _Element7);\n var _super17 = _createSuper$1(Title);\n function Title(config) {\n var _this30;\n _classCallCheck$1(this, Title);\n _this30 = _super17.call(this);\n _this30.chart = config.chart;\n _this30.options = config.options;\n _this30.ctx = config.ctx;\n _this30._padding = undefined;\n _this30.top = undefined;\n _this30.bottom = undefined;\n _this30.left = undefined;\n _this30.right = undefined;\n _this30.width = undefined;\n _this30.height = undefined;\n _this30.position = undefined;\n _this30.weight = undefined;\n _this30.fullSize = undefined;\n return _this30;\n }\n _createClass$1(Title, [{\n key: \"update\",\n value: function update(maxWidth, maxHeight) {\n var opts = this.options;\n this.left = 0;\n this.top = 0;\n if (!opts.display) {\n this.width = this.height = this.right = this.bottom = 0;\n return;\n }\n this.width = this.right = maxWidth;\n this.height = this.bottom = maxHeight;\n var lineCount = isArray(opts.text) ? opts.text.length : 1;\n this._padding = toPadding(opts.padding);\n var textSize = lineCount * toFont(opts.font).lineHeight + this._padding.height;\n if (this.isHorizontal()) {\n this.height = textSize;\n } else {\n this.width = textSize;\n }\n }\n }, {\n key: \"isHorizontal\",\n value: function isHorizontal() {\n var pos = this.options.position;\n return pos === 'top' || pos === 'bottom';\n }\n }, {\n key: \"_drawArgs\",\n value: function _drawArgs(offset) {\n var top = this.top,\n left = this.left,\n bottom = this.bottom,\n right = this.right,\n options = this.options;\n var align = options.align;\n var rotation = 0;\n var maxWidth, titleX, titleY;\n if (this.isHorizontal()) {\n titleX = _alignStartEnd(align, left, right);\n titleY = top + offset;\n maxWidth = right - left;\n } else {\n if (options.position === 'left') {\n titleX = left + offset;\n titleY = _alignStartEnd(align, bottom, top);\n rotation = PI * -0.5;\n } else {\n titleX = right - offset;\n titleY = _alignStartEnd(align, top, bottom);\n rotation = PI * 0.5;\n }\n maxWidth = bottom - top;\n }\n return {\n titleX: titleX,\n titleY: titleY,\n maxWidth: maxWidth,\n rotation: rotation\n };\n }\n }, {\n key: \"draw\",\n value: function draw() {\n var ctx = this.ctx;\n var opts = this.options;\n if (!opts.display) {\n return;\n }\n var fontOpts = toFont(opts.font);\n var lineHeight = fontOpts.lineHeight;\n var offset = lineHeight / 2 + this._padding.top;\n var _this$_drawArgs = this._drawArgs(offset),\n titleX = _this$_drawArgs.titleX,\n titleY = _this$_drawArgs.titleY,\n maxWidth = _this$_drawArgs.maxWidth,\n rotation = _this$_drawArgs.rotation;\n renderText(ctx, opts.text, 0, 0, fontOpts, {\n color: opts.color,\n maxWidth: maxWidth,\n rotation: rotation,\n textAlign: _toLeftRightCenter(opts.align),\n textBaseline: 'middle',\n translation: [titleX, titleY]\n });\n }\n }]);\n return Title;\n }(Element);\n function createTitle(chart, titleOpts) {\n var title = new Title({\n ctx: chart.ctx,\n options: titleOpts,\n chart: chart\n });\n layouts.configure(chart, title, titleOpts);\n layouts.addBox(chart, title);\n chart.titleBlock = title;\n }\n var plugin_title = {\n id: 'title',\n _element: Title,\n start: function start(chart, _args, options) {\n createTitle(chart, options);\n },\n stop: function stop(chart) {\n var titleBlock = chart.titleBlock;\n layouts.removeBox(chart, titleBlock);\n delete chart.titleBlock;\n },\n beforeUpdate: function beforeUpdate(chart, _args, options) {\n var title = chart.titleBlock;\n layouts.configure(chart, title, options);\n title.options = options;\n },\n defaults: {\n align: 'center',\n display: false,\n font: {\n weight: 'bold'\n },\n fullSize: true,\n padding: 10,\n position: 'top',\n text: '',\n weight: 2000\n },\n defaultRoutes: {\n color: 'color'\n },\n descriptors: {\n _scriptable: true,\n _indexable: false\n }\n };\n var map = new WeakMap();\n var plugin_subtitle = {\n id: 'subtitle',\n start: function start(chart, _args, options) {\n var title = new Title({\n ctx: chart.ctx,\n options: options,\n chart: chart\n });\n layouts.configure(chart, title, options);\n layouts.addBox(chart, title);\n map.set(chart, title);\n },\n stop: function stop(chart) {\n layouts.removeBox(chart, map.get(chart));\n map[\"delete\"](chart);\n },\n beforeUpdate: function beforeUpdate(chart, _args, options) {\n var title = map.get(chart);\n layouts.configure(chart, title, options);\n title.options = options;\n },\n defaults: {\n align: 'center',\n display: false,\n font: {\n weight: 'normal'\n },\n fullSize: true,\n padding: 0,\n position: 'top',\n text: '',\n weight: 1500\n },\n defaultRoutes: {\n color: 'color'\n },\n descriptors: {\n _scriptable: true,\n _indexable: false\n }\n };\n var positioners = {\n average: function average(items) {\n if (!items.length) {\n return false;\n }\n var i, len;\n var x = 0;\n var y = 0;\n var count = 0;\n for (i = 0, len = items.length; i < len; ++i) {\n var el = items[i].element;\n if (el && el.hasValue()) {\n var pos = el.tooltipPosition();\n x += pos.x;\n y += pos.y;\n ++count;\n }\n }\n return {\n x: x / count,\n y: y / count\n };\n },\n nearest: function nearest(items, eventPosition) {\n if (!items.length) {\n return false;\n }\n var x = eventPosition.x;\n var y = eventPosition.y;\n var minDistance = Number.POSITIVE_INFINITY;\n var i, len, nearestElement;\n for (i = 0, len = items.length; i < len; ++i) {\n var el = items[i].element;\n if (el && el.hasValue()) {\n var center = el.getCenterPoint();\n var d = distanceBetweenPoints(eventPosition, center);\n if (d < minDistance) {\n minDistance = d;\n nearestElement = el;\n }\n }\n }\n if (nearestElement) {\n var tp = nearestElement.tooltipPosition();\n x = tp.x;\n y = tp.y;\n }\n return {\n x: x,\n y: y\n };\n }\n };\n function pushOrConcat(base, toPush) {\n if (toPush) {\n if (isArray(toPush)) {\n Array.prototype.push.apply(base, toPush);\n } else {\n base.push(toPush);\n }\n }\n return base;\n }\n function splitNewlines(str) {\n if ((typeof str === 'string' || str instanceof String) && str.indexOf('\\n') > -1) {\n return str.split('\\n');\n }\n return str;\n }\n function createTooltipItem(chart, item) {\n var element = item.element,\n datasetIndex = item.datasetIndex,\n index = item.index;\n var controller = chart.getDatasetMeta(datasetIndex).controller;\n var _controller$getLabelA = controller.getLabelAndValue(index),\n label = _controller$getLabelA.label,\n value = _controller$getLabelA.value;\n return {\n chart: chart,\n label: label,\n parsed: controller.getParsed(index),\n raw: chart.data.datasets[datasetIndex].data[index],\n formattedValue: value,\n dataset: controller.getDataset(),\n dataIndex: index,\n datasetIndex: datasetIndex,\n element: element\n };\n }\n function getTooltipSize(tooltip, options) {\n var ctx = tooltip.chart.ctx;\n var body = tooltip.body,\n footer = tooltip.footer,\n title = tooltip.title;\n var boxWidth = options.boxWidth,\n boxHeight = options.boxHeight;\n var bodyFont = toFont(options.bodyFont);\n var titleFont = toFont(options.titleFont);\n var footerFont = toFont(options.footerFont);\n var titleLineCount = title.length;\n var footerLineCount = footer.length;\n var bodyLineItemCount = body.length;\n var padding = toPadding(options.padding);\n var height = padding.height;\n var width = 0;\n var combinedBodyLength = body.reduce(function (count, bodyItem) {\n return count + bodyItem.before.length + bodyItem.lines.length + bodyItem.after.length;\n }, 0);\n combinedBodyLength += tooltip.beforeBody.length + tooltip.afterBody.length;\n if (titleLineCount) {\n height += titleLineCount * titleFont.lineHeight + (titleLineCount - 1) * options.titleSpacing + options.titleMarginBottom;\n }\n if (combinedBodyLength) {\n var bodyLineHeight = options.displayColors ? Math.max(boxHeight, bodyFont.lineHeight) : bodyFont.lineHeight;\n height += bodyLineItemCount * bodyLineHeight + (combinedBodyLength - bodyLineItemCount) * bodyFont.lineHeight + (combinedBodyLength - 1) * options.bodySpacing;\n }\n if (footerLineCount) {\n height += options.footerMarginTop + footerLineCount * footerFont.lineHeight + (footerLineCount - 1) * options.footerSpacing;\n }\n var widthPadding = 0;\n var maxLineWidth = function maxLineWidth(line) {\n width = Math.max(width, ctx.measureText(line).width + widthPadding);\n };\n ctx.save();\n ctx.font = titleFont.string;\n each(tooltip.title, maxLineWidth);\n ctx.font = bodyFont.string;\n each(tooltip.beforeBody.concat(tooltip.afterBody), maxLineWidth);\n widthPadding = options.displayColors ? boxWidth + 2 + options.boxPadding : 0;\n each(body, function (bodyItem) {\n each(bodyItem.before, maxLineWidth);\n each(bodyItem.lines, maxLineWidth);\n each(bodyItem.after, maxLineWidth);\n });\n widthPadding = 0;\n ctx.font = footerFont.string;\n each(tooltip.footer, maxLineWidth);\n ctx.restore();\n width += padding.width;\n return {\n width: width,\n height: height\n };\n }\n function determineYAlign(chart, size) {\n var y = size.y,\n height = size.height;\n if (y < height / 2) {\n return 'top';\n } else if (y > chart.height - height / 2) {\n return 'bottom';\n }\n return 'center';\n }\n function doesNotFitWithAlign(xAlign, chart, options, size) {\n var x = size.x,\n width = size.width;\n var caret = options.caretSize + options.caretPadding;\n if (xAlign === 'left' && x + width + caret > chart.width) {\n return true;\n }\n if (xAlign === 'right' && x - width - caret < 0) {\n return true;\n }\n }\n function determineXAlign(chart, options, size, yAlign) {\n var x = size.x,\n width = size.width;\n var chartWidth = chart.width,\n _chart$chartArea = chart.chartArea,\n left = _chart$chartArea.left,\n right = _chart$chartArea.right;\n var xAlign = 'center';\n if (yAlign === 'center') {\n xAlign = x <= (left + right) / 2 ? 'left' : 'right';\n } else if (x <= width / 2) {\n xAlign = 'left';\n } else if (x >= chartWidth - width / 2) {\n xAlign = 'right';\n }\n if (doesNotFitWithAlign(xAlign, chart, options, size)) {\n xAlign = 'center';\n }\n return xAlign;\n }\n function determineAlignment(chart, options, size) {\n var yAlign = size.yAlign || options.yAlign || determineYAlign(chart, size);\n return {\n xAlign: size.xAlign || options.xAlign || determineXAlign(chart, options, size, yAlign),\n yAlign: yAlign\n };\n }\n function alignX(size, xAlign) {\n var x = size.x,\n width = size.width;\n if (xAlign === 'right') {\n x -= width;\n } else if (xAlign === 'center') {\n x -= width / 2;\n }\n return x;\n }\n function alignY(size, yAlign, paddingAndSize) {\n var y = size.y,\n height = size.height;\n if (yAlign === 'top') {\n y += paddingAndSize;\n } else if (yAlign === 'bottom') {\n y -= height + paddingAndSize;\n } else {\n y -= height / 2;\n }\n return y;\n }\n function getBackgroundPoint(options, size, alignment, chart) {\n var caretSize = options.caretSize,\n caretPadding = options.caretPadding,\n cornerRadius = options.cornerRadius;\n var xAlign = alignment.xAlign,\n yAlign = alignment.yAlign;\n var paddingAndSize = caretSize + caretPadding;\n var _toTRBLCorners = toTRBLCorners(cornerRadius),\n topLeft = _toTRBLCorners.topLeft,\n topRight = _toTRBLCorners.topRight,\n bottomLeft = _toTRBLCorners.bottomLeft,\n bottomRight = _toTRBLCorners.bottomRight;\n var x = alignX(size, xAlign);\n var y = alignY(size, yAlign, paddingAndSize);\n if (yAlign === 'center') {\n if (xAlign === 'left') {\n x += paddingAndSize;\n } else if (xAlign === 'right') {\n x -= paddingAndSize;\n }\n } else if (xAlign === 'left') {\n x -= Math.max(topLeft, bottomLeft) + caretSize;\n } else if (xAlign === 'right') {\n x += Math.max(topRight, bottomRight) + caretSize;\n }\n return {\n x: _limitValue(x, 0, chart.width - size.width),\n y: _limitValue(y, 0, chart.height - size.height)\n };\n }\n function getAlignedX(tooltip, align, options) {\n var padding = toPadding(options.padding);\n return align === 'center' ? tooltip.x + tooltip.width / 2 : align === 'right' ? tooltip.x + tooltip.width - padding.right : tooltip.x + padding.left;\n }\n function getBeforeAfterBodyLines(callback) {\n return pushOrConcat([], splitNewlines(callback));\n }\n function createTooltipContext(parent, tooltip, tooltipItems) {\n return createContext(parent, {\n tooltip: tooltip,\n tooltipItems: tooltipItems,\n type: 'tooltip'\n });\n }\n function overrideCallbacks(callbacks, context) {\n var override = context && context.dataset && context.dataset.tooltip && context.dataset.tooltip.callbacks;\n return override ? callbacks.override(override) : callbacks;\n }\n var defaultCallbacks = {\n beforeTitle: noop,\n title: function title(tooltipItems) {\n if (tooltipItems.length > 0) {\n var item = tooltipItems[0];\n var labels = item.chart.data.labels;\n var labelCount = labels ? labels.length : 0;\n if (this && this.options && this.options.mode === 'dataset') {\n return item.dataset.label || '';\n } else if (item.label) {\n return item.label;\n } else if (labelCount > 0 && item.dataIndex < labelCount) {\n return labels[item.dataIndex];\n }\n }\n return '';\n },\n afterTitle: noop,\n beforeBody: noop,\n beforeLabel: noop,\n label: function label(tooltipItem) {\n if (this && this.options && this.options.mode === 'dataset') {\n return tooltipItem.label + ': ' + tooltipItem.formattedValue || tooltipItem.formattedValue;\n }\n var label = tooltipItem.dataset.label || '';\n if (label) {\n label += ': ';\n }\n var value = tooltipItem.formattedValue;\n if (!isNullOrUndef(value)) {\n label += value;\n }\n return label;\n },\n labelColor: function labelColor(tooltipItem) {\n var meta = tooltipItem.chart.getDatasetMeta(tooltipItem.datasetIndex);\n var options = meta.controller.getStyle(tooltipItem.dataIndex);\n return {\n borderColor: options.borderColor,\n backgroundColor: options.backgroundColor,\n borderWidth: options.borderWidth,\n borderDash: options.borderDash,\n borderDashOffset: options.borderDashOffset,\n borderRadius: 0\n };\n },\n labelTextColor: function labelTextColor() {\n return this.options.bodyColor;\n },\n labelPointStyle: function labelPointStyle(tooltipItem) {\n var meta = tooltipItem.chart.getDatasetMeta(tooltipItem.datasetIndex);\n var options = meta.controller.getStyle(tooltipItem.dataIndex);\n return {\n pointStyle: options.pointStyle,\n rotation: options.rotation\n };\n },\n afterLabel: noop,\n afterBody: noop,\n beforeFooter: noop,\n footer: noop,\n afterFooter: noop\n };\n function invokeCallbackWithFallback(callbacks, name, ctx, arg) {\n var result = callbacks[name].call(ctx, arg);\n if (typeof result === 'undefined') {\n return defaultCallbacks[name].call(ctx, arg);\n }\n return result;\n }\n var Tooltip = /*#__PURE__*/function (_Element8) {\n _inherits$1(Tooltip, _Element8);\n var _super18 = _createSuper$1(Tooltip);\n function Tooltip(config) {\n var _this31;\n _classCallCheck$1(this, Tooltip);\n _this31 = _super18.call(this);\n _this31.opacity = 0;\n _this31._active = [];\n _this31._eventPosition = undefined;\n _this31._size = undefined;\n _this31._cachedAnimations = undefined;\n _this31._tooltipItems = [];\n _this31.$animations = undefined;\n _this31.$context = undefined;\n _this31.chart = config.chart;\n _this31.options = config.options;\n _this31.dataPoints = undefined;\n _this31.title = undefined;\n _this31.beforeBody = undefined;\n _this31.body = undefined;\n _this31.afterBody = undefined;\n _this31.footer = undefined;\n _this31.xAlign = undefined;\n _this31.yAlign = undefined;\n _this31.x = undefined;\n _this31.y = undefined;\n _this31.height = undefined;\n _this31.width = undefined;\n _this31.caretX = undefined;\n _this31.caretY = undefined;\n _this31.labelColors = undefined;\n _this31.labelPointStyles = undefined;\n _this31.labelTextColors = undefined;\n return _this31;\n }\n _createClass$1(Tooltip, [{\n key: \"initialize\",\n value: function initialize(options) {\n this.options = options;\n this._cachedAnimations = undefined;\n this.$context = undefined;\n }\n }, {\n key: \"_resolveAnimations\",\n value: function _resolveAnimations() {\n var cached = this._cachedAnimations;\n if (cached) {\n return cached;\n }\n var chart = this.chart;\n var options = this.options.setContext(this.getContext());\n var opts = options.enabled && chart.options.animation && options.animations;\n var animations = new Animations(this.chart, opts);\n if (opts._cacheable) {\n this._cachedAnimations = Object.freeze(animations);\n }\n return animations;\n }\n }, {\n key: \"getContext\",\n value: function getContext() {\n return this.$context || (this.$context = createTooltipContext(this.chart.getContext(), this, this._tooltipItems));\n }\n }, {\n key: \"getTitle\",\n value: function getTitle(context, options) {\n var callbacks = options.callbacks;\n var beforeTitle = invokeCallbackWithFallback(callbacks, 'beforeTitle', this, context);\n var title = invokeCallbackWithFallback(callbacks, 'title', this, context);\n var afterTitle = invokeCallbackWithFallback(callbacks, 'afterTitle', this, context);\n var lines = [];\n lines = pushOrConcat(lines, splitNewlines(beforeTitle));\n lines = pushOrConcat(lines, splitNewlines(title));\n lines = pushOrConcat(lines, splitNewlines(afterTitle));\n return lines;\n }\n }, {\n key: \"getBeforeBody\",\n value: function getBeforeBody(tooltipItems, options) {\n return getBeforeAfterBodyLines(invokeCallbackWithFallback(options.callbacks, 'beforeBody', this, tooltipItems));\n }\n }, {\n key: \"getBody\",\n value: function getBody(tooltipItems, options) {\n var _this32 = this;\n var callbacks = options.callbacks;\n var bodyItems = [];\n each(tooltipItems, function (context) {\n var bodyItem = {\n before: [],\n lines: [],\n after: []\n };\n var scoped = overrideCallbacks(callbacks, context);\n pushOrConcat(bodyItem.before, splitNewlines(invokeCallbackWithFallback(scoped, 'beforeLabel', _this32, context)));\n pushOrConcat(bodyItem.lines, invokeCallbackWithFallback(scoped, 'label', _this32, context));\n pushOrConcat(bodyItem.after, splitNewlines(invokeCallbackWithFallback(scoped, 'afterLabel', _this32, context)));\n bodyItems.push(bodyItem);\n });\n return bodyItems;\n }\n }, {\n key: \"getAfterBody\",\n value: function getAfterBody(tooltipItems, options) {\n return getBeforeAfterBodyLines(invokeCallbackWithFallback(options.callbacks, 'afterBody', this, tooltipItems));\n }\n }, {\n key: \"getFooter\",\n value: function getFooter(tooltipItems, options) {\n var callbacks = options.callbacks;\n var beforeFooter = invokeCallbackWithFallback(callbacks, 'beforeFooter', this, tooltipItems);\n var footer = invokeCallbackWithFallback(callbacks, 'footer', this, tooltipItems);\n var afterFooter = invokeCallbackWithFallback(callbacks, 'afterFooter', this, tooltipItems);\n var lines = [];\n lines = pushOrConcat(lines, splitNewlines(beforeFooter));\n lines = pushOrConcat(lines, splitNewlines(footer));\n lines = pushOrConcat(lines, splitNewlines(afterFooter));\n return lines;\n }\n }, {\n key: \"_createItems\",\n value: function _createItems(options) {\n var _this33 = this;\n var active = this._active;\n var data = this.chart.data;\n var labelColors = [];\n var labelPointStyles = [];\n var labelTextColors = [];\n var tooltipItems = [];\n var i, len;\n for (i = 0, len = active.length; i < len; ++i) {\n tooltipItems.push(createTooltipItem(this.chart, active[i]));\n }\n if (options.filter) {\n tooltipItems = tooltipItems.filter(function (element, index, array) {\n return options.filter(element, index, array, data);\n });\n }\n if (options.itemSort) {\n tooltipItems = tooltipItems.sort(function (a, b) {\n return options.itemSort(a, b, data);\n });\n }\n each(tooltipItems, function (context) {\n var scoped = overrideCallbacks(options.callbacks, context);\n labelColors.push(invokeCallbackWithFallback(scoped, 'labelColor', _this33, context));\n labelPointStyles.push(invokeCallbackWithFallback(scoped, 'labelPointStyle', _this33, context));\n labelTextColors.push(invokeCallbackWithFallback(scoped, 'labelTextColor', _this33, context));\n });\n this.labelColors = labelColors;\n this.labelPointStyles = labelPointStyles;\n this.labelTextColors = labelTextColors;\n this.dataPoints = tooltipItems;\n return tooltipItems;\n }\n }, {\n key: \"update\",\n value: function update(changed, replay) {\n var options = this.options.setContext(this.getContext());\n var active = this._active;\n var properties;\n var tooltipItems = [];\n if (!active.length) {\n if (this.opacity !== 0) {\n properties = {\n opacity: 0\n };\n }\n } else {\n var position = positioners[options.position].call(this, active, this._eventPosition);\n tooltipItems = this._createItems(options);\n this.title = this.getTitle(tooltipItems, options);\n this.beforeBody = this.getBeforeBody(tooltipItems, options);\n this.body = this.getBody(tooltipItems, options);\n this.afterBody = this.getAfterBody(tooltipItems, options);\n this.footer = this.getFooter(tooltipItems, options);\n var size = this._size = getTooltipSize(this, options);\n var positionAndSize = Object.assign({}, position, size);\n var alignment = determineAlignment(this.chart, options, positionAndSize);\n var backgroundPoint = getBackgroundPoint(options, positionAndSize, alignment, this.chart);\n this.xAlign = alignment.xAlign;\n this.yAlign = alignment.yAlign;\n properties = {\n opacity: 1,\n x: backgroundPoint.x,\n y: backgroundPoint.y,\n width: size.width,\n height: size.height,\n caretX: position.x,\n caretY: position.y\n };\n }\n this._tooltipItems = tooltipItems;\n this.$context = undefined;\n if (properties) {\n this._resolveAnimations().update(this, properties);\n }\n if (changed && options.external) {\n options.external.call(this, {\n chart: this.chart,\n tooltip: this,\n replay: replay\n });\n }\n }\n }, {\n key: \"drawCaret\",\n value: function drawCaret(tooltipPoint, ctx, size, options) {\n var caretPosition = this.getCaretPosition(tooltipPoint, size, options);\n ctx.lineTo(caretPosition.x1, caretPosition.y1);\n ctx.lineTo(caretPosition.x2, caretPosition.y2);\n ctx.lineTo(caretPosition.x3, caretPosition.y3);\n }\n }, {\n key: \"getCaretPosition\",\n value: function getCaretPosition(tooltipPoint, size, options) {\n var xAlign = this.xAlign,\n yAlign = this.yAlign;\n var caretSize = options.caretSize,\n cornerRadius = options.cornerRadius;\n var _toTRBLCorners2 = toTRBLCorners(cornerRadius),\n topLeft = _toTRBLCorners2.topLeft,\n topRight = _toTRBLCorners2.topRight,\n bottomLeft = _toTRBLCorners2.bottomLeft,\n bottomRight = _toTRBLCorners2.bottomRight;\n var ptX = tooltipPoint.x,\n ptY = tooltipPoint.y;\n var width = size.width,\n height = size.height;\n var x1, x2, x3, y1, y2, y3;\n if (yAlign === 'center') {\n y2 = ptY + height / 2;\n if (xAlign === 'left') {\n x1 = ptX;\n x2 = x1 - caretSize;\n y1 = y2 + caretSize;\n y3 = y2 - caretSize;\n } else {\n x1 = ptX + width;\n x2 = x1 + caretSize;\n y1 = y2 - caretSize;\n y3 = y2 + caretSize;\n }\n x3 = x1;\n } else {\n if (xAlign === 'left') {\n x2 = ptX + Math.max(topLeft, bottomLeft) + caretSize;\n } else if (xAlign === 'right') {\n x2 = ptX + width - Math.max(topRight, bottomRight) - caretSize;\n } else {\n x2 = this.caretX;\n }\n if (yAlign === 'top') {\n y1 = ptY;\n y2 = y1 - caretSize;\n x1 = x2 - caretSize;\n x3 = x2 + caretSize;\n } else {\n y1 = ptY + height;\n y2 = y1 + caretSize;\n x1 = x2 + caretSize;\n x3 = x2 - caretSize;\n }\n y3 = y1;\n }\n return {\n x1: x1,\n x2: x2,\n x3: x3,\n y1: y1,\n y2: y2,\n y3: y3\n };\n }\n }, {\n key: \"drawTitle\",\n value: function drawTitle(pt, ctx, options) {\n var title = this.title;\n var length = title.length;\n var titleFont, titleSpacing, i;\n if (length) {\n var rtlHelper = getRtlAdapter(options.rtl, this.x, this.width);\n pt.x = getAlignedX(this, options.titleAlign, options);\n ctx.textAlign = rtlHelper.textAlign(options.titleAlign);\n ctx.textBaseline = 'middle';\n titleFont = toFont(options.titleFont);\n titleSpacing = options.titleSpacing;\n ctx.fillStyle = options.titleColor;\n ctx.font = titleFont.string;\n for (i = 0; i < length; ++i) {\n ctx.fillText(title[i], rtlHelper.x(pt.x), pt.y + titleFont.lineHeight / 2);\n pt.y += titleFont.lineHeight + titleSpacing;\n if (i + 1 === length) {\n pt.y += options.titleMarginBottom - titleSpacing;\n }\n }\n }\n }\n }, {\n key: \"_drawColorBox\",\n value: function _drawColorBox(ctx, pt, i, rtlHelper, options) {\n var labelColor = this.labelColors[i];\n var labelPointStyle = this.labelPointStyles[i];\n var boxHeight = options.boxHeight,\n boxWidth = options.boxWidth;\n var bodyFont = toFont(options.bodyFont);\n var colorX = getAlignedX(this, 'left', options);\n var rtlColorX = rtlHelper.x(colorX);\n var yOffSet = boxHeight < bodyFont.lineHeight ? (bodyFont.lineHeight - boxHeight) / 2 : 0;\n var colorY = pt.y + yOffSet;\n if (options.usePointStyle) {\n var drawOptions = {\n radius: Math.min(boxWidth, boxHeight) / 2,\n pointStyle: labelPointStyle.pointStyle,\n rotation: labelPointStyle.rotation,\n borderWidth: 1\n };\n var centerX = rtlHelper.leftForLtr(rtlColorX, boxWidth) + boxWidth / 2;\n var centerY = colorY + boxHeight / 2;\n ctx.strokeStyle = options.multiKeyBackground;\n ctx.fillStyle = options.multiKeyBackground;\n drawPoint(ctx, drawOptions, centerX, centerY);\n ctx.strokeStyle = labelColor.borderColor;\n ctx.fillStyle = labelColor.backgroundColor;\n drawPoint(ctx, drawOptions, centerX, centerY);\n } else {\n ctx.lineWidth = isObject(labelColor.borderWidth) ? Math.max.apply(Math, _toConsumableArray(Object.values(labelColor.borderWidth))) : labelColor.borderWidth || 1;\n ctx.strokeStyle = labelColor.borderColor;\n ctx.setLineDash(labelColor.borderDash || []);\n ctx.lineDashOffset = labelColor.borderDashOffset || 0;\n var outerX = rtlHelper.leftForLtr(rtlColorX, boxWidth);\n var innerX = rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), boxWidth - 2);\n var borderRadius = toTRBLCorners(labelColor.borderRadius);\n if (Object.values(borderRadius).some(function (v) {\n return v !== 0;\n })) {\n ctx.beginPath();\n ctx.fillStyle = options.multiKeyBackground;\n addRoundedRectPath(ctx, {\n x: outerX,\n y: colorY,\n w: boxWidth,\n h: boxHeight,\n radius: borderRadius\n });\n ctx.fill();\n ctx.stroke();\n ctx.fillStyle = labelColor.backgroundColor;\n ctx.beginPath();\n addRoundedRectPath(ctx, {\n x: innerX,\n y: colorY + 1,\n w: boxWidth - 2,\n h: boxHeight - 2,\n radius: borderRadius\n });\n ctx.fill();\n } else {\n ctx.fillStyle = options.multiKeyBackground;\n ctx.fillRect(outerX, colorY, boxWidth, boxHeight);\n ctx.strokeRect(outerX, colorY, boxWidth, boxHeight);\n ctx.fillStyle = labelColor.backgroundColor;\n ctx.fillRect(innerX, colorY + 1, boxWidth - 2, boxHeight - 2);\n }\n }\n ctx.fillStyle = this.labelTextColors[i];\n }\n }, {\n key: \"drawBody\",\n value: function drawBody(pt, ctx, options) {\n var body = this.body;\n var bodySpacing = options.bodySpacing,\n bodyAlign = options.bodyAlign,\n displayColors = options.displayColors,\n boxHeight = options.boxHeight,\n boxWidth = options.boxWidth,\n boxPadding = options.boxPadding;\n var bodyFont = toFont(options.bodyFont);\n var bodyLineHeight = bodyFont.lineHeight;\n var xLinePadding = 0;\n var rtlHelper = getRtlAdapter(options.rtl, this.x, this.width);\n var fillLineOfText = function fillLineOfText(line) {\n ctx.fillText(line, rtlHelper.x(pt.x + xLinePadding), pt.y + bodyLineHeight / 2);\n pt.y += bodyLineHeight + bodySpacing;\n };\n var bodyAlignForCalculation = rtlHelper.textAlign(bodyAlign);\n var bodyItem, textColor, lines, i, j, ilen, jlen;\n ctx.textAlign = bodyAlign;\n ctx.textBaseline = 'middle';\n ctx.font = bodyFont.string;\n pt.x = getAlignedX(this, bodyAlignForCalculation, options);\n ctx.fillStyle = options.bodyColor;\n each(this.beforeBody, fillLineOfText);\n xLinePadding = displayColors && bodyAlignForCalculation !== 'right' ? bodyAlign === 'center' ? boxWidth / 2 + boxPadding : boxWidth + 2 + boxPadding : 0;\n for (i = 0, ilen = body.length; i < ilen; ++i) {\n bodyItem = body[i];\n textColor = this.labelTextColors[i];\n ctx.fillStyle = textColor;\n each(bodyItem.before, fillLineOfText);\n lines = bodyItem.lines;\n if (displayColors && lines.length) {\n this._drawColorBox(ctx, pt, i, rtlHelper, options);\n bodyLineHeight = Math.max(bodyFont.lineHeight, boxHeight);\n }\n for (j = 0, jlen = lines.length; j < jlen; ++j) {\n fillLineOfText(lines[j]);\n bodyLineHeight = bodyFont.lineHeight;\n }\n each(bodyItem.after, fillLineOfText);\n }\n xLinePadding = 0;\n bodyLineHeight = bodyFont.lineHeight;\n each(this.afterBody, fillLineOfText);\n pt.y -= bodySpacing;\n }\n }, {\n key: \"drawFooter\",\n value: function drawFooter(pt, ctx, options) {\n var footer = this.footer;\n var length = footer.length;\n var footerFont, i;\n if (length) {\n var rtlHelper = getRtlAdapter(options.rtl, this.x, this.width);\n pt.x = getAlignedX(this, options.footerAlign, options);\n pt.y += options.footerMarginTop;\n ctx.textAlign = rtlHelper.textAlign(options.footerAlign);\n ctx.textBaseline = 'middle';\n footerFont = toFont(options.footerFont);\n ctx.fillStyle = options.footerColor;\n ctx.font = footerFont.string;\n for (i = 0; i < length; ++i) {\n ctx.fillText(footer[i], rtlHelper.x(pt.x), pt.y + footerFont.lineHeight / 2);\n pt.y += footerFont.lineHeight + options.footerSpacing;\n }\n }\n }\n }, {\n key: \"drawBackground\",\n value: function drawBackground(pt, ctx, tooltipSize, options) {\n var xAlign = this.xAlign,\n yAlign = this.yAlign;\n var x = pt.x,\n y = pt.y;\n var width = tooltipSize.width,\n height = tooltipSize.height;\n var _toTRBLCorners3 = toTRBLCorners(options.cornerRadius),\n topLeft = _toTRBLCorners3.topLeft,\n topRight = _toTRBLCorners3.topRight,\n bottomLeft = _toTRBLCorners3.bottomLeft,\n bottomRight = _toTRBLCorners3.bottomRight;\n ctx.fillStyle = options.backgroundColor;\n ctx.strokeStyle = options.borderColor;\n ctx.lineWidth = options.borderWidth;\n ctx.beginPath();\n ctx.moveTo(x + topLeft, y);\n if (yAlign === 'top') {\n this.drawCaret(pt, ctx, tooltipSize, options);\n }\n ctx.lineTo(x + width - topRight, y);\n ctx.quadraticCurveTo(x + width, y, x + width, y + topRight);\n if (yAlign === 'center' && xAlign === 'right') {\n this.drawCaret(pt, ctx, tooltipSize, options);\n }\n ctx.lineTo(x + width, y + height - bottomRight);\n ctx.quadraticCurveTo(x + width, y + height, x + width - bottomRight, y + height);\n if (yAlign === 'bottom') {\n this.drawCaret(pt, ctx, tooltipSize, options);\n }\n ctx.lineTo(x + bottomLeft, y + height);\n ctx.quadraticCurveTo(x, y + height, x, y + height - bottomLeft);\n if (yAlign === 'center' && xAlign === 'left') {\n this.drawCaret(pt, ctx, tooltipSize, options);\n }\n ctx.lineTo(x, y + topLeft);\n ctx.quadraticCurveTo(x, y, x + topLeft, y);\n ctx.closePath();\n ctx.fill();\n if (options.borderWidth > 0) {\n ctx.stroke();\n }\n }\n }, {\n key: \"_updateAnimationTarget\",\n value: function _updateAnimationTarget(options) {\n var chart = this.chart;\n var anims = this.$animations;\n var animX = anims && anims.x;\n var animY = anims && anims.y;\n if (animX || animY) {\n var position = positioners[options.position].call(this, this._active, this._eventPosition);\n if (!position) {\n return;\n }\n var size = this._size = getTooltipSize(this, options);\n var positionAndSize = Object.assign({}, position, this._size);\n var alignment = determineAlignment(chart, options, positionAndSize);\n var point = getBackgroundPoint(options, positionAndSize, alignment, chart);\n if (animX._to !== point.x || animY._to !== point.y) {\n this.xAlign = alignment.xAlign;\n this.yAlign = alignment.yAlign;\n this.width = size.width;\n this.height = size.height;\n this.caretX = position.x;\n this.caretY = position.y;\n this._resolveAnimations().update(this, point);\n }\n }\n }\n }, {\n key: \"_willRender\",\n value: function _willRender() {\n return !!this.opacity;\n }\n }, {\n key: \"draw\",\n value: function draw(ctx) {\n var options = this.options.setContext(this.getContext());\n var opacity = this.opacity;\n if (!opacity) {\n return;\n }\n this._updateAnimationTarget(options);\n var tooltipSize = {\n width: this.width,\n height: this.height\n };\n var pt = {\n x: this.x,\n y: this.y\n };\n opacity = Math.abs(opacity) < 1e-3 ? 0 : opacity;\n var padding = toPadding(options.padding);\n var hasTooltipContent = this.title.length || this.beforeBody.length || this.body.length || this.afterBody.length || this.footer.length;\n if (options.enabled && hasTooltipContent) {\n ctx.save();\n ctx.globalAlpha = opacity;\n this.drawBackground(pt, ctx, tooltipSize, options);\n overrideTextDirection(ctx, options.textDirection);\n pt.y += padding.top;\n this.drawTitle(pt, ctx, options);\n this.drawBody(pt, ctx, options);\n this.drawFooter(pt, ctx, options);\n restoreTextDirection(ctx, options.textDirection);\n ctx.restore();\n }\n }\n }, {\n key: \"getActiveElements\",\n value: function getActiveElements() {\n return this._active || [];\n }\n }, {\n key: \"setActiveElements\",\n value: function setActiveElements(activeElements, eventPosition) {\n var _this34 = this;\n var lastActive = this._active;\n var active = activeElements.map(function (_ref11) {\n var datasetIndex = _ref11.datasetIndex,\n index = _ref11.index;\n var meta = _this34.chart.getDatasetMeta(datasetIndex);\n if (!meta) {\n throw new Error('Cannot find a dataset at index ' + datasetIndex);\n }\n return {\n datasetIndex: datasetIndex,\n element: meta.data[index],\n index: index\n };\n });\n var changed = !_elementsEqual(lastActive, active);\n var positionChanged = this._positionChanged(active, eventPosition);\n if (changed || positionChanged) {\n this._active = active;\n this._eventPosition = eventPosition;\n this._ignoreReplayEvents = true;\n this.update(true);\n }\n }\n }, {\n key: \"handleEvent\",\n value: function handleEvent(e, replay) {\n var inChartArea = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;\n if (replay && this._ignoreReplayEvents) {\n return false;\n }\n this._ignoreReplayEvents = false;\n var options = this.options;\n var lastActive = this._active || [];\n var active = this._getActiveElements(e, lastActive, replay, inChartArea);\n var positionChanged = this._positionChanged(active, e);\n var changed = replay || !_elementsEqual(active, lastActive) || positionChanged;\n if (changed) {\n this._active = active;\n if (options.enabled || options.external) {\n this._eventPosition = {\n x: e.x,\n y: e.y\n };\n this.update(true, replay);\n }\n }\n return changed;\n }\n }, {\n key: \"_getActiveElements\",\n value: function _getActiveElements(e, lastActive, replay, inChartArea) {\n var options = this.options;\n if (e.type === 'mouseout') {\n return [];\n }\n if (!inChartArea) {\n return lastActive;\n }\n var active = this.chart.getElementsAtEventForMode(e, options.mode, options, replay);\n if (options.reverse) {\n active.reverse();\n }\n return active;\n }\n }, {\n key: \"_positionChanged\",\n value: function _positionChanged(active, e) {\n var caretX = this.caretX,\n caretY = this.caretY,\n options = this.options;\n var position = positioners[options.position].call(this, active, e);\n return position !== false && (caretX !== position.x || caretY !== position.y);\n }\n }]);\n return Tooltip;\n }(Element);\n _defineProperty$1(Tooltip, \"positioners\", positioners);\n var plugin_tooltip = {\n id: 'tooltip',\n _element: Tooltip,\n positioners: positioners,\n afterInit: function afterInit(chart, _args, options) {\n if (options) {\n chart.tooltip = new Tooltip({\n chart: chart,\n options: options\n });\n }\n },\n beforeUpdate: function beforeUpdate(chart, _args, options) {\n if (chart.tooltip) {\n chart.tooltip.initialize(options);\n }\n },\n reset: function reset(chart, _args, options) {\n if (chart.tooltip) {\n chart.tooltip.initialize(options);\n }\n },\n afterDraw: function afterDraw(chart) {\n var tooltip = chart.tooltip;\n if (tooltip && tooltip._willRender()) {\n var args = {\n tooltip: tooltip\n };\n if (chart.notifyPlugins('beforeTooltipDraw', _objectSpread2(_objectSpread2({}, args), {}, {\n cancelable: true\n })) === false) {\n return;\n }\n tooltip.draw(chart.ctx);\n chart.notifyPlugins('afterTooltipDraw', args);\n }\n },\n afterEvent: function afterEvent(chart, args) {\n if (chart.tooltip) {\n var useFinalPosition = args.replay;\n if (chart.tooltip.handleEvent(args.event, useFinalPosition, args.inChartArea)) {\n args.changed = true;\n }\n }\n },\n defaults: {\n enabled: true,\n external: null,\n position: 'average',\n backgroundColor: 'rgba(0,0,0,0.8)',\n titleColor: '#fff',\n titleFont: {\n weight: 'bold'\n },\n titleSpacing: 2,\n titleMarginBottom: 6,\n titleAlign: 'left',\n bodyColor: '#fff',\n bodySpacing: 2,\n bodyFont: {},\n bodyAlign: 'left',\n footerColor: '#fff',\n footerSpacing: 2,\n footerMarginTop: 6,\n footerFont: {\n weight: 'bold'\n },\n footerAlign: 'left',\n padding: 6,\n caretPadding: 2,\n caretSize: 5,\n cornerRadius: 6,\n boxHeight: function boxHeight(ctx, opts) {\n return opts.bodyFont.size;\n },\n boxWidth: function boxWidth(ctx, opts) {\n return opts.bodyFont.size;\n },\n multiKeyBackground: '#fff',\n displayColors: true,\n boxPadding: 0,\n borderColor: 'rgba(0,0,0,0)',\n borderWidth: 0,\n animation: {\n duration: 400,\n easing: 'easeOutQuart'\n },\n animations: {\n numbers: {\n type: 'number',\n properties: ['x', 'y', 'width', 'height', 'caretX', 'caretY']\n },\n opacity: {\n easing: 'linear',\n duration: 200\n }\n },\n callbacks: defaultCallbacks\n },\n defaultRoutes: {\n bodyFont: 'font',\n footerFont: 'font',\n titleFont: 'font'\n },\n descriptors: {\n _scriptable: function _scriptable(name) {\n return name !== 'filter' && name !== 'itemSort' && name !== 'external';\n },\n _indexable: false,\n callbacks: {\n _scriptable: false,\n _indexable: false\n },\n animation: {\n _fallback: false\n },\n animations: {\n _fallback: 'animation'\n }\n },\n additionalOptionScopes: ['interaction']\n };\n var plugins = /*#__PURE__*/Object.freeze({\n __proto__: null,\n Colors: plugin_colors,\n Decimation: plugin_decimation,\n Filler: index,\n Legend: plugin_legend,\n SubTitle: plugin_subtitle,\n Title: plugin_title,\n Tooltip: plugin_tooltip\n });\n var addIfString = function addIfString(labels, raw, index, addedLabels) {\n if (typeof raw === 'string') {\n index = labels.push(raw) - 1;\n addedLabels.unshift({\n index: index,\n label: raw\n });\n } else if (isNaN(raw)) {\n index = null;\n }\n return index;\n };\n function findOrAddLabel(labels, raw, index, addedLabels) {\n var first = labels.indexOf(raw);\n if (first === -1) {\n return addIfString(labels, raw, index, addedLabels);\n }\n var last = labels.lastIndexOf(raw);\n return first !== last ? index : first;\n }\n var validIndex = function validIndex(index, max) {\n return index === null ? null : _limitValue(Math.round(index), 0, max);\n };\n function _getLabelForValue(value) {\n var labels = this.getLabels();\n if (value >= 0 && value < labels.length) {\n return labels[value];\n }\n return value;\n }\n var CategoryScale = /*#__PURE__*/function (_Scale) {\n _inherits$1(CategoryScale, _Scale);\n var _super19 = _createSuper$1(CategoryScale);\n function CategoryScale(cfg) {\n var _this35;\n _classCallCheck$1(this, CategoryScale);\n _this35 = _super19.call(this, cfg);\n _this35._startValue = undefined;\n _this35._valueRange = 0;\n _this35._addedLabels = [];\n return _this35;\n }\n _createClass$1(CategoryScale, [{\n key: \"init\",\n value: function init(scaleOptions) {\n var added = this._addedLabels;\n if (added.length) {\n var labels = this.getLabels();\n var _iterator25 = _createForOfIteratorHelper$1(added),\n _step25;\n try {\n for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {\n var _step25$value = _step25.value,\n _index3 = _step25$value.index,\n label = _step25$value.label;\n if (labels[_index3] === label) {\n labels.splice(_index3, 1);\n }\n }\n } catch (err) {\n _iterator25.e(err);\n } finally {\n _iterator25.f();\n }\n this._addedLabels = [];\n }\n _get(_getPrototypeOf$1(CategoryScale.prototype), \"init\", this).call(this, scaleOptions);\n }\n }, {\n key: \"parse\",\n value: function parse(raw, index) {\n if (isNullOrUndef(raw)) {\n return null;\n }\n var labels = this.getLabels();\n index = isFinite(index) && labels[index] === raw ? index : findOrAddLabel(labels, raw, valueOrDefault(index, raw), this._addedLabels);\n return validIndex(index, labels.length - 1);\n }\n }, {\n key: \"determineDataLimits\",\n value: function determineDataLimits() {\n var _this$getUserBounds2 = this.getUserBounds(),\n minDefined = _this$getUserBounds2.minDefined,\n maxDefined = _this$getUserBounds2.maxDefined;\n var _this$getMinMax = this.getMinMax(true),\n min = _this$getMinMax.min,\n max = _this$getMinMax.max;\n if (this.options.bounds === 'ticks') {\n if (!minDefined) {\n min = 0;\n }\n if (!maxDefined) {\n max = this.getLabels().length - 1;\n }\n }\n this.min = min;\n this.max = max;\n }\n }, {\n key: \"buildTicks\",\n value: function buildTicks() {\n var min = this.min;\n var max = this.max;\n var offset = this.options.offset;\n var ticks = [];\n var labels = this.getLabels();\n labels = min === 0 && max === labels.length - 1 ? labels : labels.slice(min, max + 1);\n this._valueRange = Math.max(labels.length - (offset ? 0 : 1), 1);\n this._startValue = this.min - (offset ? 0.5 : 0);\n for (var value = min; value <= max; value++) {\n ticks.push({\n value: value\n });\n }\n return ticks;\n }\n }, {\n key: \"getLabelForValue\",\n value: function getLabelForValue(value) {\n return _getLabelForValue.call(this, value);\n }\n }, {\n key: \"configure\",\n value: function configure() {\n _get(_getPrototypeOf$1(CategoryScale.prototype), \"configure\", this).call(this);\n if (!this.isHorizontal()) {\n this._reversePixels = !this._reversePixels;\n }\n }\n }, {\n key: \"getPixelForValue\",\n value: function getPixelForValue(value) {\n if (typeof value !== 'number') {\n value = this.parse(value);\n }\n return value === null ? NaN : this.getPixelForDecimal((value - this._startValue) / this._valueRange);\n }\n }, {\n key: \"getPixelForTick\",\n value: function getPixelForTick(index) {\n var ticks = this.ticks;\n if (index < 0 || index > ticks.length - 1) {\n return null;\n }\n return this.getPixelForValue(ticks[index].value);\n }\n }, {\n key: \"getValueForPixel\",\n value: function getValueForPixel(pixel) {\n return Math.round(this._startValue + this.getDecimalForPixel(pixel) * this._valueRange);\n }\n }, {\n key: \"getBasePixel\",\n value: function getBasePixel() {\n return this.bottom;\n }\n }]);\n return CategoryScale;\n }(Scale);\n _defineProperty$1(CategoryScale, \"id\", 'category');\n _defineProperty$1(CategoryScale, \"defaults\", {\n ticks: {\n callback: _getLabelForValue\n }\n });\n function generateTicks$1(generationOptions, dataRange) {\n var ticks = [];\n var MIN_SPACING = 1e-14;\n var bounds = generationOptions.bounds,\n step = generationOptions.step,\n min = generationOptions.min,\n max = generationOptions.max,\n precision = generationOptions.precision,\n count = generationOptions.count,\n maxTicks = generationOptions.maxTicks,\n maxDigits = generationOptions.maxDigits,\n includeBounds = generationOptions.includeBounds;\n var unit = step || 1;\n var maxSpaces = maxTicks - 1;\n var rmin = dataRange.min,\n rmax = dataRange.max;\n var minDefined = !isNullOrUndef(min);\n var maxDefined = !isNullOrUndef(max);\n var countDefined = !isNullOrUndef(count);\n var minSpacing = (rmax - rmin) / (maxDigits + 1);\n var spacing = niceNum((rmax - rmin) / maxSpaces / unit) * unit;\n var factor, niceMin, niceMax, numSpaces;\n if (spacing < MIN_SPACING && !minDefined && !maxDefined) {\n return [{\n value: rmin\n }, {\n value: rmax\n }];\n }\n numSpaces = Math.ceil(rmax / spacing) - Math.floor(rmin / spacing);\n if (numSpaces > maxSpaces) {\n spacing = niceNum(numSpaces * spacing / maxSpaces / unit) * unit;\n }\n if (!isNullOrUndef(precision)) {\n factor = Math.pow(10, precision);\n spacing = Math.ceil(spacing * factor) / factor;\n }\n if (bounds === 'ticks') {\n niceMin = Math.floor(rmin / spacing) * spacing;\n niceMax = Math.ceil(rmax / spacing) * spacing;\n } else {\n niceMin = rmin;\n niceMax = rmax;\n }\n if (minDefined && maxDefined && step && almostWhole((max - min) / step, spacing / 1000)) {\n numSpaces = Math.round(Math.min((max - min) / spacing, maxTicks));\n spacing = (max - min) / numSpaces;\n niceMin = min;\n niceMax = max;\n } else if (countDefined) {\n niceMin = minDefined ? min : niceMin;\n niceMax = maxDefined ? max : niceMax;\n numSpaces = count - 1;\n spacing = (niceMax - niceMin) / numSpaces;\n } else {\n numSpaces = (niceMax - niceMin) / spacing;\n if (almostEquals(numSpaces, Math.round(numSpaces), spacing / 1000)) {\n numSpaces = Math.round(numSpaces);\n } else {\n numSpaces = Math.ceil(numSpaces);\n }\n }\n var decimalPlaces = Math.max(_decimalPlaces(spacing), _decimalPlaces(niceMin));\n factor = Math.pow(10, isNullOrUndef(precision) ? decimalPlaces : precision);\n niceMin = Math.round(niceMin * factor) / factor;\n niceMax = Math.round(niceMax * factor) / factor;\n var j = 0;\n if (minDefined) {\n if (includeBounds && niceMin !== min) {\n ticks.push({\n value: min\n });\n if (niceMin < min) {\n j++;\n }\n if (almostEquals(Math.round((niceMin + j * spacing) * factor) / factor, min, relativeLabelSize(min, minSpacing, generationOptions))) {\n j++;\n }\n } else if (niceMin < min) {\n j++;\n }\n }\n for (; j < numSpaces; ++j) {\n var tickValue = Math.round((niceMin + j * spacing) * factor) / factor;\n if (maxDefined && tickValue > max) {\n break;\n }\n ticks.push({\n value: tickValue\n });\n }\n if (maxDefined && includeBounds && niceMax !== max) {\n if (ticks.length && almostEquals(ticks[ticks.length - 1].value, max, relativeLabelSize(max, minSpacing, generationOptions))) {\n ticks[ticks.length - 1].value = max;\n } else {\n ticks.push({\n value: max\n });\n }\n } else if (!maxDefined || niceMax === max) {\n ticks.push({\n value: niceMax\n });\n }\n return ticks;\n }\n function relativeLabelSize(value, minSpacing, _ref12) {\n var horizontal = _ref12.horizontal,\n minRotation = _ref12.minRotation;\n var rad = toRadians(minRotation);\n var ratio = (horizontal ? Math.sin(rad) : Math.cos(rad)) || 0.001;\n var length = 0.75 * minSpacing * ('' + value).length;\n return Math.min(minSpacing / ratio, length);\n }\n var LinearScaleBase = /*#__PURE__*/function (_Scale2) {\n _inherits$1(LinearScaleBase, _Scale2);\n var _super20 = _createSuper$1(LinearScaleBase);\n function LinearScaleBase(cfg) {\n var _this36;\n _classCallCheck$1(this, LinearScaleBase);\n _this36 = _super20.call(this, cfg);\n _this36.start = undefined;\n _this36.end = undefined;\n _this36._startValue = undefined;\n _this36._endValue = undefined;\n _this36._valueRange = 0;\n return _this36;\n }\n _createClass$1(LinearScaleBase, [{\n key: \"parse\",\n value: function parse(raw, index) {\n if (isNullOrUndef(raw)) {\n return null;\n }\n if ((typeof raw === 'number' || raw instanceof Number) && !isFinite(+raw)) {\n return null;\n }\n return +raw;\n }\n }, {\n key: \"handleTickRangeOptions\",\n value: function handleTickRangeOptions() {\n var beginAtZero = this.options.beginAtZero;\n var _this$getUserBounds3 = this.getUserBounds(),\n minDefined = _this$getUserBounds3.minDefined,\n maxDefined = _this$getUserBounds3.maxDefined;\n var min = this.min,\n max = this.max;\n var setMin = function setMin(v) {\n return min = minDefined ? min : v;\n };\n var setMax = function setMax(v) {\n return max = maxDefined ? max : v;\n };\n if (beginAtZero) {\n var minSign = sign(min);\n var maxSign = sign(max);\n if (minSign < 0 && maxSign < 0) {\n setMax(0);\n } else if (minSign > 0 && maxSign > 0) {\n setMin(0);\n }\n }\n if (min === max) {\n var offset = max === 0 ? 1 : Math.abs(max * 0.05);\n setMax(max + offset);\n if (!beginAtZero) {\n setMin(min - offset);\n }\n }\n this.min = min;\n this.max = max;\n }\n }, {\n key: \"getTickLimit\",\n value: function getTickLimit() {\n var tickOpts = this.options.ticks;\n var maxTicksLimit = tickOpts.maxTicksLimit,\n stepSize = tickOpts.stepSize;\n var maxTicks;\n if (stepSize) {\n maxTicks = Math.ceil(this.max / stepSize) - Math.floor(this.min / stepSize) + 1;\n if (maxTicks > 1000) {\n console.warn(\"scales.\".concat(this.id, \".ticks.stepSize: \").concat(stepSize, \" would result generating up to \").concat(maxTicks, \" ticks. Limiting to 1000.\"));\n maxTicks = 1000;\n }\n } else {\n maxTicks = this.computeTickLimit();\n maxTicksLimit = maxTicksLimit || 11;\n }\n if (maxTicksLimit) {\n maxTicks = Math.min(maxTicksLimit, maxTicks);\n }\n return maxTicks;\n }\n }, {\n key: \"computeTickLimit\",\n value: function computeTickLimit() {\n return Number.POSITIVE_INFINITY;\n }\n }, {\n key: \"buildTicks\",\n value: function buildTicks() {\n var opts = this.options;\n var tickOpts = opts.ticks;\n var maxTicks = this.getTickLimit();\n maxTicks = Math.max(2, maxTicks);\n var numericGeneratorOptions = {\n maxTicks: maxTicks,\n bounds: opts.bounds,\n min: opts.min,\n max: opts.max,\n precision: tickOpts.precision,\n step: tickOpts.stepSize,\n count: tickOpts.count,\n maxDigits: this._maxDigits(),\n horizontal: this.isHorizontal(),\n minRotation: tickOpts.minRotation || 0,\n includeBounds: tickOpts.includeBounds !== false\n };\n var dataRange = this._range || this;\n var ticks = generateTicks$1(numericGeneratorOptions, dataRange);\n if (opts.bounds === 'ticks') {\n _setMinAndMaxByKey(ticks, this, 'value');\n }\n if (opts.reverse) {\n ticks.reverse();\n this.start = this.max;\n this.end = this.min;\n } else {\n this.start = this.min;\n this.end = this.max;\n }\n return ticks;\n }\n }, {\n key: \"configure\",\n value: function configure() {\n var ticks = this.ticks;\n var start = this.min;\n var end = this.max;\n _get(_getPrototypeOf$1(LinearScaleBase.prototype), \"configure\", this).call(this);\n if (this.options.offset && ticks.length) {\n var offset = (end - start) / Math.max(ticks.length - 1, 1) / 2;\n start -= offset;\n end += offset;\n }\n this._startValue = start;\n this._endValue = end;\n this._valueRange = end - start;\n }\n }, {\n key: \"getLabelForValue\",\n value: function getLabelForValue(value) {\n return formatNumber(value, this.chart.options.locale, this.options.ticks.format);\n }\n }]);\n return LinearScaleBase;\n }(Scale);\n var LinearScale = /*#__PURE__*/function (_LinearScaleBase) {\n _inherits$1(LinearScale, _LinearScaleBase);\n var _super21 = _createSuper$1(LinearScale);\n function LinearScale() {\n _classCallCheck$1(this, LinearScale);\n return _super21.apply(this, arguments);\n }\n _createClass$1(LinearScale, [{\n key: \"determineDataLimits\",\n value: function determineDataLimits() {\n var _this$getMinMax2 = this.getMinMax(true),\n min = _this$getMinMax2.min,\n max = _this$getMinMax2.max;\n this.min = isNumberFinite(min) ? min : 0;\n this.max = isNumberFinite(max) ? max : 1;\n this.handleTickRangeOptions();\n }\n }, {\n key: \"computeTickLimit\",\n value: function computeTickLimit() {\n var horizontal = this.isHorizontal();\n var length = horizontal ? this.width : this.height;\n var minRotation = toRadians(this.options.ticks.minRotation);\n var ratio = (horizontal ? Math.sin(minRotation) : Math.cos(minRotation)) || 0.001;\n var tickFont = this._resolveTickFontOptions(0);\n return Math.ceil(length / Math.min(40, tickFont.lineHeight / ratio));\n }\n }, {\n key: \"getPixelForValue\",\n value: function getPixelForValue(value) {\n return value === null ? NaN : this.getPixelForDecimal((value - this._startValue) / this._valueRange);\n }\n }, {\n key: \"getValueForPixel\",\n value: function getValueForPixel(pixel) {\n return this._startValue + this.getDecimalForPixel(pixel) * this._valueRange;\n }\n }]);\n return LinearScale;\n }(LinearScaleBase);\n _defineProperty$1(LinearScale, \"id\", 'linear');\n _defineProperty$1(LinearScale, \"defaults\", {\n ticks: {\n callback: Ticks.formatters.numeric\n }\n });\n var log10Floor = function log10Floor(v) {\n return Math.floor(log10(v));\n };\n var changeExponent = function changeExponent(v, m) {\n return Math.pow(10, log10Floor(v) + m);\n };\n function isMajor(tickVal) {\n var remain = tickVal / Math.pow(10, log10Floor(tickVal));\n return remain === 1;\n }\n function steps(min, max, rangeExp) {\n var rangeStep = Math.pow(10, rangeExp);\n var start = Math.floor(min / rangeStep);\n var end = Math.ceil(max / rangeStep);\n return end - start;\n }\n function startExp(min, max) {\n var range = max - min;\n var rangeExp = log10Floor(range);\n while (steps(min, max, rangeExp) > 10) {\n rangeExp++;\n }\n while (steps(min, max, rangeExp) < 10) {\n rangeExp--;\n }\n return Math.min(rangeExp, log10Floor(min));\n }\n function generateTicks(generationOptions, _ref13) {\n var min = _ref13.min,\n max = _ref13.max;\n min = finiteOrDefault(generationOptions.min, min);\n var ticks = [];\n var minExp = log10Floor(min);\n var exp = startExp(min, max);\n var precision = exp < 0 ? Math.pow(10, Math.abs(exp)) : 1;\n var stepSize = Math.pow(10, exp);\n var base = minExp > exp ? Math.pow(10, minExp) : 0;\n var start = Math.round((min - base) * precision) / precision;\n var offset = Math.floor((min - base) / stepSize / 10) * stepSize * 10;\n var significand = Math.floor((start - offset) / Math.pow(10, exp));\n var value = finiteOrDefault(generationOptions.min, Math.round((base + offset + significand * Math.pow(10, exp)) * precision) / precision);\n while (value < max) {\n ticks.push({\n value: value,\n major: isMajor(value),\n significand: significand\n });\n if (significand >= 10) {\n significand = significand < 15 ? 15 : 20;\n } else {\n significand++;\n }\n if (significand >= 20) {\n exp++;\n significand = 2;\n precision = exp >= 0 ? 1 : precision;\n }\n value = Math.round((base + offset + significand * Math.pow(10, exp)) * precision) / precision;\n }\n var lastTick = finiteOrDefault(generationOptions.max, value);\n ticks.push({\n value: lastTick,\n major: isMajor(lastTick),\n significand: significand\n });\n return ticks;\n }\n var LogarithmicScale = /*#__PURE__*/function (_Scale3) {\n _inherits$1(LogarithmicScale, _Scale3);\n var _super22 = _createSuper$1(LogarithmicScale);\n function LogarithmicScale(cfg) {\n var _this37;\n _classCallCheck$1(this, LogarithmicScale);\n _this37 = _super22.call(this, cfg);\n _this37.start = undefined;\n _this37.end = undefined;\n _this37._startValue = undefined;\n _this37._valueRange = 0;\n return _this37;\n }\n _createClass$1(LogarithmicScale, [{\n key: \"parse\",\n value: function parse(raw, index) {\n var value = LinearScaleBase.prototype.parse.apply(this, [raw, index]);\n if (value === 0) {\n this._zero = true;\n return undefined;\n }\n return isNumberFinite(value) && value > 0 ? value : null;\n }\n }, {\n key: \"determineDataLimits\",\n value: function determineDataLimits() {\n var _this$getMinMax3 = this.getMinMax(true),\n min = _this$getMinMax3.min,\n max = _this$getMinMax3.max;\n this.min = isNumberFinite(min) ? Math.max(0, min) : null;\n this.max = isNumberFinite(max) ? Math.max(0, max) : null;\n if (this.options.beginAtZero) {\n this._zero = true;\n }\n if (this._zero && this.min !== this._suggestedMin && !isNumberFinite(this._userMin)) {\n this.min = min === changeExponent(this.min, 0) ? changeExponent(this.min, -1) : changeExponent(this.min, 0);\n }\n this.handleTickRangeOptions();\n }\n }, {\n key: \"handleTickRangeOptions\",\n value: function handleTickRangeOptions() {\n var _this$getUserBounds4 = this.getUserBounds(),\n minDefined = _this$getUserBounds4.minDefined,\n maxDefined = _this$getUserBounds4.maxDefined;\n var min = this.min;\n var max = this.max;\n var setMin = function setMin(v) {\n return min = minDefined ? min : v;\n };\n var setMax = function setMax(v) {\n return max = maxDefined ? max : v;\n };\n if (min === max) {\n if (min <= 0) {\n setMin(1);\n setMax(10);\n } else {\n setMin(changeExponent(min, -1));\n setMax(changeExponent(max, +1));\n }\n }\n if (min <= 0) {\n setMin(changeExponent(max, -1));\n }\n if (max <= 0) {\n setMax(changeExponent(min, +1));\n }\n this.min = min;\n this.max = max;\n }\n }, {\n key: \"buildTicks\",\n value: function buildTicks() {\n var opts = this.options;\n var generationOptions = {\n min: this._userMin,\n max: this._userMax\n };\n var ticks = generateTicks(generationOptions, this);\n if (opts.bounds === 'ticks') {\n _setMinAndMaxByKey(ticks, this, 'value');\n }\n if (opts.reverse) {\n ticks.reverse();\n this.start = this.max;\n this.end = this.min;\n } else {\n this.start = this.min;\n this.end = this.max;\n }\n return ticks;\n }\n }, {\n key: \"getLabelForValue\",\n value: function getLabelForValue(value) {\n return value === undefined ? '0' : formatNumber(value, this.chart.options.locale, this.options.ticks.format);\n }\n }, {\n key: \"configure\",\n value: function configure() {\n var start = this.min;\n _get(_getPrototypeOf$1(LogarithmicScale.prototype), \"configure\", this).call(this);\n this._startValue = log10(start);\n this._valueRange = log10(this.max) - log10(start);\n }\n }, {\n key: \"getPixelForValue\",\n value: function getPixelForValue(value) {\n if (value === undefined || value === 0) {\n value = this.min;\n }\n if (value === null || isNaN(value)) {\n return NaN;\n }\n return this.getPixelForDecimal(value === this.min ? 0 : (log10(value) - this._startValue) / this._valueRange);\n }\n }, {\n key: \"getValueForPixel\",\n value: function getValueForPixel(pixel) {\n var decimal = this.getDecimalForPixel(pixel);\n return Math.pow(10, this._startValue + decimal * this._valueRange);\n }\n }]);\n return LogarithmicScale;\n }(Scale);\n _defineProperty$1(LogarithmicScale, \"id\", 'logarithmic');\n _defineProperty$1(LogarithmicScale, \"defaults\", {\n ticks: {\n callback: Ticks.formatters.logarithmic,\n major: {\n enabled: true\n }\n }\n });\n function getTickBackdropHeight(opts) {\n var tickOpts = opts.ticks;\n if (tickOpts.display && opts.display) {\n var padding = toPadding(tickOpts.backdropPadding);\n return valueOrDefault(tickOpts.font && tickOpts.font.size, defaults.font.size) + padding.height;\n }\n return 0;\n }\n function measureLabelSize(ctx, font, label) {\n label = isArray(label) ? label : [label];\n return {\n w: _longestText(ctx, font.string, label),\n h: label.length * font.lineHeight\n };\n }\n function determineLimits(angle, pos, size, min, max) {\n if (angle === min || angle === max) {\n return {\n start: pos - size / 2,\n end: pos + size / 2\n };\n } else if (angle < min || angle > max) {\n return {\n start: pos - size,\n end: pos\n };\n }\n return {\n start: pos,\n end: pos + size\n };\n }\n function fitWithPointLabels(scale) {\n var orig = {\n l: scale.left + scale._padding.left,\n r: scale.right - scale._padding.right,\n t: scale.top + scale._padding.top,\n b: scale.bottom - scale._padding.bottom\n };\n var limits = Object.assign({}, orig);\n var labelSizes = [];\n var padding = [];\n var valueCount = scale._pointLabels.length;\n var pointLabelOpts = scale.options.pointLabels;\n var additionalAngle = pointLabelOpts.centerPointLabels ? PI / valueCount : 0;\n for (var i = 0; i < valueCount; i++) {\n var opts = pointLabelOpts.setContext(scale.getPointLabelContext(i));\n padding[i] = opts.padding;\n var pointPosition = scale.getPointPosition(i, scale.drawingArea + padding[i], additionalAngle);\n var plFont = toFont(opts.font);\n var textSize = measureLabelSize(scale.ctx, plFont, scale._pointLabels[i]);\n labelSizes[i] = textSize;\n var angleRadians = _normalizeAngle(scale.getIndexAngle(i) + additionalAngle);\n var angle = Math.round(toDegrees(angleRadians));\n var hLimits = determineLimits(angle, pointPosition.x, textSize.w, 0, 180);\n var vLimits = determineLimits(angle, pointPosition.y, textSize.h, 90, 270);\n updateLimits(limits, orig, angleRadians, hLimits, vLimits);\n }\n scale.setCenterPoint(orig.l - limits.l, limits.r - orig.r, orig.t - limits.t, limits.b - orig.b);\n scale._pointLabelItems = buildPointLabelItems(scale, labelSizes, padding);\n }\n function updateLimits(limits, orig, angle, hLimits, vLimits) {\n var sin = Math.abs(Math.sin(angle));\n var cos = Math.abs(Math.cos(angle));\n var x = 0;\n var y = 0;\n if (hLimits.start < orig.l) {\n x = (orig.l - hLimits.start) / sin;\n limits.l = Math.min(limits.l, orig.l - x);\n } else if (hLimits.end > orig.r) {\n x = (hLimits.end - orig.r) / sin;\n limits.r = Math.max(limits.r, orig.r + x);\n }\n if (vLimits.start < orig.t) {\n y = (orig.t - vLimits.start) / cos;\n limits.t = Math.min(limits.t, orig.t - y);\n } else if (vLimits.end > orig.b) {\n y = (vLimits.end - orig.b) / cos;\n limits.b = Math.max(limits.b, orig.b + y);\n }\n }\n function createPointLabelItem(scale, index, itemOpts) {\n var outerDistance = scale.drawingArea;\n var extra = itemOpts.extra,\n additionalAngle = itemOpts.additionalAngle,\n padding = itemOpts.padding,\n size = itemOpts.size;\n var pointLabelPosition = scale.getPointPosition(index, outerDistance + extra + padding, additionalAngle);\n var angle = Math.round(toDegrees(_normalizeAngle(pointLabelPosition.angle + HALF_PI)));\n var y = yForAngle(pointLabelPosition.y, size.h, angle);\n var textAlign = getTextAlignForAngle(angle);\n var left = leftForTextAlign(pointLabelPosition.x, size.w, textAlign);\n return {\n visible: true,\n x: pointLabelPosition.x,\n y: y,\n textAlign: textAlign,\n left: left,\n top: y,\n right: left + size.w,\n bottom: y + size.h\n };\n }\n function isNotOverlapped(item, area) {\n if (!area) {\n return true;\n }\n var left = item.left,\n top = item.top,\n right = item.right,\n bottom = item.bottom;\n var apexesInArea = _isPointInArea({\n x: left,\n y: top\n }, area) || _isPointInArea({\n x: left,\n y: bottom\n }, area) || _isPointInArea({\n x: right,\n y: top\n }, area) || _isPointInArea({\n x: right,\n y: bottom\n }, area);\n return !apexesInArea;\n }\n function buildPointLabelItems(scale, labelSizes, padding) {\n var items = [];\n var valueCount = scale._pointLabels.length;\n var opts = scale.options;\n var _opts$pointLabels = opts.pointLabels,\n centerPointLabels = _opts$pointLabels.centerPointLabels,\n display = _opts$pointLabels.display;\n var itemOpts = {\n extra: getTickBackdropHeight(opts) / 2,\n additionalAngle: centerPointLabels ? PI / valueCount : 0\n };\n var area;\n for (var i = 0; i < valueCount; i++) {\n itemOpts.padding = padding[i];\n itemOpts.size = labelSizes[i];\n var item = createPointLabelItem(scale, i, itemOpts);\n items.push(item);\n if (display === 'auto') {\n item.visible = isNotOverlapped(item, area);\n if (item.visible) {\n area = item;\n }\n }\n }\n return items;\n }\n function getTextAlignForAngle(angle) {\n if (angle === 0 || angle === 180) {\n return 'center';\n } else if (angle < 180) {\n return 'left';\n }\n return 'right';\n }\n function leftForTextAlign(x, w, align) {\n if (align === 'right') {\n x -= w;\n } else if (align === 'center') {\n x -= w / 2;\n }\n return x;\n }\n function yForAngle(y, h, angle) {\n if (angle === 90 || angle === 270) {\n y -= h / 2;\n } else if (angle > 270 || angle < 90) {\n y -= h;\n }\n return y;\n }\n function drawPointLabelBox(ctx, opts, item) {\n var left = item.left,\n top = item.top,\n right = item.right,\n bottom = item.bottom;\n var backdropColor = opts.backdropColor;\n if (!isNullOrUndef(backdropColor)) {\n var borderRadius = toTRBLCorners(opts.borderRadius);\n var padding = toPadding(opts.backdropPadding);\n ctx.fillStyle = backdropColor;\n var backdropLeft = left - padding.left;\n var backdropTop = top - padding.top;\n var backdropWidth = right - left + padding.width;\n var backdropHeight = bottom - top + padding.height;\n if (Object.values(borderRadius).some(function (v) {\n return v !== 0;\n })) {\n ctx.beginPath();\n addRoundedRectPath(ctx, {\n x: backdropLeft,\n y: backdropTop,\n w: backdropWidth,\n h: backdropHeight,\n radius: borderRadius\n });\n ctx.fill();\n } else {\n ctx.fillRect(backdropLeft, backdropTop, backdropWidth, backdropHeight);\n }\n }\n }\n function drawPointLabels(scale, labelCount) {\n var ctx = scale.ctx,\n pointLabels = scale.options.pointLabels;\n for (var i = labelCount - 1; i >= 0; i--) {\n var item = scale._pointLabelItems[i];\n if (!item.visible) {\n continue;\n }\n var optsAtIndex = pointLabels.setContext(scale.getPointLabelContext(i));\n drawPointLabelBox(ctx, optsAtIndex, item);\n var plFont = toFont(optsAtIndex.font);\n var x = item.x,\n y = item.y,\n textAlign = item.textAlign;\n renderText(ctx, scale._pointLabels[i], x, y + plFont.lineHeight / 2, plFont, {\n color: optsAtIndex.color,\n textAlign: textAlign,\n textBaseline: 'middle'\n });\n }\n }\n function pathRadiusLine(scale, radius, circular, labelCount) {\n var ctx = scale.ctx;\n if (circular) {\n ctx.arc(scale.xCenter, scale.yCenter, radius, 0, TAU);\n } else {\n var pointPosition = scale.getPointPosition(0, radius);\n ctx.moveTo(pointPosition.x, pointPosition.y);\n for (var i = 1; i < labelCount; i++) {\n pointPosition = scale.getPointPosition(i, radius);\n ctx.lineTo(pointPosition.x, pointPosition.y);\n }\n }\n }\n function drawRadiusLine(scale, gridLineOpts, radius, labelCount, borderOpts) {\n var ctx = scale.ctx;\n var circular = gridLineOpts.circular;\n var color = gridLineOpts.color,\n lineWidth = gridLineOpts.lineWidth;\n if (!circular && !labelCount || !color || !lineWidth || radius < 0) {\n return;\n }\n ctx.save();\n ctx.strokeStyle = color;\n ctx.lineWidth = lineWidth;\n ctx.setLineDash(borderOpts.dash);\n ctx.lineDashOffset = borderOpts.dashOffset;\n ctx.beginPath();\n pathRadiusLine(scale, radius, circular, labelCount);\n ctx.closePath();\n ctx.stroke();\n ctx.restore();\n }\n function createPointLabelContext(parent, index, label) {\n return createContext(parent, {\n label: label,\n index: index,\n type: 'pointLabel'\n });\n }\n var RadialLinearScale = /*#__PURE__*/function (_LinearScaleBase2) {\n _inherits$1(RadialLinearScale, _LinearScaleBase2);\n var _super23 = _createSuper$1(RadialLinearScale);\n function RadialLinearScale(cfg) {\n var _this38;\n _classCallCheck$1(this, RadialLinearScale);\n _this38 = _super23.call(this, cfg);\n _this38.xCenter = undefined;\n _this38.yCenter = undefined;\n _this38.drawingArea = undefined;\n _this38._pointLabels = [];\n _this38._pointLabelItems = [];\n return _this38;\n }\n _createClass$1(RadialLinearScale, [{\n key: \"setDimensions\",\n value: function setDimensions() {\n var padding = this._padding = toPadding(getTickBackdropHeight(this.options) / 2);\n var w = this.width = this.maxWidth - padding.width;\n var h = this.height = this.maxHeight - padding.height;\n this.xCenter = Math.floor(this.left + w / 2 + padding.left);\n this.yCenter = Math.floor(this.top + h / 2 + padding.top);\n this.drawingArea = Math.floor(Math.min(w, h) / 2);\n }\n }, {\n key: \"determineDataLimits\",\n value: function determineDataLimits() {\n var _this$getMinMax4 = this.getMinMax(false),\n min = _this$getMinMax4.min,\n max = _this$getMinMax4.max;\n this.min = isNumberFinite(min) && !isNaN(min) ? min : 0;\n this.max = isNumberFinite(max) && !isNaN(max) ? max : 0;\n this.handleTickRangeOptions();\n }\n }, {\n key: \"computeTickLimit\",\n value: function computeTickLimit() {\n return Math.ceil(this.drawingArea / getTickBackdropHeight(this.options));\n }\n }, {\n key: \"generateTickLabels\",\n value: function generateTickLabels(ticks) {\n var _this39 = this;\n LinearScaleBase.prototype.generateTickLabels.call(this, ticks);\n this._pointLabels = this.getLabels().map(function (value, index) {\n var label = callback(_this39.options.pointLabels.callback, [value, index], _this39);\n return label || label === 0 ? label : '';\n }).filter(function (v, i) {\n return _this39.chart.getDataVisibility(i);\n });\n }\n }, {\n key: \"fit\",\n value: function fit() {\n var opts = this.options;\n if (opts.display && opts.pointLabels.display) {\n fitWithPointLabels(this);\n } else {\n this.setCenterPoint(0, 0, 0, 0);\n }\n }\n }, {\n key: \"setCenterPoint\",\n value: function setCenterPoint(leftMovement, rightMovement, topMovement, bottomMovement) {\n this.xCenter += Math.floor((leftMovement - rightMovement) / 2);\n this.yCenter += Math.floor((topMovement - bottomMovement) / 2);\n this.drawingArea -= Math.min(this.drawingArea / 2, Math.max(leftMovement, rightMovement, topMovement, bottomMovement));\n }\n }, {\n key: \"getIndexAngle\",\n value: function getIndexAngle(index) {\n var angleMultiplier = TAU / (this._pointLabels.length || 1);\n var startAngle = this.options.startAngle || 0;\n return _normalizeAngle(index * angleMultiplier + toRadians(startAngle));\n }\n }, {\n key: \"getDistanceFromCenterForValue\",\n value: function getDistanceFromCenterForValue(value) {\n if (isNullOrUndef(value)) {\n return NaN;\n }\n var scalingFactor = this.drawingArea / (this.max - this.min);\n if (this.options.reverse) {\n return (this.max - value) * scalingFactor;\n }\n return (value - this.min) * scalingFactor;\n }\n }, {\n key: \"getValueForDistanceFromCenter\",\n value: function getValueForDistanceFromCenter(distance) {\n if (isNullOrUndef(distance)) {\n return NaN;\n }\n var scaledDistance = distance / (this.drawingArea / (this.max - this.min));\n return this.options.reverse ? this.max - scaledDistance : this.min + scaledDistance;\n }\n }, {\n key: \"getPointLabelContext\",\n value: function getPointLabelContext(index) {\n var pointLabels = this._pointLabels || [];\n if (index >= 0 && index < pointLabels.length) {\n var pointLabel = pointLabels[index];\n return createPointLabelContext(this.getContext(), index, pointLabel);\n }\n }\n }, {\n key: \"getPointPosition\",\n value: function getPointPosition(index, distanceFromCenter) {\n var additionalAngle = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;\n var angle = this.getIndexAngle(index) - HALF_PI + additionalAngle;\n return {\n x: Math.cos(angle) * distanceFromCenter + this.xCenter,\n y: Math.sin(angle) * distanceFromCenter + this.yCenter,\n angle: angle\n };\n }\n }, {\n key: \"getPointPositionForValue\",\n value: function getPointPositionForValue(index, value) {\n return this.getPointPosition(index, this.getDistanceFromCenterForValue(value));\n }\n }, {\n key: \"getBasePosition\",\n value: function getBasePosition(index) {\n return this.getPointPositionForValue(index || 0, this.getBaseValue());\n }\n }, {\n key: \"getPointLabelPosition\",\n value: function getPointLabelPosition(index) {\n var _this$_pointLabelItem = this._pointLabelItems[index],\n left = _this$_pointLabelItem.left,\n top = _this$_pointLabelItem.top,\n right = _this$_pointLabelItem.right,\n bottom = _this$_pointLabelItem.bottom;\n return {\n left: left,\n top: top,\n right: right,\n bottom: bottom\n };\n }\n }, {\n key: \"drawBackground\",\n value: function drawBackground() {\n var _this$options16 = this.options,\n backgroundColor = _this$options16.backgroundColor,\n circular = _this$options16.grid.circular;\n if (backgroundColor) {\n var ctx = this.ctx;\n ctx.save();\n ctx.beginPath();\n pathRadiusLine(this, this.getDistanceFromCenterForValue(this._endValue), circular, this._pointLabels.length);\n ctx.closePath();\n ctx.fillStyle = backgroundColor;\n ctx.fill();\n ctx.restore();\n }\n }\n }, {\n key: \"drawGrid\",\n value: function drawGrid() {\n var _this40 = this;\n var ctx = this.ctx;\n var opts = this.options;\n var angleLines = opts.angleLines,\n grid = opts.grid,\n border = opts.border;\n var labelCount = this._pointLabels.length;\n var i, offset, position;\n if (opts.pointLabels.display) {\n drawPointLabels(this, labelCount);\n }\n if (grid.display) {\n this.ticks.forEach(function (tick, index) {\n if (index !== 0) {\n offset = _this40.getDistanceFromCenterForValue(tick.value);\n var context = _this40.getContext(index);\n var optsAtIndex = grid.setContext(context);\n var optsAtIndexBorder = border.setContext(context);\n drawRadiusLine(_this40, optsAtIndex, offset, labelCount, optsAtIndexBorder);\n }\n });\n }\n if (angleLines.display) {\n ctx.save();\n for (i = labelCount - 1; i >= 0; i--) {\n var optsAtIndex = angleLines.setContext(this.getPointLabelContext(i));\n var color = optsAtIndex.color,\n lineWidth = optsAtIndex.lineWidth;\n if (!lineWidth || !color) {\n continue;\n }\n ctx.lineWidth = lineWidth;\n ctx.strokeStyle = color;\n ctx.setLineDash(optsAtIndex.borderDash);\n ctx.lineDashOffset = optsAtIndex.borderDashOffset;\n offset = this.getDistanceFromCenterForValue(opts.ticks.reverse ? this.min : this.max);\n position = this.getPointPosition(i, offset);\n ctx.beginPath();\n ctx.moveTo(this.xCenter, this.yCenter);\n ctx.lineTo(position.x, position.y);\n ctx.stroke();\n }\n ctx.restore();\n }\n }\n }, {\n key: \"drawBorder\",\n value: function drawBorder() {}\n }, {\n key: \"drawLabels\",\n value: function drawLabels() {\n var _this41 = this;\n var ctx = this.ctx;\n var opts = this.options;\n var tickOpts = opts.ticks;\n if (!tickOpts.display) {\n return;\n }\n var startAngle = this.getIndexAngle(0);\n var offset, width;\n ctx.save();\n ctx.translate(this.xCenter, this.yCenter);\n ctx.rotate(startAngle);\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n this.ticks.forEach(function (tick, index) {\n if (index === 0 && !opts.reverse) {\n return;\n }\n var optsAtIndex = tickOpts.setContext(_this41.getContext(index));\n var tickFont = toFont(optsAtIndex.font);\n offset = _this41.getDistanceFromCenterForValue(_this41.ticks[index].value);\n if (optsAtIndex.showLabelBackdrop) {\n ctx.font = tickFont.string;\n width = ctx.measureText(tick.label).width;\n ctx.fillStyle = optsAtIndex.backdropColor;\n var padding = toPadding(optsAtIndex.backdropPadding);\n ctx.fillRect(-width / 2 - padding.left, -offset - tickFont.size / 2 - padding.top, width + padding.width, tickFont.size + padding.height);\n }\n renderText(ctx, tick.label, 0, -offset, tickFont, {\n color: optsAtIndex.color,\n strokeColor: optsAtIndex.textStrokeColor,\n strokeWidth: optsAtIndex.textStrokeWidth\n });\n });\n ctx.restore();\n }\n }, {\n key: \"drawTitle\",\n value: function drawTitle() {}\n }]);\n return RadialLinearScale;\n }(LinearScaleBase);\n _defineProperty$1(RadialLinearScale, \"id\", 'radialLinear');\n _defineProperty$1(RadialLinearScale, \"defaults\", {\n display: true,\n animate: true,\n position: 'chartArea',\n angleLines: {\n display: true,\n lineWidth: 1,\n borderDash: [],\n borderDashOffset: 0.0\n },\n grid: {\n circular: false\n },\n startAngle: 0,\n ticks: {\n showLabelBackdrop: true,\n callback: Ticks.formatters.numeric\n },\n pointLabels: {\n backdropColor: undefined,\n backdropPadding: 2,\n display: true,\n font: {\n size: 10\n },\n callback: function callback(label) {\n return label;\n },\n padding: 5,\n centerPointLabels: false\n }\n });\n _defineProperty$1(RadialLinearScale, \"defaultRoutes\", {\n 'angleLines.color': 'borderColor',\n 'pointLabels.color': 'color',\n 'ticks.color': 'color'\n });\n _defineProperty$1(RadialLinearScale, \"descriptors\", {\n angleLines: {\n _fallback: 'grid'\n }\n });\n var INTERVALS = {\n millisecond: {\n common: true,\n size: 1,\n steps: 1000\n },\n second: {\n common: true,\n size: 1000,\n steps: 60\n },\n minute: {\n common: true,\n size: 60000,\n steps: 60\n },\n hour: {\n common: true,\n size: 3600000,\n steps: 24\n },\n day: {\n common: true,\n size: 86400000,\n steps: 30\n },\n week: {\n common: false,\n size: 604800000,\n steps: 4\n },\n month: {\n common: true,\n size: 2.628e9,\n steps: 12\n },\n quarter: {\n common: false,\n size: 7.884e9,\n steps: 4\n },\n year: {\n common: true,\n size: 3.154e10\n }\n };\n var UNITS = /* #__PURE__ */Object.keys(INTERVALS);\n function sorter(a, b) {\n return a - b;\n }\n function _parse(scale, input) {\n if (isNullOrUndef(input)) {\n return null;\n }\n var adapter = scale._adapter;\n var _scale$_parseOpts = scale._parseOpts,\n parser = _scale$_parseOpts.parser,\n round = _scale$_parseOpts.round,\n isoWeekday = _scale$_parseOpts.isoWeekday;\n var value = input;\n if (typeof parser === 'function') {\n value = parser(value);\n }\n if (!isNumberFinite(value)) {\n value = typeof parser === 'string' ? adapter.parse(value, parser) : adapter.parse(value);\n }\n if (value === null) {\n return null;\n }\n if (round) {\n value = round === 'week' && (isNumber(isoWeekday) || isoWeekday === true) ? adapter.startOf(value, 'isoWeek', isoWeekday) : adapter.startOf(value, round);\n }\n return +value;\n }\n function determineUnitForAutoTicks(minUnit, min, max, capacity) {\n var ilen = UNITS.length;\n for (var i = UNITS.indexOf(minUnit); i < ilen - 1; ++i) {\n var interval = INTERVALS[UNITS[i]];\n var factor = interval.steps ? interval.steps : Number.MAX_SAFE_INTEGER;\n if (interval.common && Math.ceil((max - min) / (factor * interval.size)) <= capacity) {\n return UNITS[i];\n }\n }\n return UNITS[ilen - 1];\n }\n function determineUnitForFormatting(scale, numTicks, minUnit, min, max) {\n for (var i = UNITS.length - 1; i >= UNITS.indexOf(minUnit); i--) {\n var unit = UNITS[i];\n if (INTERVALS[unit].common && scale._adapter.diff(max, min, unit) >= numTicks - 1) {\n return unit;\n }\n }\n return UNITS[minUnit ? UNITS.indexOf(minUnit) : 0];\n }\n function determineMajorUnit(unit) {\n for (var i = UNITS.indexOf(unit) + 1, ilen = UNITS.length; i < ilen; ++i) {\n if (INTERVALS[UNITS[i]].common) {\n return UNITS[i];\n }\n }\n }\n function addTick(ticks, time, timestamps) {\n if (!timestamps) {\n ticks[time] = true;\n } else if (timestamps.length) {\n var _lookup2 = _lookup(timestamps, time),\n lo = _lookup2.lo,\n hi = _lookup2.hi;\n var timestamp = timestamps[lo] >= time ? timestamps[lo] : timestamps[hi];\n ticks[timestamp] = true;\n }\n }\n function setMajorTicks(scale, ticks, map, majorUnit) {\n var adapter = scale._adapter;\n var first = +adapter.startOf(ticks[0].value, majorUnit);\n var last = ticks[ticks.length - 1].value;\n var major, index;\n for (major = first; major <= last; major = +adapter.add(major, 1, majorUnit)) {\n index = map[major];\n if (index >= 0) {\n ticks[index].major = true;\n }\n }\n return ticks;\n }\n function ticksFromTimestamps(scale, values, majorUnit) {\n var ticks = [];\n var map = {};\n var ilen = values.length;\n var i, value;\n for (i = 0; i < ilen; ++i) {\n value = values[i];\n map[value] = i;\n ticks.push({\n value: value,\n major: false\n });\n }\n return ilen === 0 || !majorUnit ? ticks : setMajorTicks(scale, ticks, map, majorUnit);\n }\n var TimeScale = /*#__PURE__*/function (_Scale4) {\n _inherits$1(TimeScale, _Scale4);\n var _super24 = _createSuper$1(TimeScale);\n function TimeScale(props) {\n var _this42;\n _classCallCheck$1(this, TimeScale);\n _this42 = _super24.call(this, props);\n _this42._cache = {\n data: [],\n labels: [],\n all: []\n };\n _this42._unit = 'day';\n _this42._majorUnit = undefined;\n _this42._offsets = {};\n _this42._normalized = false;\n _this42._parseOpts = undefined;\n return _this42;\n }\n _createClass$1(TimeScale, [{\n key: \"init\",\n value: function init(scaleOpts) {\n var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var time = scaleOpts.time || (scaleOpts.time = {});\n var adapter = this._adapter = new adapters._date(scaleOpts.adapters.date);\n adapter.init(opts);\n mergeIf(time.displayFormats, adapter.formats());\n this._parseOpts = {\n parser: time.parser,\n round: time.round,\n isoWeekday: time.isoWeekday\n };\n _get(_getPrototypeOf$1(TimeScale.prototype), \"init\", this).call(this, scaleOpts);\n this._normalized = opts.normalized;\n }\n }, {\n key: \"parse\",\n value: function parse(raw, index) {\n if (raw === undefined) {\n return null;\n }\n return _parse(this, raw);\n }\n }, {\n key: \"beforeLayout\",\n value: function beforeLayout() {\n _get(_getPrototypeOf$1(TimeScale.prototype), \"beforeLayout\", this).call(this);\n this._cache = {\n data: [],\n labels: [],\n all: []\n };\n }\n }, {\n key: \"determineDataLimits\",\n value: function determineDataLimits() {\n var options = this.options;\n var adapter = this._adapter;\n var unit = options.time.unit || 'day';\n var _this$getUserBounds5 = this.getUserBounds(),\n min = _this$getUserBounds5.min,\n max = _this$getUserBounds5.max,\n minDefined = _this$getUserBounds5.minDefined,\n maxDefined = _this$getUserBounds5.maxDefined;\n function _applyBounds(bounds) {\n if (!minDefined && !isNaN(bounds.min)) {\n min = Math.min(min, bounds.min);\n }\n if (!maxDefined && !isNaN(bounds.max)) {\n max = Math.max(max, bounds.max);\n }\n }\n if (!minDefined || !maxDefined) {\n _applyBounds(this._getLabelBounds());\n if (options.bounds !== 'ticks' || options.ticks.source !== 'labels') {\n _applyBounds(this.getMinMax(false));\n }\n }\n min = isNumberFinite(min) && !isNaN(min) ? min : +adapter.startOf(Date.now(), unit);\n max = isNumberFinite(max) && !isNaN(max) ? max : +adapter.endOf(Date.now(), unit) + 1;\n this.min = Math.min(min, max - 1);\n this.max = Math.max(min + 1, max);\n }\n }, {\n key: \"_getLabelBounds\",\n value: function _getLabelBounds() {\n var arr = this.getLabelTimestamps();\n var min = Number.POSITIVE_INFINITY;\n var max = Number.NEGATIVE_INFINITY;\n if (arr.length) {\n min = arr[0];\n max = arr[arr.length - 1];\n }\n return {\n min: min,\n max: max\n };\n }\n }, {\n key: \"buildTicks\",\n value: function buildTicks() {\n var options = this.options;\n var timeOpts = options.time;\n var tickOpts = options.ticks;\n var timestamps = tickOpts.source === 'labels' ? this.getLabelTimestamps() : this._generate();\n if (options.bounds === 'ticks' && timestamps.length) {\n this.min = this._userMin || timestamps[0];\n this.max = this._userMax || timestamps[timestamps.length - 1];\n }\n var min = this.min;\n var max = this.max;\n var ticks = _filterBetween(timestamps, min, max);\n this._unit = timeOpts.unit || (tickOpts.autoSkip ? determineUnitForAutoTicks(timeOpts.minUnit, this.min, this.max, this._getLabelCapacity(min)) : determineUnitForFormatting(this, ticks.length, timeOpts.minUnit, this.min, this.max));\n this._majorUnit = !tickOpts.major.enabled || this._unit === 'year' ? undefined : determineMajorUnit(this._unit);\n this.initOffsets(timestamps);\n if (options.reverse) {\n ticks.reverse();\n }\n return ticksFromTimestamps(this, ticks, this._majorUnit);\n }\n }, {\n key: \"afterAutoSkip\",\n value: function afterAutoSkip() {\n if (this.options.offsetAfterAutoskip) {\n this.initOffsets(this.ticks.map(function (tick) {\n return +tick.value;\n }));\n }\n }\n }, {\n key: \"initOffsets\",\n value: function initOffsets() {\n var timestamps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var start = 0;\n var end = 0;\n var first, last;\n if (this.options.offset && timestamps.length) {\n first = this.getDecimalForValue(timestamps[0]);\n if (timestamps.length === 1) {\n start = 1 - first;\n } else {\n start = (this.getDecimalForValue(timestamps[1]) - first) / 2;\n }\n last = this.getDecimalForValue(timestamps[timestamps.length - 1]);\n if (timestamps.length === 1) {\n end = last;\n } else {\n end = (last - this.getDecimalForValue(timestamps[timestamps.length - 2])) / 2;\n }\n }\n var limit = timestamps.length < 3 ? 0.5 : 0.25;\n start = _limitValue(start, 0, limit);\n end = _limitValue(end, 0, limit);\n this._offsets = {\n start: start,\n end: end,\n factor: 1 / (start + 1 + end)\n };\n }\n }, {\n key: \"_generate\",\n value: function _generate() {\n var adapter = this._adapter;\n var min = this.min;\n var max = this.max;\n var options = this.options;\n var timeOpts = options.time;\n var minor = timeOpts.unit || determineUnitForAutoTicks(timeOpts.minUnit, min, max, this._getLabelCapacity(min));\n var stepSize = valueOrDefault(options.ticks.stepSize, 1);\n var weekday = minor === 'week' ? timeOpts.isoWeekday : false;\n var hasWeekday = isNumber(weekday) || weekday === true;\n var ticks = {};\n var first = min;\n var time, count;\n if (hasWeekday) {\n first = +adapter.startOf(first, 'isoWeek', weekday);\n }\n first = +adapter.startOf(first, hasWeekday ? 'day' : minor);\n if (adapter.diff(max, min, minor) > 100000 * stepSize) {\n throw new Error(min + ' and ' + max + ' are too far apart with stepSize of ' + stepSize + ' ' + minor);\n }\n var timestamps = options.ticks.source === 'data' && this.getDataTimestamps();\n for (time = first, count = 0; time < max; time = +adapter.add(time, stepSize, minor), count++) {\n addTick(ticks, time, timestamps);\n }\n if (time === max || options.bounds === 'ticks' || count === 1) {\n addTick(ticks, time, timestamps);\n }\n return Object.keys(ticks).sort(sorter).map(function (x) {\n return +x;\n });\n }\n }, {\n key: \"getLabelForValue\",\n value: function getLabelForValue(value) {\n var adapter = this._adapter;\n var timeOpts = this.options.time;\n if (timeOpts.tooltipFormat) {\n return adapter.format(value, timeOpts.tooltipFormat);\n }\n return adapter.format(value, timeOpts.displayFormats.datetime);\n }\n }, {\n key: \"format\",\n value: function format(value, _format) {\n var options = this.options;\n var formats = options.time.displayFormats;\n var unit = this._unit;\n var fmt = _format || formats[unit];\n return this._adapter.format(value, fmt);\n }\n }, {\n key: \"_tickFormatFunction\",\n value: function _tickFormatFunction(time, index, ticks, format) {\n var options = this.options;\n var formatter = options.ticks.callback;\n if (formatter) {\n return callback(formatter, [time, index, ticks], this);\n }\n var formats = options.time.displayFormats;\n var unit = this._unit;\n var majorUnit = this._majorUnit;\n var minorFormat = unit && formats[unit];\n var majorFormat = majorUnit && formats[majorUnit];\n var tick = ticks[index];\n var major = majorUnit && majorFormat && tick && tick.major;\n return this._adapter.format(time, format || (major ? majorFormat : minorFormat));\n }\n }, {\n key: \"generateTickLabels\",\n value: function generateTickLabels(ticks) {\n var i, ilen, tick;\n for (i = 0, ilen = ticks.length; i < ilen; ++i) {\n tick = ticks[i];\n tick.label = this._tickFormatFunction(tick.value, i, ticks);\n }\n }\n }, {\n key: \"getDecimalForValue\",\n value: function getDecimalForValue(value) {\n return value === null ? NaN : (value - this.min) / (this.max - this.min);\n }\n }, {\n key: \"getPixelForValue\",\n value: function getPixelForValue(value) {\n var offsets = this._offsets;\n var pos = this.getDecimalForValue(value);\n return this.getPixelForDecimal((offsets.start + pos) * offsets.factor);\n }\n }, {\n key: \"getValueForPixel\",\n value: function getValueForPixel(pixel) {\n var offsets = this._offsets;\n var pos = this.getDecimalForPixel(pixel) / offsets.factor - offsets.end;\n return this.min + pos * (this.max - this.min);\n }\n }, {\n key: \"_getLabelSize\",\n value: function _getLabelSize(label) {\n var ticksOpts = this.options.ticks;\n var tickLabelWidth = this.ctx.measureText(label).width;\n var angle = toRadians(this.isHorizontal() ? ticksOpts.maxRotation : ticksOpts.minRotation);\n var cosRotation = Math.cos(angle);\n var sinRotation = Math.sin(angle);\n var tickFontSize = this._resolveTickFontOptions(0).size;\n return {\n w: tickLabelWidth * cosRotation + tickFontSize * sinRotation,\n h: tickLabelWidth * sinRotation + tickFontSize * cosRotation\n };\n }\n }, {\n key: \"_getLabelCapacity\",\n value: function _getLabelCapacity(exampleTime) {\n var timeOpts = this.options.time;\n var displayFormats = timeOpts.displayFormats;\n var format = displayFormats[timeOpts.unit] || displayFormats.millisecond;\n var exampleLabel = this._tickFormatFunction(exampleTime, 0, ticksFromTimestamps(this, [exampleTime], this._majorUnit), format);\n var size = this._getLabelSize(exampleLabel);\n var capacity = Math.floor(this.isHorizontal() ? this.width / size.w : this.height / size.h) - 1;\n return capacity > 0 ? capacity : 1;\n }\n }, {\n key: \"getDataTimestamps\",\n value: function getDataTimestamps() {\n var timestamps = this._cache.data || [];\n var i, ilen;\n if (timestamps.length) {\n return timestamps;\n }\n var metas = this.getMatchingVisibleMetas();\n if (this._normalized && metas.length) {\n return this._cache.data = metas[0].controller.getAllParsedValues(this);\n }\n for (i = 0, ilen = metas.length; i < ilen; ++i) {\n timestamps = timestamps.concat(metas[i].controller.getAllParsedValues(this));\n }\n return this._cache.data = this.normalize(timestamps);\n }\n }, {\n key: \"getLabelTimestamps\",\n value: function getLabelTimestamps() {\n var timestamps = this._cache.labels || [];\n var i, ilen;\n if (timestamps.length) {\n return timestamps;\n }\n var labels = this.getLabels();\n for (i = 0, ilen = labels.length; i < ilen; ++i) {\n timestamps.push(_parse(this, labels[i]));\n }\n return this._cache.labels = this._normalized ? timestamps : this.normalize(timestamps);\n }\n }, {\n key: \"normalize\",\n value: function normalize(values) {\n return _arrayUnique(values.sort(sorter));\n }\n }]);\n return TimeScale;\n }(Scale);\n _defineProperty$1(TimeScale, \"id\", 'time');\n _defineProperty$1(TimeScale, \"defaults\", {\n bounds: 'data',\n adapters: {},\n time: {\n parser: false,\n unit: false,\n round: false,\n isoWeekday: false,\n minUnit: 'millisecond',\n displayFormats: {}\n },\n ticks: {\n source: 'auto',\n callback: false,\n major: {\n enabled: false\n }\n }\n });\n function interpolate(table, val, reverse) {\n var lo = 0;\n var hi = table.length - 1;\n var prevSource, nextSource, prevTarget, nextTarget;\n if (reverse) {\n if (val >= table[lo].pos && val <= table[hi].pos) {\n var _lookupByKey2 = _lookupByKey(table, 'pos', val);\n lo = _lookupByKey2.lo;\n hi = _lookupByKey2.hi;\n }\n var _table$lo = table[lo];\n prevSource = _table$lo.pos;\n prevTarget = _table$lo.time;\n var _table$hi = table[hi];\n nextSource = _table$hi.pos;\n nextTarget = _table$hi.time;\n } else {\n if (val >= table[lo].time && val <= table[hi].time) {\n var _lookupByKey3 = _lookupByKey(table, 'time', val);\n lo = _lookupByKey3.lo;\n hi = _lookupByKey3.hi;\n }\n var _table$lo2 = table[lo];\n prevSource = _table$lo2.time;\n prevTarget = _table$lo2.pos;\n var _table$hi2 = table[hi];\n nextSource = _table$hi2.time;\n nextTarget = _table$hi2.pos;\n }\n var span = nextSource - prevSource;\n return span ? prevTarget + (nextTarget - prevTarget) * (val - prevSource) / span : prevTarget;\n }\n var TimeSeriesScale = /*#__PURE__*/function (_TimeScale) {\n _inherits$1(TimeSeriesScale, _TimeScale);\n var _super25 = _createSuper$1(TimeSeriesScale);\n function TimeSeriesScale(props) {\n var _this43;\n _classCallCheck$1(this, TimeSeriesScale);\n _this43 = _super25.call(this, props);\n _this43._table = [];\n _this43._minPos = undefined;\n _this43._tableRange = undefined;\n return _this43;\n }\n _createClass$1(TimeSeriesScale, [{\n key: \"initOffsets\",\n value: function initOffsets() {\n var timestamps = this._getTimestampsForTable();\n var table = this._table = this.buildLookupTable(timestamps);\n this._minPos = interpolate(table, this.min);\n this._tableRange = interpolate(table, this.max) - this._minPos;\n _get(_getPrototypeOf$1(TimeSeriesScale.prototype), \"initOffsets\", this).call(this, timestamps);\n }\n }, {\n key: \"buildLookupTable\",\n value: function buildLookupTable(timestamps) {\n var min = this.min,\n max = this.max;\n var items = [];\n var table = [];\n var i, ilen, prev, curr, next;\n for (i = 0, ilen = timestamps.length; i < ilen; ++i) {\n curr = timestamps[i];\n if (curr >= min && curr <= max) {\n items.push(curr);\n }\n }\n if (items.length < 2) {\n return [{\n time: min,\n pos: 0\n }, {\n time: max,\n pos: 1\n }];\n }\n for (i = 0, ilen = items.length; i < ilen; ++i) {\n next = items[i + 1];\n prev = items[i - 1];\n curr = items[i];\n if (Math.round((next + prev) / 2) !== curr) {\n table.push({\n time: curr,\n pos: i / (ilen - 1)\n });\n }\n }\n return table;\n }\n }, {\n key: \"_generate\",\n value: function _generate() {\n var min = this.min;\n var max = this.max;\n var timestamps = _get(_getPrototypeOf$1(TimeSeriesScale.prototype), \"getDataTimestamps\", this).call(this);\n if (!timestamps.includes(min) || !timestamps.length) {\n timestamps.splice(0, 0, min);\n }\n if (!timestamps.includes(max) || timestamps.length === 1) {\n timestamps.push(max);\n }\n return timestamps.sort(function (a, b) {\n return a - b;\n });\n }\n }, {\n key: \"_getTimestampsForTable\",\n value: function _getTimestampsForTable() {\n var timestamps = this._cache.all || [];\n if (timestamps.length) {\n return timestamps;\n }\n var data = this.getDataTimestamps();\n var label = this.getLabelTimestamps();\n if (data.length && label.length) {\n timestamps = this.normalize(data.concat(label));\n } else {\n timestamps = data.length ? data : label;\n }\n timestamps = this._cache.all = timestamps;\n return timestamps;\n }\n }, {\n key: \"getDecimalForValue\",\n value: function getDecimalForValue(value) {\n return (interpolate(this._table, value) - this._minPos) / this._tableRange;\n }\n }, {\n key: \"getValueForPixel\",\n value: function getValueForPixel(pixel) {\n var offsets = this._offsets;\n var decimal = this.getDecimalForPixel(pixel) / offsets.factor - offsets.end;\n return interpolate(this._table, decimal * this._tableRange + this._minPos, true);\n }\n }]);\n return TimeSeriesScale;\n }(TimeScale);\n _defineProperty$1(TimeSeriesScale, \"id\", 'timeseries');\n _defineProperty$1(TimeSeriesScale, \"defaults\", TimeScale.defaults);\n var scales = /*#__PURE__*/Object.freeze({\n __proto__: null,\n CategoryScale: CategoryScale,\n LinearScale: LinearScale,\n LogarithmicScale: LogarithmicScale,\n RadialLinearScale: RadialLinearScale,\n TimeScale: TimeScale,\n TimeSeriesScale: TimeSeriesScale\n });\n var registerables = [controllers, elements, plugins, scales];\n\n Chart.register.apply(Chart, _toConsumableArray(registerables));\n\n var helpers = /*#__PURE__*/Object.freeze({\n __proto__: null,\n HALF_PI: HALF_PI,\n INFINITY: INFINITY,\n PI: PI,\n PITAU: PITAU,\n QUARTER_PI: QUARTER_PI,\n RAD_PER_DEG: RAD_PER_DEG,\n TAU: TAU,\n TWO_THIRDS_PI: TWO_THIRDS_PI,\n _addGrace: _addGrace,\n _alignPixel: _alignPixel,\n _alignStartEnd: _alignStartEnd,\n _angleBetween: _angleBetween,\n _angleDiff: _angleDiff,\n _arrayUnique: _arrayUnique,\n _attachContext: _attachContext,\n _bezierCurveTo: _bezierCurveTo,\n _bezierInterpolation: _bezierInterpolation,\n _boundSegment: _boundSegment,\n _boundSegments: _boundSegments,\n _capitalize: _capitalize,\n _computeSegments: _computeSegments,\n _createResolver: _createResolver,\n _decimalPlaces: _decimalPlaces,\n _deprecated: _deprecated,\n _descriptors: _descriptors,\n _elementsEqual: _elementsEqual,\n _factorize: _factorize,\n _filterBetween: _filterBetween,\n _getParentNode: _getParentNode,\n _getStartAndCountOfVisiblePoints: _getStartAndCountOfVisiblePoints,\n _int16Range: _int16Range,\n _isBetween: _isBetween,\n _isClickEvent: _isClickEvent,\n _isDomSupported: _isDomSupported,\n _isPointInArea: _isPointInArea,\n _limitValue: _limitValue,\n _longestText: _longestText,\n _lookup: _lookup,\n _lookupByKey: _lookupByKey,\n _measureText: _measureText,\n _merger: _merger,\n _mergerIf: _mergerIf,\n _normalizeAngle: _normalizeAngle,\n _parseObjectDataRadialScale: _parseObjectDataRadialScale,\n _pointInLine: _pointInLine,\n _readValueToProps: _readValueToProps,\n _rlookupByKey: _rlookupByKey,\n _scaleRangesChanged: _scaleRangesChanged,\n _setMinAndMaxByKey: _setMinAndMaxByKey,\n _splitKey: _splitKey,\n _steppedInterpolation: _steppedInterpolation,\n _steppedLineTo: _steppedLineTo,\n _textX: _textX,\n _toLeftRightCenter: _toLeftRightCenter,\n _updateBezierControlPoints: _updateBezierControlPoints,\n addRoundedRectPath: addRoundedRectPath,\n almostEquals: almostEquals,\n almostWhole: almostWhole,\n callback: callback,\n clearCanvas: clearCanvas,\n clipArea: clipArea,\n clone: clone,\n color: color,\n createContext: createContext,\n debounce: debounce,\n defined: defined,\n distanceBetweenPoints: distanceBetweenPoints,\n drawPoint: drawPoint,\n drawPointLegend: drawPointLegend,\n each: each,\n easingEffects: effects,\n finiteOrDefault: finiteOrDefault,\n fontString: fontString,\n formatNumber: formatNumber,\n getAngleFromPoint: getAngleFromPoint,\n getHoverColor: getHoverColor,\n getMaximumSize: getMaximumSize,\n getRelativePosition: getRelativePosition,\n getRtlAdapter: getRtlAdapter,\n getStyle: getStyle,\n isArray: isArray,\n isFinite: isNumberFinite,\n isFunction: isFunction,\n isNullOrUndef: isNullOrUndef,\n isNumber: isNumber,\n isObject: isObject,\n isPatternOrGradient: isPatternOrGradient,\n listenArrayEvents: listenArrayEvents,\n log10: log10,\n merge: merge,\n mergeIf: mergeIf,\n niceNum: niceNum,\n noop: noop,\n overrideTextDirection: overrideTextDirection,\n readUsedSize: readUsedSize,\n renderText: renderText,\n requestAnimFrame: requestAnimFrame,\n resolve: resolve,\n resolveObjectKey: resolveObjectKey,\n restoreTextDirection: restoreTextDirection,\n retinaScale: retinaScale,\n setsEqual: setsEqual,\n sign: sign,\n splineCurve: splineCurve,\n splineCurveMonotone: splineCurveMonotone,\n supportsEventListenerOptions: supportsEventListenerOptions,\n throttled: throttled,\n toDegrees: toDegrees,\n toDimension: toDimension,\n toFont: toFont,\n toFontString: toFontString,\n toLineHeight: toLineHeight,\n toPadding: toPadding,\n toPercentage: toPercentage,\n toRadians: toRadians,\n toTRBL: toTRBL,\n toTRBLCorners: toTRBLCorners,\n uid: uid,\n unclipArea: unclipArea,\n unlistenArrayEvents: unlistenArrayEvents,\n valueOrDefault: valueOrDefault\n });\n\n function _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) {\n return typeof obj;\n } : function (obj) {\n return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n }, _typeof(obj);\n }\n\n function toInteger(dirtyNumber) {\n if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {\n return NaN;\n }\n var number = Number(dirtyNumber);\n if (isNaN(number)) {\n return number;\n }\n return number < 0 ? Math.ceil(number) : Math.floor(number);\n }\n\n function requiredArgs(required, args) {\n if (args.length < required) {\n throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');\n }\n }\n\n /**\n * @name toDate\n * @category Common Helpers\n * @summary Convert the given argument to an instance of Date.\n *\n * @description\n * Convert the given argument to an instance of Date.\n *\n * If the argument is an instance of Date, the function returns its clone.\n *\n * If the argument is a number, it is treated as a timestamp.\n *\n * If the argument is none of the above, the function returns Invalid Date.\n *\n * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.\n *\n * @param {Date|Number} argument - the value to convert\n * @returns {Date} the parsed date in the local time zone\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // Clone the date:\n * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))\n * //=> Tue Feb 11 2014 11:30:30\n *\n * @example\n * // Convert the timestamp to date:\n * const result = toDate(1392098430000)\n * //=> Tue Feb 11 2014 11:30:30\n */\n function toDate(argument) {\n requiredArgs(1, arguments);\n var argStr = Object.prototype.toString.call(argument);\n\n // Clone the date\n if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {\n // Prevent the date to lose the milliseconds when passed to new Date() in IE10\n return new Date(argument.getTime());\n } else if (typeof argument === 'number' || argStr === '[object Number]') {\n return new Date(argument);\n } else {\n if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {\n // eslint-disable-next-line no-console\n console.warn(\"Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments\");\n // eslint-disable-next-line no-console\n console.warn(new Error().stack);\n }\n return new Date(NaN);\n }\n }\n\n /**\n * @name addDays\n * @category Day Helpers\n * @summary Add the specified number of days to the given date.\n *\n * @description\n * Add the specified number of days to the given date.\n *\n * @param {Date|Number} date - the date to be changed\n * @param {Number} amount - the amount of days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n * @returns {Date} - the new date with the days added\n * @throws {TypeError} - 2 arguments required\n *\n * @example\n * // Add 10 days to 1 September 2014:\n * const result = addDays(new Date(2014, 8, 1), 10)\n * //=> Thu Sep 11 2014 00:00:00\n */\n function addDays(dirtyDate, dirtyAmount) {\n requiredArgs(2, arguments);\n var date = toDate(dirtyDate);\n var amount = toInteger(dirtyAmount);\n if (isNaN(amount)) {\n return new Date(NaN);\n }\n if (!amount) {\n // If 0 days, no-op to avoid changing times in the hour before end of DST\n return date;\n }\n date.setDate(date.getDate() + amount);\n return date;\n }\n\n /**\n * @name addMonths\n * @category Month Helpers\n * @summary Add the specified number of months to the given date.\n *\n * @description\n * Add the specified number of months to the given date.\n *\n * @param {Date|Number} date - the date to be changed\n * @param {Number} amount - the amount of months to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n * @returns {Date} the new date with the months added\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // Add 5 months to 1 September 2014:\n * const result = addMonths(new Date(2014, 8, 1), 5)\n * //=> Sun Feb 01 2015 00:00:00\n */\n function addMonths(dirtyDate, dirtyAmount) {\n requiredArgs(2, arguments);\n var date = toDate(dirtyDate);\n var amount = toInteger(dirtyAmount);\n if (isNaN(amount)) {\n return new Date(NaN);\n }\n if (!amount) {\n // If 0 months, no-op to avoid changing times in the hour before end of DST\n return date;\n }\n var dayOfMonth = date.getDate();\n\n // The JS Date object supports date math by accepting out-of-bounds values for\n // month, day, etc. For example, new Date(2020, 0, 0) returns 31 Dec 2019 and\n // new Date(2020, 13, 1) returns 1 Feb 2021. This is *almost* the behavior we\n // want except that dates will wrap around the end of a month, meaning that\n // new Date(2020, 13, 31) will return 3 Mar 2021 not 28 Feb 2021 as desired. So\n // we'll default to the end of the desired month by adding 1 to the desired\n // month and using a date of 0 to back up one day to the end of the desired\n // month.\n var endOfDesiredMonth = new Date(date.getTime());\n endOfDesiredMonth.setMonth(date.getMonth() + amount + 1, 0);\n var daysInMonth = endOfDesiredMonth.getDate();\n if (dayOfMonth >= daysInMonth) {\n // If we're already at the end of the month, then this is the correct date\n // and we're done.\n return endOfDesiredMonth;\n } else {\n // Otherwise, we now know that setting the original day-of-month value won't\n // cause an overflow, so set the desired day-of-month. Note that we can't\n // just set the date of `endOfDesiredMonth` because that object may have had\n // its time changed in the unusual case where where a DST transition was on\n // the last day of the month and its local time was in the hour skipped or\n // repeated next to a DST transition. So we use `date` instead which is\n // guaranteed to still have the original time.\n date.setFullYear(endOfDesiredMonth.getFullYear(), endOfDesiredMonth.getMonth(), dayOfMonth);\n return date;\n }\n }\n\n /**\n * @name addMilliseconds\n * @category Millisecond Helpers\n * @summary Add the specified number of milliseconds to the given date.\n *\n * @description\n * Add the specified number of milliseconds to the given date.\n *\n * @param {Date|Number} date - the date to be changed\n * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n * @returns {Date} the new date with the milliseconds added\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // Add 750 milliseconds to 10 July 2014 12:45:30.000:\n * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)\n * //=> Thu Jul 10 2014 12:45:30.750\n */\n function addMilliseconds(dirtyDate, dirtyAmount) {\n requiredArgs(2, arguments);\n var timestamp = toDate(dirtyDate).getTime();\n var amount = toInteger(dirtyAmount);\n return new Date(timestamp + amount);\n }\n\n var MILLISECONDS_IN_HOUR = 3600000;\n\n /**\n * @name addHours\n * @category Hour Helpers\n * @summary Add the specified number of hours to the given date.\n *\n * @description\n * Add the specified number of hours to the given date.\n *\n * @param {Date|Number} date - the date to be changed\n * @param {Number} amount - the amount of hours to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n * @returns {Date} the new date with the hours added\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // Add 2 hours to 10 July 2014 23:00:00:\n * const result = addHours(new Date(2014, 6, 10, 23, 0), 2)\n * //=> Fri Jul 11 2014 01:00:00\n */\n function addHours(dirtyDate, dirtyAmount) {\n requiredArgs(2, arguments);\n var amount = toInteger(dirtyAmount);\n return addMilliseconds(dirtyDate, amount * MILLISECONDS_IN_HOUR);\n }\n\n var defaultOptions = {};\n function getDefaultOptions() {\n return defaultOptions;\n }\n\n /**\n * @name startOfWeek\n * @category Week Helpers\n * @summary Return the start of a week for the given date.\n *\n * @description\n * Return the start of a week for the given date.\n * The result will be in the local timezone.\n *\n * @param {Date|Number} date - the original date\n * @param {Object} [options] - an object with options.\n * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}\n * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)\n * @returns {Date} the start of a week\n * @throws {TypeError} 1 argument required\n * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6\n *\n * @example\n * // The start of a week for 2 September 2014 11:55:00:\n * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0))\n * //=> Sun Aug 31 2014 00:00:00\n *\n * @example\n * // If the week starts on Monday, the start of the week for 2 September 2014 11:55:00:\n * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })\n * //=> Mon Sep 01 2014 00:00:00\n */\n function startOfWeek(dirtyDate, options) {\n var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;\n requiredArgs(1, arguments);\n var defaultOptions = getDefaultOptions();\n var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);\n\n // Test if weekStartsOn is between 0 and 6 _and_ is not NaN\n if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {\n throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');\n }\n var date = toDate(dirtyDate);\n var day = date.getDay();\n var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;\n date.setDate(date.getDate() - diff);\n date.setHours(0, 0, 0, 0);\n return date;\n }\n\n /**\n * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.\n * They usually appear for dates that denote time before the timezones were introduced\n * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891\n * and GMT+01:00:00 after that date)\n *\n * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,\n * which would lead to incorrect calculations.\n *\n * This function returns the timezone offset in milliseconds that takes seconds in account.\n */\n function getTimezoneOffsetInMilliseconds(date) {\n var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));\n utcDate.setUTCFullYear(date.getFullYear());\n return date.getTime() - utcDate.getTime();\n }\n\n /**\n * @name startOfDay\n * @category Day Helpers\n * @summary Return the start of a day for the given date.\n *\n * @description\n * Return the start of a day for the given date.\n * The result will be in the local timezone.\n *\n * @param {Date|Number} date - the original date\n * @returns {Date} the start of a day\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // The start of a day for 2 September 2014 11:55:00:\n * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))\n * //=> Tue Sep 02 2014 00:00:00\n */\n function startOfDay(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n date.setHours(0, 0, 0, 0);\n return date;\n }\n\n var MILLISECONDS_IN_DAY$1 = 86400000;\n\n /**\n * @name differenceInCalendarDays\n * @category Day Helpers\n * @summary Get the number of calendar days between the given dates.\n *\n * @description\n * Get the number of calendar days between the given dates. This means that the times are removed\n * from the dates and then the difference in days is calculated.\n *\n * @param {Date|Number} dateLeft - the later date\n * @param {Date|Number} dateRight - the earlier date\n * @returns {Number} the number of calendar days\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // How many calendar days are between\n * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?\n * const result = differenceInCalendarDays(\n * new Date(2012, 6, 2, 0, 0),\n * new Date(2011, 6, 2, 23, 0)\n * )\n * //=> 366\n * // How many calendar days are between\n * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?\n * const result = differenceInCalendarDays(\n * new Date(2011, 6, 3, 0, 1),\n * new Date(2011, 6, 2, 23, 59)\n * )\n * //=> 1\n */\n function differenceInCalendarDays(dirtyDateLeft, dirtyDateRight) {\n requiredArgs(2, arguments);\n var startOfDayLeft = startOfDay(dirtyDateLeft);\n var startOfDayRight = startOfDay(dirtyDateRight);\n var timestampLeft = startOfDayLeft.getTime() - getTimezoneOffsetInMilliseconds(startOfDayLeft);\n var timestampRight = startOfDayRight.getTime() - getTimezoneOffsetInMilliseconds(startOfDayRight);\n\n // Round the number of days to the nearest integer\n // because the number of milliseconds in a day is not constant\n // (e.g. it's different in the day of the daylight saving time clock shift)\n return Math.round((timestampLeft - timestampRight) / MILLISECONDS_IN_DAY$1);\n }\n\n var MILLISECONDS_IN_MINUTE = 60000;\n\n /**\n * @name addMinutes\n * @category Minute Helpers\n * @summary Add the specified number of minutes to the given date.\n *\n * @description\n * Add the specified number of minutes to the given date.\n *\n * @param {Date|Number} date - the date to be changed\n * @param {Number} amount - the amount of minutes to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n * @returns {Date} the new date with the minutes added\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // Add 30 minutes to 10 July 2014 12:00:00:\n * const result = addMinutes(new Date(2014, 6, 10, 12, 0), 30)\n * //=> Thu Jul 10 2014 12:30:00\n */\n function addMinutes(dirtyDate, dirtyAmount) {\n requiredArgs(2, arguments);\n var amount = toInteger(dirtyAmount);\n return addMilliseconds(dirtyDate, amount * MILLISECONDS_IN_MINUTE);\n }\n\n /**\n * @name addQuarters\n * @category Quarter Helpers\n * @summary Add the specified number of year quarters to the given date.\n *\n * @description\n * Add the specified number of year quarters to the given date.\n *\n * @param {Date|Number} date - the date to be changed\n * @param {Number} amount - the amount of quarters to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n * @returns {Date} the new date with the quarters added\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // Add 1 quarter to 1 September 2014:\n * const result = addQuarters(new Date(2014, 8, 1), 1)\n * //=> Mon Dec 01 2014 00:00:00\n */\n function addQuarters(dirtyDate, dirtyAmount) {\n requiredArgs(2, arguments);\n var amount = toInteger(dirtyAmount);\n var months = amount * 3;\n return addMonths(dirtyDate, months);\n }\n\n /**\n * @name addSeconds\n * @category Second Helpers\n * @summary Add the specified number of seconds to the given date.\n *\n * @description\n * Add the specified number of seconds to the given date.\n *\n * @param {Date|Number} date - the date to be changed\n * @param {Number} amount - the amount of seconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n * @returns {Date} the new date with the seconds added\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // Add 30 seconds to 10 July 2014 12:45:00:\n * const result = addSeconds(new Date(2014, 6, 10, 12, 45, 0), 30)\n * //=> Thu Jul 10 2014 12:45:30\n */\n function addSeconds(dirtyDate, dirtyAmount) {\n requiredArgs(2, arguments);\n var amount = toInteger(dirtyAmount);\n return addMilliseconds(dirtyDate, amount * 1000);\n }\n\n /**\n * @name addWeeks\n * @category Week Helpers\n * @summary Add the specified number of weeks to the given date.\n *\n * @description\n * Add the specified number of week to the given date.\n *\n * @param {Date|Number} date - the date to be changed\n * @param {Number} amount - the amount of weeks to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n * @returns {Date} the new date with the weeks added\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // Add 4 weeks to 1 September 2014:\n * const result = addWeeks(new Date(2014, 8, 1), 4)\n * //=> Mon Sep 29 2014 00:00:00\n */\n function addWeeks(dirtyDate, dirtyAmount) {\n requiredArgs(2, arguments);\n var amount = toInteger(dirtyAmount);\n var days = amount * 7;\n return addDays(dirtyDate, days);\n }\n\n /**\n * @name addYears\n * @category Year Helpers\n * @summary Add the specified number of years to the given date.\n *\n * @description\n * Add the specified number of years to the given date.\n *\n * @param {Date|Number} date - the date to be changed\n * @param {Number} amount - the amount of years to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n * @returns {Date} the new date with the years added\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // Add 5 years to 1 September 2014:\n * const result = addYears(new Date(2014, 8, 1), 5)\n * //=> Sun Sep 01 2019 00:00:00\n */\n function addYears(dirtyDate, dirtyAmount) {\n requiredArgs(2, arguments);\n var amount = toInteger(dirtyAmount);\n return addMonths(dirtyDate, amount * 12);\n }\n\n /**\n * @name compareAsc\n * @category Common Helpers\n * @summary Compare the two dates and return -1, 0 or 1.\n *\n * @description\n * Compare the two dates and return 1 if the first date is after the second,\n * -1 if the first date is before the second or 0 if dates are equal.\n *\n * @param {Date|Number} dateLeft - the first date to compare\n * @param {Date|Number} dateRight - the second date to compare\n * @returns {Number} the result of the comparison\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // Compare 11 February 1987 and 10 July 1989:\n * const result = compareAsc(new Date(1987, 1, 11), new Date(1989, 6, 10))\n * //=> -1\n *\n * @example\n * // Sort the array of dates:\n * const result = [\n * new Date(1995, 6, 2),\n * new Date(1987, 1, 11),\n * new Date(1989, 6, 10)\n * ].sort(compareAsc)\n * //=> [\n * // Wed Feb 11 1987 00:00:00,\n * // Mon Jul 10 1989 00:00:00,\n * // Sun Jul 02 1995 00:00:00\n * // ]\n */\n function compareAsc(dirtyDateLeft, dirtyDateRight) {\n requiredArgs(2, arguments);\n var dateLeft = toDate(dirtyDateLeft);\n var dateRight = toDate(dirtyDateRight);\n var diff = dateLeft.getTime() - dateRight.getTime();\n if (diff < 0) {\n return -1;\n } else if (diff > 0) {\n return 1;\n // Return 0 if diff is 0; return NaN if diff is NaN\n } else {\n return diff;\n }\n }\n\n /**\n * Days in 1 week.\n *\n * @name daysInWeek\n * @constant\n * @type {number}\n * @default\n */\n\n /**\n * Milliseconds in 1 minute\n *\n * @name millisecondsInMinute\n * @constant\n * @type {number}\n * @default\n */\n var millisecondsInMinute = 60000;\n\n /**\n * Milliseconds in 1 hour\n *\n * @name millisecondsInHour\n * @constant\n * @type {number}\n * @default\n */\n var millisecondsInHour = 3600000;\n\n /**\n * Milliseconds in 1 second\n *\n * @name millisecondsInSecond\n * @constant\n * @type {number}\n * @default\n */\n var millisecondsInSecond = 1000;\n\n /**\n * @name isDate\n * @category Common Helpers\n * @summary Is the given value a date?\n *\n * @description\n * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.\n *\n * @param {*} value - the value to check\n * @returns {boolean} true if the given value is a date\n * @throws {TypeError} 1 arguments required\n *\n * @example\n * // For a valid date:\n * const result = isDate(new Date())\n * //=> true\n *\n * @example\n * // For an invalid date:\n * const result = isDate(new Date(NaN))\n * //=> true\n *\n * @example\n * // For some value:\n * const result = isDate('2014-02-31')\n * //=> false\n *\n * @example\n * // For an object:\n * const result = isDate({})\n * //=> false\n */\n function isDate(value) {\n requiredArgs(1, arguments);\n return value instanceof Date || _typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';\n }\n\n /**\n * @name isValid\n * @category Common Helpers\n * @summary Is the given date valid?\n *\n * @description\n * Returns false if argument is Invalid Date and true otherwise.\n * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}\n * Invalid Date is a Date, whose time value is NaN.\n *\n * Time value of Date: http://es5.github.io/#x15.9.1.1\n *\n * @param {*} date - the date to check\n * @returns {Boolean} the date is valid\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // For the valid date:\n * const result = isValid(new Date(2014, 1, 31))\n * //=> true\n *\n * @example\n * // For the value, convertable into a date:\n * const result = isValid(1393804800000)\n * //=> true\n *\n * @example\n * // For the invalid date:\n * const result = isValid(new Date(''))\n * //=> false\n */\n function isValid(dirtyDate) {\n requiredArgs(1, arguments);\n if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {\n return false;\n }\n var date = toDate(dirtyDate);\n return !isNaN(Number(date));\n }\n\n /**\n * @name differenceInCalendarMonths\n * @category Month Helpers\n * @summary Get the number of calendar months between the given dates.\n *\n * @description\n * Get the number of calendar months between the given dates.\n *\n * @param {Date|Number} dateLeft - the later date\n * @param {Date|Number} dateRight - the earlier date\n * @returns {Number} the number of calendar months\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // How many calendar months are between 31 January 2014 and 1 September 2014?\n * const result = differenceInCalendarMonths(\n * new Date(2014, 8, 1),\n * new Date(2014, 0, 31)\n * )\n * //=> 8\n */\n function differenceInCalendarMonths(dirtyDateLeft, dirtyDateRight) {\n requiredArgs(2, arguments);\n var dateLeft = toDate(dirtyDateLeft);\n var dateRight = toDate(dirtyDateRight);\n var yearDiff = dateLeft.getFullYear() - dateRight.getFullYear();\n var monthDiff = dateLeft.getMonth() - dateRight.getMonth();\n return yearDiff * 12 + monthDiff;\n }\n\n /**\n * @name differenceInCalendarYears\n * @category Year Helpers\n * @summary Get the number of calendar years between the given dates.\n *\n * @description\n * Get the number of calendar years between the given dates.\n *\n * @param {Date|Number} dateLeft - the later date\n * @param {Date|Number} dateRight - the earlier date\n * @returns {Number} the number of calendar years\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // How many calendar years are between 31 December 2013 and 11 February 2015?\n * const result = differenceInCalendarYears(\n * new Date(2015, 1, 11),\n * new Date(2013, 11, 31)\n * )\n * //=> 2\n */\n function differenceInCalendarYears(dirtyDateLeft, dirtyDateRight) {\n requiredArgs(2, arguments);\n var dateLeft = toDate(dirtyDateLeft);\n var dateRight = toDate(dirtyDateRight);\n return dateLeft.getFullYear() - dateRight.getFullYear();\n }\n\n // for accurate equality comparisons of UTC timestamps that end up\n // having the same representation in local time, e.g. one hour before\n // DST ends vs. the instant that DST ends.\n function compareLocalAsc(dateLeft, dateRight) {\n var diff = dateLeft.getFullYear() - dateRight.getFullYear() || dateLeft.getMonth() - dateRight.getMonth() || dateLeft.getDate() - dateRight.getDate() || dateLeft.getHours() - dateRight.getHours() || dateLeft.getMinutes() - dateRight.getMinutes() || dateLeft.getSeconds() - dateRight.getSeconds() || dateLeft.getMilliseconds() - dateRight.getMilliseconds();\n if (diff < 0) {\n return -1;\n } else if (diff > 0) {\n return 1;\n // Return 0 if diff is 0; return NaN if diff is NaN\n } else {\n return diff;\n }\n }\n\n /**\n * @name differenceInDays\n * @category Day Helpers\n * @summary Get the number of full days between the given dates.\n *\n * @description\n * Get the number of full day periods between two dates. Fractional days are\n * truncated towards zero.\n *\n * One \"full day\" is the distance between a local time in one day to the same\n * local time on the next or previous day. A full day can sometimes be less than\n * or more than 24 hours if a daylight savings change happens between two dates.\n *\n * To ignore DST and only measure exact 24-hour periods, use this instead:\n * `Math.floor(differenceInHours(dateLeft, dateRight)/24)|0`.\n *\n *\n * @param {Date|Number} dateLeft - the later date\n * @param {Date|Number} dateRight - the earlier date\n * @returns {Number} the number of full days according to the local timezone\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // How many full days are between\n * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?\n * const result = differenceInDays(\n * new Date(2012, 6, 2, 0, 0),\n * new Date(2011, 6, 2, 23, 0)\n * )\n * //=> 365\n * // How many full days are between\n * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?\n * const result = differenceInDays(\n * new Date(2011, 6, 3, 0, 1),\n * new Date(2011, 6, 2, 23, 59)\n * )\n * //=> 0\n * // How many full days are between\n * // 1 March 2020 0:00 and 1 June 2020 0:00 ?\n * // Note: because local time is used, the\n * // result will always be 92 days, even in\n * // time zones where DST starts and the\n * // period has only 92*24-1 hours.\n * const result = differenceInDays(\n * new Date(2020, 5, 1),\n * new Date(2020, 2, 1)\n * )\n //=> 92\n */\n function differenceInDays(dirtyDateLeft, dirtyDateRight) {\n requiredArgs(2, arguments);\n var dateLeft = toDate(dirtyDateLeft);\n var dateRight = toDate(dirtyDateRight);\n var sign = compareLocalAsc(dateLeft, dateRight);\n var difference = Math.abs(differenceInCalendarDays(dateLeft, dateRight));\n dateLeft.setDate(dateLeft.getDate() - sign * difference);\n\n // Math.abs(diff in full days - diff in calendar days) === 1 if last calendar day is not full\n // If so, result must be decreased by 1 in absolute value\n var isLastDayNotFull = Number(compareLocalAsc(dateLeft, dateRight) === -sign);\n var result = sign * (difference - isLastDayNotFull);\n // Prevent negative zero\n return result === 0 ? 0 : result;\n }\n\n /**\n * @name differenceInMilliseconds\n * @category Millisecond Helpers\n * @summary Get the number of milliseconds between the given dates.\n *\n * @description\n * Get the number of milliseconds between the given dates.\n *\n * @param {Date|Number} dateLeft - the later date\n * @param {Date|Number} dateRight - the earlier date\n * @returns {Number} the number of milliseconds\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // How many milliseconds are between\n * // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?\n * const result = differenceInMilliseconds(\n * new Date(2014, 6, 2, 12, 30, 21, 700),\n * new Date(2014, 6, 2, 12, 30, 20, 600)\n * )\n * //=> 1100\n */\n function differenceInMilliseconds(dateLeft, dateRight) {\n requiredArgs(2, arguments);\n return toDate(dateLeft).getTime() - toDate(dateRight).getTime();\n }\n\n var roundingMap = {\n ceil: Math.ceil,\n round: Math.round,\n floor: Math.floor,\n trunc: function trunc(value) {\n return value < 0 ? Math.ceil(value) : Math.floor(value);\n } // Math.trunc is not supported by IE\n };\n\n var defaultRoundingMethod = 'trunc';\n function getRoundingMethod(method) {\n return method ? roundingMap[method] : roundingMap[defaultRoundingMethod];\n }\n\n /**\n * @name differenceInHours\n * @category Hour Helpers\n * @summary Get the number of hours between the given dates.\n *\n * @description\n * Get the number of hours between the given dates.\n *\n * @param {Date|Number} dateLeft - the later date\n * @param {Date|Number} dateRight - the earlier date\n * @param {Object} [options] - an object with options.\n * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)\n * @returns {Number} the number of hours\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // How many hours are between 2 July 2014 06:50:00 and 2 July 2014 19:00:00?\n * const result = differenceInHours(\n * new Date(2014, 6, 2, 19, 0),\n * new Date(2014, 6, 2, 6, 50)\n * )\n * //=> 12\n */\n function differenceInHours(dateLeft, dateRight, options) {\n requiredArgs(2, arguments);\n var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInHour;\n return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);\n }\n\n /**\n * @name differenceInMinutes\n * @category Minute Helpers\n * @summary Get the number of minutes between the given dates.\n *\n * @description\n * Get the signed number of full (rounded towards 0) minutes between the given dates.\n *\n * @param {Date|Number} dateLeft - the later date\n * @param {Date|Number} dateRight - the earlier date\n * @param {Object} [options] - an object with options.\n * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)\n * @returns {Number} the number of minutes\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // How many minutes are between 2 July 2014 12:07:59 and 2 July 2014 12:20:00?\n * const result = differenceInMinutes(\n * new Date(2014, 6, 2, 12, 20, 0),\n * new Date(2014, 6, 2, 12, 7, 59)\n * )\n * //=> 12\n *\n * @example\n * // How many minutes are between 10:01:59 and 10:00:00\n * const result = differenceInMinutes(\n * new Date(2000, 0, 1, 10, 0, 0),\n * new Date(2000, 0, 1, 10, 1, 59)\n * )\n * //=> -1\n */\n function differenceInMinutes(dateLeft, dateRight, options) {\n requiredArgs(2, arguments);\n var diff = differenceInMilliseconds(dateLeft, dateRight) / millisecondsInMinute;\n return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);\n }\n\n /**\n * @name endOfDay\n * @category Day Helpers\n * @summary Return the end of a day for the given date.\n *\n * @description\n * Return the end of a day for the given date.\n * The result will be in the local timezone.\n *\n * @param {Date|Number} date - the original date\n * @returns {Date} the end of a day\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // The end of a day for 2 September 2014 11:55:00:\n * const result = endOfDay(new Date(2014, 8, 2, 11, 55, 0))\n * //=> Tue Sep 02 2014 23:59:59.999\n */\n function endOfDay(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n date.setHours(23, 59, 59, 999);\n return date;\n }\n\n /**\n * @name endOfMonth\n * @category Month Helpers\n * @summary Return the end of a month for the given date.\n *\n * @description\n * Return the end of a month for the given date.\n * The result will be in the local timezone.\n *\n * @param {Date|Number} date - the original date\n * @returns {Date} the end of a month\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // The end of a month for 2 September 2014 11:55:00:\n * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))\n * //=> Tue Sep 30 2014 23:59:59.999\n */\n function endOfMonth(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n var month = date.getMonth();\n date.setFullYear(date.getFullYear(), month + 1, 0);\n date.setHours(23, 59, 59, 999);\n return date;\n }\n\n /**\n * @name isLastDayOfMonth\n * @category Month Helpers\n * @summary Is the given date the last day of a month?\n *\n * @description\n * Is the given date the last day of a month?\n *\n * @param {Date|Number} date - the date to check\n * @returns {Boolean} the date is the last day of a month\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // Is 28 February 2014 the last day of a month?\n * const result = isLastDayOfMonth(new Date(2014, 1, 28))\n * //=> true\n */\n function isLastDayOfMonth(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n return endOfDay(date).getTime() === endOfMonth(date).getTime();\n }\n\n /**\n * @name differenceInMonths\n * @category Month Helpers\n * @summary Get the number of full months between the given dates.\n *\n * @description\n * Get the number of full months between the given dates using trunc as a default rounding method.\n *\n * @param {Date|Number} dateLeft - the later date\n * @param {Date|Number} dateRight - the earlier date\n * @returns {Number} the number of full months\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // How many full months are between 31 January 2014 and 1 September 2014?\n * const result = differenceInMonths(new Date(2014, 8, 1), new Date(2014, 0, 31))\n * //=> 7\n */\n function differenceInMonths(dirtyDateLeft, dirtyDateRight) {\n requiredArgs(2, arguments);\n var dateLeft = toDate(dirtyDateLeft);\n var dateRight = toDate(dirtyDateRight);\n var sign = compareAsc(dateLeft, dateRight);\n var difference = Math.abs(differenceInCalendarMonths(dateLeft, dateRight));\n var result;\n\n // Check for the difference of less than month\n if (difference < 1) {\n result = 0;\n } else {\n if (dateLeft.getMonth() === 1 && dateLeft.getDate() > 27) {\n // This will check if the date is end of Feb and assign a higher end of month date\n // to compare it with Jan\n dateLeft.setDate(30);\n }\n dateLeft.setMonth(dateLeft.getMonth() - sign * difference);\n\n // Math.abs(diff in full months - diff in calendar months) === 1 if last calendar month is not full\n // If so, result must be decreased by 1 in absolute value\n var isLastMonthNotFull = compareAsc(dateLeft, dateRight) === -sign;\n\n // Check for cases of one full calendar month\n if (isLastDayOfMonth(toDate(dirtyDateLeft)) && difference === 1 && compareAsc(dirtyDateLeft, dateRight) === 1) {\n isLastMonthNotFull = false;\n }\n result = sign * (difference - Number(isLastMonthNotFull));\n }\n\n // Prevent negative zero\n return result === 0 ? 0 : result;\n }\n\n /**\n * @name differenceInQuarters\n * @category Quarter Helpers\n * @summary Get the number of quarters between the given dates.\n *\n * @description\n * Get the number of quarters between the given dates.\n *\n * @param {Date|Number} dateLeft - the later date\n * @param {Date|Number} dateRight - the earlier date\n * @param {Object} [options] - an object with options.\n * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)\n * @returns {Number} the number of full quarters\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // How many full quarters are between 31 December 2013 and 2 July 2014?\n * const result = differenceInQuarters(new Date(2014, 6, 2), new Date(2013, 11, 31))\n * //=> 2\n */\n function differenceInQuarters(dateLeft, dateRight, options) {\n requiredArgs(2, arguments);\n var diff = differenceInMonths(dateLeft, dateRight) / 3;\n return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);\n }\n\n /**\n * @name differenceInSeconds\n * @category Second Helpers\n * @summary Get the number of seconds between the given dates.\n *\n * @description\n * Get the number of seconds between the given dates.\n *\n * @param {Date|Number} dateLeft - the later date\n * @param {Date|Number} dateRight - the earlier date\n * @param {Object} [options] - an object with options.\n * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)\n * @returns {Number} the number of seconds\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // How many seconds are between\n * // 2 July 2014 12:30:07.999 and 2 July 2014 12:30:20.000?\n * const result = differenceInSeconds(\n * new Date(2014, 6, 2, 12, 30, 20, 0),\n * new Date(2014, 6, 2, 12, 30, 7, 999)\n * )\n * //=> 12\n */\n function differenceInSeconds(dateLeft, dateRight, options) {\n requiredArgs(2, arguments);\n var diff = differenceInMilliseconds(dateLeft, dateRight) / 1000;\n return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);\n }\n\n /**\n * @name differenceInWeeks\n * @category Week Helpers\n * @summary Get the number of full weeks between the given dates.\n *\n * @description\n * Get the number of full weeks between two dates. Fractional weeks are\n * truncated towards zero by default.\n *\n * One \"full week\" is the distance between a local time in one day to the same\n * local time 7 days earlier or later. A full week can sometimes be less than\n * or more than 7*24 hours if a daylight savings change happens between two dates.\n *\n * To ignore DST and only measure exact 7*24-hour periods, use this instead:\n * `Math.floor(differenceInHours(dateLeft, dateRight)/(7*24))|0`.\n *\n *\n * @param {Date|Number} dateLeft - the later date\n * @param {Date|Number} dateRight - the earlier date\n * @param {Object} [options] - an object with options.\n * @param {String} [options.roundingMethod='trunc'] - a rounding method (`ceil`, `floor`, `round` or `trunc`)\n * @returns {Number} the number of full weeks\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // How many full weeks are between 5 July 2014 and 20 July 2014?\n * const result = differenceInWeeks(new Date(2014, 6, 20), new Date(2014, 6, 5))\n * //=> 2\n *\n * // How many full weeks are between\n * // 1 March 2020 0:00 and 6 June 2020 0:00 ?\n * // Note: because local time is used, the\n * // result will always be 8 weeks (54 days),\n * // even if DST starts and the period has\n * // only 54*24-1 hours.\n * const result = differenceInWeeks(\n * new Date(2020, 5, 1),\n * new Date(2020, 2, 6)\n * )\n * //=> 8\n */\n function differenceInWeeks(dateLeft, dateRight, options) {\n requiredArgs(2, arguments);\n var diff = differenceInDays(dateLeft, dateRight) / 7;\n return getRoundingMethod(options === null || options === void 0 ? void 0 : options.roundingMethod)(diff);\n }\n\n /**\n * @name differenceInYears\n * @category Year Helpers\n * @summary Get the number of full years between the given dates.\n *\n * @description\n * Get the number of full years between the given dates.\n *\n * @param {Date|Number} dateLeft - the later date\n * @param {Date|Number} dateRight - the earlier date\n * @returns {Number} the number of full years\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // How many full years are between 31 December 2013 and 11 February 2015?\n * const result = differenceInYears(new Date(2015, 1, 11), new Date(2013, 11, 31))\n * //=> 1\n */\n function differenceInYears(dirtyDateLeft, dirtyDateRight) {\n requiredArgs(2, arguments);\n var dateLeft = toDate(dirtyDateLeft);\n var dateRight = toDate(dirtyDateRight);\n var sign = compareAsc(dateLeft, dateRight);\n var difference = Math.abs(differenceInCalendarYears(dateLeft, dateRight));\n\n // Set both dates to a valid leap year for accurate comparison when dealing\n // with leap days\n dateLeft.setFullYear(1584);\n dateRight.setFullYear(1584);\n\n // Math.abs(diff in full years - diff in calendar years) === 1 if last calendar year is not full\n // If so, result must be decreased by 1 in absolute value\n var isLastYearNotFull = compareAsc(dateLeft, dateRight) === -sign;\n var result = sign * (difference - Number(isLastYearNotFull));\n // Prevent negative zero\n return result === 0 ? 0 : result;\n }\n\n /**\n * @name startOfMinute\n * @category Minute Helpers\n * @summary Return the start of a minute for the given date.\n *\n * @description\n * Return the start of a minute for the given date.\n * The result will be in the local timezone.\n *\n * @param {Date|Number} date - the original date\n * @returns {Date} the start of a minute\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // The start of a minute for 1 December 2014 22:15:45.400:\n * const result = startOfMinute(new Date(2014, 11, 1, 22, 15, 45, 400))\n * //=> Mon Dec 01 2014 22:15:00\n */\n function startOfMinute(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n date.setSeconds(0, 0);\n return date;\n }\n\n /**\n * @name startOfQuarter\n * @category Quarter Helpers\n * @summary Return the start of a year quarter for the given date.\n *\n * @description\n * Return the start of a year quarter for the given date.\n * The result will be in the local timezone.\n *\n * @param {Date|Number} date - the original date\n * @returns {Date} the start of a quarter\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // The start of a quarter for 2 September 2014 11:55:00:\n * const result = startOfQuarter(new Date(2014, 8, 2, 11, 55, 0))\n * //=> Tue Jul 01 2014 00:00:00\n */\n function startOfQuarter(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n var currentMonth = date.getMonth();\n var month = currentMonth - currentMonth % 3;\n date.setMonth(month, 1);\n date.setHours(0, 0, 0, 0);\n return date;\n }\n\n /**\n * @name startOfMonth\n * @category Month Helpers\n * @summary Return the start of a month for the given date.\n *\n * @description\n * Return the start of a month for the given date.\n * The result will be in the local timezone.\n *\n * @param {Date|Number} date - the original date\n * @returns {Date} the start of a month\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // The start of a month for 2 September 2014 11:55:00:\n * const result = startOfMonth(new Date(2014, 8, 2, 11, 55, 0))\n * //=> Mon Sep 01 2014 00:00:00\n */\n function startOfMonth(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n date.setDate(1);\n date.setHours(0, 0, 0, 0);\n return date;\n }\n\n /**\n * @name endOfYear\n * @category Year Helpers\n * @summary Return the end of a year for the given date.\n *\n * @description\n * Return the end of a year for the given date.\n * The result will be in the local timezone.\n *\n * @param {Date|Number} date - the original date\n * @returns {Date} the end of a year\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // The end of a year for 2 September 2014 11:55:00:\n * const result = endOfYear(new Date(2014, 8, 2, 11, 55, 00))\n * //=> Wed Dec 31 2014 23:59:59.999\n */\n function endOfYear(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n var year = date.getFullYear();\n date.setFullYear(year + 1, 0, 0);\n date.setHours(23, 59, 59, 999);\n return date;\n }\n\n /**\n * @name startOfYear\n * @category Year Helpers\n * @summary Return the start of a year for the given date.\n *\n * @description\n * Return the start of a year for the given date.\n * The result will be in the local timezone.\n *\n * @param {Date|Number} date - the original date\n * @returns {Date} the start of a year\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // The start of a year for 2 September 2014 11:55:00:\n * const result = startOfYear(new Date(2014, 8, 2, 11, 55, 00))\n * //=> Wed Jan 01 2014 00:00:00\n */\n function startOfYear(dirtyDate) {\n requiredArgs(1, arguments);\n var cleanDate = toDate(dirtyDate);\n var date = new Date(0);\n date.setFullYear(cleanDate.getFullYear(), 0, 1);\n date.setHours(0, 0, 0, 0);\n return date;\n }\n\n /**\n * @name endOfHour\n * @category Hour Helpers\n * @summary Return the end of an hour for the given date.\n *\n * @description\n * Return the end of an hour for the given date.\n * The result will be in the local timezone.\n *\n * @param {Date|Number} date - the original date\n * @returns {Date} the end of an hour\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // The end of an hour for 2 September 2014 11:55:00:\n * const result = endOfHour(new Date(2014, 8, 2, 11, 55))\n * //=> Tue Sep 02 2014 11:59:59.999\n */\n function endOfHour(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n date.setMinutes(59, 59, 999);\n return date;\n }\n\n /**\n * @name endOfWeek\n * @category Week Helpers\n * @summary Return the end of a week for the given date.\n *\n * @description\n * Return the end of a week for the given date.\n * The result will be in the local timezone.\n *\n * @param {Date|Number} date - the original date\n * @param {Object} [options] - an object with options.\n * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}\n * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)\n * @returns {Date} the end of a week\n * @throws {TypeError} 1 argument required\n * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6\n *\n * @example\n * // The end of a week for 2 September 2014 11:55:00:\n * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0))\n * //=> Sat Sep 06 2014 23:59:59.999\n *\n * @example\n * // If the week starts on Monday, the end of the week for 2 September 2014 11:55:00:\n * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })\n * //=> Sun Sep 07 2014 23:59:59.999\n */\n function endOfWeek(dirtyDate, options) {\n var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;\n requiredArgs(1, arguments);\n var defaultOptions = getDefaultOptions();\n var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);\n\n // Test if weekStartsOn is between 0 and 6 _and_ is not NaN\n if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {\n throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');\n }\n var date = toDate(dirtyDate);\n var day = date.getDay();\n var diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn);\n date.setDate(date.getDate() + diff);\n date.setHours(23, 59, 59, 999);\n return date;\n }\n\n /**\n * @name endOfMinute\n * @category Minute Helpers\n * @summary Return the end of a minute for the given date.\n *\n * @description\n * Return the end of a minute for the given date.\n * The result will be in the local timezone.\n *\n * @param {Date|Number} date - the original date\n * @returns {Date} the end of a minute\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // The end of a minute for 1 December 2014 22:15:45.400:\n * const result = endOfMinute(new Date(2014, 11, 1, 22, 15, 45, 400))\n * //=> Mon Dec 01 2014 22:15:59.999\n */\n function endOfMinute(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n date.setSeconds(59, 999);\n return date;\n }\n\n /**\n * @name endOfQuarter\n * @category Quarter Helpers\n * @summary Return the end of a year quarter for the given date.\n *\n * @description\n * Return the end of a year quarter for the given date.\n * The result will be in the local timezone.\n *\n * @param {Date|Number} date - the original date\n * @returns {Date} the end of a quarter\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // The end of a quarter for 2 September 2014 11:55:00:\n * const result = endOfQuarter(new Date(2014, 8, 2, 11, 55, 0))\n * //=> Tue Sep 30 2014 23:59:59.999\n */\n function endOfQuarter(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n var currentMonth = date.getMonth();\n var month = currentMonth - currentMonth % 3 + 3;\n date.setMonth(month, 0);\n date.setHours(23, 59, 59, 999);\n return date;\n }\n\n /**\n * @name endOfSecond\n * @category Second Helpers\n * @summary Return the end of a second for the given date.\n *\n * @description\n * Return the end of a second for the given date.\n * The result will be in the local timezone.\n *\n * @param {Date|Number} date - the original date\n * @returns {Date} the end of a second\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // The end of a second for 1 December 2014 22:15:45.400:\n * const result = endOfSecond(new Date(2014, 11, 1, 22, 15, 45, 400))\n * //=> Mon Dec 01 2014 22:15:45.999\n */\n function endOfSecond(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n date.setMilliseconds(999);\n return date;\n }\n\n /**\n * @name subMilliseconds\n * @category Millisecond Helpers\n * @summary Subtract the specified number of milliseconds from the given date.\n *\n * @description\n * Subtract the specified number of milliseconds from the given date.\n *\n * @param {Date|Number} date - the date to be changed\n * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n * @returns {Date} the new date with the milliseconds subtracted\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:\n * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)\n * //=> Thu Jul 10 2014 12:45:29.250\n */\n function subMilliseconds(dirtyDate, dirtyAmount) {\n requiredArgs(2, arguments);\n var amount = toInteger(dirtyAmount);\n return addMilliseconds(dirtyDate, -amount);\n }\n\n var MILLISECONDS_IN_DAY = 86400000;\n function getUTCDayOfYear(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n var timestamp = date.getTime();\n date.setUTCMonth(0, 1);\n date.setUTCHours(0, 0, 0, 0);\n var startOfYearTimestamp = date.getTime();\n var difference = timestamp - startOfYearTimestamp;\n return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;\n }\n\n function startOfUTCISOWeek(dirtyDate) {\n requiredArgs(1, arguments);\n var weekStartsOn = 1;\n var date = toDate(dirtyDate);\n var day = date.getUTCDay();\n var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;\n date.setUTCDate(date.getUTCDate() - diff);\n date.setUTCHours(0, 0, 0, 0);\n return date;\n }\n\n function getUTCISOWeekYear(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n var year = date.getUTCFullYear();\n var fourthOfJanuaryOfNextYear = new Date(0);\n fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);\n fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);\n var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);\n var fourthOfJanuaryOfThisYear = new Date(0);\n fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);\n fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);\n var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);\n if (date.getTime() >= startOfNextYear.getTime()) {\n return year + 1;\n } else if (date.getTime() >= startOfThisYear.getTime()) {\n return year;\n } else {\n return year - 1;\n }\n }\n\n function startOfUTCISOWeekYear(dirtyDate) {\n requiredArgs(1, arguments);\n var year = getUTCISOWeekYear(dirtyDate);\n var fourthOfJanuary = new Date(0);\n fourthOfJanuary.setUTCFullYear(year, 0, 4);\n fourthOfJanuary.setUTCHours(0, 0, 0, 0);\n var date = startOfUTCISOWeek(fourthOfJanuary);\n return date;\n }\n\n var MILLISECONDS_IN_WEEK$1 = 604800000;\n function getUTCISOWeek(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime();\n\n // Round the number of days to the nearest integer\n // because the number of milliseconds in a week is not constant\n // (e.g. it's different in the week of the daylight saving time clock shift)\n return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;\n }\n\n function startOfUTCWeek(dirtyDate, options) {\n var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;\n requiredArgs(1, arguments);\n var defaultOptions = getDefaultOptions();\n var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);\n\n // Test if weekStartsOn is between 0 and 6 _and_ is not NaN\n if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {\n throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');\n }\n var date = toDate(dirtyDate);\n var day = date.getUTCDay();\n var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;\n date.setUTCDate(date.getUTCDate() - diff);\n date.setUTCHours(0, 0, 0, 0);\n return date;\n }\n\n function getUTCWeekYear(dirtyDate, options) {\n var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n var year = date.getUTCFullYear();\n var defaultOptions = getDefaultOptions();\n var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);\n\n // Test if weekStartsOn is between 1 and 7 _and_ is not NaN\n if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {\n throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');\n }\n var firstWeekOfNextYear = new Date(0);\n firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);\n firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);\n var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);\n var firstWeekOfThisYear = new Date(0);\n firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);\n firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);\n var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);\n if (date.getTime() >= startOfNextYear.getTime()) {\n return year + 1;\n } else if (date.getTime() >= startOfThisYear.getTime()) {\n return year;\n } else {\n return year - 1;\n }\n }\n\n function startOfUTCWeekYear(dirtyDate, options) {\n var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;\n requiredArgs(1, arguments);\n var defaultOptions = getDefaultOptions();\n var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);\n var year = getUTCWeekYear(dirtyDate, options);\n var firstWeek = new Date(0);\n firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);\n firstWeek.setUTCHours(0, 0, 0, 0);\n var date = startOfUTCWeek(firstWeek, options);\n return date;\n }\n\n var MILLISECONDS_IN_WEEK = 604800000;\n function getUTCWeek(dirtyDate, options) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime();\n\n // Round the number of days to the nearest integer\n // because the number of milliseconds in a week is not constant\n // (e.g. it's different in the week of the daylight saving time clock shift)\n return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;\n }\n\n function addLeadingZeros(number, targetLength) {\n var sign = number < 0 ? '-' : '';\n var output = Math.abs(number).toString();\n while (output.length < targetLength) {\n output = '0' + output;\n }\n return sign + output;\n }\n\n /*\n * | | Unit | | Unit |\n * |-----|--------------------------------|-----|--------------------------------|\n * | a | AM, PM | A* | |\n * | d | Day of month | D | |\n * | h | Hour [1-12] | H | Hour [0-23] |\n * | m | Minute | M | Month |\n * | s | Second | S | Fraction of second |\n * | y | Year (abs) | Y | |\n *\n * Letters marked by * are not implemented but reserved by Unicode standard.\n */\n var formatters$2 = {\n // Year\n y: function y(date, token) {\n // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens\n // | Year | y | yy | yyy | yyyy | yyyyy |\n // |----------|-------|----|-------|-------|-------|\n // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |\n // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |\n // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |\n // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |\n // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |\n\n var signedYear = date.getUTCFullYear();\n // Returns 1 for 1 BC (which is year 0 in JavaScript)\n var year = signedYear > 0 ? signedYear : 1 - signedYear;\n return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);\n },\n // Month\n M: function M(date, token) {\n var month = date.getUTCMonth();\n return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);\n },\n // Day of the month\n d: function d(date, token) {\n return addLeadingZeros(date.getUTCDate(), token.length);\n },\n // AM or PM\n a: function a(date, token) {\n var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';\n switch (token) {\n case 'a':\n case 'aa':\n return dayPeriodEnumValue.toUpperCase();\n case 'aaa':\n return dayPeriodEnumValue;\n case 'aaaaa':\n return dayPeriodEnumValue[0];\n case 'aaaa':\n default:\n return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';\n }\n },\n // Hour [1-12]\n h: function h(date, token) {\n return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);\n },\n // Hour [0-23]\n H: function H(date, token) {\n return addLeadingZeros(date.getUTCHours(), token.length);\n },\n // Minute\n m: function m(date, token) {\n return addLeadingZeros(date.getUTCMinutes(), token.length);\n },\n // Second\n s: function s(date, token) {\n return addLeadingZeros(date.getUTCSeconds(), token.length);\n },\n // Fraction of second\n S: function S(date, token) {\n var numberOfDigits = token.length;\n var milliseconds = date.getUTCMilliseconds();\n var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));\n return addLeadingZeros(fractionalSeconds, token.length);\n }\n };\n var formatters$3 = formatters$2;\n\n var dayPeriodEnum = {\n am: 'am',\n pm: 'pm',\n midnight: 'midnight',\n noon: 'noon',\n morning: 'morning',\n afternoon: 'afternoon',\n evening: 'evening',\n night: 'night'\n };\n /*\n * | | Unit | | Unit |\n * |-----|--------------------------------|-----|--------------------------------|\n * | a | AM, PM | A* | Milliseconds in day |\n * | b | AM, PM, noon, midnight | B | Flexible day period |\n * | c | Stand-alone local day of week | C* | Localized hour w/ day period |\n * | d | Day of month | D | Day of year |\n * | e | Local day of week | E | Day of week |\n * | f | | F* | Day of week in month |\n * | g* | Modified Julian day | G | Era |\n * | h | Hour [1-12] | H | Hour [0-23] |\n * | i! | ISO day of week | I! | ISO week of year |\n * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |\n * | k | Hour [1-24] | K | Hour [0-11] |\n * | l* | (deprecated) | L | Stand-alone month |\n * | m | Minute | M | Month |\n * | n | | N | |\n * | o! | Ordinal number modifier | O | Timezone (GMT) |\n * | p! | Long localized time | P! | Long localized date |\n * | q | Stand-alone quarter | Q | Quarter |\n * | r* | Related Gregorian year | R! | ISO week-numbering year |\n * | s | Second | S | Fraction of second |\n * | t! | Seconds timestamp | T! | Milliseconds timestamp |\n * | u | Extended year | U* | Cyclic year |\n * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |\n * | w | Local week of year | W* | Week of month |\n * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |\n * | y | Year (abs) | Y | Local week-numbering year |\n * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |\n *\n * Letters marked by * are not implemented but reserved by Unicode standard.\n *\n * Letters marked by ! are non-standard, but implemented by date-fns:\n * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)\n * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,\n * i.e. 7 for Sunday, 1 for Monday, etc.\n * - `I` is ISO week of year, as opposed to `w` which is local week of year.\n * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.\n * `R` is supposed to be used in conjunction with `I` and `i`\n * for universal ISO week-numbering date, whereas\n * `Y` is supposed to be used in conjunction with `w` and `e`\n * for week-numbering date specific to the locale.\n * - `P` is long localized date format\n * - `p` is long localized time format\n */\n\n var formatters = {\n // Era\n G: function G(date, token, localize) {\n var era = date.getUTCFullYear() > 0 ? 1 : 0;\n switch (token) {\n // AD, BC\n case 'G':\n case 'GG':\n case 'GGG':\n return localize.era(era, {\n width: 'abbreviated'\n });\n // A, B\n case 'GGGGG':\n return localize.era(era, {\n width: 'narrow'\n });\n // Anno Domini, Before Christ\n case 'GGGG':\n default:\n return localize.era(era, {\n width: 'wide'\n });\n }\n },\n // Year\n y: function y(date, token, localize) {\n // Ordinal number\n if (token === 'yo') {\n var signedYear = date.getUTCFullYear();\n // Returns 1 for 1 BC (which is year 0 in JavaScript)\n var year = signedYear > 0 ? signedYear : 1 - signedYear;\n return localize.ordinalNumber(year, {\n unit: 'year'\n });\n }\n return formatters$3.y(date, token);\n },\n // Local week-numbering year\n Y: function Y(date, token, localize, options) {\n var signedWeekYear = getUTCWeekYear(date, options);\n // Returns 1 for 1 BC (which is year 0 in JavaScript)\n var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;\n\n // Two digit year\n if (token === 'YY') {\n var twoDigitYear = weekYear % 100;\n return addLeadingZeros(twoDigitYear, 2);\n }\n\n // Ordinal number\n if (token === 'Yo') {\n return localize.ordinalNumber(weekYear, {\n unit: 'year'\n });\n }\n\n // Padding\n return addLeadingZeros(weekYear, token.length);\n },\n // ISO week-numbering year\n R: function R(date, token) {\n var isoWeekYear = getUTCISOWeekYear(date);\n\n // Padding\n return addLeadingZeros(isoWeekYear, token.length);\n },\n // Extended year. This is a single number designating the year of this calendar system.\n // The main difference between `y` and `u` localizers are B.C. years:\n // | Year | `y` | `u` |\n // |------|-----|-----|\n // | AC 1 | 1 | 1 |\n // | BC 1 | 1 | 0 |\n // | BC 2 | 2 | -1 |\n // Also `yy` always returns the last two digits of a year,\n // while `uu` pads single digit years to 2 characters and returns other years unchanged.\n u: function u(date, token) {\n var year = date.getUTCFullYear();\n return addLeadingZeros(year, token.length);\n },\n // Quarter\n Q: function Q(date, token, localize) {\n var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);\n switch (token) {\n // 1, 2, 3, 4\n case 'Q':\n return String(quarter);\n // 01, 02, 03, 04\n case 'QQ':\n return addLeadingZeros(quarter, 2);\n // 1st, 2nd, 3rd, 4th\n case 'Qo':\n return localize.ordinalNumber(quarter, {\n unit: 'quarter'\n });\n // Q1, Q2, Q3, Q4\n case 'QQQ':\n return localize.quarter(quarter, {\n width: 'abbreviated',\n context: 'formatting'\n });\n // 1, 2, 3, 4 (narrow quarter; could be not numerical)\n case 'QQQQQ':\n return localize.quarter(quarter, {\n width: 'narrow',\n context: 'formatting'\n });\n // 1st quarter, 2nd quarter, ...\n case 'QQQQ':\n default:\n return localize.quarter(quarter, {\n width: 'wide',\n context: 'formatting'\n });\n }\n },\n // Stand-alone quarter\n q: function q(date, token, localize) {\n var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);\n switch (token) {\n // 1, 2, 3, 4\n case 'q':\n return String(quarter);\n // 01, 02, 03, 04\n case 'qq':\n return addLeadingZeros(quarter, 2);\n // 1st, 2nd, 3rd, 4th\n case 'qo':\n return localize.ordinalNumber(quarter, {\n unit: 'quarter'\n });\n // Q1, Q2, Q3, Q4\n case 'qqq':\n return localize.quarter(quarter, {\n width: 'abbreviated',\n context: 'standalone'\n });\n // 1, 2, 3, 4 (narrow quarter; could be not numerical)\n case 'qqqqq':\n return localize.quarter(quarter, {\n width: 'narrow',\n context: 'standalone'\n });\n // 1st quarter, 2nd quarter, ...\n case 'qqqq':\n default:\n return localize.quarter(quarter, {\n width: 'wide',\n context: 'standalone'\n });\n }\n },\n // Month\n M: function M(date, token, localize) {\n var month = date.getUTCMonth();\n switch (token) {\n case 'M':\n case 'MM':\n return formatters$3.M(date, token);\n // 1st, 2nd, ..., 12th\n case 'Mo':\n return localize.ordinalNumber(month + 1, {\n unit: 'month'\n });\n // Jan, Feb, ..., Dec\n case 'MMM':\n return localize.month(month, {\n width: 'abbreviated',\n context: 'formatting'\n });\n // J, F, ..., D\n case 'MMMMM':\n return localize.month(month, {\n width: 'narrow',\n context: 'formatting'\n });\n // January, February, ..., December\n case 'MMMM':\n default:\n return localize.month(month, {\n width: 'wide',\n context: 'formatting'\n });\n }\n },\n // Stand-alone month\n L: function L(date, token, localize) {\n var month = date.getUTCMonth();\n switch (token) {\n // 1, 2, ..., 12\n case 'L':\n return String(month + 1);\n // 01, 02, ..., 12\n case 'LL':\n return addLeadingZeros(month + 1, 2);\n // 1st, 2nd, ..., 12th\n case 'Lo':\n return localize.ordinalNumber(month + 1, {\n unit: 'month'\n });\n // Jan, Feb, ..., Dec\n case 'LLL':\n return localize.month(month, {\n width: 'abbreviated',\n context: 'standalone'\n });\n // J, F, ..., D\n case 'LLLLL':\n return localize.month(month, {\n width: 'narrow',\n context: 'standalone'\n });\n // January, February, ..., December\n case 'LLLL':\n default:\n return localize.month(month, {\n width: 'wide',\n context: 'standalone'\n });\n }\n },\n // Local week of year\n w: function w(date, token, localize, options) {\n var week = getUTCWeek(date, options);\n if (token === 'wo') {\n return localize.ordinalNumber(week, {\n unit: 'week'\n });\n }\n return addLeadingZeros(week, token.length);\n },\n // ISO week of year\n I: function I(date, token, localize) {\n var isoWeek = getUTCISOWeek(date);\n if (token === 'Io') {\n return localize.ordinalNumber(isoWeek, {\n unit: 'week'\n });\n }\n return addLeadingZeros(isoWeek, token.length);\n },\n // Day of the month\n d: function d(date, token, localize) {\n if (token === 'do') {\n return localize.ordinalNumber(date.getUTCDate(), {\n unit: 'date'\n });\n }\n return formatters$3.d(date, token);\n },\n // Day of year\n D: function D(date, token, localize) {\n var dayOfYear = getUTCDayOfYear(date);\n if (token === 'Do') {\n return localize.ordinalNumber(dayOfYear, {\n unit: 'dayOfYear'\n });\n }\n return addLeadingZeros(dayOfYear, token.length);\n },\n // Day of week\n E: function E(date, token, localize) {\n var dayOfWeek = date.getUTCDay();\n switch (token) {\n // Tue\n case 'E':\n case 'EE':\n case 'EEE':\n return localize.day(dayOfWeek, {\n width: 'abbreviated',\n context: 'formatting'\n });\n // T\n case 'EEEEE':\n return localize.day(dayOfWeek, {\n width: 'narrow',\n context: 'formatting'\n });\n // Tu\n case 'EEEEEE':\n return localize.day(dayOfWeek, {\n width: 'short',\n context: 'formatting'\n });\n // Tuesday\n case 'EEEE':\n default:\n return localize.day(dayOfWeek, {\n width: 'wide',\n context: 'formatting'\n });\n }\n },\n // Local day of week\n e: function e(date, token, localize, options) {\n var dayOfWeek = date.getUTCDay();\n var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;\n switch (token) {\n // Numerical value (Nth day of week with current locale or weekStartsOn)\n case 'e':\n return String(localDayOfWeek);\n // Padded numerical value\n case 'ee':\n return addLeadingZeros(localDayOfWeek, 2);\n // 1st, 2nd, ..., 7th\n case 'eo':\n return localize.ordinalNumber(localDayOfWeek, {\n unit: 'day'\n });\n case 'eee':\n return localize.day(dayOfWeek, {\n width: 'abbreviated',\n context: 'formatting'\n });\n // T\n case 'eeeee':\n return localize.day(dayOfWeek, {\n width: 'narrow',\n context: 'formatting'\n });\n // Tu\n case 'eeeeee':\n return localize.day(dayOfWeek, {\n width: 'short',\n context: 'formatting'\n });\n // Tuesday\n case 'eeee':\n default:\n return localize.day(dayOfWeek, {\n width: 'wide',\n context: 'formatting'\n });\n }\n },\n // Stand-alone local day of week\n c: function c(date, token, localize, options) {\n var dayOfWeek = date.getUTCDay();\n var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;\n switch (token) {\n // Numerical value (same as in `e`)\n case 'c':\n return String(localDayOfWeek);\n // Padded numerical value\n case 'cc':\n return addLeadingZeros(localDayOfWeek, token.length);\n // 1st, 2nd, ..., 7th\n case 'co':\n return localize.ordinalNumber(localDayOfWeek, {\n unit: 'day'\n });\n case 'ccc':\n return localize.day(dayOfWeek, {\n width: 'abbreviated',\n context: 'standalone'\n });\n // T\n case 'ccccc':\n return localize.day(dayOfWeek, {\n width: 'narrow',\n context: 'standalone'\n });\n // Tu\n case 'cccccc':\n return localize.day(dayOfWeek, {\n width: 'short',\n context: 'standalone'\n });\n // Tuesday\n case 'cccc':\n default:\n return localize.day(dayOfWeek, {\n width: 'wide',\n context: 'standalone'\n });\n }\n },\n // ISO day of week\n i: function i(date, token, localize) {\n var dayOfWeek = date.getUTCDay();\n var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;\n switch (token) {\n // 2\n case 'i':\n return String(isoDayOfWeek);\n // 02\n case 'ii':\n return addLeadingZeros(isoDayOfWeek, token.length);\n // 2nd\n case 'io':\n return localize.ordinalNumber(isoDayOfWeek, {\n unit: 'day'\n });\n // Tue\n case 'iii':\n return localize.day(dayOfWeek, {\n width: 'abbreviated',\n context: 'formatting'\n });\n // T\n case 'iiiii':\n return localize.day(dayOfWeek, {\n width: 'narrow',\n context: 'formatting'\n });\n // Tu\n case 'iiiiii':\n return localize.day(dayOfWeek, {\n width: 'short',\n context: 'formatting'\n });\n // Tuesday\n case 'iiii':\n default:\n return localize.day(dayOfWeek, {\n width: 'wide',\n context: 'formatting'\n });\n }\n },\n // AM or PM\n a: function a(date, token, localize) {\n var hours = date.getUTCHours();\n var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';\n switch (token) {\n case 'a':\n case 'aa':\n return localize.dayPeriod(dayPeriodEnumValue, {\n width: 'abbreviated',\n context: 'formatting'\n });\n case 'aaa':\n return localize.dayPeriod(dayPeriodEnumValue, {\n width: 'abbreviated',\n context: 'formatting'\n }).toLowerCase();\n case 'aaaaa':\n return localize.dayPeriod(dayPeriodEnumValue, {\n width: 'narrow',\n context: 'formatting'\n });\n case 'aaaa':\n default:\n return localize.dayPeriod(dayPeriodEnumValue, {\n width: 'wide',\n context: 'formatting'\n });\n }\n },\n // AM, PM, midnight, noon\n b: function b(date, token, localize) {\n var hours = date.getUTCHours();\n var dayPeriodEnumValue;\n if (hours === 12) {\n dayPeriodEnumValue = dayPeriodEnum.noon;\n } else if (hours === 0) {\n dayPeriodEnumValue = dayPeriodEnum.midnight;\n } else {\n dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';\n }\n switch (token) {\n case 'b':\n case 'bb':\n return localize.dayPeriod(dayPeriodEnumValue, {\n width: 'abbreviated',\n context: 'formatting'\n });\n case 'bbb':\n return localize.dayPeriod(dayPeriodEnumValue, {\n width: 'abbreviated',\n context: 'formatting'\n }).toLowerCase();\n case 'bbbbb':\n return localize.dayPeriod(dayPeriodEnumValue, {\n width: 'narrow',\n context: 'formatting'\n });\n case 'bbbb':\n default:\n return localize.dayPeriod(dayPeriodEnumValue, {\n width: 'wide',\n context: 'formatting'\n });\n }\n },\n // in the morning, in the afternoon, in the evening, at night\n B: function B(date, token, localize) {\n var hours = date.getUTCHours();\n var dayPeriodEnumValue;\n if (hours >= 17) {\n dayPeriodEnumValue = dayPeriodEnum.evening;\n } else if (hours >= 12) {\n dayPeriodEnumValue = dayPeriodEnum.afternoon;\n } else if (hours >= 4) {\n dayPeriodEnumValue = dayPeriodEnum.morning;\n } else {\n dayPeriodEnumValue = dayPeriodEnum.night;\n }\n switch (token) {\n case 'B':\n case 'BB':\n case 'BBB':\n return localize.dayPeriod(dayPeriodEnumValue, {\n width: 'abbreviated',\n context: 'formatting'\n });\n case 'BBBBB':\n return localize.dayPeriod(dayPeriodEnumValue, {\n width: 'narrow',\n context: 'formatting'\n });\n case 'BBBB':\n default:\n return localize.dayPeriod(dayPeriodEnumValue, {\n width: 'wide',\n context: 'formatting'\n });\n }\n },\n // Hour [1-12]\n h: function h(date, token, localize) {\n if (token === 'ho') {\n var hours = date.getUTCHours() % 12;\n if (hours === 0) hours = 12;\n return localize.ordinalNumber(hours, {\n unit: 'hour'\n });\n }\n return formatters$3.h(date, token);\n },\n // Hour [0-23]\n H: function H(date, token, localize) {\n if (token === 'Ho') {\n return localize.ordinalNumber(date.getUTCHours(), {\n unit: 'hour'\n });\n }\n return formatters$3.H(date, token);\n },\n // Hour [0-11]\n K: function K(date, token, localize) {\n var hours = date.getUTCHours() % 12;\n if (token === 'Ko') {\n return localize.ordinalNumber(hours, {\n unit: 'hour'\n });\n }\n return addLeadingZeros(hours, token.length);\n },\n // Hour [1-24]\n k: function k(date, token, localize) {\n var hours = date.getUTCHours();\n if (hours === 0) hours = 24;\n if (token === 'ko') {\n return localize.ordinalNumber(hours, {\n unit: 'hour'\n });\n }\n return addLeadingZeros(hours, token.length);\n },\n // Minute\n m: function m(date, token, localize) {\n if (token === 'mo') {\n return localize.ordinalNumber(date.getUTCMinutes(), {\n unit: 'minute'\n });\n }\n return formatters$3.m(date, token);\n },\n // Second\n s: function s(date, token, localize) {\n if (token === 'so') {\n return localize.ordinalNumber(date.getUTCSeconds(), {\n unit: 'second'\n });\n }\n return formatters$3.s(date, token);\n },\n // Fraction of second\n S: function S(date, token) {\n return formatters$3.S(date, token);\n },\n // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)\n X: function X(date, token, _localize, options) {\n var originalDate = options._originalDate || date;\n var timezoneOffset = originalDate.getTimezoneOffset();\n if (timezoneOffset === 0) {\n return 'Z';\n }\n switch (token) {\n // Hours and optional minutes\n case 'X':\n return formatTimezoneWithOptionalMinutes(timezoneOffset);\n\n // Hours, minutes and optional seconds without `:` delimiter\n // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets\n // so this token always has the same output as `XX`\n case 'XXXX':\n case 'XX':\n // Hours and minutes without `:` delimiter\n return formatTimezone(timezoneOffset);\n\n // Hours, minutes and optional seconds with `:` delimiter\n // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets\n // so this token always has the same output as `XXX`\n case 'XXXXX':\n case 'XXX': // Hours and minutes with `:` delimiter\n default:\n return formatTimezone(timezoneOffset, ':');\n }\n },\n // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)\n x: function x(date, token, _localize, options) {\n var originalDate = options._originalDate || date;\n var timezoneOffset = originalDate.getTimezoneOffset();\n switch (token) {\n // Hours and optional minutes\n case 'x':\n return formatTimezoneWithOptionalMinutes(timezoneOffset);\n\n // Hours, minutes and optional seconds without `:` delimiter\n // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets\n // so this token always has the same output as `xx`\n case 'xxxx':\n case 'xx':\n // Hours and minutes without `:` delimiter\n return formatTimezone(timezoneOffset);\n\n // Hours, minutes and optional seconds with `:` delimiter\n // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets\n // so this token always has the same output as `xxx`\n case 'xxxxx':\n case 'xxx': // Hours and minutes with `:` delimiter\n default:\n return formatTimezone(timezoneOffset, ':');\n }\n },\n // Timezone (GMT)\n O: function O(date, token, _localize, options) {\n var originalDate = options._originalDate || date;\n var timezoneOffset = originalDate.getTimezoneOffset();\n switch (token) {\n // Short\n case 'O':\n case 'OO':\n case 'OOO':\n return 'GMT' + formatTimezoneShort(timezoneOffset, ':');\n // Long\n case 'OOOO':\n default:\n return 'GMT' + formatTimezone(timezoneOffset, ':');\n }\n },\n // Timezone (specific non-location)\n z: function z(date, token, _localize, options) {\n var originalDate = options._originalDate || date;\n var timezoneOffset = originalDate.getTimezoneOffset();\n switch (token) {\n // Short\n case 'z':\n case 'zz':\n case 'zzz':\n return 'GMT' + formatTimezoneShort(timezoneOffset, ':');\n // Long\n case 'zzzz':\n default:\n return 'GMT' + formatTimezone(timezoneOffset, ':');\n }\n },\n // Seconds timestamp\n t: function t(date, token, _localize, options) {\n var originalDate = options._originalDate || date;\n var timestamp = Math.floor(originalDate.getTime() / 1000);\n return addLeadingZeros(timestamp, token.length);\n },\n // Milliseconds timestamp\n T: function T(date, token, _localize, options) {\n var originalDate = options._originalDate || date;\n var timestamp = originalDate.getTime();\n return addLeadingZeros(timestamp, token.length);\n }\n };\n function formatTimezoneShort(offset, dirtyDelimiter) {\n var sign = offset > 0 ? '-' : '+';\n var absOffset = Math.abs(offset);\n var hours = Math.floor(absOffset / 60);\n var minutes = absOffset % 60;\n if (minutes === 0) {\n return sign + String(hours);\n }\n var delimiter = dirtyDelimiter || '';\n return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);\n }\n function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {\n if (offset % 60 === 0) {\n var sign = offset > 0 ? '-' : '+';\n return sign + addLeadingZeros(Math.abs(offset) / 60, 2);\n }\n return formatTimezone(offset, dirtyDelimiter);\n }\n function formatTimezone(offset, dirtyDelimiter) {\n var delimiter = dirtyDelimiter || '';\n var sign = offset > 0 ? '-' : '+';\n var absOffset = Math.abs(offset);\n var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);\n var minutes = addLeadingZeros(absOffset % 60, 2);\n return sign + hours + delimiter + minutes;\n }\n var formatters$1 = formatters;\n\n var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {\n switch (pattern) {\n case 'P':\n return formatLong.date({\n width: 'short'\n });\n case 'PP':\n return formatLong.date({\n width: 'medium'\n });\n case 'PPP':\n return formatLong.date({\n width: 'long'\n });\n case 'PPPP':\n default:\n return formatLong.date({\n width: 'full'\n });\n }\n };\n var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {\n switch (pattern) {\n case 'p':\n return formatLong.time({\n width: 'short'\n });\n case 'pp':\n return formatLong.time({\n width: 'medium'\n });\n case 'ppp':\n return formatLong.time({\n width: 'long'\n });\n case 'pppp':\n default:\n return formatLong.time({\n width: 'full'\n });\n }\n };\n var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {\n var matchResult = pattern.match(/(P+)(p+)?/) || [];\n var datePattern = matchResult[1];\n var timePattern = matchResult[2];\n if (!timePattern) {\n return dateLongFormatter(pattern, formatLong);\n }\n var dateTimeFormat;\n switch (datePattern) {\n case 'P':\n dateTimeFormat = formatLong.dateTime({\n width: 'short'\n });\n break;\n case 'PP':\n dateTimeFormat = formatLong.dateTime({\n width: 'medium'\n });\n break;\n case 'PPP':\n dateTimeFormat = formatLong.dateTime({\n width: 'long'\n });\n break;\n case 'PPPP':\n default:\n dateTimeFormat = formatLong.dateTime({\n width: 'full'\n });\n break;\n }\n return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));\n };\n var longFormatters = {\n p: timeLongFormatter,\n P: dateTimeLongFormatter\n };\n var longFormatters$1 = longFormatters;\n\n var protectedDayOfYearTokens = ['D', 'DD'];\n var protectedWeekYearTokens = ['YY', 'YYYY'];\n function isProtectedDayOfYearToken(token) {\n return protectedDayOfYearTokens.indexOf(token) !== -1;\n }\n function isProtectedWeekYearToken(token) {\n return protectedWeekYearTokens.indexOf(token) !== -1;\n }\n function throwProtectedError(token, format, input) {\n if (token === 'YYYY') {\n throw new RangeError(\"Use `yyyy` instead of `YYYY` (in `\".concat(format, \"`) for formatting years to the input `\").concat(input, \"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\"));\n } else if (token === 'YY') {\n throw new RangeError(\"Use `yy` instead of `YY` (in `\".concat(format, \"`) for formatting years to the input `\").concat(input, \"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\"));\n } else if (token === 'D') {\n throw new RangeError(\"Use `d` instead of `D` (in `\".concat(format, \"`) for formatting days of the month to the input `\").concat(input, \"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\"));\n } else if (token === 'DD') {\n throw new RangeError(\"Use `dd` instead of `DD` (in `\".concat(format, \"`) for formatting days of the month to the input `\").concat(input, \"`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\"));\n }\n }\n\n var formatDistanceLocale = {\n lessThanXSeconds: {\n one: 'less than a second',\n other: 'less than {{count}} seconds'\n },\n xSeconds: {\n one: '1 second',\n other: '{{count}} seconds'\n },\n halfAMinute: 'half a minute',\n lessThanXMinutes: {\n one: 'less than a minute',\n other: 'less than {{count}} minutes'\n },\n xMinutes: {\n one: '1 minute',\n other: '{{count}} minutes'\n },\n aboutXHours: {\n one: 'about 1 hour',\n other: 'about {{count}} hours'\n },\n xHours: {\n one: '1 hour',\n other: '{{count}} hours'\n },\n xDays: {\n one: '1 day',\n other: '{{count}} days'\n },\n aboutXWeeks: {\n one: 'about 1 week',\n other: 'about {{count}} weeks'\n },\n xWeeks: {\n one: '1 week',\n other: '{{count}} weeks'\n },\n aboutXMonths: {\n one: 'about 1 month',\n other: 'about {{count}} months'\n },\n xMonths: {\n one: '1 month',\n other: '{{count}} months'\n },\n aboutXYears: {\n one: 'about 1 year',\n other: 'about {{count}} years'\n },\n xYears: {\n one: '1 year',\n other: '{{count}} years'\n },\n overXYears: {\n one: 'over 1 year',\n other: 'over {{count}} years'\n },\n almostXYears: {\n one: 'almost 1 year',\n other: 'almost {{count}} years'\n }\n };\n var formatDistance = function formatDistance(token, count, options) {\n var result;\n var tokenValue = formatDistanceLocale[token];\n if (typeof tokenValue === 'string') {\n result = tokenValue;\n } else if (count === 1) {\n result = tokenValue.one;\n } else {\n result = tokenValue.other.replace('{{count}}', count.toString());\n }\n if (options !== null && options !== void 0 && options.addSuffix) {\n if (options.comparison && options.comparison > 0) {\n return 'in ' + result;\n } else {\n return result + ' ago';\n }\n }\n return result;\n };\n var formatDistance$1 = formatDistance;\n\n function buildFormatLongFn(args) {\n return function () {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n // TODO: Remove String()\n var width = options.width ? String(options.width) : args.defaultWidth;\n var format = args.formats[width] || args.formats[args.defaultWidth];\n return format;\n };\n }\n\n var dateFormats = {\n full: 'EEEE, MMMM do, y',\n \"long\": 'MMMM do, y',\n medium: 'MMM d, y',\n \"short\": 'MM/dd/yyyy'\n };\n var timeFormats = {\n full: 'h:mm:ss a zzzz',\n \"long\": 'h:mm:ss a z',\n medium: 'h:mm:ss a',\n \"short\": 'h:mm a'\n };\n var dateTimeFormats = {\n full: \"{{date}} 'at' {{time}}\",\n \"long\": \"{{date}} 'at' {{time}}\",\n medium: '{{date}}, {{time}}',\n \"short\": '{{date}}, {{time}}'\n };\n var formatLong = {\n date: buildFormatLongFn({\n formats: dateFormats,\n defaultWidth: 'full'\n }),\n time: buildFormatLongFn({\n formats: timeFormats,\n defaultWidth: 'full'\n }),\n dateTime: buildFormatLongFn({\n formats: dateTimeFormats,\n defaultWidth: 'full'\n })\n };\n var formatLong$1 = formatLong;\n\n var formatRelativeLocale = {\n lastWeek: \"'last' eeee 'at' p\",\n yesterday: \"'yesterday at' p\",\n today: \"'today at' p\",\n tomorrow: \"'tomorrow at' p\",\n nextWeek: \"eeee 'at' p\",\n other: 'P'\n };\n var formatRelative = function formatRelative(token, _date, _baseDate, _options) {\n return formatRelativeLocale[token];\n };\n var formatRelative$1 = formatRelative;\n\n function buildLocalizeFn(args) {\n return function (dirtyIndex, options) {\n var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';\n var valuesArray;\n if (context === 'formatting' && args.formattingValues) {\n var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;\n var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;\n valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];\n } else {\n var _defaultWidth = args.defaultWidth;\n var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;\n valuesArray = args.values[_width] || args.values[_defaultWidth];\n }\n var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;\n // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!\n return valuesArray[index];\n };\n }\n\n var eraValues = {\n narrow: ['B', 'A'],\n abbreviated: ['BC', 'AD'],\n wide: ['Before Christ', 'Anno Domini']\n };\n var quarterValues = {\n narrow: ['1', '2', '3', '4'],\n abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],\n wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']\n };\n\n // Note: in English, the names of days of the week and months are capitalized.\n // If you are making a new locale based on this one, check if the same is true for the language you're working on.\n // Generally, formatted dates should look like they are in the middle of a sentence,\n // e.g. in Spanish language the weekdays and months should be in the lowercase.\n var monthValues = {\n narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],\n abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],\n wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']\n };\n var dayValues = {\n narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],\n \"short\": ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],\n abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],\n wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']\n };\n var dayPeriodValues = {\n narrow: {\n am: 'a',\n pm: 'p',\n midnight: 'mi',\n noon: 'n',\n morning: 'morning',\n afternoon: 'afternoon',\n evening: 'evening',\n night: 'night'\n },\n abbreviated: {\n am: 'AM',\n pm: 'PM',\n midnight: 'midnight',\n noon: 'noon',\n morning: 'morning',\n afternoon: 'afternoon',\n evening: 'evening',\n night: 'night'\n },\n wide: {\n am: 'a.m.',\n pm: 'p.m.',\n midnight: 'midnight',\n noon: 'noon',\n morning: 'morning',\n afternoon: 'afternoon',\n evening: 'evening',\n night: 'night'\n }\n };\n var formattingDayPeriodValues = {\n narrow: {\n am: 'a',\n pm: 'p',\n midnight: 'mi',\n noon: 'n',\n morning: 'in the morning',\n afternoon: 'in the afternoon',\n evening: 'in the evening',\n night: 'at night'\n },\n abbreviated: {\n am: 'AM',\n pm: 'PM',\n midnight: 'midnight',\n noon: 'noon',\n morning: 'in the morning',\n afternoon: 'in the afternoon',\n evening: 'in the evening',\n night: 'at night'\n },\n wide: {\n am: 'a.m.',\n pm: 'p.m.',\n midnight: 'midnight',\n noon: 'noon',\n morning: 'in the morning',\n afternoon: 'in the afternoon',\n evening: 'in the evening',\n night: 'at night'\n }\n };\n var ordinalNumber = function ordinalNumber(dirtyNumber, _options) {\n var number = Number(dirtyNumber);\n\n // If ordinal numbers depend on context, for example,\n // if they are different for different grammatical genders,\n // use `options.unit`.\n //\n // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',\n // 'day', 'hour', 'minute', 'second'.\n\n var rem100 = number % 100;\n if (rem100 > 20 || rem100 < 10) {\n switch (rem100 % 10) {\n case 1:\n return number + 'st';\n case 2:\n return number + 'nd';\n case 3:\n return number + 'rd';\n }\n }\n return number + 'th';\n };\n var localize = {\n ordinalNumber: ordinalNumber,\n era: buildLocalizeFn({\n values: eraValues,\n defaultWidth: 'wide'\n }),\n quarter: buildLocalizeFn({\n values: quarterValues,\n defaultWidth: 'wide',\n argumentCallback: function argumentCallback(quarter) {\n return quarter - 1;\n }\n }),\n month: buildLocalizeFn({\n values: monthValues,\n defaultWidth: 'wide'\n }),\n day: buildLocalizeFn({\n values: dayValues,\n defaultWidth: 'wide'\n }),\n dayPeriod: buildLocalizeFn({\n values: dayPeriodValues,\n defaultWidth: 'wide',\n formattingValues: formattingDayPeriodValues,\n defaultFormattingWidth: 'wide'\n })\n };\n var localize$1 = localize;\n\n function buildMatchFn(args) {\n return function (string) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var width = options.width;\n var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];\n var matchResult = string.match(matchPattern);\n if (!matchResult) {\n return null;\n }\n var matchedString = matchResult[0];\n var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];\n var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {\n return pattern.test(matchedString);\n }) : findKey(parsePatterns, function (pattern) {\n return pattern.test(matchedString);\n });\n var value;\n value = args.valueCallback ? args.valueCallback(key) : key;\n value = options.valueCallback ? options.valueCallback(value) : value;\n var rest = string.slice(matchedString.length);\n return {\n value: value,\n rest: rest\n };\n };\n }\n function findKey(object, predicate) {\n for (var key in object) {\n if (object.hasOwnProperty(key) && predicate(object[key])) {\n return key;\n }\n }\n return undefined;\n }\n function findIndex(array, predicate) {\n for (var key = 0; key < array.length; key++) {\n if (predicate(array[key])) {\n return key;\n }\n }\n return undefined;\n }\n\n function buildMatchPatternFn(args) {\n return function (string) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var matchResult = string.match(args.matchPattern);\n if (!matchResult) return null;\n var matchedString = matchResult[0];\n var parseResult = string.match(args.parsePattern);\n if (!parseResult) return null;\n var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];\n value = options.valueCallback ? options.valueCallback(value) : value;\n var rest = string.slice(matchedString.length);\n return {\n value: value,\n rest: rest\n };\n };\n }\n\n var matchOrdinalNumberPattern = /^(\\d+)(th|st|nd|rd)?/i;\n var parseOrdinalNumberPattern = /\\d+/i;\n var matchEraPatterns = {\n narrow: /^(b|a)/i,\n abbreviated: /^(b\\.?\\s?c\\.?|b\\.?\\s?c\\.?\\s?e\\.?|a\\.?\\s?d\\.?|c\\.?\\s?e\\.?)/i,\n wide: /^(before christ|before common era|anno domini|common era)/i\n };\n var parseEraPatterns = {\n any: [/^b/i, /^(a|c)/i]\n };\n var matchQuarterPatterns = {\n narrow: /^[1234]/i,\n abbreviated: /^q[1234]/i,\n wide: /^[1234](th|st|nd|rd)? quarter/i\n };\n var parseQuarterPatterns = {\n any: [/1/i, /2/i, /3/i, /4/i]\n };\n var matchMonthPatterns = {\n narrow: /^[jfmasond]/i,\n abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,\n wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i\n };\n var parseMonthPatterns = {\n narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],\n any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]\n };\n var matchDayPatterns = {\n narrow: /^[smtwf]/i,\n \"short\": /^(su|mo|tu|we|th|fr|sa)/i,\n abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,\n wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i\n };\n var parseDayPatterns = {\n narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],\n any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]\n };\n var matchDayPeriodPatterns = {\n narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,\n any: /^([ap]\\.?\\s?m\\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i\n };\n var parseDayPeriodPatterns = {\n any: {\n am: /^a/i,\n pm: /^p/i,\n midnight: /^mi/i,\n noon: /^no/i,\n morning: /morning/i,\n afternoon: /afternoon/i,\n evening: /evening/i,\n night: /night/i\n }\n };\n var match = {\n ordinalNumber: buildMatchPatternFn({\n matchPattern: matchOrdinalNumberPattern,\n parsePattern: parseOrdinalNumberPattern,\n valueCallback: function valueCallback(value) {\n return parseInt(value, 10);\n }\n }),\n era: buildMatchFn({\n matchPatterns: matchEraPatterns,\n defaultMatchWidth: 'wide',\n parsePatterns: parseEraPatterns,\n defaultParseWidth: 'any'\n }),\n quarter: buildMatchFn({\n matchPatterns: matchQuarterPatterns,\n defaultMatchWidth: 'wide',\n parsePatterns: parseQuarterPatterns,\n defaultParseWidth: 'any',\n valueCallback: function valueCallback(index) {\n return index + 1;\n }\n }),\n month: buildMatchFn({\n matchPatterns: matchMonthPatterns,\n defaultMatchWidth: 'wide',\n parsePatterns: parseMonthPatterns,\n defaultParseWidth: 'any'\n }),\n day: buildMatchFn({\n matchPatterns: matchDayPatterns,\n defaultMatchWidth: 'wide',\n parsePatterns: parseDayPatterns,\n defaultParseWidth: 'any'\n }),\n dayPeriod: buildMatchFn({\n matchPatterns: matchDayPeriodPatterns,\n defaultMatchWidth: 'any',\n parsePatterns: parseDayPeriodPatterns,\n defaultParseWidth: 'any'\n })\n };\n var match$1 = match;\n\n /**\n * @type {Locale}\n * @category Locales\n * @summary English locale (United States).\n * @language English\n * @iso-639-2 eng\n * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}\n * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}\n */\n var locale = {\n code: 'en-US',\n formatDistance: formatDistance$1,\n formatLong: formatLong$1,\n formatRelative: formatRelative$1,\n localize: localize$1,\n match: match$1,\n options: {\n weekStartsOn: 0 /* Sunday */,\n firstWeekContainsDate: 1\n }\n };\n var defaultLocale = locale;\n\n // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token\n // (one of the certain letters followed by `o`)\n // - (\\w)\\1* matches any sequences of the same letter\n // - '' matches two quote characters in a row\n // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),\n // except a single quote symbol, which ends the sequence.\n // Two quote characters do not end the sequence.\n // If there is no matching single quote\n // then the sequence will continue until the end of the string.\n // - . matches any single character unmatched by previous parts of the RegExps\n var formattingTokensRegExp$1 = /[yYQqMLwIdDecihHKkms]o|(\\w)\\1*|''|'(''|[^'])+('|$)|./g;\n\n // This RegExp catches symbols escaped by quotes, and also\n // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`\n var longFormattingTokensRegExp$1 = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;\n var escapedStringRegExp$1 = /^'([^]*?)'?$/;\n var doubleQuoteRegExp$1 = /''/g;\n var unescapedLatinCharacterRegExp$1 = /[a-zA-Z]/;\n\n /**\n * @name format\n * @category Common Helpers\n * @summary Format the date.\n *\n * @description\n * Return the formatted date string in the given format. The result may vary by locale.\n *\n * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.\n * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n *\n * The characters wrapped between two single quotes characters (') are escaped.\n * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.\n * (see the last example)\n *\n * Format of the string is based on Unicode Technical Standard #35:\n * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table\n * with a few additions (see note 7 below the table).\n *\n * Accepted patterns:\n * | Unit | Pattern | Result examples | Notes |\n * |---------------------------------|---------|-----------------------------------|-------|\n * | Era | G..GGG | AD, BC | |\n * | | GGGG | Anno Domini, Before Christ | 2 |\n * | | GGGGG | A, B | |\n * | Calendar year | y | 44, 1, 1900, 2017 | 5 |\n * | | yo | 44th, 1st, 0th, 17th | 5,7 |\n * | | yy | 44, 01, 00, 17 | 5 |\n * | | yyy | 044, 001, 1900, 2017 | 5 |\n * | | yyyy | 0044, 0001, 1900, 2017 | 5 |\n * | | yyyyy | ... | 3,5 |\n * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |\n * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |\n * | | YY | 44, 01, 00, 17 | 5,8 |\n * | | YYY | 044, 001, 1900, 2017 | 5 |\n * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |\n * | | YYYYY | ... | 3,5 |\n * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |\n * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |\n * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |\n * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |\n * | | RRRRR | ... | 3,5,7 |\n * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |\n * | | uu | -43, 01, 1900, 2017 | 5 |\n * | | uuu | -043, 001, 1900, 2017 | 5 |\n * | | uuuu | -0043, 0001, 1900, 2017 | 5 |\n * | | uuuuu | ... | 3,5 |\n * | Quarter (formatting) | Q | 1, 2, 3, 4 | |\n * | | Qo | 1st, 2nd, 3rd, 4th | 7 |\n * | | QQ | 01, 02, 03, 04 | |\n * | | QQQ | Q1, Q2, Q3, Q4 | |\n * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |\n * | | QQQQQ | 1, 2, 3, 4 | 4 |\n * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |\n * | | qo | 1st, 2nd, 3rd, 4th | 7 |\n * | | qq | 01, 02, 03, 04 | |\n * | | qqq | Q1, Q2, Q3, Q4 | |\n * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |\n * | | qqqqq | 1, 2, 3, 4 | 4 |\n * | Month (formatting) | M | 1, 2, ..., 12 | |\n * | | Mo | 1st, 2nd, ..., 12th | 7 |\n * | | MM | 01, 02, ..., 12 | |\n * | | MMM | Jan, Feb, ..., Dec | |\n * | | MMMM | January, February, ..., December | 2 |\n * | | MMMMM | J, F, ..., D | |\n * | Month (stand-alone) | L | 1, 2, ..., 12 | |\n * | | Lo | 1st, 2nd, ..., 12th | 7 |\n * | | LL | 01, 02, ..., 12 | |\n * | | LLL | Jan, Feb, ..., Dec | |\n * | | LLLL | January, February, ..., December | 2 |\n * | | LLLLL | J, F, ..., D | |\n * | Local week of year | w | 1, 2, ..., 53 | |\n * | | wo | 1st, 2nd, ..., 53th | 7 |\n * | | ww | 01, 02, ..., 53 | |\n * | ISO week of year | I | 1, 2, ..., 53 | 7 |\n * | | Io | 1st, 2nd, ..., 53th | 7 |\n * | | II | 01, 02, ..., 53 | 7 |\n * | Day of month | d | 1, 2, ..., 31 | |\n * | | do | 1st, 2nd, ..., 31st | 7 |\n * | | dd | 01, 02, ..., 31 | |\n * | Day of year | D | 1, 2, ..., 365, 366 | 9 |\n * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |\n * | | DD | 01, 02, ..., 365, 366 | 9 |\n * | | DDD | 001, 002, ..., 365, 366 | |\n * | | DDDD | ... | 3 |\n * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |\n * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |\n * | | EEEEE | M, T, W, T, F, S, S | |\n * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |\n * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |\n * | | io | 1st, 2nd, ..., 7th | 7 |\n * | | ii | 01, 02, ..., 07 | 7 |\n * | | iii | Mon, Tue, Wed, ..., Sun | 7 |\n * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |\n * | | iiiii | M, T, W, T, F, S, S | 7 |\n * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |\n * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |\n * | | eo | 2nd, 3rd, ..., 1st | 7 |\n * | | ee | 02, 03, ..., 01 | |\n * | | eee | Mon, Tue, Wed, ..., Sun | |\n * | | eeee | Monday, Tuesday, ..., Sunday | 2 |\n * | | eeeee | M, T, W, T, F, S, S | |\n * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |\n * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |\n * | | co | 2nd, 3rd, ..., 1st | 7 |\n * | | cc | 02, 03, ..., 01 | |\n * | | ccc | Mon, Tue, Wed, ..., Sun | |\n * | | cccc | Monday, Tuesday, ..., Sunday | 2 |\n * | | ccccc | M, T, W, T, F, S, S | |\n * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |\n * | AM, PM | a..aa | AM, PM | |\n * | | aaa | am, pm | |\n * | | aaaa | a.m., p.m. | 2 |\n * | | aaaaa | a, p | |\n * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |\n * | | bbb | am, pm, noon, midnight | |\n * | | bbbb | a.m., p.m., noon, midnight | 2 |\n * | | bbbbb | a, p, n, mi | |\n * | Flexible day period | B..BBB | at night, in the morning, ... | |\n * | | BBBB | at night, in the morning, ... | 2 |\n * | | BBBBB | at night, in the morning, ... | |\n * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |\n * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |\n * | | hh | 01, 02, ..., 11, 12 | |\n * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |\n * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |\n * | | HH | 00, 01, 02, ..., 23 | |\n * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |\n * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |\n * | | KK | 01, 02, ..., 11, 00 | |\n * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |\n * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |\n * | | kk | 24, 01, 02, ..., 23 | |\n * | Minute | m | 0, 1, ..., 59 | |\n * | | mo | 0th, 1st, ..., 59th | 7 |\n * | | mm | 00, 01, ..., 59 | |\n * | Second | s | 0, 1, ..., 59 | |\n * | | so | 0th, 1st, ..., 59th | 7 |\n * | | ss | 00, 01, ..., 59 | |\n * | Fraction of second | S | 0, 1, ..., 9 | |\n * | | SS | 00, 01, ..., 99 | |\n * | | SSS | 000, 001, ..., 999 | |\n * | | SSSS | ... | 3 |\n * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |\n * | | XX | -0800, +0530, Z | |\n * | | XXX | -08:00, +05:30, Z | |\n * | | XXXX | -0800, +0530, Z, +123456 | 2 |\n * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |\n * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |\n * | | xx | -0800, +0530, +0000 | |\n * | | xxx | -08:00, +05:30, +00:00 | 2 |\n * | | xxxx | -0800, +0530, +0000, +123456 | |\n * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |\n * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |\n * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |\n * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |\n * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |\n * | Seconds timestamp | t | 512969520 | 7 |\n * | | tt | ... | 3,7 |\n * | Milliseconds timestamp | T | 512969520900 | 7 |\n * | | TT | ... | 3,7 |\n * | Long localized date | P | 04/29/1453 | 7 |\n * | | PP | Apr 29, 1453 | 7 |\n * | | PPP | April 29th, 1453 | 7 |\n * | | PPPP | Friday, April 29th, 1453 | 2,7 |\n * | Long localized time | p | 12:00 AM | 7 |\n * | | pp | 12:00:00 AM | 7 |\n * | | ppp | 12:00:00 AM GMT+2 | 7 |\n * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |\n * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |\n * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |\n * | | PPPppp | April 29th, 1453 at ... | 7 |\n * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |\n * Notes:\n * 1. \"Formatting\" units (e.g. formatting quarter) in the default en-US locale\n * are the same as \"stand-alone\" units, but are different in some languages.\n * \"Formatting\" units are declined according to the rules of the language\n * in the context of a date. \"Stand-alone\" units are always nominative singular:\n *\n * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`\n *\n * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`\n *\n * 2. Any sequence of the identical letters is a pattern, unless it is escaped by\n * the single quote characters (see below).\n * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)\n * the output will be the same as default pattern for this unit, usually\n * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units\n * are marked with \"2\" in the last column of the table.\n *\n * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`\n *\n * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`\n *\n * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`\n *\n * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`\n *\n * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`\n *\n * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).\n * The output will be padded with zeros to match the length of the pattern.\n *\n * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`\n *\n * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.\n * These tokens represent the shortest form of the quarter.\n *\n * 5. The main difference between `y` and `u` patterns are B.C. years:\n *\n * | Year | `y` | `u` |\n * |------|-----|-----|\n * | AC 1 | 1 | 1 |\n * | BC 1 | 1 | 0 |\n * | BC 2 | 2 | -1 |\n *\n * Also `yy` always returns the last two digits of a year,\n * while `uu` pads single digit years to 2 characters and returns other years unchanged:\n *\n * | Year | `yy` | `uu` |\n * |------|------|------|\n * | 1 | 01 | 01 |\n * | 14 | 14 | 14 |\n * | 376 | 76 | 376 |\n * | 1453 | 53 | 1453 |\n *\n * The same difference is true for local and ISO week-numbering years (`Y` and `R`),\n * except local week-numbering years are dependent on `options.weekStartsOn`\n * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}\n * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).\n *\n * 6. Specific non-location timezones are currently unavailable in `date-fns`,\n * so right now these tokens fall back to GMT timezones.\n *\n * 7. These patterns are not in the Unicode Technical Standard #35:\n * - `i`: ISO day of week\n * - `I`: ISO week of year\n * - `R`: ISO week-numbering year\n * - `t`: seconds timestamp\n * - `T`: milliseconds timestamp\n * - `o`: ordinal number modifier\n * - `P`: long localized date\n * - `p`: long localized time\n *\n * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.\n * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n *\n * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.\n * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n *\n * @param {Date|Number} date - the original date\n * @param {String} format - the string of tokens\n * @param {Object} [options] - an object with options.\n * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}\n * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)\n * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is\n * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;\n * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;\n * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n * @returns {String} the formatted date string\n * @throws {TypeError} 2 arguments required\n * @throws {RangeError} `date` must not be Invalid Date\n * @throws {RangeError} `options.locale` must contain `localize` property\n * @throws {RangeError} `options.locale` must contain `formatLong` property\n * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6\n * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7\n * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n * @throws {RangeError} format string contains an unescaped latin alphabet character\n *\n * @example\n * // Represent 11 February 2014 in middle-endian format:\n * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')\n * //=> '02/11/2014'\n *\n * @example\n * // Represent 2 July 2014 in Esperanto:\n * import { eoLocale } from 'date-fns/locale/eo'\n * const result = format(new Date(2014, 6, 2), \"do 'de' MMMM yyyy\", {\n * locale: eoLocale\n * })\n * //=> '2-a de julio 2014'\n *\n * @example\n * // Escape string by single quote characters:\n * const result = format(new Date(2014, 6, 2, 15), \"h 'o''clock'\")\n * //=> \"3 o'clock\"\n */\n\n function format(dirtyDate, dirtyFormatStr, options) {\n var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4;\n requiredArgs(2, arguments);\n var formatStr = String(dirtyFormatStr);\n var defaultOptions = getDefaultOptions();\n var locale = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : defaultLocale;\n var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1);\n\n // Test if weekStartsOn is between 1 and 7 _and_ is not NaN\n if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {\n throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');\n }\n var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0);\n\n // Test if weekStartsOn is between 0 and 6 _and_ is not NaN\n if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {\n throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');\n }\n if (!locale.localize) {\n throw new RangeError('locale must contain localize property');\n }\n if (!locale.formatLong) {\n throw new RangeError('locale must contain formatLong property');\n }\n var originalDate = toDate(dirtyDate);\n if (!isValid(originalDate)) {\n throw new RangeError('Invalid time value');\n }\n\n // Convert the date in system timezone to the same date in UTC+00:00 timezone.\n // This ensures that when UTC functions will be implemented, locales will be compatible with them.\n // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376\n var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);\n var utcDate = subMilliseconds(originalDate, timezoneOffset);\n var formatterOptions = {\n firstWeekContainsDate: firstWeekContainsDate,\n weekStartsOn: weekStartsOn,\n locale: locale,\n _originalDate: originalDate\n };\n var result = formatStr.match(longFormattingTokensRegExp$1).map(function (substring) {\n var firstCharacter = substring[0];\n if (firstCharacter === 'p' || firstCharacter === 'P') {\n var longFormatter = longFormatters$1[firstCharacter];\n return longFormatter(substring, locale.formatLong);\n }\n return substring;\n }).join('').match(formattingTokensRegExp$1).map(function (substring) {\n // Replace two single quote characters with one single quote character\n if (substring === \"''\") {\n return \"'\";\n }\n var firstCharacter = substring[0];\n if (firstCharacter === \"'\") {\n return cleanEscapedString$1(substring);\n }\n var formatter = formatters$1[firstCharacter];\n if (formatter) {\n if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {\n throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));\n }\n if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {\n throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));\n }\n return formatter(utcDate, substring, locale.localize, formatterOptions);\n }\n if (firstCharacter.match(unescapedLatinCharacterRegExp$1)) {\n throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');\n }\n return substring;\n }).join('');\n return result;\n }\n function cleanEscapedString$1(input) {\n var matched = input.match(escapedStringRegExp$1);\n if (!matched) {\n return input;\n }\n return matched[1].replace(doubleQuoteRegExp$1, \"'\");\n }\n\n function assign(target, object) {\n if (target == null) {\n throw new TypeError('assign requires that input parameter not be null or undefined');\n }\n for (var property in object) {\n if (Object.prototype.hasOwnProperty.call(object, property)) {\n target[property] = object[property];\n }\n }\n return target;\n }\n\n function _arrayLikeToArray(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n return arr2;\n }\n\n function _unsupportedIterableToArray(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return _arrayLikeToArray(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(o);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);\n }\n\n function _createForOfIteratorHelper(o, allowArrayLike) {\n var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"];\n if (!it) {\n if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") {\n if (it) o = it;\n var i = 0;\n var F = function F() {};\n return {\n s: F,\n n: function n() {\n if (i >= o.length) return {\n done: true\n };\n return {\n done: false,\n value: o[i++]\n };\n },\n e: function e(_e) {\n throw _e;\n },\n f: F\n };\n }\n throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n }\n var normalCompletion = true,\n didErr = false,\n err;\n return {\n s: function s() {\n it = it.call(o);\n },\n n: function n() {\n var step = it.next();\n normalCompletion = step.done;\n return step;\n },\n e: function e(_e2) {\n didErr = true;\n err = _e2;\n },\n f: function f() {\n try {\n if (!normalCompletion && it[\"return\"] != null) it[\"return\"]();\n } finally {\n if (didErr) throw err;\n }\n }\n };\n }\n\n function _assertThisInitialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n return self;\n }\n\n function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n return _setPrototypeOf(o, p);\n }\n\n function _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n Object.defineProperty(subClass, \"prototype\", {\n writable: false\n });\n if (superClass) _setPrototypeOf(subClass, superClass);\n }\n\n function _getPrototypeOf(o) {\n _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {\n return o.__proto__ || Object.getPrototypeOf(o);\n };\n return _getPrototypeOf(o);\n }\n\n function _isNativeReflectConstruct() {\n if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n if (Reflect.construct.sham) return false;\n if (typeof Proxy === \"function\") return true;\n try {\n Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n return true;\n } catch (e) {\n return false;\n }\n }\n\n function _possibleConstructorReturn(self, call) {\n if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) {\n return call;\n } else if (call !== void 0) {\n throw new TypeError(\"Derived constructors may only return object or undefined\");\n }\n return _assertThisInitialized(self);\n }\n\n function _createSuper(Derived) {\n var hasNativeReflectConstruct = _isNativeReflectConstruct();\n return function _createSuperInternal() {\n var Super = _getPrototypeOf(Derived),\n result;\n if (hasNativeReflectConstruct) {\n var NewTarget = _getPrototypeOf(this).constructor;\n result = Reflect.construct(Super, arguments, NewTarget);\n } else {\n result = Super.apply(this, arguments);\n }\n return _possibleConstructorReturn(this, result);\n };\n }\n\n function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n }\n\n function _toPrimitive(input, hint) {\n if (_typeof(input) !== \"object\" || input === null) return input;\n var prim = input[Symbol.toPrimitive];\n if (prim !== undefined) {\n var res = prim.call(input, hint || \"default\");\n if (_typeof(res) !== \"object\") return res;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (hint === \"string\" ? String : Number)(input);\n }\n\n function _toPropertyKey(arg) {\n var key = _toPrimitive(arg, \"string\");\n return _typeof(key) === \"symbol\" ? key : String(key);\n }\n\n function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);\n }\n }\n function _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n Object.defineProperty(Constructor, \"prototype\", {\n writable: false\n });\n return Constructor;\n }\n\n function _defineProperty(obj, key, value) {\n key = _toPropertyKey(key);\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n }\n\n var TIMEZONE_UNIT_PRIORITY = 10;\n var Setter = /*#__PURE__*/function () {\n function Setter() {\n _classCallCheck(this, Setter);\n _defineProperty(this, \"priority\", void 0);\n _defineProperty(this, \"subPriority\", 0);\n }\n _createClass(Setter, [{\n key: \"validate\",\n value: function validate(_utcDate, _options) {\n return true;\n }\n }]);\n return Setter;\n }();\n var ValueSetter = /*#__PURE__*/function (_Setter) {\n _inherits(ValueSetter, _Setter);\n var _super = _createSuper(ValueSetter);\n function ValueSetter(value, validateValue, setValue, priority, subPriority) {\n var _this;\n _classCallCheck(this, ValueSetter);\n _this = _super.call(this);\n _this.value = value;\n _this.validateValue = validateValue;\n _this.setValue = setValue;\n _this.priority = priority;\n if (subPriority) {\n _this.subPriority = subPriority;\n }\n return _this;\n }\n _createClass(ValueSetter, [{\n key: \"validate\",\n value: function validate(utcDate, options) {\n return this.validateValue(utcDate, this.value, options);\n }\n }, {\n key: \"set\",\n value: function set(utcDate, flags, options) {\n return this.setValue(utcDate, flags, this.value, options);\n }\n }]);\n return ValueSetter;\n }(Setter);\n var DateToSystemTimezoneSetter = /*#__PURE__*/function (_Setter2) {\n _inherits(DateToSystemTimezoneSetter, _Setter2);\n var _super2 = _createSuper(DateToSystemTimezoneSetter);\n function DateToSystemTimezoneSetter() {\n var _this2;\n _classCallCheck(this, DateToSystemTimezoneSetter);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this2 = _super2.call.apply(_super2, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this2), \"priority\", TIMEZONE_UNIT_PRIORITY);\n _defineProperty(_assertThisInitialized(_this2), \"subPriority\", -1);\n return _this2;\n }\n _createClass(DateToSystemTimezoneSetter, [{\n key: \"set\",\n value: function set(date, flags) {\n if (flags.timestampIsSet) {\n return date;\n }\n var convertedDate = new Date(0);\n convertedDate.setFullYear(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());\n convertedDate.setHours(date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.getUTCMilliseconds());\n return convertedDate;\n }\n }]);\n return DateToSystemTimezoneSetter;\n }(Setter);\n\n var Parser = /*#__PURE__*/function () {\n function Parser() {\n _classCallCheck(this, Parser);\n _defineProperty(this, \"incompatibleTokens\", void 0);\n _defineProperty(this, \"priority\", void 0);\n _defineProperty(this, \"subPriority\", void 0);\n }\n _createClass(Parser, [{\n key: \"run\",\n value: function run(dateString, token, match, options) {\n var result = this.parse(dateString, token, match, options);\n if (!result) {\n return null;\n }\n return {\n setter: new ValueSetter(result.value, this.validate, this.set, this.priority, this.subPriority),\n rest: result.rest\n };\n }\n }, {\n key: \"validate\",\n value: function validate(_utcDate, _value, _options) {\n return true;\n }\n }]);\n return Parser;\n }();\n\n var EraParser = /*#__PURE__*/function (_Parser) {\n _inherits(EraParser, _Parser);\n var _super = _createSuper(EraParser);\n function EraParser() {\n var _this;\n _classCallCheck(this, EraParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 140);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['R', 'u', 't', 'T']);\n return _this;\n }\n _createClass(EraParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n switch (token) {\n // AD, BC\n case 'G':\n case 'GG':\n case 'GGG':\n return match.era(dateString, {\n width: 'abbreviated'\n }) || match.era(dateString, {\n width: 'narrow'\n });\n // A, B\n case 'GGGGG':\n return match.era(dateString, {\n width: 'narrow'\n });\n // Anno Domini, Before Christ\n case 'GGGG':\n default:\n return match.era(dateString, {\n width: 'wide'\n }) || match.era(dateString, {\n width: 'abbreviated'\n }) || match.era(dateString, {\n width: 'narrow'\n });\n }\n }\n }, {\n key: \"set\",\n value: function set(date, flags, value) {\n flags.era = value;\n date.setUTCFullYear(value, 0, 1);\n date.setUTCHours(0, 0, 0, 0);\n return date;\n }\n }]);\n return EraParser;\n }(Parser);\n\n var numericPatterns = {\n month: /^(1[0-2]|0?\\d)/,\n // 0 to 12\n date: /^(3[0-1]|[0-2]?\\d)/,\n // 0 to 31\n dayOfYear: /^(36[0-6]|3[0-5]\\d|[0-2]?\\d?\\d)/,\n // 0 to 366\n week: /^(5[0-3]|[0-4]?\\d)/,\n // 0 to 53\n hour23h: /^(2[0-3]|[0-1]?\\d)/,\n // 0 to 23\n hour24h: /^(2[0-4]|[0-1]?\\d)/,\n // 0 to 24\n hour11h: /^(1[0-1]|0?\\d)/,\n // 0 to 11\n hour12h: /^(1[0-2]|0?\\d)/,\n // 0 to 12\n minute: /^[0-5]?\\d/,\n // 0 to 59\n second: /^[0-5]?\\d/,\n // 0 to 59\n\n singleDigit: /^\\d/,\n // 0 to 9\n twoDigits: /^\\d{1,2}/,\n // 0 to 99\n threeDigits: /^\\d{1,3}/,\n // 0 to 999\n fourDigits: /^\\d{1,4}/,\n // 0 to 9999\n\n anyDigitsSigned: /^-?\\d+/,\n singleDigitSigned: /^-?\\d/,\n // 0 to 9, -0 to -9\n twoDigitsSigned: /^-?\\d{1,2}/,\n // 0 to 99, -0 to -99\n threeDigitsSigned: /^-?\\d{1,3}/,\n // 0 to 999, -0 to -999\n fourDigitsSigned: /^-?\\d{1,4}/ // 0 to 9999, -0 to -9999\n };\n\n var timezonePatterns = {\n basicOptionalMinutes: /^([+-])(\\d{2})(\\d{2})?|Z/,\n basic: /^([+-])(\\d{2})(\\d{2})|Z/,\n basicOptionalSeconds: /^([+-])(\\d{2})(\\d{2})((\\d{2}))?|Z/,\n extended: /^([+-])(\\d{2}):(\\d{2})|Z/,\n extendedOptionalSeconds: /^([+-])(\\d{2}):(\\d{2})(:(\\d{2}))?|Z/\n };\n\n function mapValue(parseFnResult, mapFn) {\n if (!parseFnResult) {\n return parseFnResult;\n }\n return {\n value: mapFn(parseFnResult.value),\n rest: parseFnResult.rest\n };\n }\n function parseNumericPattern(pattern, dateString) {\n var matchResult = dateString.match(pattern);\n if (!matchResult) {\n return null;\n }\n return {\n value: parseInt(matchResult[0], 10),\n rest: dateString.slice(matchResult[0].length)\n };\n }\n function parseTimezonePattern(pattern, dateString) {\n var matchResult = dateString.match(pattern);\n if (!matchResult) {\n return null;\n }\n\n // Input is 'Z'\n if (matchResult[0] === 'Z') {\n return {\n value: 0,\n rest: dateString.slice(1)\n };\n }\n var sign = matchResult[1] === '+' ? 1 : -1;\n var hours = matchResult[2] ? parseInt(matchResult[2], 10) : 0;\n var minutes = matchResult[3] ? parseInt(matchResult[3], 10) : 0;\n var seconds = matchResult[5] ? parseInt(matchResult[5], 10) : 0;\n return {\n value: sign * (hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * millisecondsInSecond),\n rest: dateString.slice(matchResult[0].length)\n };\n }\n function parseAnyDigitsSigned(dateString) {\n return parseNumericPattern(numericPatterns.anyDigitsSigned, dateString);\n }\n function parseNDigits(n, dateString) {\n switch (n) {\n case 1:\n return parseNumericPattern(numericPatterns.singleDigit, dateString);\n case 2:\n return parseNumericPattern(numericPatterns.twoDigits, dateString);\n case 3:\n return parseNumericPattern(numericPatterns.threeDigits, dateString);\n case 4:\n return parseNumericPattern(numericPatterns.fourDigits, dateString);\n default:\n return parseNumericPattern(new RegExp('^\\\\d{1,' + n + '}'), dateString);\n }\n }\n function parseNDigitsSigned(n, dateString) {\n switch (n) {\n case 1:\n return parseNumericPattern(numericPatterns.singleDigitSigned, dateString);\n case 2:\n return parseNumericPattern(numericPatterns.twoDigitsSigned, dateString);\n case 3:\n return parseNumericPattern(numericPatterns.threeDigitsSigned, dateString);\n case 4:\n return parseNumericPattern(numericPatterns.fourDigitsSigned, dateString);\n default:\n return parseNumericPattern(new RegExp('^-?\\\\d{1,' + n + '}'), dateString);\n }\n }\n function dayPeriodEnumToHours(dayPeriod) {\n switch (dayPeriod) {\n case 'morning':\n return 4;\n case 'evening':\n return 17;\n case 'pm':\n case 'noon':\n case 'afternoon':\n return 12;\n case 'am':\n case 'midnight':\n case 'night':\n default:\n return 0;\n }\n }\n function normalizeTwoDigitYear(twoDigitYear, currentYear) {\n var isCommonEra = currentYear > 0;\n // Absolute number of the current year:\n // 1 -> 1 AC\n // 0 -> 1 BC\n // -1 -> 2 BC\n var absCurrentYear = isCommonEra ? currentYear : 1 - currentYear;\n var result;\n if (absCurrentYear <= 50) {\n result = twoDigitYear || 100;\n } else {\n var rangeEnd = absCurrentYear + 50;\n var rangeEndCentury = Math.floor(rangeEnd / 100) * 100;\n var isPreviousCentury = twoDigitYear >= rangeEnd % 100;\n result = twoDigitYear + rangeEndCentury - (isPreviousCentury ? 100 : 0);\n }\n return isCommonEra ? result : 1 - result;\n }\n function isLeapYearIndex$1(year) {\n return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;\n }\n\n // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns\n // | Year | y | yy | yyy | yyyy | yyyyy |\n // |----------|-------|----|-------|-------|-------|\n // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |\n // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |\n // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |\n // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |\n // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |\n var YearParser = /*#__PURE__*/function (_Parser) {\n _inherits(YearParser, _Parser);\n var _super = _createSuper(YearParser);\n function YearParser() {\n var _this;\n _classCallCheck(this, YearParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 130);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['Y', 'R', 'u', 'w', 'I', 'i', 'e', 'c', 't', 'T']);\n return _this;\n }\n _createClass(YearParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n var valueCallback = function valueCallback(year) {\n return {\n year: year,\n isTwoDigitYear: token === 'yy'\n };\n };\n switch (token) {\n case 'y':\n return mapValue(parseNDigits(4, dateString), valueCallback);\n case 'yo':\n return mapValue(match.ordinalNumber(dateString, {\n unit: 'year'\n }), valueCallback);\n default:\n return mapValue(parseNDigits(token.length, dateString), valueCallback);\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value.isTwoDigitYear || value.year > 0;\n }\n }, {\n key: \"set\",\n value: function set(date, flags, value) {\n var currentYear = date.getUTCFullYear();\n if (value.isTwoDigitYear) {\n var normalizedTwoDigitYear = normalizeTwoDigitYear(value.year, currentYear);\n date.setUTCFullYear(normalizedTwoDigitYear, 0, 1);\n date.setUTCHours(0, 0, 0, 0);\n return date;\n }\n var year = !('era' in flags) || flags.era === 1 ? value.year : 1 - value.year;\n date.setUTCFullYear(year, 0, 1);\n date.setUTCHours(0, 0, 0, 0);\n return date;\n }\n }]);\n return YearParser;\n }(Parser);\n\n // Local week-numbering year\n var LocalWeekYearParser = /*#__PURE__*/function (_Parser) {\n _inherits(LocalWeekYearParser, _Parser);\n var _super = _createSuper(LocalWeekYearParser);\n function LocalWeekYearParser() {\n var _this;\n _classCallCheck(this, LocalWeekYearParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 130);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['y', 'R', 'u', 'Q', 'q', 'M', 'L', 'I', 'd', 'D', 'i', 't', 'T']);\n return _this;\n }\n _createClass(LocalWeekYearParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n var valueCallback = function valueCallback(year) {\n return {\n year: year,\n isTwoDigitYear: token === 'YY'\n };\n };\n switch (token) {\n case 'Y':\n return mapValue(parseNDigits(4, dateString), valueCallback);\n case 'Yo':\n return mapValue(match.ordinalNumber(dateString, {\n unit: 'year'\n }), valueCallback);\n default:\n return mapValue(parseNDigits(token.length, dateString), valueCallback);\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value.isTwoDigitYear || value.year > 0;\n }\n }, {\n key: \"set\",\n value: function set(date, flags, value, options) {\n var currentYear = getUTCWeekYear(date, options);\n if (value.isTwoDigitYear) {\n var normalizedTwoDigitYear = normalizeTwoDigitYear(value.year, currentYear);\n date.setUTCFullYear(normalizedTwoDigitYear, 0, options.firstWeekContainsDate);\n date.setUTCHours(0, 0, 0, 0);\n return startOfUTCWeek(date, options);\n }\n var year = !('era' in flags) || flags.era === 1 ? value.year : 1 - value.year;\n date.setUTCFullYear(year, 0, options.firstWeekContainsDate);\n date.setUTCHours(0, 0, 0, 0);\n return startOfUTCWeek(date, options);\n }\n }]);\n return LocalWeekYearParser;\n }(Parser);\n\n var ISOWeekYearParser = /*#__PURE__*/function (_Parser) {\n _inherits(ISOWeekYearParser, _Parser);\n var _super = _createSuper(ISOWeekYearParser);\n function ISOWeekYearParser() {\n var _this;\n _classCallCheck(this, ISOWeekYearParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 130);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['G', 'y', 'Y', 'u', 'Q', 'q', 'M', 'L', 'w', 'd', 'D', 'e', 'c', 't', 'T']);\n return _this;\n }\n _createClass(ISOWeekYearParser, [{\n key: \"parse\",\n value: function parse(dateString, token) {\n if (token === 'R') {\n return parseNDigitsSigned(4, dateString);\n }\n return parseNDigitsSigned(token.length, dateString);\n }\n }, {\n key: \"set\",\n value: function set(_date, _flags, value) {\n var firstWeekOfYear = new Date(0);\n firstWeekOfYear.setUTCFullYear(value, 0, 4);\n firstWeekOfYear.setUTCHours(0, 0, 0, 0);\n return startOfUTCISOWeek(firstWeekOfYear);\n }\n }]);\n return ISOWeekYearParser;\n }(Parser);\n\n var ExtendedYearParser = /*#__PURE__*/function (_Parser) {\n _inherits(ExtendedYearParser, _Parser);\n var _super = _createSuper(ExtendedYearParser);\n function ExtendedYearParser() {\n var _this;\n _classCallCheck(this, ExtendedYearParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 130);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['G', 'y', 'Y', 'R', 'w', 'I', 'i', 'e', 'c', 't', 'T']);\n return _this;\n }\n _createClass(ExtendedYearParser, [{\n key: \"parse\",\n value: function parse(dateString, token) {\n if (token === 'u') {\n return parseNDigitsSigned(4, dateString);\n }\n return parseNDigitsSigned(token.length, dateString);\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n date.setUTCFullYear(value, 0, 1);\n date.setUTCHours(0, 0, 0, 0);\n return date;\n }\n }]);\n return ExtendedYearParser;\n }(Parser);\n\n var QuarterParser = /*#__PURE__*/function (_Parser) {\n _inherits(QuarterParser, _Parser);\n var _super = _createSuper(QuarterParser);\n function QuarterParser() {\n var _this;\n _classCallCheck(this, QuarterParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 120);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['Y', 'R', 'q', 'M', 'L', 'w', 'I', 'd', 'D', 'i', 'e', 'c', 't', 'T']);\n return _this;\n }\n _createClass(QuarterParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n switch (token) {\n // 1, 2, 3, 4\n case 'Q':\n case 'QQ':\n // 01, 02, 03, 04\n return parseNDigits(token.length, dateString);\n // 1st, 2nd, 3rd, 4th\n case 'Qo':\n return match.ordinalNumber(dateString, {\n unit: 'quarter'\n });\n // Q1, Q2, Q3, Q4\n case 'QQQ':\n return match.quarter(dateString, {\n width: 'abbreviated',\n context: 'formatting'\n }) || match.quarter(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n // 1, 2, 3, 4 (narrow quarter; could be not numerical)\n case 'QQQQQ':\n return match.quarter(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n // 1st quarter, 2nd quarter, ...\n case 'QQQQ':\n default:\n return match.quarter(dateString, {\n width: 'wide',\n context: 'formatting'\n }) || match.quarter(dateString, {\n width: 'abbreviated',\n context: 'formatting'\n }) || match.quarter(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value >= 1 && value <= 4;\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n date.setUTCMonth((value - 1) * 3, 1);\n date.setUTCHours(0, 0, 0, 0);\n return date;\n }\n }]);\n return QuarterParser;\n }(Parser);\n\n var StandAloneQuarterParser = /*#__PURE__*/function (_Parser) {\n _inherits(StandAloneQuarterParser, _Parser);\n var _super = _createSuper(StandAloneQuarterParser);\n function StandAloneQuarterParser() {\n var _this;\n _classCallCheck(this, StandAloneQuarterParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 120);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['Y', 'R', 'Q', 'M', 'L', 'w', 'I', 'd', 'D', 'i', 'e', 'c', 't', 'T']);\n return _this;\n }\n _createClass(StandAloneQuarterParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n switch (token) {\n // 1, 2, 3, 4\n case 'q':\n case 'qq':\n // 01, 02, 03, 04\n return parseNDigits(token.length, dateString);\n // 1st, 2nd, 3rd, 4th\n case 'qo':\n return match.ordinalNumber(dateString, {\n unit: 'quarter'\n });\n // Q1, Q2, Q3, Q4\n case 'qqq':\n return match.quarter(dateString, {\n width: 'abbreviated',\n context: 'standalone'\n }) || match.quarter(dateString, {\n width: 'narrow',\n context: 'standalone'\n });\n // 1, 2, 3, 4 (narrow quarter; could be not numerical)\n case 'qqqqq':\n return match.quarter(dateString, {\n width: 'narrow',\n context: 'standalone'\n });\n // 1st quarter, 2nd quarter, ...\n case 'qqqq':\n default:\n return match.quarter(dateString, {\n width: 'wide',\n context: 'standalone'\n }) || match.quarter(dateString, {\n width: 'abbreviated',\n context: 'standalone'\n }) || match.quarter(dateString, {\n width: 'narrow',\n context: 'standalone'\n });\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value >= 1 && value <= 4;\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n date.setUTCMonth((value - 1) * 3, 1);\n date.setUTCHours(0, 0, 0, 0);\n return date;\n }\n }]);\n return StandAloneQuarterParser;\n }(Parser);\n\n var MonthParser = /*#__PURE__*/function (_Parser) {\n _inherits(MonthParser, _Parser);\n var _super = _createSuper(MonthParser);\n function MonthParser() {\n var _this;\n _classCallCheck(this, MonthParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['Y', 'R', 'q', 'Q', 'L', 'w', 'I', 'D', 'i', 'e', 'c', 't', 'T']);\n _defineProperty(_assertThisInitialized(_this), \"priority\", 110);\n return _this;\n }\n _createClass(MonthParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n var valueCallback = function valueCallback(value) {\n return value - 1;\n };\n switch (token) {\n // 1, 2, ..., 12\n case 'M':\n return mapValue(parseNumericPattern(numericPatterns.month, dateString), valueCallback);\n // 01, 02, ..., 12\n case 'MM':\n return mapValue(parseNDigits(2, dateString), valueCallback);\n // 1st, 2nd, ..., 12th\n case 'Mo':\n return mapValue(match.ordinalNumber(dateString, {\n unit: 'month'\n }), valueCallback);\n // Jan, Feb, ..., Dec\n case 'MMM':\n return match.month(dateString, {\n width: 'abbreviated',\n context: 'formatting'\n }) || match.month(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n // J, F, ..., D\n case 'MMMMM':\n return match.month(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n // January, February, ..., December\n case 'MMMM':\n default:\n return match.month(dateString, {\n width: 'wide',\n context: 'formatting'\n }) || match.month(dateString, {\n width: 'abbreviated',\n context: 'formatting'\n }) || match.month(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value >= 0 && value <= 11;\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n date.setUTCMonth(value, 1);\n date.setUTCHours(0, 0, 0, 0);\n return date;\n }\n }]);\n return MonthParser;\n }(Parser);\n\n var StandAloneMonthParser = /*#__PURE__*/function (_Parser) {\n _inherits(StandAloneMonthParser, _Parser);\n var _super = _createSuper(StandAloneMonthParser);\n function StandAloneMonthParser() {\n var _this;\n _classCallCheck(this, StandAloneMonthParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 110);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['Y', 'R', 'q', 'Q', 'M', 'w', 'I', 'D', 'i', 'e', 'c', 't', 'T']);\n return _this;\n }\n _createClass(StandAloneMonthParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n var valueCallback = function valueCallback(value) {\n return value - 1;\n };\n switch (token) {\n // 1, 2, ..., 12\n case 'L':\n return mapValue(parseNumericPattern(numericPatterns.month, dateString), valueCallback);\n // 01, 02, ..., 12\n case 'LL':\n return mapValue(parseNDigits(2, dateString), valueCallback);\n // 1st, 2nd, ..., 12th\n case 'Lo':\n return mapValue(match.ordinalNumber(dateString, {\n unit: 'month'\n }), valueCallback);\n // Jan, Feb, ..., Dec\n case 'LLL':\n return match.month(dateString, {\n width: 'abbreviated',\n context: 'standalone'\n }) || match.month(dateString, {\n width: 'narrow',\n context: 'standalone'\n });\n // J, F, ..., D\n case 'LLLLL':\n return match.month(dateString, {\n width: 'narrow',\n context: 'standalone'\n });\n // January, February, ..., December\n case 'LLLL':\n default:\n return match.month(dateString, {\n width: 'wide',\n context: 'standalone'\n }) || match.month(dateString, {\n width: 'abbreviated',\n context: 'standalone'\n }) || match.month(dateString, {\n width: 'narrow',\n context: 'standalone'\n });\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value >= 0 && value <= 11;\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n date.setUTCMonth(value, 1);\n date.setUTCHours(0, 0, 0, 0);\n return date;\n }\n }]);\n return StandAloneMonthParser;\n }(Parser);\n\n function setUTCWeek(dirtyDate, dirtyWeek, options) {\n requiredArgs(2, arguments);\n var date = toDate(dirtyDate);\n var week = toInteger(dirtyWeek);\n var diff = getUTCWeek(date, options) - week;\n date.setUTCDate(date.getUTCDate() - diff * 7);\n return date;\n }\n\n var LocalWeekParser = /*#__PURE__*/function (_Parser) {\n _inherits(LocalWeekParser, _Parser);\n var _super = _createSuper(LocalWeekParser);\n function LocalWeekParser() {\n var _this;\n _classCallCheck(this, LocalWeekParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 100);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['y', 'R', 'u', 'q', 'Q', 'M', 'L', 'I', 'd', 'D', 'i', 't', 'T']);\n return _this;\n }\n _createClass(LocalWeekParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n switch (token) {\n case 'w':\n return parseNumericPattern(numericPatterns.week, dateString);\n case 'wo':\n return match.ordinalNumber(dateString, {\n unit: 'week'\n });\n default:\n return parseNDigits(token.length, dateString);\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value >= 1 && value <= 53;\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value, options) {\n return startOfUTCWeek(setUTCWeek(date, value, options), options);\n }\n }]);\n return LocalWeekParser;\n }(Parser);\n\n function setUTCISOWeek(dirtyDate, dirtyISOWeek) {\n requiredArgs(2, arguments);\n var date = toDate(dirtyDate);\n var isoWeek = toInteger(dirtyISOWeek);\n var diff = getUTCISOWeek(date) - isoWeek;\n date.setUTCDate(date.getUTCDate() - diff * 7);\n return date;\n }\n\n var ISOWeekParser = /*#__PURE__*/function (_Parser) {\n _inherits(ISOWeekParser, _Parser);\n var _super = _createSuper(ISOWeekParser);\n function ISOWeekParser() {\n var _this;\n _classCallCheck(this, ISOWeekParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 100);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['y', 'Y', 'u', 'q', 'Q', 'M', 'L', 'w', 'd', 'D', 'e', 'c', 't', 'T']);\n return _this;\n }\n _createClass(ISOWeekParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n switch (token) {\n case 'I':\n return parseNumericPattern(numericPatterns.week, dateString);\n case 'Io':\n return match.ordinalNumber(dateString, {\n unit: 'week'\n });\n default:\n return parseNDigits(token.length, dateString);\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value >= 1 && value <= 53;\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n return startOfUTCISOWeek(setUTCISOWeek(date, value));\n }\n }]);\n return ISOWeekParser;\n }(Parser);\n\n var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n var DAYS_IN_MONTH_LEAP_YEAR = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n\n // Day of the month\n var DateParser = /*#__PURE__*/function (_Parser) {\n _inherits(DateParser, _Parser);\n var _super = _createSuper(DateParser);\n function DateParser() {\n var _this;\n _classCallCheck(this, DateParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 90);\n _defineProperty(_assertThisInitialized(_this), \"subPriority\", 1);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['Y', 'R', 'q', 'Q', 'w', 'I', 'D', 'i', 'e', 'c', 't', 'T']);\n return _this;\n }\n _createClass(DateParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n switch (token) {\n case 'd':\n return parseNumericPattern(numericPatterns.date, dateString);\n case 'do':\n return match.ordinalNumber(dateString, {\n unit: 'date'\n });\n default:\n return parseNDigits(token.length, dateString);\n }\n }\n }, {\n key: \"validate\",\n value: function validate(date, value) {\n var year = date.getUTCFullYear();\n var isLeapYear = isLeapYearIndex$1(year);\n var month = date.getUTCMonth();\n if (isLeapYear) {\n return value >= 1 && value <= DAYS_IN_MONTH_LEAP_YEAR[month];\n } else {\n return value >= 1 && value <= DAYS_IN_MONTH[month];\n }\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n date.setUTCDate(value);\n date.setUTCHours(0, 0, 0, 0);\n return date;\n }\n }]);\n return DateParser;\n }(Parser);\n\n var DayOfYearParser = /*#__PURE__*/function (_Parser) {\n _inherits(DayOfYearParser, _Parser);\n var _super = _createSuper(DayOfYearParser);\n function DayOfYearParser() {\n var _this;\n _classCallCheck(this, DayOfYearParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 90);\n _defineProperty(_assertThisInitialized(_this), \"subpriority\", 1);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['Y', 'R', 'q', 'Q', 'M', 'L', 'w', 'I', 'd', 'E', 'i', 'e', 'c', 't', 'T']);\n return _this;\n }\n _createClass(DayOfYearParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n switch (token) {\n case 'D':\n case 'DD':\n return parseNumericPattern(numericPatterns.dayOfYear, dateString);\n case 'Do':\n return match.ordinalNumber(dateString, {\n unit: 'date'\n });\n default:\n return parseNDigits(token.length, dateString);\n }\n }\n }, {\n key: \"validate\",\n value: function validate(date, value) {\n var year = date.getUTCFullYear();\n var isLeapYear = isLeapYearIndex$1(year);\n if (isLeapYear) {\n return value >= 1 && value <= 366;\n } else {\n return value >= 1 && value <= 365;\n }\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n date.setUTCMonth(0, value);\n date.setUTCHours(0, 0, 0, 0);\n return date;\n }\n }]);\n return DayOfYearParser;\n }(Parser);\n\n function setUTCDay(dirtyDate, dirtyDay, options) {\n var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;\n requiredArgs(2, arguments);\n var defaultOptions = getDefaultOptions();\n var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);\n\n // Test if weekStartsOn is between 0 and 6 _and_ is not NaN\n if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {\n throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');\n }\n var date = toDate(dirtyDate);\n var day = toInteger(dirtyDay);\n var currentDay = date.getUTCDay();\n var remainder = day % 7;\n var dayIndex = (remainder + 7) % 7;\n var diff = (dayIndex < weekStartsOn ? 7 : 0) + day - currentDay;\n date.setUTCDate(date.getUTCDate() + diff);\n return date;\n }\n\n var DayParser = /*#__PURE__*/function (_Parser) {\n _inherits(DayParser, _Parser);\n var _super = _createSuper(DayParser);\n function DayParser() {\n var _this;\n _classCallCheck(this, DayParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 90);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['D', 'i', 'e', 'c', 't', 'T']);\n return _this;\n }\n _createClass(DayParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n switch (token) {\n // Tue\n case 'E':\n case 'EE':\n case 'EEE':\n return match.day(dateString, {\n width: 'abbreviated',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'short',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n // T\n case 'EEEEE':\n return match.day(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n // Tu\n case 'EEEEEE':\n return match.day(dateString, {\n width: 'short',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n // Tuesday\n case 'EEEE':\n default:\n return match.day(dateString, {\n width: 'wide',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'abbreviated',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'short',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value >= 0 && value <= 6;\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value, options) {\n date = setUTCDay(date, value, options);\n date.setUTCHours(0, 0, 0, 0);\n return date;\n }\n }]);\n return DayParser;\n }(Parser);\n\n var LocalDayParser = /*#__PURE__*/function (_Parser) {\n _inherits(LocalDayParser, _Parser);\n var _super = _createSuper(LocalDayParser);\n function LocalDayParser() {\n var _this;\n _classCallCheck(this, LocalDayParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 90);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['y', 'R', 'u', 'q', 'Q', 'M', 'L', 'I', 'd', 'D', 'E', 'i', 'c', 't', 'T']);\n return _this;\n }\n _createClass(LocalDayParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match, options) {\n var valueCallback = function valueCallback(value) {\n var wholeWeekDays = Math.floor((value - 1) / 7) * 7;\n return (value + options.weekStartsOn + 6) % 7 + wholeWeekDays;\n };\n switch (token) {\n // 3\n case 'e':\n case 'ee':\n // 03\n return mapValue(parseNDigits(token.length, dateString), valueCallback);\n // 3rd\n case 'eo':\n return mapValue(match.ordinalNumber(dateString, {\n unit: 'day'\n }), valueCallback);\n // Tue\n case 'eee':\n return match.day(dateString, {\n width: 'abbreviated',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'short',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n // T\n case 'eeeee':\n return match.day(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n // Tu\n case 'eeeeee':\n return match.day(dateString, {\n width: 'short',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n // Tuesday\n case 'eeee':\n default:\n return match.day(dateString, {\n width: 'wide',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'abbreviated',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'short',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value >= 0 && value <= 6;\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value, options) {\n date = setUTCDay(date, value, options);\n date.setUTCHours(0, 0, 0, 0);\n return date;\n }\n }]);\n return LocalDayParser;\n }(Parser);\n\n var StandAloneLocalDayParser = /*#__PURE__*/function (_Parser) {\n _inherits(StandAloneLocalDayParser, _Parser);\n var _super = _createSuper(StandAloneLocalDayParser);\n function StandAloneLocalDayParser() {\n var _this;\n _classCallCheck(this, StandAloneLocalDayParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 90);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['y', 'R', 'u', 'q', 'Q', 'M', 'L', 'I', 'd', 'D', 'E', 'i', 'e', 't', 'T']);\n return _this;\n }\n _createClass(StandAloneLocalDayParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match, options) {\n var valueCallback = function valueCallback(value) {\n var wholeWeekDays = Math.floor((value - 1) / 7) * 7;\n return (value + options.weekStartsOn + 6) % 7 + wholeWeekDays;\n };\n switch (token) {\n // 3\n case 'c':\n case 'cc':\n // 03\n return mapValue(parseNDigits(token.length, dateString), valueCallback);\n // 3rd\n case 'co':\n return mapValue(match.ordinalNumber(dateString, {\n unit: 'day'\n }), valueCallback);\n // Tue\n case 'ccc':\n return match.day(dateString, {\n width: 'abbreviated',\n context: 'standalone'\n }) || match.day(dateString, {\n width: 'short',\n context: 'standalone'\n }) || match.day(dateString, {\n width: 'narrow',\n context: 'standalone'\n });\n // T\n case 'ccccc':\n return match.day(dateString, {\n width: 'narrow',\n context: 'standalone'\n });\n // Tu\n case 'cccccc':\n return match.day(dateString, {\n width: 'short',\n context: 'standalone'\n }) || match.day(dateString, {\n width: 'narrow',\n context: 'standalone'\n });\n // Tuesday\n case 'cccc':\n default:\n return match.day(dateString, {\n width: 'wide',\n context: 'standalone'\n }) || match.day(dateString, {\n width: 'abbreviated',\n context: 'standalone'\n }) || match.day(dateString, {\n width: 'short',\n context: 'standalone'\n }) || match.day(dateString, {\n width: 'narrow',\n context: 'standalone'\n });\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value >= 0 && value <= 6;\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value, options) {\n date = setUTCDay(date, value, options);\n date.setUTCHours(0, 0, 0, 0);\n return date;\n }\n }]);\n return StandAloneLocalDayParser;\n }(Parser);\n\n function setUTCISODay(dirtyDate, dirtyDay) {\n requiredArgs(2, arguments);\n var day = toInteger(dirtyDay);\n if (day % 7 === 0) {\n day = day - 7;\n }\n var weekStartsOn = 1;\n var date = toDate(dirtyDate);\n var currentDay = date.getUTCDay();\n var remainder = day % 7;\n var dayIndex = (remainder + 7) % 7;\n var diff = (dayIndex < weekStartsOn ? 7 : 0) + day - currentDay;\n date.setUTCDate(date.getUTCDate() + diff);\n return date;\n }\n\n var ISODayParser = /*#__PURE__*/function (_Parser) {\n _inherits(ISODayParser, _Parser);\n var _super = _createSuper(ISODayParser);\n function ISODayParser() {\n var _this;\n _classCallCheck(this, ISODayParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 90);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['y', 'Y', 'u', 'q', 'Q', 'M', 'L', 'w', 'd', 'D', 'E', 'e', 'c', 't', 'T']);\n return _this;\n }\n _createClass(ISODayParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n var valueCallback = function valueCallback(value) {\n if (value === 0) {\n return 7;\n }\n return value;\n };\n switch (token) {\n // 2\n case 'i':\n case 'ii':\n // 02\n return parseNDigits(token.length, dateString);\n // 2nd\n case 'io':\n return match.ordinalNumber(dateString, {\n unit: 'day'\n });\n // Tue\n case 'iii':\n return mapValue(match.day(dateString, {\n width: 'abbreviated',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'short',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'narrow',\n context: 'formatting'\n }), valueCallback);\n // T\n case 'iiiii':\n return mapValue(match.day(dateString, {\n width: 'narrow',\n context: 'formatting'\n }), valueCallback);\n // Tu\n case 'iiiiii':\n return mapValue(match.day(dateString, {\n width: 'short',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'narrow',\n context: 'formatting'\n }), valueCallback);\n // Tuesday\n case 'iiii':\n default:\n return mapValue(match.day(dateString, {\n width: 'wide',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'abbreviated',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'short',\n context: 'formatting'\n }) || match.day(dateString, {\n width: 'narrow',\n context: 'formatting'\n }), valueCallback);\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value >= 1 && value <= 7;\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n date = setUTCISODay(date, value);\n date.setUTCHours(0, 0, 0, 0);\n return date;\n }\n }]);\n return ISODayParser;\n }(Parser);\n\n var AMPMParser = /*#__PURE__*/function (_Parser) {\n _inherits(AMPMParser, _Parser);\n var _super = _createSuper(AMPMParser);\n function AMPMParser() {\n var _this;\n _classCallCheck(this, AMPMParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 80);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['b', 'B', 'H', 'k', 't', 'T']);\n return _this;\n }\n _createClass(AMPMParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n switch (token) {\n case 'a':\n case 'aa':\n case 'aaa':\n return match.dayPeriod(dateString, {\n width: 'abbreviated',\n context: 'formatting'\n }) || match.dayPeriod(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n case 'aaaaa':\n return match.dayPeriod(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n case 'aaaa':\n default:\n return match.dayPeriod(dateString, {\n width: 'wide',\n context: 'formatting'\n }) || match.dayPeriod(dateString, {\n width: 'abbreviated',\n context: 'formatting'\n }) || match.dayPeriod(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n }\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n date.setUTCHours(dayPeriodEnumToHours(value), 0, 0, 0);\n return date;\n }\n }]);\n return AMPMParser;\n }(Parser);\n\n var AMPMMidnightParser = /*#__PURE__*/function (_Parser) {\n _inherits(AMPMMidnightParser, _Parser);\n var _super = _createSuper(AMPMMidnightParser);\n function AMPMMidnightParser() {\n var _this;\n _classCallCheck(this, AMPMMidnightParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 80);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['a', 'B', 'H', 'k', 't', 'T']);\n return _this;\n }\n _createClass(AMPMMidnightParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n switch (token) {\n case 'b':\n case 'bb':\n case 'bbb':\n return match.dayPeriod(dateString, {\n width: 'abbreviated',\n context: 'formatting'\n }) || match.dayPeriod(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n case 'bbbbb':\n return match.dayPeriod(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n case 'bbbb':\n default:\n return match.dayPeriod(dateString, {\n width: 'wide',\n context: 'formatting'\n }) || match.dayPeriod(dateString, {\n width: 'abbreviated',\n context: 'formatting'\n }) || match.dayPeriod(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n }\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n date.setUTCHours(dayPeriodEnumToHours(value), 0, 0, 0);\n return date;\n }\n }]);\n return AMPMMidnightParser;\n }(Parser);\n\n var DayPeriodParser = /*#__PURE__*/function (_Parser) {\n _inherits(DayPeriodParser, _Parser);\n var _super = _createSuper(DayPeriodParser);\n function DayPeriodParser() {\n var _this;\n _classCallCheck(this, DayPeriodParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 80);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['a', 'b', 't', 'T']);\n return _this;\n }\n _createClass(DayPeriodParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n switch (token) {\n case 'B':\n case 'BB':\n case 'BBB':\n return match.dayPeriod(dateString, {\n width: 'abbreviated',\n context: 'formatting'\n }) || match.dayPeriod(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n case 'BBBBB':\n return match.dayPeriod(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n case 'BBBB':\n default:\n return match.dayPeriod(dateString, {\n width: 'wide',\n context: 'formatting'\n }) || match.dayPeriod(dateString, {\n width: 'abbreviated',\n context: 'formatting'\n }) || match.dayPeriod(dateString, {\n width: 'narrow',\n context: 'formatting'\n });\n }\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n date.setUTCHours(dayPeriodEnumToHours(value), 0, 0, 0);\n return date;\n }\n }]);\n return DayPeriodParser;\n }(Parser);\n\n var Hour1to12Parser = /*#__PURE__*/function (_Parser) {\n _inherits(Hour1to12Parser, _Parser);\n var _super = _createSuper(Hour1to12Parser);\n function Hour1to12Parser() {\n var _this;\n _classCallCheck(this, Hour1to12Parser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 70);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['H', 'K', 'k', 't', 'T']);\n return _this;\n }\n _createClass(Hour1to12Parser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n switch (token) {\n case 'h':\n return parseNumericPattern(numericPatterns.hour12h, dateString);\n case 'ho':\n return match.ordinalNumber(dateString, {\n unit: 'hour'\n });\n default:\n return parseNDigits(token.length, dateString);\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value >= 1 && value <= 12;\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n var isPM = date.getUTCHours() >= 12;\n if (isPM && value < 12) {\n date.setUTCHours(value + 12, 0, 0, 0);\n } else if (!isPM && value === 12) {\n date.setUTCHours(0, 0, 0, 0);\n } else {\n date.setUTCHours(value, 0, 0, 0);\n }\n return date;\n }\n }]);\n return Hour1to12Parser;\n }(Parser);\n\n var Hour0to23Parser = /*#__PURE__*/function (_Parser) {\n _inherits(Hour0to23Parser, _Parser);\n var _super = _createSuper(Hour0to23Parser);\n function Hour0to23Parser() {\n var _this;\n _classCallCheck(this, Hour0to23Parser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 70);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['a', 'b', 'h', 'K', 'k', 't', 'T']);\n return _this;\n }\n _createClass(Hour0to23Parser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n switch (token) {\n case 'H':\n return parseNumericPattern(numericPatterns.hour23h, dateString);\n case 'Ho':\n return match.ordinalNumber(dateString, {\n unit: 'hour'\n });\n default:\n return parseNDigits(token.length, dateString);\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value >= 0 && value <= 23;\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n date.setUTCHours(value, 0, 0, 0);\n return date;\n }\n }]);\n return Hour0to23Parser;\n }(Parser);\n\n var Hour0To11Parser = /*#__PURE__*/function (_Parser) {\n _inherits(Hour0To11Parser, _Parser);\n var _super = _createSuper(Hour0To11Parser);\n function Hour0To11Parser() {\n var _this;\n _classCallCheck(this, Hour0To11Parser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 70);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['h', 'H', 'k', 't', 'T']);\n return _this;\n }\n _createClass(Hour0To11Parser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n switch (token) {\n case 'K':\n return parseNumericPattern(numericPatterns.hour11h, dateString);\n case 'Ko':\n return match.ordinalNumber(dateString, {\n unit: 'hour'\n });\n default:\n return parseNDigits(token.length, dateString);\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value >= 0 && value <= 11;\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n var isPM = date.getUTCHours() >= 12;\n if (isPM && value < 12) {\n date.setUTCHours(value + 12, 0, 0, 0);\n } else {\n date.setUTCHours(value, 0, 0, 0);\n }\n return date;\n }\n }]);\n return Hour0To11Parser;\n }(Parser);\n\n var Hour1To24Parser = /*#__PURE__*/function (_Parser) {\n _inherits(Hour1To24Parser, _Parser);\n var _super = _createSuper(Hour1To24Parser);\n function Hour1To24Parser() {\n var _this;\n _classCallCheck(this, Hour1To24Parser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 70);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['a', 'b', 'h', 'H', 'K', 't', 'T']);\n return _this;\n }\n _createClass(Hour1To24Parser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n switch (token) {\n case 'k':\n return parseNumericPattern(numericPatterns.hour24h, dateString);\n case 'ko':\n return match.ordinalNumber(dateString, {\n unit: 'hour'\n });\n default:\n return parseNDigits(token.length, dateString);\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value >= 1 && value <= 24;\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n var hours = value <= 24 ? value % 24 : value;\n date.setUTCHours(hours, 0, 0, 0);\n return date;\n }\n }]);\n return Hour1To24Parser;\n }(Parser);\n\n var MinuteParser = /*#__PURE__*/function (_Parser) {\n _inherits(MinuteParser, _Parser);\n var _super = _createSuper(MinuteParser);\n function MinuteParser() {\n var _this;\n _classCallCheck(this, MinuteParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 60);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['t', 'T']);\n return _this;\n }\n _createClass(MinuteParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n switch (token) {\n case 'm':\n return parseNumericPattern(numericPatterns.minute, dateString);\n case 'mo':\n return match.ordinalNumber(dateString, {\n unit: 'minute'\n });\n default:\n return parseNDigits(token.length, dateString);\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value >= 0 && value <= 59;\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n date.setUTCMinutes(value, 0, 0);\n return date;\n }\n }]);\n return MinuteParser;\n }(Parser);\n\n var SecondParser = /*#__PURE__*/function (_Parser) {\n _inherits(SecondParser, _Parser);\n var _super = _createSuper(SecondParser);\n function SecondParser() {\n var _this;\n _classCallCheck(this, SecondParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 50);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['t', 'T']);\n return _this;\n }\n _createClass(SecondParser, [{\n key: \"parse\",\n value: function parse(dateString, token, match) {\n switch (token) {\n case 's':\n return parseNumericPattern(numericPatterns.second, dateString);\n case 'so':\n return match.ordinalNumber(dateString, {\n unit: 'second'\n });\n default:\n return parseNDigits(token.length, dateString);\n }\n }\n }, {\n key: \"validate\",\n value: function validate(_date, value) {\n return value >= 0 && value <= 59;\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n date.setUTCSeconds(value, 0);\n return date;\n }\n }]);\n return SecondParser;\n }(Parser);\n\n var FractionOfSecondParser = /*#__PURE__*/function (_Parser) {\n _inherits(FractionOfSecondParser, _Parser);\n var _super = _createSuper(FractionOfSecondParser);\n function FractionOfSecondParser() {\n var _this;\n _classCallCheck(this, FractionOfSecondParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 30);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['t', 'T']);\n return _this;\n }\n _createClass(FractionOfSecondParser, [{\n key: \"parse\",\n value: function parse(dateString, token) {\n var valueCallback = function valueCallback(value) {\n return Math.floor(value * Math.pow(10, -token.length + 3));\n };\n return mapValue(parseNDigits(token.length, dateString), valueCallback);\n }\n }, {\n key: \"set\",\n value: function set(date, _flags, value) {\n date.setUTCMilliseconds(value);\n return date;\n }\n }]);\n return FractionOfSecondParser;\n }(Parser);\n\n var ISOTimezoneWithZParser = /*#__PURE__*/function (_Parser) {\n _inherits(ISOTimezoneWithZParser, _Parser);\n var _super = _createSuper(ISOTimezoneWithZParser);\n function ISOTimezoneWithZParser() {\n var _this;\n _classCallCheck(this, ISOTimezoneWithZParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 10);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['t', 'T', 'x']);\n return _this;\n }\n _createClass(ISOTimezoneWithZParser, [{\n key: \"parse\",\n value: function parse(dateString, token) {\n switch (token) {\n case 'X':\n return parseTimezonePattern(timezonePatterns.basicOptionalMinutes, dateString);\n case 'XX':\n return parseTimezonePattern(timezonePatterns.basic, dateString);\n case 'XXXX':\n return parseTimezonePattern(timezonePatterns.basicOptionalSeconds, dateString);\n case 'XXXXX':\n return parseTimezonePattern(timezonePatterns.extendedOptionalSeconds, dateString);\n case 'XXX':\n default:\n return parseTimezonePattern(timezonePatterns.extended, dateString);\n }\n }\n }, {\n key: \"set\",\n value: function set(date, flags, value) {\n if (flags.timestampIsSet) {\n return date;\n }\n return new Date(date.getTime() - value);\n }\n }]);\n return ISOTimezoneWithZParser;\n }(Parser);\n\n var ISOTimezoneParser = /*#__PURE__*/function (_Parser) {\n _inherits(ISOTimezoneParser, _Parser);\n var _super = _createSuper(ISOTimezoneParser);\n function ISOTimezoneParser() {\n var _this;\n _classCallCheck(this, ISOTimezoneParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 10);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", ['t', 'T', 'X']);\n return _this;\n }\n _createClass(ISOTimezoneParser, [{\n key: \"parse\",\n value: function parse(dateString, token) {\n switch (token) {\n case 'x':\n return parseTimezonePattern(timezonePatterns.basicOptionalMinutes, dateString);\n case 'xx':\n return parseTimezonePattern(timezonePatterns.basic, dateString);\n case 'xxxx':\n return parseTimezonePattern(timezonePatterns.basicOptionalSeconds, dateString);\n case 'xxxxx':\n return parseTimezonePattern(timezonePatterns.extendedOptionalSeconds, dateString);\n case 'xxx':\n default:\n return parseTimezonePattern(timezonePatterns.extended, dateString);\n }\n }\n }, {\n key: \"set\",\n value: function set(date, flags, value) {\n if (flags.timestampIsSet) {\n return date;\n }\n return new Date(date.getTime() - value);\n }\n }]);\n return ISOTimezoneParser;\n }(Parser);\n\n var TimestampSecondsParser = /*#__PURE__*/function (_Parser) {\n _inherits(TimestampSecondsParser, _Parser);\n var _super = _createSuper(TimestampSecondsParser);\n function TimestampSecondsParser() {\n var _this;\n _classCallCheck(this, TimestampSecondsParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 40);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", '*');\n return _this;\n }\n _createClass(TimestampSecondsParser, [{\n key: \"parse\",\n value: function parse(dateString) {\n return parseAnyDigitsSigned(dateString);\n }\n }, {\n key: \"set\",\n value: function set(_date, _flags, value) {\n return [new Date(value * 1000), {\n timestampIsSet: true\n }];\n }\n }]);\n return TimestampSecondsParser;\n }(Parser);\n\n var TimestampMillisecondsParser = /*#__PURE__*/function (_Parser) {\n _inherits(TimestampMillisecondsParser, _Parser);\n var _super = _createSuper(TimestampMillisecondsParser);\n function TimestampMillisecondsParser() {\n var _this;\n _classCallCheck(this, TimestampMillisecondsParser);\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n _this = _super.call.apply(_super, [this].concat(args));\n _defineProperty(_assertThisInitialized(_this), \"priority\", 20);\n _defineProperty(_assertThisInitialized(_this), \"incompatibleTokens\", '*');\n return _this;\n }\n _createClass(TimestampMillisecondsParser, [{\n key: \"parse\",\n value: function parse(dateString) {\n return parseAnyDigitsSigned(dateString);\n }\n }, {\n key: \"set\",\n value: function set(_date, _flags, value) {\n return [new Date(value), {\n timestampIsSet: true\n }];\n }\n }]);\n return TimestampMillisecondsParser;\n }(Parser);\n\n /*\n * | | Unit | | Unit |\n * |-----|--------------------------------|-----|--------------------------------|\n * | a | AM, PM | A* | Milliseconds in day |\n * | b | AM, PM, noon, midnight | B | Flexible day period |\n * | c | Stand-alone local day of week | C* | Localized hour w/ day period |\n * | d | Day of month | D | Day of year |\n * | e | Local day of week | E | Day of week |\n * | f | | F* | Day of week in month |\n * | g* | Modified Julian day | G | Era |\n * | h | Hour [1-12] | H | Hour [0-23] |\n * | i! | ISO day of week | I! | ISO week of year |\n * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |\n * | k | Hour [1-24] | K | Hour [0-11] |\n * | l* | (deprecated) | L | Stand-alone month |\n * | m | Minute | M | Month |\n * | n | | N | |\n * | o! | Ordinal number modifier | O* | Timezone (GMT) |\n * | p | | P | |\n * | q | Stand-alone quarter | Q | Quarter |\n * | r* | Related Gregorian year | R! | ISO week-numbering year |\n * | s | Second | S | Fraction of second |\n * | t! | Seconds timestamp | T! | Milliseconds timestamp |\n * | u | Extended year | U* | Cyclic year |\n * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |\n * | w | Local week of year | W* | Week of month |\n * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |\n * | y | Year (abs) | Y | Local week-numbering year |\n * | z* | Timezone (specific non-locat.) | Z* | Timezone (aliases) |\n *\n * Letters marked by * are not implemented but reserved by Unicode standard.\n *\n * Letters marked by ! are non-standard, but implemented by date-fns:\n * - `o` modifies the previous token to turn it into an ordinal (see `parse` docs)\n * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,\n * i.e. 7 for Sunday, 1 for Monday, etc.\n * - `I` is ISO week of year, as opposed to `w` which is local week of year.\n * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.\n * `R` is supposed to be used in conjunction with `I` and `i`\n * for universal ISO week-numbering date, whereas\n * `Y` is supposed to be used in conjunction with `w` and `e`\n * for week-numbering date specific to the locale.\n */\n var parsers = {\n G: new EraParser(),\n y: new YearParser(),\n Y: new LocalWeekYearParser(),\n R: new ISOWeekYearParser(),\n u: new ExtendedYearParser(),\n Q: new QuarterParser(),\n q: new StandAloneQuarterParser(),\n M: new MonthParser(),\n L: new StandAloneMonthParser(),\n w: new LocalWeekParser(),\n I: new ISOWeekParser(),\n d: new DateParser(),\n D: new DayOfYearParser(),\n E: new DayParser(),\n e: new LocalDayParser(),\n c: new StandAloneLocalDayParser(),\n i: new ISODayParser(),\n a: new AMPMParser(),\n b: new AMPMMidnightParser(),\n B: new DayPeriodParser(),\n h: new Hour1to12Parser(),\n H: new Hour0to23Parser(),\n K: new Hour0To11Parser(),\n k: new Hour1To24Parser(),\n m: new MinuteParser(),\n s: new SecondParser(),\n S: new FractionOfSecondParser(),\n X: new ISOTimezoneWithZParser(),\n x: new ISOTimezoneParser(),\n t: new TimestampSecondsParser(),\n T: new TimestampMillisecondsParser()\n };\n\n // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token\n // (one of the certain letters followed by `o`)\n // - (\\w)\\1* matches any sequences of the same letter\n // - '' matches two quote characters in a row\n // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),\n // except a single quote symbol, which ends the sequence.\n // Two quote characters do not end the sequence.\n // If there is no matching single quote\n // then the sequence will continue until the end of the string.\n // - . matches any single character unmatched by previous parts of the RegExps\n var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\\w)\\1*|''|'(''|[^'])+('|$)|./g;\n\n // This RegExp catches symbols escaped by quotes, and also\n // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`\n var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;\n var escapedStringRegExp = /^'([^]*?)'?$/;\n var doubleQuoteRegExp = /''/g;\n var notWhitespaceRegExp = /\\S/;\n var unescapedLatinCharacterRegExp = /[a-zA-Z]/;\n\n /**\n * @name parse\n * @category Common Helpers\n * @summary Parse the date.\n *\n * @description\n * Return the date parsed from string using the given format string.\n *\n * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.\n * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n *\n * The characters in the format string wrapped between two single quotes characters (') are escaped.\n * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.\n *\n * Format of the format string is based on Unicode Technical Standard #35:\n * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table\n * with a few additions (see note 5 below the table).\n *\n * Not all tokens are compatible. Combinations that don't make sense or could lead to bugs are prohibited\n * and will throw `RangeError`. For example usage of 24-hour format token with AM/PM token will throw an exception:\n *\n * ```javascript\n * parse('23 AM', 'HH a', new Date())\n * //=> RangeError: The format string mustn't contain `HH` and `a` at the same time\n * ```\n *\n * See the compatibility table: https://docs.google.com/spreadsheets/d/e/2PACX-1vQOPU3xUhplll6dyoMmVUXHKl_8CRDs6_ueLmex3SoqwhuolkuN3O05l4rqx5h1dKX8eb46Ul-CCSrq/pubhtml?gid=0&single=true\n *\n * Accepted format string patterns:\n * | Unit |Prior| Pattern | Result examples | Notes |\n * |---------------------------------|-----|---------|-----------------------------------|-------|\n * | Era | 140 | G..GGG | AD, BC | |\n * | | | GGGG | Anno Domini, Before Christ | 2 |\n * | | | GGGGG | A, B | |\n * | Calendar year | 130 | y | 44, 1, 1900, 2017, 9999 | 4 |\n * | | | yo | 44th, 1st, 1900th, 9999999th | 4,5 |\n * | | | yy | 44, 01, 00, 17 | 4 |\n * | | | yyy | 044, 001, 123, 999 | 4 |\n * | | | yyyy | 0044, 0001, 1900, 2017 | 4 |\n * | | | yyyyy | ... | 2,4 |\n * | Local week-numbering year | 130 | Y | 44, 1, 1900, 2017, 9000 | 4 |\n * | | | Yo | 44th, 1st, 1900th, 9999999th | 4,5 |\n * | | | YY | 44, 01, 00, 17 | 4,6 |\n * | | | YYY | 044, 001, 123, 999 | 4 |\n * | | | YYYY | 0044, 0001, 1900, 2017 | 4,6 |\n * | | | YYYYY | ... | 2,4 |\n * | ISO week-numbering year | 130 | R | -43, 1, 1900, 2017, 9999, -9999 | 4,5 |\n * | | | RR | -43, 01, 00, 17 | 4,5 |\n * | | | RRR | -043, 001, 123, 999, -999 | 4,5 |\n * | | | RRRR | -0043, 0001, 2017, 9999, -9999 | 4,5 |\n * | | | RRRRR | ... | 2,4,5 |\n * | Extended year | 130 | u | -43, 1, 1900, 2017, 9999, -999 | 4 |\n * | | | uu | -43, 01, 99, -99 | 4 |\n * | | | uuu | -043, 001, 123, 999, -999 | 4 |\n * | | | uuuu | -0043, 0001, 2017, 9999, -9999 | 4 |\n * | | | uuuuu | ... | 2,4 |\n * | Quarter (formatting) | 120 | Q | 1, 2, 3, 4 | |\n * | | | Qo | 1st, 2nd, 3rd, 4th | 5 |\n * | | | QQ | 01, 02, 03, 04 | |\n * | | | QQQ | Q1, Q2, Q3, Q4 | |\n * | | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |\n * | | | QQQQQ | 1, 2, 3, 4 | 4 |\n * | Quarter (stand-alone) | 120 | q | 1, 2, 3, 4 | |\n * | | | qo | 1st, 2nd, 3rd, 4th | 5 |\n * | | | qq | 01, 02, 03, 04 | |\n * | | | qqq | Q1, Q2, Q3, Q4 | |\n * | | | qqqq | 1st quarter, 2nd quarter, ... | 2 |\n * | | | qqqqq | 1, 2, 3, 4 | 3 |\n * | Month (formatting) | 110 | M | 1, 2, ..., 12 | |\n * | | | Mo | 1st, 2nd, ..., 12th | 5 |\n * | | | MM | 01, 02, ..., 12 | |\n * | | | MMM | Jan, Feb, ..., Dec | |\n * | | | MMMM | January, February, ..., December | 2 |\n * | | | MMMMM | J, F, ..., D | |\n * | Month (stand-alone) | 110 | L | 1, 2, ..., 12 | |\n * | | | Lo | 1st, 2nd, ..., 12th | 5 |\n * | | | LL | 01, 02, ..., 12 | |\n * | | | LLL | Jan, Feb, ..., Dec | |\n * | | | LLLL | January, February, ..., December | 2 |\n * | | | LLLLL | J, F, ..., D | |\n * | Local week of year | 100 | w | 1, 2, ..., 53 | |\n * | | | wo | 1st, 2nd, ..., 53th | 5 |\n * | | | ww | 01, 02, ..., 53 | |\n * | ISO week of year | 100 | I | 1, 2, ..., 53 | 5 |\n * | | | Io | 1st, 2nd, ..., 53th | 5 |\n * | | | II | 01, 02, ..., 53 | 5 |\n * | Day of month | 90 | d | 1, 2, ..., 31 | |\n * | | | do | 1st, 2nd, ..., 31st | 5 |\n * | | | dd | 01, 02, ..., 31 | |\n * | Day of year | 90 | D | 1, 2, ..., 365, 366 | 7 |\n * | | | Do | 1st, 2nd, ..., 365th, 366th | 5 |\n * | | | DD | 01, 02, ..., 365, 366 | 7 |\n * | | | DDD | 001, 002, ..., 365, 366 | |\n * | | | DDDD | ... | 2 |\n * | Day of week (formatting) | 90 | E..EEE | Mon, Tue, Wed, ..., Sun | |\n * | | | EEEE | Monday, Tuesday, ..., Sunday | 2 |\n * | | | EEEEE | M, T, W, T, F, S, S | |\n * | | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |\n * | ISO day of week (formatting) | 90 | i | 1, 2, 3, ..., 7 | 5 |\n * | | | io | 1st, 2nd, ..., 7th | 5 |\n * | | | ii | 01, 02, ..., 07 | 5 |\n * | | | iii | Mon, Tue, Wed, ..., Sun | 5 |\n * | | | iiii | Monday, Tuesday, ..., Sunday | 2,5 |\n * | | | iiiii | M, T, W, T, F, S, S | 5 |\n * | | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 5 |\n * | Local day of week (formatting) | 90 | e | 2, 3, 4, ..., 1 | |\n * | | | eo | 2nd, 3rd, ..., 1st | 5 |\n * | | | ee | 02, 03, ..., 01 | |\n * | | | eee | Mon, Tue, Wed, ..., Sun | |\n * | | | eeee | Monday, Tuesday, ..., Sunday | 2 |\n * | | | eeeee | M, T, W, T, F, S, S | |\n * | | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |\n * | Local day of week (stand-alone) | 90 | c | 2, 3, 4, ..., 1 | |\n * | | | co | 2nd, 3rd, ..., 1st | 5 |\n * | | | cc | 02, 03, ..., 01 | |\n * | | | ccc | Mon, Tue, Wed, ..., Sun | |\n * | | | cccc | Monday, Tuesday, ..., Sunday | 2 |\n * | | | ccccc | M, T, W, T, F, S, S | |\n * | | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |\n * | AM, PM | 80 | a..aaa | AM, PM | |\n * | | | aaaa | a.m., p.m. | 2 |\n * | | | aaaaa | a, p | |\n * | AM, PM, noon, midnight | 80 | b..bbb | AM, PM, noon, midnight | |\n * | | | bbbb | a.m., p.m., noon, midnight | 2 |\n * | | | bbbbb | a, p, n, mi | |\n * | Flexible day period | 80 | B..BBB | at night, in the morning, ... | |\n * | | | BBBB | at night, in the morning, ... | 2 |\n * | | | BBBBB | at night, in the morning, ... | |\n * | Hour [1-12] | 70 | h | 1, 2, ..., 11, 12 | |\n * | | | ho | 1st, 2nd, ..., 11th, 12th | 5 |\n * | | | hh | 01, 02, ..., 11, 12 | |\n * | Hour [0-23] | 70 | H | 0, 1, 2, ..., 23 | |\n * | | | Ho | 0th, 1st, 2nd, ..., 23rd | 5 |\n * | | | HH | 00, 01, 02, ..., 23 | |\n * | Hour [0-11] | 70 | K | 1, 2, ..., 11, 0 | |\n * | | | Ko | 1st, 2nd, ..., 11th, 0th | 5 |\n * | | | KK | 01, 02, ..., 11, 00 | |\n * | Hour [1-24] | 70 | k | 24, 1, 2, ..., 23 | |\n * | | | ko | 24th, 1st, 2nd, ..., 23rd | 5 |\n * | | | kk | 24, 01, 02, ..., 23 | |\n * | Minute | 60 | m | 0, 1, ..., 59 | |\n * | | | mo | 0th, 1st, ..., 59th | 5 |\n * | | | mm | 00, 01, ..., 59 | |\n * | Second | 50 | s | 0, 1, ..., 59 | |\n * | | | so | 0th, 1st, ..., 59th | 5 |\n * | | | ss | 00, 01, ..., 59 | |\n * | Seconds timestamp | 40 | t | 512969520 | |\n * | | | tt | ... | 2 |\n * | Fraction of second | 30 | S | 0, 1, ..., 9 | |\n * | | | SS | 00, 01, ..., 99 | |\n * | | | SSS | 000, 001, ..., 999 | |\n * | | | SSSS | ... | 2 |\n * | Milliseconds timestamp | 20 | T | 512969520900 | |\n * | | | TT | ... | 2 |\n * | Timezone (ISO-8601 w/ Z) | 10 | X | -08, +0530, Z | |\n * | | | XX | -0800, +0530, Z | |\n * | | | XXX | -08:00, +05:30, Z | |\n * | | | XXXX | -0800, +0530, Z, +123456 | 2 |\n * | | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |\n * | Timezone (ISO-8601 w/o Z) | 10 | x | -08, +0530, +00 | |\n * | | | xx | -0800, +0530, +0000 | |\n * | | | xxx | -08:00, +05:30, +00:00 | 2 |\n * | | | xxxx | -0800, +0530, +0000, +123456 | |\n * | | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |\n * | Long localized date | NA | P | 05/29/1453 | 5,8 |\n * | | | PP | May 29, 1453 | |\n * | | | PPP | May 29th, 1453 | |\n * | | | PPPP | Sunday, May 29th, 1453 | 2,5,8 |\n * | Long localized time | NA | p | 12:00 AM | 5,8 |\n * | | | pp | 12:00:00 AM | |\n * | Combination of date and time | NA | Pp | 05/29/1453, 12:00 AM | |\n * | | | PPpp | May 29, 1453, 12:00:00 AM | |\n * | | | PPPpp | May 29th, 1453 at ... | |\n * | | | PPPPpp | Sunday, May 29th, 1453 at ... | 2,5,8 |\n * Notes:\n * 1. \"Formatting\" units (e.g. formatting quarter) in the default en-US locale\n * are the same as \"stand-alone\" units, but are different in some languages.\n * \"Formatting\" units are declined according to the rules of the language\n * in the context of a date. \"Stand-alone\" units are always nominative singular.\n * In `format` function, they will produce different result:\n *\n * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`\n *\n * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`\n *\n * `parse` will try to match both formatting and stand-alone units interchangably.\n *\n * 2. Any sequence of the identical letters is a pattern, unless it is escaped by\n * the single quote characters (see below).\n * If the sequence is longer than listed in table:\n * - for numerical units (`yyyyyyyy`) `parse` will try to match a number\n * as wide as the sequence\n * - for text units (`MMMMMMMM`) `parse` will try to match the widest variation of the unit.\n * These variations are marked with \"2\" in the last column of the table.\n *\n * 3. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.\n * These tokens represent the shortest form of the quarter.\n *\n * 4. The main difference between `y` and `u` patterns are B.C. years:\n *\n * | Year | `y` | `u` |\n * |------|-----|-----|\n * | AC 1 | 1 | 1 |\n * | BC 1 | 1 | 0 |\n * | BC 2 | 2 | -1 |\n *\n * Also `yy` will try to guess the century of two digit year by proximity with `referenceDate`:\n *\n * `parse('50', 'yy', new Date(2018, 0, 1)) //=> Sat Jan 01 2050 00:00:00`\n *\n * `parse('75', 'yy', new Date(2018, 0, 1)) //=> Wed Jan 01 1975 00:00:00`\n *\n * while `uu` will just assign the year as is:\n *\n * `parse('50', 'uu', new Date(2018, 0, 1)) //=> Sat Jan 01 0050 00:00:00`\n *\n * `parse('75', 'uu', new Date(2018, 0, 1)) //=> Tue Jan 01 0075 00:00:00`\n *\n * The same difference is true for local and ISO week-numbering years (`Y` and `R`),\n * except local week-numbering years are dependent on `options.weekStartsOn`\n * and `options.firstWeekContainsDate` (compare [setISOWeekYear]{@link https://date-fns.org/docs/setISOWeekYear}\n * and [setWeekYear]{@link https://date-fns.org/docs/setWeekYear}).\n *\n * 5. These patterns are not in the Unicode Technical Standard #35:\n * - `i`: ISO day of week\n * - `I`: ISO week of year\n * - `R`: ISO week-numbering year\n * - `o`: ordinal number modifier\n * - `P`: long localized date\n * - `p`: long localized time\n *\n * 6. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.\n * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n *\n * 7. `D` and `DD` tokens represent days of the year but they are ofthen confused with days of the month.\n * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n *\n * 8. `P+` tokens do not have a defined priority since they are merely aliases to other tokens based\n * on the given locale.\n *\n * using `en-US` locale: `P` => `MM/dd/yyyy`\n * using `en-US` locale: `p` => `hh:mm a`\n * using `pt-BR` locale: `P` => `dd/MM/yyyy`\n * using `pt-BR` locale: `p` => `HH:mm`\n *\n * Values will be assigned to the date in the descending order of its unit's priority.\n * Units of an equal priority overwrite each other in the order of appearance.\n *\n * If no values of higher priority are parsed (e.g. when parsing string 'January 1st' without a year),\n * the values will be taken from 3rd argument `referenceDate` which works as a context of parsing.\n *\n * `referenceDate` must be passed for correct work of the function.\n * If you're not sure which `referenceDate` to supply, create a new instance of Date:\n * `parse('02/11/2014', 'MM/dd/yyyy', new Date())`\n * In this case parsing will be done in the context of the current date.\n * If `referenceDate` is `Invalid Date` or a value not convertible to valid `Date`,\n * then `Invalid Date` will be returned.\n *\n * The result may vary by locale.\n *\n * If `formatString` matches with `dateString` but does not provides tokens, `referenceDate` will be returned.\n *\n * If parsing failed, `Invalid Date` will be returned.\n * Invalid Date is a Date, whose time value is NaN.\n * Time value of Date: http://es5.github.io/#x15.9.1.1\n *\n * @param {String} dateString - the string to parse\n * @param {String} formatString - the string of tokens\n * @param {Date|Number} referenceDate - defines values missing from the parsed dateString\n * @param {Object} [options] - an object with options.\n * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}\n * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)\n * @param {1|2|3|4|5|6|7} [options.firstWeekContainsDate=1] - the day of January, which is always in the first week of the year\n * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;\n * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;\n * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n * @returns {Date} the parsed date\n * @throws {TypeError} 3 arguments required\n * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6\n * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7\n * @throws {RangeError} `options.locale` must contain `match` property\n * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md\n * @throws {RangeError} format string contains an unescaped latin alphabet character\n *\n * @example\n * // Parse 11 February 2014 from middle-endian format:\n * var result = parse('02/11/2014', 'MM/dd/yyyy', new Date())\n * //=> Tue Feb 11 2014 00:00:00\n *\n * @example\n * // Parse 28th of February in Esperanto locale in the context of 2010 year:\n * import eo from 'date-fns/locale/eo'\n * var result = parse('28-a de februaro', \"do 'de' MMMM\", new Date(2010, 0, 1), {\n * locale: eo\n * })\n * //=> Sun Feb 28 2010 00:00:00\n */\n \n function parse(dirtyDateString, dirtyFormatString, dirtyReferenceDate, options) {\n var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4;\n requiredArgs(3, arguments);\n var dateString = String(dirtyDateString);\n var formatString = String(dirtyFormatString);\n var defaultOptions = getDefaultOptions();\n var locale = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : defaultLocale;\n if (!locale.match) {\n throw new RangeError('locale must contain match property');\n }\n var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1);\n\n // Test if weekStartsOn is between 1 and 7 _and_ is not NaN\n if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {\n throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');\n }\n var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0);\n\n // Test if weekStartsOn is between 0 and 6 _and_ is not NaN\n if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {\n throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');\n }\n if (formatString === '') {\n if (dateString === '') {\n return toDate(dirtyReferenceDate);\n } else {\n return new Date(NaN);\n }\n }\n var subFnOptions = {\n firstWeekContainsDate: firstWeekContainsDate,\n weekStartsOn: weekStartsOn,\n locale: locale\n };\n\n // If timezone isn't specified, it will be set to the system timezone\n var setters = [new DateToSystemTimezoneSetter()];\n var tokens = formatString.match(longFormattingTokensRegExp).map(function (substring) {\n var firstCharacter = substring[0];\n if (firstCharacter in longFormatters$1) {\n var longFormatter = longFormatters$1[firstCharacter];\n return longFormatter(substring, locale.formatLong);\n }\n return substring;\n }).join('').match(formattingTokensRegExp);\n var usedTokens = [];\n var _iterator = _createForOfIteratorHelper(tokens),\n _step;\n try {\n var _loop = function _loop() {\n var token = _step.value;\n if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(token)) {\n throwProtectedError(token, formatString, dirtyDateString);\n }\n if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(token)) {\n throwProtectedError(token, formatString, dirtyDateString);\n }\n var firstCharacter = token[0];\n var parser = parsers[firstCharacter];\n if (parser) {\n var incompatibleTokens = parser.incompatibleTokens;\n if (Array.isArray(incompatibleTokens)) {\n var incompatibleToken = usedTokens.find(function (usedToken) {\n return incompatibleTokens.includes(usedToken.token) || usedToken.token === firstCharacter;\n });\n if (incompatibleToken) {\n throw new RangeError(\"The format string mustn't contain `\".concat(incompatibleToken.fullToken, \"` and `\").concat(token, \"` at the same time\"));\n }\n } else if (parser.incompatibleTokens === '*' && usedTokens.length > 0) {\n throw new RangeError(\"The format string mustn't contain `\".concat(token, \"` and any other token at the same time\"));\n }\n usedTokens.push({\n token: firstCharacter,\n fullToken: token\n });\n var parseResult = parser.run(dateString, token, locale.match, subFnOptions);\n if (!parseResult) {\n return {\n v: new Date(NaN)\n };\n }\n setters.push(parseResult.setter);\n dateString = parseResult.rest;\n } else {\n if (firstCharacter.match(unescapedLatinCharacterRegExp)) {\n throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');\n }\n\n // Replace two single quote characters with one single quote character\n if (token === \"''\") {\n token = \"'\";\n } else if (firstCharacter === \"'\") {\n token = cleanEscapedString(token);\n }\n\n // Cut token from string, or, if string doesn't match the token, return Invalid Date\n if (dateString.indexOf(token) === 0) {\n dateString = dateString.slice(token.length);\n } else {\n return {\n v: new Date(NaN)\n };\n }\n }\n };\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var _ret = _loop();\n if (_typeof(_ret) === \"object\") return _ret.v;\n }\n\n // Check if the remaining input contains something other than whitespace\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n if (dateString.length > 0 && notWhitespaceRegExp.test(dateString)) {\n return new Date(NaN);\n }\n var uniquePrioritySetters = setters.map(function (setter) {\n return setter.priority;\n }).sort(function (a, b) {\n return b - a;\n }).filter(function (priority, index, array) {\n return array.indexOf(priority) === index;\n }).map(function (priority) {\n return setters.filter(function (setter) {\n return setter.priority === priority;\n }).sort(function (a, b) {\n return b.subPriority - a.subPriority;\n });\n }).map(function (setterArray) {\n return setterArray[0];\n });\n var date = toDate(dirtyReferenceDate);\n if (isNaN(date.getTime())) {\n return new Date(NaN);\n }\n\n // Convert the date in system timezone to the same date in UTC+00:00 timezone.\n var utcDate = subMilliseconds(date, getTimezoneOffsetInMilliseconds(date));\n var flags = {};\n var _iterator2 = _createForOfIteratorHelper(uniquePrioritySetters),\n _step2;\n try {\n for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n var setter = _step2.value;\n if (!setter.validate(utcDate, subFnOptions)) {\n return new Date(NaN);\n }\n var result = setter.set(utcDate, flags, subFnOptions);\n // Result is tuple (date, flags)\n if (Array.isArray(result)) {\n utcDate = result[0];\n assign(flags, result[1]);\n // Result is date\n } else {\n utcDate = result;\n }\n }\n } catch (err) {\n _iterator2.e(err);\n } finally {\n _iterator2.f();\n }\n return utcDate;\n }\n function cleanEscapedString(input) {\n return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp, \"'\");\n }\n\n /**\n * @name startOfHour\n * @category Hour Helpers\n * @summary Return the start of an hour for the given date.\n *\n * @description\n * Return the start of an hour for the given date.\n * The result will be in the local timezone.\n *\n * @param {Date|Number} date - the original date\n * @returns {Date} the start of an hour\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // The start of an hour for 2 September 2014 11:55:00:\n * const result = startOfHour(new Date(2014, 8, 2, 11, 55))\n * //=> Tue Sep 02 2014 11:00:00\n */\n function startOfHour(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n date.setMinutes(0, 0, 0);\n return date;\n }\n\n /**\n * @name startOfSecond\n * @category Second Helpers\n * @summary Return the start of a second for the given date.\n *\n * @description\n * Return the start of a second for the given date.\n * The result will be in the local timezone.\n *\n * @param {Date|Number} date - the original date\n * @returns {Date} the start of a second\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // The start of a second for 1 December 2014 22:15:45.400:\n * const result = startOfSecond(new Date(2014, 11, 1, 22, 15, 45, 400))\n * //=> Mon Dec 01 2014 22:15:45.000\n */\n function startOfSecond(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n date.setMilliseconds(0);\n return date;\n }\n\n /**\n * @name parseISO\n * @category Common Helpers\n * @summary Parse ISO string\n *\n * @description\n * Parse the given string in ISO 8601 format and return an instance of Date.\n *\n * Function accepts complete ISO 8601 formats as well as partial implementations.\n * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601\n *\n * If the argument isn't a string, the function cannot parse the string or\n * the values are invalid, it returns Invalid Date.\n *\n * @param {String} argument - the value to convert\n * @param {Object} [options] - an object with options.\n * @param {0|1|2} [options.additionalDigits=2] - the additional number of digits in the extended year format\n * @returns {Date} the parsed date in the local time zone\n * @throws {TypeError} 1 argument required\n * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2\n *\n * @example\n * // Convert string '2014-02-11T11:30:30' to date:\n * const result = parseISO('2014-02-11T11:30:30')\n * //=> Tue Feb 11 2014 11:30:30\n *\n * @example\n * // Convert string '+02014101' to date,\n * // if the additional number of digits in the extended year format is 1:\n * const result = parseISO('+02014101', { additionalDigits: 1 })\n * //=> Fri Apr 11 2014 00:00:00\n */\n function parseISO(argument, options) {\n var _options$additionalDi;\n requiredArgs(1, arguments);\n var additionalDigits = toInteger((_options$additionalDi = options === null || options === void 0 ? void 0 : options.additionalDigits) !== null && _options$additionalDi !== void 0 ? _options$additionalDi : 2);\n if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) {\n throw new RangeError('additionalDigits must be 0, 1 or 2');\n }\n if (!(typeof argument === 'string' || Object.prototype.toString.call(argument) === '[object String]')) {\n return new Date(NaN);\n }\n var dateStrings = splitDateString(argument);\n var date;\n if (dateStrings.date) {\n var parseYearResult = parseYear(dateStrings.date, additionalDigits);\n date = parseDate(parseYearResult.restDateString, parseYearResult.year);\n }\n if (!date || isNaN(date.getTime())) {\n return new Date(NaN);\n }\n var timestamp = date.getTime();\n var time = 0;\n var offset;\n if (dateStrings.time) {\n time = parseTime(dateStrings.time);\n if (isNaN(time)) {\n return new Date(NaN);\n }\n }\n if (dateStrings.timezone) {\n offset = parseTimezone(dateStrings.timezone);\n if (isNaN(offset)) {\n return new Date(NaN);\n }\n } else {\n var dirtyDate = new Date(timestamp + time);\n // js parsed string assuming it's in UTC timezone\n // but we need it to be parsed in our timezone\n // so we use utc values to build date in our timezone.\n // Year values from 0 to 99 map to the years 1900 to 1999\n // so set year explicitly with setFullYear.\n var result = new Date(0);\n result.setFullYear(dirtyDate.getUTCFullYear(), dirtyDate.getUTCMonth(), dirtyDate.getUTCDate());\n result.setHours(dirtyDate.getUTCHours(), dirtyDate.getUTCMinutes(), dirtyDate.getUTCSeconds(), dirtyDate.getUTCMilliseconds());\n return result;\n }\n return new Date(timestamp + time + offset);\n }\n var patterns = {\n dateTimeDelimiter: /[T ]/,\n timeZoneDelimiter: /[Z ]/i,\n timezone: /([Z+-].*)$/\n };\n var dateRegex = /^-?(?:(\\d{3})|(\\d{2})(?:-?(\\d{2}))?|W(\\d{2})(?:-?(\\d{1}))?|)$/;\n var timeRegex = /^(\\d{2}(?:[.,]\\d*)?)(?::?(\\d{2}(?:[.,]\\d*)?))?(?::?(\\d{2}(?:[.,]\\d*)?))?$/;\n var timezoneRegex = /^([+-])(\\d{2})(?::?(\\d{2}))?$/;\n function splitDateString(dateString) {\n var dateStrings = {};\n var array = dateString.split(patterns.dateTimeDelimiter);\n var timeString;\n\n // The regex match should only return at maximum two array elements.\n // [date], [time], or [date, time].\n if (array.length > 2) {\n return dateStrings;\n }\n if (/:/.test(array[0])) {\n timeString = array[0];\n } else {\n dateStrings.date = array[0];\n timeString = array[1];\n if (patterns.timeZoneDelimiter.test(dateStrings.date)) {\n dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];\n timeString = dateString.substr(dateStrings.date.length, dateString.length);\n }\n }\n if (timeString) {\n var token = patterns.timezone.exec(timeString);\n if (token) {\n dateStrings.time = timeString.replace(token[1], '');\n dateStrings.timezone = token[1];\n } else {\n dateStrings.time = timeString;\n }\n }\n return dateStrings;\n }\n function parseYear(dateString, additionalDigits) {\n var regex = new RegExp('^(?:(\\\\d{4}|[+-]\\\\d{' + (4 + additionalDigits) + '})|(\\\\d{2}|[+-]\\\\d{' + (2 + additionalDigits) + '})$)');\n var captures = dateString.match(regex);\n // Invalid ISO-formatted year\n if (!captures) return {\n year: NaN,\n restDateString: ''\n };\n var year = captures[1] ? parseInt(captures[1]) : null;\n var century = captures[2] ? parseInt(captures[2]) : null;\n\n // either year or century is null, not both\n return {\n year: century === null ? year : century * 100,\n restDateString: dateString.slice((captures[1] || captures[2]).length)\n };\n }\n function parseDate(dateString, year) {\n // Invalid ISO-formatted year\n if (year === null) return new Date(NaN);\n var captures = dateString.match(dateRegex);\n // Invalid ISO-formatted string\n if (!captures) return new Date(NaN);\n var isWeekDate = !!captures[4];\n var dayOfYear = parseDateUnit(captures[1]);\n var month = parseDateUnit(captures[2]) - 1;\n var day = parseDateUnit(captures[3]);\n var week = parseDateUnit(captures[4]);\n var dayOfWeek = parseDateUnit(captures[5]) - 1;\n if (isWeekDate) {\n if (!validateWeekDate(year, week, dayOfWeek)) {\n return new Date(NaN);\n }\n return dayOfISOWeekYear(year, week, dayOfWeek);\n } else {\n var date = new Date(0);\n if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {\n return new Date(NaN);\n }\n date.setUTCFullYear(year, month, Math.max(dayOfYear, day));\n return date;\n }\n }\n function parseDateUnit(value) {\n return value ? parseInt(value) : 1;\n }\n function parseTime(timeString) {\n var captures = timeString.match(timeRegex);\n if (!captures) return NaN; // Invalid ISO-formatted time\n\n var hours = parseTimeUnit(captures[1]);\n var minutes = parseTimeUnit(captures[2]);\n var seconds = parseTimeUnit(captures[3]);\n if (!validateTime(hours, minutes, seconds)) {\n return NaN;\n }\n return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1000;\n }\n function parseTimeUnit(value) {\n return value && parseFloat(value.replace(',', '.')) || 0;\n }\n function parseTimezone(timezoneString) {\n if (timezoneString === 'Z') return 0;\n var captures = timezoneString.match(timezoneRegex);\n if (!captures) return 0;\n var sign = captures[1] === '+' ? -1 : 1;\n var hours = parseInt(captures[2]);\n var minutes = captures[3] && parseInt(captures[3]) || 0;\n if (!validateTimezone(hours, minutes)) {\n return NaN;\n }\n return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);\n }\n function dayOfISOWeekYear(isoWeekYear, week, day) {\n var date = new Date(0);\n date.setUTCFullYear(isoWeekYear, 0, 4);\n var fourthOfJanuaryDay = date.getUTCDay() || 7;\n var diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;\n date.setUTCDate(date.getUTCDate() + diff);\n return date;\n }\n\n // Validation functions\n\n // February is null to handle the leap year (using ||)\n var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n function isLeapYearIndex(year) {\n return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;\n }\n function validateDate(year, month, date) {\n return month >= 0 && month <= 11 && date >= 1 && date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));\n }\n function validateDayOfYearDate(year, dayOfYear) {\n return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);\n }\n function validateWeekDate(_year, week, day) {\n return week >= 1 && week <= 53 && day >= 0 && day <= 6;\n }\n function validateTime(hours, minutes, seconds) {\n if (hours === 24) {\n return minutes === 0 && seconds === 0;\n }\n return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;\n }\n function validateTimezone(_hours, minutes) {\n return minutes >= 0 && minutes <= 59;\n }\n\n var FORMATS = {\n datetime: 'MMM d, yyyy, h:mm:ss aaaa',\n millisecond: 'h:mm:ss.SSS aaaa',\n second: 'h:mm:ss aaaa',\n minute: 'h:mm aaaa',\n hour: 'ha',\n day: 'MMM d',\n week: 'PP',\n month: 'MMM yyyy',\n quarter: 'qqq - yyyy',\n year: 'yyyy'\n };\n adapters._date.override({\n _id: 'date-fns',\n // DEBUG\n\n formats: function formats() {\n return FORMATS;\n },\n parse: function parse$1(value, fmt) {\n if (value === null || typeof value === 'undefined') {\n return null;\n }\n var type = _typeof$1(value);\n if (type === 'number' || value instanceof Date) {\n value = toDate(value);\n } else if (type === 'string') {\n if (typeof fmt === 'string') {\n value = parse(value, fmt, new Date(), this.options);\n } else {\n value = parseISO(value, this.options);\n }\n }\n return isValid(value) ? value.getTime() : null;\n },\n format: function format$1(time, fmt) {\n return format(time, fmt, this.options);\n },\n add: function add(time, amount, unit) {\n switch (unit) {\n case 'millisecond':\n return addMilliseconds(time, amount);\n case 'second':\n return addSeconds(time, amount);\n case 'minute':\n return addMinutes(time, amount);\n case 'hour':\n return addHours(time, amount);\n case 'day':\n return addDays(time, amount);\n case 'week':\n return addWeeks(time, amount);\n case 'month':\n return addMonths(time, amount);\n case 'quarter':\n return addQuarters(time, amount);\n case 'year':\n return addYears(time, amount);\n default:\n return time;\n }\n },\n diff: function diff(max, min, unit) {\n switch (unit) {\n case 'millisecond':\n return differenceInMilliseconds(max, min);\n case 'second':\n return differenceInSeconds(max, min);\n case 'minute':\n return differenceInMinutes(max, min);\n case 'hour':\n return differenceInHours(max, min);\n case 'day':\n return differenceInDays(max, min);\n case 'week':\n return differenceInWeeks(max, min);\n case 'month':\n return differenceInMonths(max, min);\n case 'quarter':\n return differenceInQuarters(max, min);\n case 'year':\n return differenceInYears(max, min);\n default:\n return 0;\n }\n },\n startOf: function startOf(time, unit, weekday) {\n switch (unit) {\n case 'second':\n return startOfSecond(time);\n case 'minute':\n return startOfMinute(time);\n case 'hour':\n return startOfHour(time);\n case 'day':\n return startOfDay(time);\n case 'week':\n return startOfWeek(time);\n case 'isoWeek':\n return startOfWeek(time, {\n weekStartsOn: +weekday\n });\n case 'month':\n return startOfMonth(time);\n case 'quarter':\n return startOfQuarter(time);\n case 'year':\n return startOfYear(time);\n default:\n return time;\n }\n },\n endOf: function endOf(time, unit) {\n switch (unit) {\n case 'second':\n return endOfSecond(time);\n case 'minute':\n return endOfMinute(time);\n case 'hour':\n return endOfHour(time);\n case 'day':\n return endOfDay(time);\n case 'week':\n return endOfWeek(time);\n case 'month':\n return endOfMonth(time);\n case 'quarter':\n return endOfQuarter(time);\n case 'year':\n return endOfYear(time);\n default:\n return time;\n }\n }\n });\n\n // for plugins\n // match src/index.umd.ts in Chart.js\n // except for platforms (not exported)\n Chart.helpers = _objectSpread2({}, helpers);\n Chart._adapters = adapters;\n Chart.Animation = Animation;\n Chart.Animations = Animations;\n Chart.animator = animator;\n Chart.controllers = registry.controllers.items;\n Chart.DatasetController = DatasetController;\n Chart.Element = Element;\n Chart.elements = elements;\n Chart.Interaction = Interaction;\n Chart.layouts = layouts;\n Chart.Scale = Scale;\n Chart.Ticks = Ticks;\n Object.assign(Chart, controllers, scales, elements, plugins);\n Chart.Chart = Chart;\n\n return Chart;\n\n}));\n","// This file is automatically compiled by Webpack, along with any other files\n// present in this directory. You're encouraged to place your actual application logic in\n// a relevant structure within app/javascript and only use these pack files to reference\n// that code so it'll be compiled.\n\nrequire(\"jquery\")\nrequire(\"@nathanvda/cocoon\")\n\n//チャート追加\nimport Chart from \"./Chart.bundle\"\nwindow.Chart = Chart; // Chartをグローバルスコープにエクスポート\n\nimport \"./chartkick\"\n\nimport $ from 'jquery';\nwindow.$ = $;\nwindow.jQuery = $;\n\n\n\nimport Rails from \"@rails/ujs\"\nimport Turbolinks from \"turbolinks\"\nimport * as ActiveStorage from \"@rails/activestorage\"\nimport \"channels\"\nimport \"./slick\"\nimport \"./sliderSetting\"\n\n\nRails.start()\nTurbolinks.start()\nActiveStorage.start()\n","/*!\n * Chartkick.js v5.0.1\n * Create beautiful charts with one line of JavaScript\n * https://github.com/ankane/chartkick.js\n * MIT License\n */\n\nconsole.log(\"This is a test message(chartkick)\");\n\n(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Chartkick = factory());\n})(this, (function () { 'use strict';\n\n function isArray(variable) {\n return Object.prototype.toString.call(variable) === \"[object Array]\";\n }\n\n function isFunction(variable) {\n return variable instanceof Function;\n }\n\n function isPlainObject(variable) {\n // protect against prototype pollution, defense 2\n return Object.prototype.toString.call(variable) === \"[object Object]\" && !isFunction(variable) && variable instanceof Object;\n }\n\n // https://github.com/madrobby/zepto/blob/master/src/zepto.js\n function extend(target, source) {\n for (var key in source) {\n // protect against prototype pollution, defense 1\n if (key === \"__proto__\") { continue; }\n\n if (isPlainObject(source[key]) || isArray(source[key])) {\n if (isPlainObject(source[key]) && !isPlainObject(target[key])) {\n target[key] = {};\n }\n if (isArray(source[key]) && !isArray(target[key])) {\n target[key] = [];\n }\n extend(target[key], source[key]);\n } else if (source[key] !== undefined) {\n target[key] = source[key];\n }\n }\n }\n\n function merge(obj1, obj2) {\n var target = {};\n extend(target, obj1);\n extend(target, obj2);\n return target;\n }\n\n var DATE_PATTERN = /^(\\d\\d\\d\\d)(?:-)?(\\d\\d)(?:-)?(\\d\\d)$/i;\n\n function negativeValues(series) {\n for (var i = 0; i < series.length; i++) {\n var data = series[i].data;\n for (var j = 0; j < data.length; j++) {\n if (data[j][1] < 0) {\n return true;\n }\n }\n }\n return false;\n }\n\n function toStr(obj) {\n return \"\" + obj;\n }\n\n function toFloat(obj) {\n return parseFloat(obj);\n }\n\n function toDate(obj) {\n if (obj instanceof Date) {\n return obj;\n } else if (typeof obj === \"number\") {\n return new Date(obj * 1000); // ms\n } else {\n var s = toStr(obj);\n var matches = s.match(DATE_PATTERN);\n if (matches) {\n var year = parseInt(matches[1], 10);\n var month = parseInt(matches[2], 10) - 1;\n var day = parseInt(matches[3], 10);\n return new Date(year, month, day);\n } else {\n // try our best to get the str into iso8601\n // TODO be smarter about this\n var str = s.replace(/ /, \"T\").replace(\" \", \"\").replace(\"UTC\", \"Z\");\n // Date.parse returns milliseconds if valid and NaN if invalid\n return new Date(Date.parse(str) || s);\n }\n }\n }\n\n function toArr(obj) {\n if (isArray(obj)) {\n return obj;\n } else {\n var arr = [];\n for (var i in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, i)) {\n arr.push([i, obj[i]]);\n }\n }\n return arr;\n }\n }\n\n function jsOptionsFunc(defaultOptions, hideLegend, setTitle, setMin, setMax, setStacked, setXtitle, setYtitle) {\n return function (chart, opts, chartOptions) {\n var series = chart.data;\n var options = merge({}, defaultOptions);\n options = merge(options, chartOptions || {});\n\n if (chart.singleSeriesFormat || \"legend\" in opts) {\n hideLegend(options, opts.legend, chart.singleSeriesFormat);\n }\n\n if (opts.title) {\n setTitle(options, opts.title);\n }\n\n // min\n if (\"min\" in opts) {\n setMin(options, opts.min);\n } else if (!negativeValues(series)) {\n setMin(options, 0);\n }\n\n // max\n if (opts.max) {\n setMax(options, opts.max);\n }\n\n if (\"stacked\" in opts) {\n setStacked(options, opts.stacked);\n }\n\n if (opts.colors) {\n options.colors = opts.colors;\n }\n\n if (opts.xtitle) {\n setXtitle(options, opts.xtitle);\n }\n\n if (opts.ytitle) {\n setYtitle(options, opts.ytitle);\n }\n\n // merge library last\n options = merge(options, opts.library || {});\n\n return options;\n };\n }\n\n function sortByTime(a, b) {\n return a[0].getTime() - b[0].getTime();\n }\n\n function sortByNumberSeries(a, b) {\n return a[0] - b[0];\n }\n\n // needed since sort() without arguments does string comparison\n function sortByNumber(a, b) {\n return a - b;\n }\n\n function every(values, fn) {\n for (var i = 0; i < values.length; i++) {\n if (!fn(values[i])) {\n return false;\n }\n }\n return true;\n }\n\n function isDay(timeUnit) {\n return timeUnit === \"day\" || timeUnit === \"week\" || timeUnit === \"month\" || timeUnit === \"year\";\n }\n\n function calculateTimeUnit(values, maxDay) {\n if ( maxDay === void 0 ) maxDay = false;\n\n if (values.length === 0) {\n return null;\n }\n\n var minute = every(values, function (d) { return d.getMilliseconds() === 0 && d.getSeconds() === 0; });\n if (!minute) {\n return null;\n }\n\n var hour = every(values, function (d) { return d.getMinutes() === 0; });\n if (!hour) {\n return \"minute\";\n }\n\n var day = every(values, function (d) { return d.getHours() === 0; });\n if (!day) {\n return \"hour\";\n }\n\n if (maxDay) {\n return \"day\";\n }\n\n var month = every(values, function (d) { return d.getDate() === 1; });\n if (!month) {\n var dayOfWeek = values[0].getDay();\n var week = every(values, function (d) { return d.getDay() === dayOfWeek; });\n return (week ? \"week\" : \"day\");\n }\n\n var year = every(values, function (d) { return d.getMonth() === 0; });\n if (!year) {\n return \"month\";\n }\n\n return \"year\";\n }\n\n function isDate(obj) {\n return !isNaN(toDate(obj)) && toStr(obj).length >= 6;\n }\n\n function isNumber(obj) {\n return typeof obj === \"number\";\n }\n\n var byteSuffixes = [\"bytes\", \"KB\", \"MB\", \"GB\", \"TB\", \"PB\", \"EB\"];\n\n function formatValue(pre, value, options, axis) {\n pre = pre || \"\";\n if (options.prefix) {\n if (value < 0) {\n value = value * -1;\n pre += \"-\";\n }\n pre += options.prefix;\n }\n\n var suffix = options.suffix || \"\";\n var precision = options.precision;\n var round = options.round;\n\n if (options.byteScale) {\n var positive = value >= 0;\n if (!positive) {\n value *= -1;\n }\n\n var baseValue = axis ? options.byteScale : value;\n\n var suffixIdx;\n if (baseValue >= 1152921504606846976) {\n value /= 1152921504606846976;\n suffixIdx = 6;\n } else if (baseValue >= 1125899906842624) {\n value /= 1125899906842624;\n suffixIdx = 5;\n } else if (baseValue >= 1099511627776) {\n value /= 1099511627776;\n suffixIdx = 4;\n } else if (baseValue >= 1073741824) {\n value /= 1073741824;\n suffixIdx = 3;\n } else if (baseValue >= 1048576) {\n value /= 1048576;\n suffixIdx = 2;\n } else if (baseValue >= 1024) {\n value /= 1024;\n suffixIdx = 1;\n } else {\n suffixIdx = 0;\n }\n\n // TODO handle manual precision case\n if (precision === undefined && round === undefined) {\n if (value >= 1023.5) {\n if (suffixIdx < byteSuffixes.length - 1) {\n value = 1.0;\n suffixIdx += 1;\n }\n }\n precision = value >= 1000 ? 4 : 3;\n }\n suffix = \" \" + byteSuffixes[suffixIdx];\n\n // flip value back\n if (!positive) {\n value *= -1;\n }\n }\n\n if (precision !== undefined && round !== undefined) {\n throw Error(\"Use either round or precision, not both\");\n }\n\n if (!axis) {\n if (precision !== undefined) {\n value = value.toPrecision(precision);\n if (!options.zeros) {\n value = parseFloat(value);\n }\n }\n\n if (round !== undefined) {\n if (round < 0) {\n var num = Math.pow(10, -1 * round);\n value = parseInt((1.0 * value / num).toFixed(0)) * num;\n } else {\n value = value.toFixed(round);\n if (!options.zeros) {\n value = parseFloat(value);\n }\n }\n }\n }\n\n if (options.thousands || options.decimal) {\n value = toStr(value);\n var parts = value.split(\".\");\n value = parts[0];\n if (options.thousands) {\n value = value.replace(/\\B(?=(\\d{3})+(?!\\d))/g, options.thousands);\n }\n if (parts.length > 1) {\n value += (options.decimal || \".\") + parts[1];\n }\n }\n\n return pre + value + suffix;\n }\n\n function seriesOption(chart, series, option) {\n if (option in series) {\n return series[option];\n } else if (option in chart.options) {\n return chart.options[option];\n }\n return null;\n }\n\n var baseOptions = {\n maintainAspectRatio: false,\n animation: false,\n plugins: {\n legend: {},\n tooltip: {\n displayColors: false,\n callbacks: {}\n },\n title: {\n font: {\n size: 20\n },\n color: \"#333\"\n }\n },\n interaction: {}\n };\n\n var defaultOptions$2 = {\n scales: {\n y: {\n ticks: {\n maxTicksLimit: 4\n },\n title: {\n font: {\n size: 16\n },\n color: \"#333\"\n },\n grid: {}\n },\n x: {\n grid: {\n drawOnChartArea: false\n },\n title: {\n font: {\n size: 16\n },\n color: \"#333\"\n },\n time: {},\n ticks: {}\n }\n }\n };\n\n // http://there4.io/2012/05/02/google-chart-color-list/\n var defaultColors = [\n \"#3366CC\", \"#DC3912\", \"#FF9900\", \"#109618\", \"#990099\", \"#3B3EAC\", \"#0099C6\",\n \"#DD4477\", \"#66AA00\", \"#B82E2E\", \"#316395\", \"#994499\", \"#22AA99\", \"#AAAA11\",\n \"#6633CC\", \"#E67300\", \"#8B0707\", \"#329262\", \"#5574A6\", \"#651067\"\n ];\n\n function hideLegend$2(options, legend, hideLegend) {\n if (legend !== undefined) {\n options.plugins.legend.display = !!legend;\n if (legend && legend !== true) {\n options.plugins.legend.position = legend;\n }\n } else if (hideLegend) {\n options.plugins.legend.display = false;\n }\n }\n\n function setTitle$2(options, title) {\n options.plugins.title.display = true;\n options.plugins.title.text = title;\n }\n\n function setMin$2(options, min) {\n if (min !== null) {\n options.scales.y.min = toFloat(min);\n }\n }\n\n function setMax$2(options, max) {\n options.scales.y.max = toFloat(max);\n }\n\n function setBarMin$1(options, min) {\n if (min !== null) {\n options.scales.x.min = toFloat(min);\n }\n }\n\n function setBarMax$1(options, max) {\n options.scales.x.max = toFloat(max);\n }\n\n function setStacked$2(options, stacked) {\n options.scales.x.stacked = !!stacked;\n options.scales.y.stacked = !!stacked;\n }\n\n function setXtitle$2(options, title) {\n options.scales.x.title.display = true;\n options.scales.x.title.text = title;\n }\n\n function setYtitle$2(options, title) {\n options.scales.y.title.display = true;\n options.scales.y.title.text = title;\n }\n\n // https://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb\n function addOpacity(hex, opacity) {\n var result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n return result ? \"rgba(\" + parseInt(result[1], 16) + \", \" + parseInt(result[2], 16) + \", \" + parseInt(result[3], 16) + \", \" + opacity + \")\" : hex;\n }\n\n function notnull(x) {\n return x !== null && x !== undefined;\n }\n\n function setLabelSize(chart, data, options) {\n var maxLabelSize = Math.ceil(chart.element.offsetWidth / 4.0 / data.labels.length);\n if (maxLabelSize > 25) {\n maxLabelSize = 25;\n } else if (maxLabelSize < 10) {\n maxLabelSize = 10;\n }\n if (!options.scales.x.ticks.callback) {\n options.scales.x.ticks.callback = function (value) {\n value = toStr(this.getLabelForValue(value));\n if (value.length > maxLabelSize) {\n return value.substring(0, maxLabelSize - 2) + \"...\";\n } else {\n return value;\n }\n };\n }\n }\n\n function calculateScale(series) {\n var scale = 1;\n var max = maxAbsY(series);\n while (max >= 1024) {\n scale *= 1024;\n max /= 1024;\n }\n return scale;\n }\n\n function setFormatOptions$1(chart, options, chartType) {\n // options to apply to x and r values for scatter and bubble\n var numericOptions = {\n thousands: chart.options.thousands,\n decimal: chart.options.decimal\n };\n\n // options to apply to y value\n var formatOptions = merge({\n prefix: chart.options.prefix,\n suffix: chart.options.suffix,\n precision: chart.options.precision,\n round: chart.options.round,\n zeros: chart.options.zeros\n }, numericOptions);\n\n if (chart.options.bytes) {\n var series = chart.data;\n if (chartType === \"pie\") {\n series = [{data: series}];\n }\n\n // set step size\n formatOptions.byteScale = calculateScale(series);\n }\n\n if (chartType !== \"pie\") {\n var axis = options.scales.y;\n if (chartType === \"bar\") {\n axis = options.scales.x;\n }\n\n if (formatOptions.byteScale) {\n if (!axis.ticks.stepSize) {\n axis.ticks.stepSize = formatOptions.byteScale / 2;\n }\n if (!axis.ticks.maxTicksLimit) {\n axis.ticks.maxTicksLimit = 4;\n }\n }\n\n if (!axis.ticks.callback) {\n axis.ticks.callback = function (value) {\n return formatValue(\"\", value, formatOptions, true);\n };\n }\n\n if ((chartType === \"scatter\" || chartType === \"bubble\") && !options.scales.x.ticks.callback) {\n options.scales.x.ticks.callback = function (value) {\n return formatValue(\"\", value, numericOptions, true);\n };\n }\n }\n\n if (!options.plugins.tooltip.callbacks.label) {\n if (chartType === \"scatter\") {\n options.plugins.tooltip.callbacks.label = function (context) {\n var label = context.dataset.label || '';\n if (label) {\n label += ': ';\n }\n\n var dataPoint = context.parsed;\n return label + '(' + formatValue('', dataPoint.x, numericOptions) + ', ' + formatValue('', dataPoint.y, formatOptions) + ')';\n };\n } else if (chartType === \"bubble\") {\n options.plugins.tooltip.callbacks.label = function (context) {\n var label = context.dataset.label || '';\n if (label) {\n label += ': ';\n }\n var dataPoint = context.raw;\n return label + '(' + formatValue('', dataPoint.x, numericOptions) + ', ' + formatValue('', dataPoint.y, formatOptions) + ', ' + formatValue('', dataPoint.v, numericOptions) + ')';\n };\n } else if (chartType === \"pie\") {\n // need to use separate label for pie charts\n options.plugins.tooltip.callbacks.label = function (context) {\n return formatValue('', context.parsed, formatOptions);\n };\n } else {\n var valueLabel = chartType === \"bar\" ? \"x\" : \"y\";\n options.plugins.tooltip.callbacks.label = function (context) {\n // don't show null values for stacked charts\n if (context.parsed[valueLabel] === null) {\n return;\n }\n\n var label = context.dataset.label || '';\n if (label) {\n label += ': ';\n }\n return formatValue(label, context.parsed[valueLabel], formatOptions);\n };\n }\n }\n\n // avoid formatting x-axis labels\n // by default, Chart.js applies locale\n if ((chartType === \"line\" || chartType === \"area\") && chart.xtype === \"number\") {\n if (!options.scales.x.ticks.callback) {\n options.scales.x.ticks.callback = function (value) {\n return toStr(value);\n };\n }\n\n if (!options.plugins.tooltip.callbacks.title) {\n options.plugins.tooltip.callbacks.title = function (context) {\n return toStr(context[0].parsed.x);\n };\n }\n }\n }\n\n function maxAbsY(series) {\n var max = 0;\n for (var i = 0; i < series.length; i++) {\n var data = series[i].data;\n for (var j = 0; j < data.length; j++) {\n var v = Math.abs(data[j][1]);\n if (v > max) {\n max = v;\n }\n }\n }\n return max;\n }\n\n function maxR(series) {\n // start at zero since radius must be positive\n var max = 0;\n for (var i = 0; i < series.length; i++) {\n var data = series[i].data;\n for (var j = 0; j < data.length; j++) {\n var v = data[j][2];\n if (v > max) {\n max = v;\n }\n }\n }\n return max;\n }\n\n var jsOptions$2 = jsOptionsFunc(merge(baseOptions, defaultOptions$2), hideLegend$2, setTitle$2, setMin$2, setMax$2, setStacked$2, setXtitle$2, setYtitle$2);\n\n function prepareDefaultData(chart) {\n var series = chart.data;\n var rows = {};\n var keys = [];\n var labels = [];\n var values = [];\n\n for (var i = 0; i < series.length; i++) {\n var data = series[i].data;\n\n for (var j = 0; j < data.length; j++) {\n var d = data[j];\n var key = chart.xtype === \"datetime\" ? d[0].getTime() : d[0];\n if (!rows[key]) {\n rows[key] = new Array(series.length);\n keys.push(key);\n }\n rows[key][i] = d[1];\n }\n }\n\n if (chart.xtype === \"datetime\" || chart.xtype === \"number\") {\n keys.sort(sortByNumber);\n }\n\n for (var i$1 = 0; i$1 < series.length; i$1++) {\n values.push([]);\n }\n\n for (var i$2 = 0; i$2 < keys.length; i$2++) {\n var key$1 = keys[i$2];\n\n var label = chart.xtype === \"datetime\" ? new Date(key$1) : key$1;\n labels.push(label);\n\n var row = rows[key$1];\n for (var j$1 = 0; j$1 < series.length; j$1++) {\n var v = row[j$1];\n // Chart.js doesn't like undefined\n values[j$1].push(v === undefined ? null : v);\n }\n }\n\n return {\n labels: labels,\n values: values\n };\n }\n\n function prepareBubbleData(chart) {\n var series = chart.data;\n var values = [];\n var max = maxR(series);\n\n for (var i = 0; i < series.length; i++) {\n var data = series[i].data;\n var points = [];\n for (var j = 0; j < data.length; j++) {\n var v = data[j];\n points.push({\n x: v[0],\n y: v[1],\n r: v[2] * 20 / max,\n // custom attribute, for tooltip\n v: v[2]\n });\n }\n values.push(points);\n }\n\n return {\n labels: [],\n values: values\n };\n }\n\n // scatter or numeric line/area\n function prepareNumberData(chart) {\n var series = chart.data;\n var values = [];\n\n for (var i = 0; i < series.length; i++) {\n var data = series[i].data;\n\n data.sort(sortByNumberSeries);\n\n var points = [];\n for (var j = 0; j < data.length; j++) {\n var v = data[j];\n points.push({\n x: v[0],\n y: v[1]\n });\n }\n values.push(points);\n }\n\n return {\n labels: [],\n values: values\n };\n }\n\n function prepareData(chart, chartType) {\n if (chartType === \"bubble\") {\n return prepareBubbleData(chart);\n } else if (chart.xtype === \"number\" && chartType !== \"bar\" && chartType !== \"column\") {\n return prepareNumberData(chart);\n } else {\n return prepareDefaultData(chart);\n }\n }\n\n function createDataTable(chart, options, chartType) {\n var ref = prepareData(chart, chartType);\n var labels = ref.labels;\n var values = ref.values;\n\n var series = chart.data;\n var datasets = [];\n var colors = chart.options.colors || defaultColors;\n for (var i = 0; i < series.length; i++) {\n var s = series[i];\n\n // use colors for each bar for single series format\n var color = (void 0);\n var backgroundColor = (void 0);\n if (chart.options.colors && chart.singleSeriesFormat && (chartType === \"bar\" || chartType === \"column\") && !s.color && isArray(chart.options.colors) && !isArray(chart.options.colors[0])) {\n color = colors;\n backgroundColor = [];\n for (var j = 0; j < colors.length; j++) {\n backgroundColor[j] = addOpacity(color[j], 0.5);\n }\n } else {\n color = s.color || colors[i];\n backgroundColor = chartType !== \"line\" ? addOpacity(color, 0.5) : color;\n }\n\n var dataset = {\n label: s.name || \"\",\n data: values[i],\n fill: chartType === \"area\",\n borderColor: color,\n backgroundColor: backgroundColor,\n borderWidth: 2\n };\n\n var pointChart = chartType === \"line\" || chartType === \"area\" || chartType === \"scatter\" || chartType === \"bubble\";\n if (pointChart) {\n dataset.pointBackgroundColor = color;\n dataset.pointHoverBackgroundColor = color;\n dataset.pointHitRadius = 50;\n }\n\n if (chartType === \"bubble\") {\n dataset.pointBackgroundColor = backgroundColor;\n dataset.pointHoverBackgroundColor = backgroundColor;\n dataset.pointHoverBorderWidth = 2;\n }\n\n if (s.stack) {\n dataset.stack = s.stack;\n }\n\n var curve = seriesOption(chart, s, \"curve\");\n if (curve === false) {\n dataset.tension = 0;\n } else if (pointChart) {\n dataset.tension = 0.4;\n }\n\n var points = seriesOption(chart, s, \"points\");\n if (points === false) {\n dataset.pointRadius = 0;\n dataset.pointHoverRadius = 0;\n }\n\n dataset = merge(dataset, chart.options.dataset || {});\n dataset = merge(dataset, s.library || {});\n dataset = merge(dataset, s.dataset || {});\n\n datasets.push(dataset);\n }\n\n var xmin = chart.options.xmin;\n var xmax = chart.options.xmax;\n\n if (chart.xtype === \"datetime\") {\n if (notnull(xmin)) {\n options.scales.x.min = toDate(xmin).getTime();\n }\n if (notnull(xmax)) {\n options.scales.x.max = toDate(xmax).getTime();\n }\n } else if (chart.xtype === \"number\") {\n if (notnull(xmin)) {\n options.scales.x.min = xmin;\n }\n if (notnull(xmax)) {\n options.scales.x.max = xmax;\n }\n }\n\n if (chart.xtype === \"datetime\") {\n var timeUnit = calculateTimeUnit(labels);\n\n // for empty datetime chart\n if (labels.length === 0) {\n if (notnull(xmin)) {\n labels.push(toDate(xmin));\n }\n if (notnull(xmax)) {\n labels.push(toDate(xmax));\n }\n }\n\n if (labels.length > 0) {\n var minTime = (notnull(xmin) ? toDate(xmin) : labels[0]).getTime();\n var maxTime = (notnull(xmax) ? toDate(xmax) : labels[0]).getTime();\n\n for (var i$1 = 1; i$1 < labels.length; i$1++) {\n var value = labels[i$1].getTime();\n if (value < minTime) {\n minTime = value;\n }\n if (value > maxTime) {\n maxTime = value;\n }\n }\n\n var timeDiff = (maxTime - minTime) / (86400 * 1000.0);\n\n if (!options.scales.x.time.unit) {\n var step;\n if (timeUnit === \"year\" || timeDiff > 365 * 10) {\n options.scales.x.time.unit = \"year\";\n step = 365;\n } else if (timeUnit === \"month\" || timeDiff > 30 * 10) {\n options.scales.x.time.unit = \"month\";\n step = 30;\n } else if (timeUnit === \"week\" || timeUnit === \"day\" || timeDiff > 10) {\n options.scales.x.time.unit = \"day\";\n step = 1;\n } else if (timeUnit === \"hour\" || timeDiff > 0.5) {\n options.scales.x.time.displayFormats = {hour: \"MMM d, h a\"};\n options.scales.x.time.unit = \"hour\";\n step = 1 / 24.0;\n } else if (timeUnit === \"minute\") {\n options.scales.x.time.displayFormats = {minute: \"h:mm a\"};\n options.scales.x.time.unit = \"minute\";\n step = 1 / 24.0 / 60.0;\n }\n\n if (step && timeDiff > 0) {\n // width not available for hidden elements\n var width = chart.element.offsetWidth;\n if (width > 0) {\n var unitStepSize = Math.ceil(timeDiff / step / (width / 100.0));\n if (timeUnit === \"week\" && step === 1) {\n unitStepSize = Math.ceil(unitStepSize / 7.0) * 7;\n }\n options.scales.x.ticks.stepSize = unitStepSize;\n }\n }\n }\n\n if (!options.scales.x.time.tooltipFormat) {\n if (timeUnit === \"year\") {\n options.scales.x.time.tooltipFormat = \"yyyy\";\n } else if (timeUnit === \"month\") {\n options.scales.x.time.tooltipFormat = \"MMM yyyy\";\n } else if (timeUnit === \"week\" || timeUnit === \"day\") {\n options.scales.x.time.tooltipFormat = \"PP\";\n } else if (timeUnit === \"hour\") {\n options.scales.x.time.tooltipFormat = \"MMM d, h a\";\n } else if (timeUnit === \"minute\") {\n options.scales.x.time.tooltipFormat = \"h:mm a\";\n }\n }\n }\n }\n\n return {\n labels: labels,\n datasets: datasets\n };\n }\n\n var defaultExport$2 = function defaultExport(library) {\n this.name = \"chartjs\";\n this.library = library;\n };\n\n defaultExport$2.prototype.renderLineChart = function renderLineChart (chart, chartType) {\n if (!chartType) {\n chartType = \"line\";\n }\n\n var chartOptions = {};\n\n var options = jsOptions$2(chart, merge(chartOptions, chart.options));\n setFormatOptions$1(chart, options, chartType);\n\n var data = createDataTable(chart, options, chartType);\n\n if (chart.xtype === \"number\") {\n options.scales.x.type = options.scales.x.type || \"linear\";\n options.scales.x.position = options.scales.x.position || \"bottom\";\n } else {\n options.scales.x.type = chart.xtype === \"string\" ? \"category\" : \"time\";\n }\n\n this.drawChart(chart, \"line\", data, options);\n };\n\n defaultExport$2.prototype.renderPieChart = function renderPieChart (chart) {\n var options = merge({}, baseOptions);\n if (chart.options.donut) {\n options.cutout = \"50%\";\n }\n\n if (\"legend\" in chart.options) {\n hideLegend$2(options, chart.options.legend);\n }\n\n if (chart.options.title) {\n setTitle$2(options, chart.options.title);\n }\n\n options = merge(options, chart.options.library || {});\n setFormatOptions$1(chart, options, \"pie\");\n\n var labels = [];\n var values = [];\n for (var i = 0; i < chart.data.length; i++) {\n var point = chart.data[i];\n labels.push(point[0]);\n values.push(point[1]);\n }\n\n var dataset = {\n data: values,\n backgroundColor: chart.options.colors || defaultColors\n };\n dataset = merge(dataset, chart.options.dataset || {});\n\n var data = {\n labels: labels,\n datasets: [dataset]\n };\n\n this.drawChart(chart, \"pie\", data, options);\n };\n\n defaultExport$2.prototype.renderColumnChart = function renderColumnChart (chart, chartType) {\n var options;\n if (chartType === \"bar\") {\n var barOptions = merge(baseOptions, defaultOptions$2);\n barOptions.indexAxis = \"y\";\n\n // ensure gridlines have proper orientation\n barOptions.scales.x.grid.drawOnChartArea = true;\n barOptions.scales.y.grid.drawOnChartArea = false;\n delete barOptions.scales.y.ticks.maxTicksLimit;\n\n options = jsOptionsFunc(barOptions, hideLegend$2, setTitle$2, setBarMin$1, setBarMax$1, setStacked$2, setXtitle$2, setYtitle$2)(chart, chart.options);\n } else {\n options = jsOptions$2(chart, chart.options);\n }\n setFormatOptions$1(chart, options, chartType);\n var data = createDataTable(chart, options, \"column\");\n if (chartType !== \"bar\") {\n setLabelSize(chart, data, options);\n }\n if (!(\"mode\" in options.interaction)) {\n options.interaction.mode = \"index\";\n }\n this.drawChart(chart, \"bar\", data, options);\n };\n\n defaultExport$2.prototype.renderAreaChart = function renderAreaChart (chart) {\n this.renderLineChart(chart, \"area\");\n };\n\n defaultExport$2.prototype.renderBarChart = function renderBarChart (chart) {\n this.renderColumnChart(chart, \"bar\");\n };\n\n defaultExport$2.prototype.renderScatterChart = function renderScatterChart (chart, chartType) {\n chartType = chartType || \"scatter\";\n\n var options = jsOptions$2(chart, chart.options);\n setFormatOptions$1(chart, options, chartType);\n\n if (!(\"showLine\" in options)) {\n options.showLine = false;\n }\n\n var data = createDataTable(chart, options, chartType);\n\n options.scales.x.type = options.scales.x.type || \"linear\";\n options.scales.x.position = options.scales.x.position || \"bottom\";\n\n // prevent grouping hover and tooltips\n if (!(\"mode\" in options.interaction)) {\n options.interaction.mode = \"nearest\";\n }\n\n this.drawChart(chart, chartType, data, options);\n };\n\n defaultExport$2.prototype.renderBubbleChart = function renderBubbleChart (chart) {\n this.renderScatterChart(chart, \"bubble\");\n };\n\n defaultExport$2.prototype.destroy = function destroy (chart) {\n if (chart.chart) {\n chart.chart.destroy();\n }\n };\n\n defaultExport$2.prototype.drawChart = function drawChart (chart, type, data, options) {\n this.destroy(chart);\n if (chart.destroyed) { return; }\n\n var chartOptions = {\n type: type,\n data: data,\n options: options\n };\n\n if (chart.options.code) {\n window.console.log(\"new Chart(ctx, \" + JSON.stringify(chartOptions) + \");\");\n }\n\n chart.element.innerHTML = \"\";\n var ctx = chart.element.getElementsByTagName(\"CANVAS\")[0];\n chart.chart = new this.library(ctx, chartOptions);\n };\n\n var defaultOptions$1 = {\n chart: {},\n xAxis: {\n title: {\n text: null\n },\n labels: {\n style: {\n fontSize: \"12px\"\n }\n }\n },\n yAxis: {\n title: {\n text: null\n },\n labels: {\n style: {\n fontSize: \"12px\"\n }\n }\n },\n title: {\n text: null\n },\n credits: {\n enabled: false\n },\n legend: {\n borderWidth: 0\n },\n tooltip: {\n style: {\n fontSize: \"12px\"\n }\n },\n plotOptions: {\n areaspline: {},\n area: {},\n series: {\n marker: {}\n }\n },\n time: {\n useUTC: false\n }\n };\n\n function hideLegend$1(options, legend, hideLegend) {\n if (legend !== undefined) {\n options.legend.enabled = !!legend;\n if (legend && legend !== true) {\n if (legend === \"top\" || legend === \"bottom\") {\n options.legend.verticalAlign = legend;\n } else {\n options.legend.layout = \"vertical\";\n options.legend.verticalAlign = \"middle\";\n options.legend.align = legend;\n }\n }\n } else if (hideLegend) {\n options.legend.enabled = false;\n }\n }\n\n function setTitle$1(options, title) {\n options.title.text = title;\n }\n\n function setMin$1(options, min) {\n options.yAxis.min = min;\n }\n\n function setMax$1(options, max) {\n options.yAxis.max = max;\n }\n\n function setStacked$1(options, stacked) {\n var stackedValue = stacked ? (stacked === true ? \"normal\" : stacked) : null;\n options.plotOptions.series.stacking = stackedValue;\n options.plotOptions.area.stacking = stackedValue;\n options.plotOptions.areaspline.stacking = stackedValue;\n }\n\n function setXtitle$1(options, title) {\n options.xAxis.title.text = title;\n }\n\n function setYtitle$1(options, title) {\n options.yAxis.title.text = title;\n }\n\n var jsOptions$1 = jsOptionsFunc(defaultOptions$1, hideLegend$1, setTitle$1, setMin$1, setMax$1, setStacked$1, setXtitle$1, setYtitle$1);\n\n function setFormatOptions(chart, options, chartType) {\n var formatOptions = {\n prefix: chart.options.prefix,\n suffix: chart.options.suffix,\n thousands: chart.options.thousands,\n decimal: chart.options.decimal,\n precision: chart.options.precision,\n round: chart.options.round,\n zeros: chart.options.zeros\n };\n\n // skip when axis is an array (like with min/max)\n if (chartType !== \"pie\" && !isArray(options.yAxis) && !options.yAxis.labels.formatter) {\n options.yAxis.labels.formatter = function () {\n return formatValue(\"\", this.value, formatOptions);\n };\n }\n\n if (!options.tooltip.pointFormatter && !options.tooltip.pointFormat) {\n options.tooltip.pointFormatter = function () {\n return '\\u25CF ' + formatValue(this.series.name + ': ', this.y, formatOptions) + '
';\n };\n }\n }\n\n var defaultExport$1 = function defaultExport(library) {\n this.name = \"highcharts\";\n this.library = library;\n };\n\n defaultExport$1.prototype.renderLineChart = function renderLineChart (chart, chartType) {\n chartType = chartType || \"spline\";\n var chartOptions = {};\n if (chartType === \"areaspline\") {\n chartOptions = {\n plotOptions: {\n areaspline: {\n stacking: \"normal\"\n },\n area: {\n stacking: \"normal\"\n },\n series: {\n marker: {\n enabled: false\n }\n }\n }\n };\n }\n\n if (chart.options.curve === false) {\n if (chartType === \"areaspline\") {\n chartType = \"area\";\n } else if (chartType === \"spline\") {\n chartType = \"line\";\n }\n }\n\n var options = jsOptions$1(chart, chart.options, chartOptions);\n if (chart.xtype === \"number\") {\n options.xAxis.type = options.xAxis.type || \"linear\";\n } else {\n options.xAxis.type = chart.xtype === \"string\" ? \"category\" : \"datetime\";\n }\n if (!options.chart.type) {\n options.chart.type = chartType;\n }\n setFormatOptions(chart, options, chartType);\n\n var series = chart.data;\n for (var i = 0; i < series.length; i++) {\n series[i].name = series[i].name || \"Value\";\n var data = series[i].data;\n if (chart.xtype === \"datetime\") {\n for (var j = 0; j < data.length; j++) {\n data[j][0] = data[j][0].getTime();\n }\n } else if (chart.xtype === \"number\") {\n data.sort(sortByNumberSeries);\n }\n series[i].marker = {symbol: \"circle\"};\n if (chart.options.points === false) {\n series[i].marker.enabled = false;\n }\n }\n\n this.drawChart(chart, series, options);\n };\n\n defaultExport$1.prototype.renderScatterChart = function renderScatterChart (chart) {\n var options = jsOptions$1(chart, chart.options, {});\n options.chart.type = \"scatter\";\n this.drawChart(chart, chart.data, options);\n };\n\n defaultExport$1.prototype.renderPieChart = function renderPieChart (chart) {\n var chartOptions = merge(defaultOptions$1, {});\n\n if (chart.options.colors) {\n chartOptions.colors = chart.options.colors;\n }\n if (chart.options.donut) {\n chartOptions.plotOptions = {pie: {innerSize: \"50%\"}};\n }\n\n if (\"legend\" in chart.options) {\n hideLegend$1(chartOptions, chart.options.legend);\n }\n\n if (chart.options.title) {\n setTitle$1(chartOptions, chart.options.title);\n }\n\n var options = merge(chartOptions, chart.options.library || {});\n setFormatOptions(chart, options, \"pie\");\n var series = [{\n type: \"pie\",\n name: chart.options.label || \"Value\",\n data: chart.data\n }];\n\n this.drawChart(chart, series, options);\n };\n\n defaultExport$1.prototype.renderColumnChart = function renderColumnChart (chart, chartType) {\n chartType = chartType || \"column\";\n var series = chart.data;\n var options = jsOptions$1(chart, chart.options);\n var rows = [];\n var categories = [];\n options.chart.type = chartType;\n setFormatOptions(chart, options, chartType);\n\n for (var i = 0; i < series.length; i++) {\n var s = series[i];\n\n for (var j = 0; j < s.data.length; j++) {\n var d = s.data[j];\n if (!rows[d[0]]) {\n rows[d[0]] = new Array(series.length);\n categories.push(d[0]);\n }\n rows[d[0]][i] = d[1];\n }\n }\n\n if (chart.xtype === \"number\") {\n categories.sort(sortByNumber);\n }\n\n options.xAxis.categories = categories;\n\n var newSeries = [];\n for (var i$1 = 0; i$1 < series.length; i$1++) {\n var d$1 = [];\n for (var j$1 = 0; j$1 < categories.length; j$1++) {\n d$1.push(rows[categories[j$1]][i$1] || 0);\n }\n\n var d2 = {\n name: series[i$1].name || \"Value\",\n data: d$1\n };\n if (series[i$1].stack) {\n d2.stack = series[i$1].stack;\n }\n\n newSeries.push(d2);\n }\n\n this.drawChart(chart, newSeries, options);\n };\n\n defaultExport$1.prototype.renderBarChart = function renderBarChart (chart) {\n this.renderColumnChart(chart, \"bar\");\n };\n\n defaultExport$1.prototype.renderAreaChart = function renderAreaChart (chart) {\n this.renderLineChart(chart, \"areaspline\");\n };\n\n defaultExport$1.prototype.destroy = function destroy (chart) {\n if (chart.chart) {\n chart.chart.destroy();\n }\n };\n\n defaultExport$1.prototype.drawChart = function drawChart (chart, data, options) {\n this.destroy(chart);\n if (chart.destroyed) { return; }\n\n options.chart.renderTo = chart.element.id;\n options.series = data;\n\n if (chart.options.code) {\n window.console.log(\"new Highcharts.Chart(\" + JSON.stringify(options) + \");\");\n }\n\n chart.chart = new this.library.Chart(options);\n };\n\n var loaded = {};\n var callbacks = [];\n\n // Set chart options\n var defaultOptions = {\n chartArea: {},\n fontName: \"'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helvetica, sans-serif\",\n pointSize: 6,\n legend: {\n textStyle: {\n fontSize: 12,\n color: \"#444\"\n },\n alignment: \"center\",\n position: \"right\"\n },\n curveType: \"function\",\n hAxis: {\n textStyle: {\n color: \"#666\",\n fontSize: 12\n },\n titleTextStyle: {},\n gridlines: {\n color: \"transparent\"\n },\n baselineColor: \"#ccc\",\n viewWindow: {}\n },\n vAxis: {\n textStyle: {\n color: \"#666\",\n fontSize: 12\n },\n titleTextStyle: {},\n baselineColor: \"#ccc\",\n viewWindow: {}\n },\n tooltip: {\n textStyle: {\n color: \"#666\",\n fontSize: 12\n }\n }\n };\n\n function hideLegend(options, legend, hideLegend) {\n if (legend !== undefined) {\n var position;\n if (!legend) {\n position = \"none\";\n } else if (legend === true) {\n position = \"right\";\n } else {\n position = legend;\n }\n options.legend.position = position;\n } else if (hideLegend) {\n options.legend.position = \"none\";\n }\n }\n\n function setTitle(options, title) {\n options.title = title;\n options.titleTextStyle = {color: \"#333\", fontSize: \"20px\"};\n }\n\n function setMin(options, min) {\n options.vAxis.viewWindow.min = min;\n }\n\n function setMax(options, max) {\n options.vAxis.viewWindow.max = max;\n }\n\n function setBarMin(options, min) {\n options.hAxis.viewWindow.min = min;\n }\n\n function setBarMax(options, max) {\n options.hAxis.viewWindow.max = max;\n }\n\n function setStacked(options, stacked) {\n options.isStacked = stacked || false;\n }\n\n function setXtitle(options, title) {\n options.hAxis.title = title;\n options.hAxis.titleTextStyle.italic = false;\n }\n\n function setYtitle(options, title) {\n options.vAxis.title = title;\n options.vAxis.titleTextStyle.italic = false;\n }\n\n var jsOptions = jsOptionsFunc(defaultOptions, hideLegend, setTitle, setMin, setMax, setStacked, setXtitle, setYtitle);\n\n function resize(callback) {\n if (window.attachEvent) {\n window.attachEvent(\"onresize\", callback);\n } else if (window.addEventListener) {\n window.addEventListener(\"resize\", callback, true);\n }\n callback();\n }\n\n var defaultExport = function defaultExport(library) {\n this.name = \"google\";\n this.library = library;\n };\n\n defaultExport.prototype.renderLineChart = function renderLineChart (chart) {\n var this$1$1 = this;\n\n this.waitForLoaded(chart, function () {\n var chartOptions = {};\n\n if (chart.options.curve === false) {\n chartOptions.curveType = \"none\";\n }\n\n if (chart.options.points === false) {\n chartOptions.pointSize = 0;\n }\n\n var options = jsOptions(chart, chart.options, chartOptions);\n var data = this$1$1.createDataTable(chart.data, chart.xtype);\n\n this$1$1.drawChart(chart, \"LineChart\", data, options);\n });\n };\n\n defaultExport.prototype.renderPieChart = function renderPieChart (chart) {\n var this$1$1 = this;\n\n this.waitForLoaded(chart, function () {\n var chartOptions = {\n chartArea: {\n top: \"10%\",\n height: \"80%\"\n },\n legend: {}\n };\n if (chart.options.colors) {\n chartOptions.colors = chart.options.colors;\n }\n if (chart.options.donut) {\n chartOptions.pieHole = 0.5;\n }\n if (\"legend\" in chart.options) {\n hideLegend(chartOptions, chart.options.legend);\n }\n if (chart.options.title) {\n setTitle(chartOptions, chart.options.title);\n }\n var options = merge(merge(defaultOptions, chartOptions), chart.options.library || {});\n\n var data = new this$1$1.library.visualization.DataTable();\n data.addColumn(\"string\", \"\");\n data.addColumn(\"number\", \"Value\");\n data.addRows(chart.data);\n\n this$1$1.drawChart(chart, \"PieChart\", data, options);\n });\n };\n\n defaultExport.prototype.renderColumnChart = function renderColumnChart (chart) {\n var this$1$1 = this;\n\n this.waitForLoaded(chart, function () {\n var options = jsOptions(chart, chart.options);\n var data = this$1$1.createDataTable(chart.data, chart.xtype);\n\n this$1$1.drawChart(chart, \"ColumnChart\", data, options);\n });\n };\n\n defaultExport.prototype.renderBarChart = function renderBarChart (chart) {\n var this$1$1 = this;\n\n this.waitForLoaded(chart, function () {\n var chartOptions = {\n hAxis: {\n gridlines: {\n color: \"#ccc\"\n }\n }\n };\n var options = jsOptionsFunc(defaultOptions, hideLegend, setTitle, setBarMin, setBarMax, setStacked, setXtitle, setYtitle)(chart, chart.options, chartOptions);\n var data = this$1$1.createDataTable(chart.data, chart.xtype);\n\n this$1$1.drawChart(chart, \"BarChart\", data, options);\n });\n };\n\n defaultExport.prototype.renderAreaChart = function renderAreaChart (chart) {\n var this$1$1 = this;\n\n this.waitForLoaded(chart, function () {\n var chartOptions = {\n isStacked: true,\n pointSize: 0,\n areaOpacity: 0.5\n };\n\n var options = jsOptions(chart, chart.options, chartOptions);\n var data = this$1$1.createDataTable(chart.data, chart.xtype);\n\n this$1$1.drawChart(chart, \"AreaChart\", data, options);\n });\n };\n\n defaultExport.prototype.renderGeoChart = function renderGeoChart (chart) {\n var this$1$1 = this;\n\n this.waitForLoaded(chart, \"geochart\", function () {\n var chartOptions = {\n legend: \"none\",\n colorAxis: {\n colors: chart.options.colors || [\"#f6c7b6\", \"#ce502d\"]\n }\n };\n var options = merge(merge(defaultOptions, chartOptions), chart.options.library || {});\n\n var data = new this$1$1.library.visualization.DataTable();\n data.addColumn(\"string\", \"\");\n data.addColumn(\"number\", chart.options.label || \"Value\");\n data.addRows(chart.data);\n\n this$1$1.drawChart(chart, \"GeoChart\", data, options);\n });\n };\n\n defaultExport.prototype.renderScatterChart = function renderScatterChart (chart) {\n var this$1$1 = this;\n\n this.waitForLoaded(chart, function () {\n var chartOptions = {};\n var options = jsOptions(chart, chart.options, chartOptions);\n\n var series = chart.data;\n var rows2 = [];\n for (var i = 0; i < series.length; i++) {\n series[i].name = series[i].name || \"Value\";\n var d = series[i].data;\n for (var j = 0; j < d.length; j++) {\n var row = new Array(series.length + 1);\n row[0] = d[j][0];\n row[i + 1] = d[j][1];\n rows2.push(row);\n }\n }\n\n var data = new this$1$1.library.visualization.DataTable();\n data.addColumn(\"number\", \"\");\n for (var i$1 = 0; i$1 < series.length; i$1++) {\n data.addColumn(\"number\", series[i$1].name);\n }\n data.addRows(rows2);\n\n this$1$1.drawChart(chart, \"ScatterChart\", data, options);\n });\n };\n\n defaultExport.prototype.renderTimeline = function renderTimeline (chart) {\n var this$1$1 = this;\n\n this.waitForLoaded(chart, \"timeline\", function () {\n var chartOptions = {\n legend: \"none\"\n };\n\n if (chart.options.colors) {\n chartOptions.colors = chart.options.colors;\n }\n var options = merge(merge(defaultOptions, chartOptions), chart.options.library || {});\n\n var data = new this$1$1.library.visualization.DataTable();\n data.addColumn({type: \"string\", id: \"Name\"});\n data.addColumn({type: \"date\", id: \"Start\"});\n data.addColumn({type: \"date\", id: \"End\"});\n data.addRows(chart.data);\n\n chart.element.style.lineHeight = \"normal\";\n\n this$1$1.drawChart(chart, \"Timeline\", data, options);\n });\n };\n\n // TODO remove resize events\n defaultExport.prototype.destroy = function destroy (chart) {\n if (chart.chart) {\n chart.chart.clearChart();\n }\n };\n\n defaultExport.prototype.drawChart = function drawChart (chart, type, data, options) {\n this.destroy(chart);\n if (chart.destroyed) { return; }\n\n if (chart.options.code) {\n window.console.log(\"var data = new google.visualization.DataTable(\" + data.toJSON() + \");\\nvar chart = new google.visualization.\" + type + \"(element);\\nchart.draw(data, \" + JSON.stringify(options) + \");\");\n }\n\n chart.chart = new this.library.visualization[type](chart.element);\n resize(function () {\n chart.chart.draw(data, options);\n });\n };\n\n defaultExport.prototype.waitForLoaded = function waitForLoaded (chart, pack, callback) {\n var this$1$1 = this;\n\n if (!callback) {\n callback = pack;\n pack = \"corechart\";\n }\n\n callbacks.push({pack: pack, callback: callback});\n\n if (loaded[pack]) {\n this.runCallbacks();\n } else {\n loaded[pack] = true;\n\n // https://groups.google.com/forum/#!topic/google-visualization-api/fMKJcyA2yyI\n var loadOptions = {\n packages: [pack],\n callback: function () { this$1$1.runCallbacks(); }\n };\n var config = chart.__config();\n if (config.language) {\n loadOptions.language = config.language;\n }\n if (pack === \"geochart\" && config.mapsApiKey) {\n loadOptions.mapsApiKey = config.mapsApiKey;\n }\n\n this.library.charts.load(\"current\", loadOptions);\n }\n };\n\n defaultExport.prototype.runCallbacks = function runCallbacks () {\n for (var i = 0; i < callbacks.length; i++) {\n var cb = callbacks[i];\n var call = this.library.visualization && ((cb.pack === \"corechart\" && this.library.visualization.LineChart) || (cb.pack === \"timeline\" && this.library.visualization.Timeline) || (cb.pack === \"geochart\" && this.library.visualization.GeoChart));\n if (call) {\n cb.callback();\n callbacks.splice(i, 1);\n i--;\n }\n }\n };\n\n // cant use object as key\n defaultExport.prototype.createDataTable = function createDataTable (series, columnType) {\n var rows = [];\n var sortedLabels = [];\n for (var i = 0; i < series.length; i++) {\n var s = series[i];\n series[i].name = series[i].name || \"Value\";\n\n for (var j = 0; j < s.data.length; j++) {\n var d = s.data[j];\n var key = columnType === \"datetime\" ? d[0].getTime() : d[0];\n if (!rows[key]) {\n rows[key] = new Array(series.length);\n sortedLabels.push(key);\n }\n rows[key][i] = d[1];\n }\n }\n\n var rows2 = [];\n var values = [];\n for (var j$1 = 0; j$1 < sortedLabels.length; j$1++) {\n var i$1 = sortedLabels[j$1];\n var value = (void 0);\n if (columnType === \"datetime\") {\n value = new Date(i$1);\n values.push(value);\n } else {\n value = i$1;\n }\n rows2.push([value].concat(rows[i$1]));\n }\n\n var day = true;\n if (columnType === \"datetime\") {\n rows2.sort(sortByTime);\n\n var timeUnit = calculateTimeUnit(values, true);\n day = isDay(timeUnit);\n } else if (columnType === \"number\") {\n rows2.sort(sortByNumberSeries);\n\n for (var i$2 = 0; i$2 < rows2.length; i$2++) {\n rows2[i$2][0] = toStr(rows2[i$2][0]);\n }\n\n columnType = \"string\";\n }\n\n // create datatable\n var data = new this.library.visualization.DataTable();\n columnType = columnType === \"datetime\" && day ? \"date\" : columnType;\n data.addColumn(columnType, \"\");\n for (var i$3 = 0; i$3 < series.length; i$3++) {\n data.addColumn(\"number\", series[i$3].name);\n }\n data.addRows(rows2);\n\n return data;\n };\n\n var adapters = [];\n\n function getAdapterType(library) {\n if (library) {\n if (library.product === \"Highcharts\") {\n return defaultExport$1;\n } else if (library.charts) {\n return defaultExport;\n } else if (isFunction(library)) {\n return defaultExport$2;\n }\n }\n throw new Error(\"Unknown adapter\");\n }\n\n function addAdapter(library) {\n var adapterType = getAdapterType(library);\n\n for (var i = 0; i < adapters.length; i++) {\n if (adapters[i].library === library) {\n return;\n }\n }\n\n adapters.push(new adapterType(library));\n }\n\n function loadAdapters() {\n console.log(\"Chart object:\", window.Chart);\n \n if (\"Chart\" in window) {\n addAdapter(window.Chart);\n }\n\n if (\"Highcharts\" in window) {\n addAdapter(window.Highcharts);\n }\n\n if (window.google && window.google.charts) {\n addAdapter(window.google);\n }\n }\n\n // TODO remove chartType if cross-browser way\n // to get the name of the chart class\n function callAdapter(chartType, chart) {\n var fnName = \"render\" + chartType;\n var adapterName = chart.options.adapter;\n\n loadAdapters();\n\n for (var i = 0; i < adapters.length; i++) {\n var adapter = adapters[i];\n if ((!adapterName || adapterName === adapter.name) && isFunction(adapter[fnName])) {\n chart.adapter = adapter.name;\n chart.__adapterObject = adapter;\n return adapter[fnName](chart);\n }\n }\n\n if (adapters.length > 0) {\n throw new Error(\"No charting library found for \" + chartType);\n } else {\n throw new Error(\"No charting libraries found - be sure to include one before your charts\");\n }\n }\n\n var Chartkick = {\n charts: {},\n configure: function (options) {\n for (var key in options) {\n if (Object.prototype.hasOwnProperty.call(options, key)) {\n Chartkick.config[key] = options[key];\n }\n }\n },\n setDefaultOptions: function (opts) {\n Chartkick.options = opts;\n },\n eachChart: function (callback) {\n for (var chartId in Chartkick.charts) {\n if (Object.prototype.hasOwnProperty.call(Chartkick.charts, chartId)) {\n callback(Chartkick.charts[chartId]);\n }\n }\n },\n destroyAll: function () {\n for (var chartId in Chartkick.charts) {\n if (Object.prototype.hasOwnProperty.call(Chartkick.charts, chartId)) {\n Chartkick.charts[chartId].destroy();\n delete Chartkick.charts[chartId];\n }\n }\n },\n config: {},\n options: {},\n adapters: adapters,\n addAdapter: addAdapter,\n use: function (adapter) {\n addAdapter(adapter);\n return Chartkick;\n }\n };\n\n function formatSeriesBubble(data) {\n var r = [];\n for (var i = 0; i < data.length; i++) {\n r.push([toFloat(data[i][0]), toFloat(data[i][1]), toFloat(data[i][2])]);\n }\n return r;\n }\n\n // casts data to proper type\n // sorting is left to adapters\n function formatSeriesData(data, keyType) {\n if (keyType === \"bubble\") {\n return formatSeriesBubble(data);\n }\n\n var keyFunc;\n if (keyType === \"number\") {\n keyFunc = toFloat;\n } else if (keyType === \"datetime\") {\n keyFunc = toDate;\n } else {\n keyFunc = toStr;\n }\n\n var r = [];\n for (var i = 0; i < data.length; i++) {\n r.push([keyFunc(data[i][0]), toFloat(data[i][1])]);\n }\n return r;\n }\n\n function detectXType(series, noDatetime, options) {\n if (dataEmpty(series)) {\n if ((options.xmin || options.xmax) && (!options.xmin || isDate(options.xmin)) && (!options.xmax || isDate(options.xmax))) {\n return \"datetime\";\n } else {\n return \"number\";\n }\n } else if (detectXTypeWithFunction(series, isNumber)) {\n return \"number\";\n } else if (!noDatetime && detectXTypeWithFunction(series, isDate)) {\n return \"datetime\";\n } else {\n return \"string\";\n }\n }\n\n function detectXTypeWithFunction(series, func) {\n for (var i = 0; i < series.length; i++) {\n var data = toArr(series[i].data);\n for (var j = 0; j < data.length; j++) {\n if (!func(data[j][0])) {\n return false;\n }\n }\n }\n return true;\n }\n\n // creates a shallow copy of each element of the array\n // elements are expected to be objects\n function copySeries(series) {\n var newSeries = [];\n for (var i = 0; i < series.length; i++) {\n var copy = {};\n for (var j in series[i]) {\n if (Object.prototype.hasOwnProperty.call(series[i], j)) {\n copy[j] = series[i][j];\n }\n }\n newSeries.push(copy);\n }\n return newSeries;\n }\n\n function processSeries(chart, keyType, noDatetime) {\n var opts = chart.options;\n var series = chart.rawData;\n\n // see if one series or multiple\n chart.singleSeriesFormat = !isArray(series) || !isPlainObject(series[0]);\n if (chart.singleSeriesFormat) {\n series = [{name: opts.label, data: series}];\n }\n\n // convert to array\n // must come before dataEmpty check\n series = copySeries(series);\n for (var i = 0; i < series.length; i++) {\n series[i].data = toArr(series[i].data);\n }\n\n chart.xtype = keyType || (opts.discrete ? \"string\" : detectXType(series, noDatetime, opts));\n\n // right format\n for (var i$1 = 0; i$1 < series.length; i$1++) {\n series[i$1].data = formatSeriesData(series[i$1].data, chart.xtype);\n }\n\n return series;\n }\n\n function processSimple(chart) {\n var perfectData = toArr(chart.rawData);\n for (var i = 0; i < perfectData.length; i++) {\n perfectData[i] = [toStr(perfectData[i][0]), toFloat(perfectData[i][1])];\n }\n return perfectData;\n }\n\n function dataEmpty(data, chartType) {\n if (chartType === \"PieChart\" || chartType === \"GeoChart\" || chartType === \"Timeline\") {\n return data.length === 0;\n } else {\n for (var i = 0; i < data.length; i++) {\n if (data[i].data.length > 0) {\n return false;\n }\n }\n return true;\n }\n }\n\n function addDownloadButton(chart) {\n var download = chart.options.download;\n if (download === true) {\n download = {};\n } else if (typeof download === \"string\") {\n download = {filename: download};\n }\n\n var link = document.createElement(\"a\");\n link.download = download.filename || \"chart.png\";\n link.style.position = \"absolute\";\n link.style.top = \"20px\";\n link.style.right = \"20px\";\n link.style.zIndex = 1000;\n link.style.lineHeight = \"20px\";\n link.target = \"_blank\"; // for safari\n\n var image = document.createElement(\"img\");\n // icon from Font Awesome, modified to set fill color\n var svg = \"\";\n image.src = \"data:image/svg+xml;utf8,\" + (encodeURIComponent(svg));\n image.alt = \"Download\";\n image.style.width = \"20px\";\n image.style.height = \"20px\";\n image.style.border = \"none\";\n link.appendChild(image);\n\n var element = chart.element;\n element.style.position = \"relative\";\n\n chart.__downloadAttached = true;\n\n // mouseenter\n chart.__enterEvent = element.addEventListener(\"mouseover\", function (e) {\n var related = e.relatedTarget;\n // check download option again to ensure it wasn't changed\n if ((!related || (related !== this && !this.contains(related))) && chart.options.download) {\n link.href = chart.toImage(download);\n element.appendChild(link);\n }\n });\n\n // mouseleave\n chart.__leaveEvent = element.addEventListener(\"mouseout\", function (e) {\n var related = e.relatedTarget;\n if (!related || (related !== this && !this.contains(related))) {\n if (link.parentNode) {\n link.parentNode.removeChild(link);\n }\n }\n });\n }\n\n var pendingRequests = [];\n var runningRequests = 0;\n var maxRequests = 4;\n\n function pushRequest(url, success, error) {\n pendingRequests.push([url, success, error]);\n runNext();\n }\n\n function runNext() {\n if (runningRequests < maxRequests) {\n var request = pendingRequests.shift();\n if (request) {\n runningRequests++;\n getJSON(request[0], request[1], request[2]);\n runNext();\n }\n }\n }\n\n function requestComplete() {\n runningRequests--;\n runNext();\n }\n\n function getJSON(url, success, error) {\n var xhr = new XMLHttpRequest();\n xhr.open(\"GET\", url, true);\n xhr.setRequestHeader(\"Content-Type\", \"application/json\");\n xhr.onload = function () {\n requestComplete();\n if (xhr.status === 200) {\n success(JSON.parse(xhr.responseText));\n } else {\n error(xhr.statusText);\n }\n };\n xhr.send();\n }\n\n // helpers\n\n function setText(element, text) {\n element.textContent = text;\n }\n\n // TODO remove prefix for all messages\n function chartError(element, message, noPrefix) {\n if (!noPrefix) {\n message = \"Error Loading Chart: \" + message;\n }\n setText(element, message);\n element.style.color = \"#ff0000\";\n }\n\n function errorCatcher(chart) {\n try {\n chart.__render();\n } catch (err) {\n chartError(chart.element, err.message);\n throw err;\n }\n }\n\n function fetchDataSource(chart, dataSource, showLoading) {\n // only show loading message for urls and callbacks\n if (showLoading && chart.options.loading && (typeof dataSource === \"string\" || typeof dataSource === \"function\")) {\n setText(chart.element, chart.options.loading);\n }\n\n if (typeof dataSource === \"string\") {\n pushRequest(dataSource, function (data) {\n chart.rawData = data;\n errorCatcher(chart);\n }, function (message) {\n chartError(chart.element, message);\n });\n } else if (typeof dataSource === \"function\") {\n try {\n dataSource(function (data) {\n chart.rawData = data;\n errorCatcher(chart);\n }, function (message) {\n chartError(chart.element, message, true);\n });\n } catch (err) {\n chartError(chart.element, err, true);\n }\n } else {\n chart.rawData = dataSource;\n errorCatcher(chart);\n }\n }\n\n function renderChart(chartType, chart) {\n if (dataEmpty(chart.data, chartType)) {\n var message = chart.options.empty || (chart.options.messages && chart.options.messages.empty) || \"No data\";\n setText(chart.element, message);\n } else {\n callAdapter(chartType, chart);\n // TODO add downloadSupported method to adapter\n if (chart.options.download && !chart.__downloadAttached && chart.adapter === \"chartjs\") {\n addDownloadButton(chart);\n }\n }\n }\n\n function getElement(element) {\n if (typeof element === \"string\") {\n var elementId = element;\n element = document.getElementById(element);\n if (!element) {\n throw new Error(\"No element with id \" + elementId);\n }\n }\n return element;\n }\n\n // define classes\n\n var Chart = function Chart(element, dataSource, options) {\n this.element = getElement(element);\n this.options = merge(Chartkick.options, options || {});\n this.dataSource = dataSource;\n\n // TODO handle charts without an id for eachChart and destroyAll\n if (this.element.id) {\n Chartkick.charts[this.element.id] = this;\n }\n\n fetchDataSource(this, dataSource, true);\n\n if (this.options.refresh) {\n this.startRefresh();\n }\n };\n\n Chart.prototype.getElement = function getElement () {\n return this.element;\n };\n\n Chart.prototype.getDataSource = function getDataSource () {\n return this.dataSource;\n };\n\n Chart.prototype.getData = function getData () {\n return this.data;\n };\n\n Chart.prototype.getOptions = function getOptions () {\n return this.options;\n };\n\n Chart.prototype.getChartObject = function getChartObject () {\n return this.chart;\n };\n\n Chart.prototype.getAdapter = function getAdapter () {\n return this.adapter;\n };\n\n Chart.prototype.updateData = function updateData (dataSource, options) {\n this.dataSource = dataSource;\n if (options) {\n this.__updateOptions(options);\n }\n fetchDataSource(this, dataSource, true);\n };\n\n Chart.prototype.setOptions = function setOptions (options) {\n this.__updateOptions(options);\n this.redraw();\n };\n\n Chart.prototype.redraw = function redraw () {\n fetchDataSource(this, this.rawData);\n };\n\n Chart.prototype.refreshData = function refreshData () {\n if (typeof this.dataSource === \"string\") {\n // prevent browser from caching\n var sep = this.dataSource.indexOf(\"?\") === -1 ? \"?\" : \"&\";\n var url = this.dataSource + sep + \"_=\" + (new Date()).getTime();\n fetchDataSource(this, url);\n } else if (typeof this.dataSource === \"function\") {\n fetchDataSource(this, this.dataSource);\n }\n };\n\n Chart.prototype.startRefresh = function startRefresh () {\n var this$1$1 = this;\n\n var refresh = this.options.refresh;\n\n if (refresh && typeof this.dataSource !== \"string\" && typeof this.dataSource !== \"function\") {\n throw new Error(\"Data source must be a URL or callback for refresh\");\n }\n\n if (!this.intervalId) {\n if (refresh) {\n this.intervalId = setInterval(function () {\n this$1$1.refreshData();\n }, refresh * 1000);\n } else {\n throw new Error(\"No refresh interval\");\n }\n }\n };\n\n Chart.prototype.stopRefresh = function stopRefresh () {\n if (this.intervalId) {\n clearInterval(this.intervalId);\n this.intervalId = null;\n }\n };\n\n Chart.prototype.toImage = function toImage (download) {\n // TODO move logic to adapter\n if (this.adapter === \"chartjs\") {\n if (download && download.background && download.background !== \"transparent\") {\n // https://stackoverflow.com/questions/30464750/chartjs-line-chart-set-background-color\n var canvas = this.chart.canvas;\n var ctx = this.chart.ctx;\n var tmpCanvas = document.createElement(\"canvas\");\n var tmpCtx = tmpCanvas.getContext(\"2d\");\n tmpCanvas.width = ctx.canvas.width;\n tmpCanvas.height = ctx.canvas.height;\n tmpCtx.fillStyle = download.background;\n tmpCtx.fillRect(0, 0, tmpCanvas.width, tmpCanvas.height);\n tmpCtx.drawImage(canvas, 0, 0);\n return tmpCanvas.toDataURL(\"image/png\");\n } else {\n return this.chart.toBase64Image();\n }\n } else {\n throw new Error(\"Feature only available for Chart.js\");\n }\n };\n\n Chart.prototype.destroy = function destroy () {\n this.destroyed = true;\n this.stopRefresh();\n\n if (this.__adapterObject) {\n this.__adapterObject.destroy(this);\n }\n\n if (this.__enterEvent) {\n this.element.removeEventListener(\"mouseover\", this.__enterEvent);\n }\n\n if (this.__leaveEvent) {\n this.element.removeEventListener(\"mouseout\", this.__leaveEvent);\n }\n };\n\n Chart.prototype.__updateOptions = function __updateOptions (options) {\n var updateRefresh = options.refresh && options.refresh !== this.options.refresh;\n this.options = merge(Chartkick.options, options);\n if (updateRefresh) {\n this.stopRefresh();\n this.startRefresh();\n }\n };\n\n Chart.prototype.__render = function __render () {\n this.data = this.__processData();\n renderChart(this.__chartName(), this);\n };\n\n Chart.prototype.__config = function __config () {\n return Chartkick.config;\n };\n\n var LineChart = /*@__PURE__*/(function (Chart) {\n function LineChart () {\n Chart.apply(this, arguments);\n }\n\n if ( Chart ) LineChart.__proto__ = Chart;\n LineChart.prototype = Object.create( Chart && Chart.prototype );\n LineChart.prototype.constructor = LineChart;\n\n LineChart.prototype.__processData = function __processData () {\n return processSeries(this);\n };\n\n LineChart.prototype.__chartName = function __chartName () {\n return \"LineChart\";\n };\n\n return LineChart;\n }(Chart));\n\n var PieChart = /*@__PURE__*/(function (Chart) {\n function PieChart () {\n Chart.apply(this, arguments);\n }\n\n if ( Chart ) PieChart.__proto__ = Chart;\n PieChart.prototype = Object.create( Chart && Chart.prototype );\n PieChart.prototype.constructor = PieChart;\n\n PieChart.prototype.__processData = function __processData () {\n return processSimple(this);\n };\n\n PieChart.prototype.__chartName = function __chartName () {\n return \"PieChart\";\n };\n\n return PieChart;\n }(Chart));\n\n var ColumnChart = /*@__PURE__*/(function (Chart) {\n function ColumnChart () {\n Chart.apply(this, arguments);\n }\n\n if ( Chart ) ColumnChart.__proto__ = Chart;\n ColumnChart.prototype = Object.create( Chart && Chart.prototype );\n ColumnChart.prototype.constructor = ColumnChart;\n\n ColumnChart.prototype.__processData = function __processData () {\n return processSeries(this, null, true);\n };\n\n ColumnChart.prototype.__chartName = function __chartName () {\n return \"ColumnChart\";\n };\n\n return ColumnChart;\n }(Chart));\n\n var BarChart = /*@__PURE__*/(function (Chart) {\n function BarChart () {\n Chart.apply(this, arguments);\n }\n\n if ( Chart ) BarChart.__proto__ = Chart;\n BarChart.prototype = Object.create( Chart && Chart.prototype );\n BarChart.prototype.constructor = BarChart;\n\n BarChart.prototype.__processData = function __processData () {\n return processSeries(this, null, true);\n };\n\n BarChart.prototype.__chartName = function __chartName () {\n return \"BarChart\";\n };\n\n return BarChart;\n }(Chart));\n\n var AreaChart = /*@__PURE__*/(function (Chart) {\n function AreaChart () {\n Chart.apply(this, arguments);\n }\n\n if ( Chart ) AreaChart.__proto__ = Chart;\n AreaChart.prototype = Object.create( Chart && Chart.prototype );\n AreaChart.prototype.constructor = AreaChart;\n\n AreaChart.prototype.__processData = function __processData () {\n return processSeries(this);\n };\n\n AreaChart.prototype.__chartName = function __chartName () {\n return \"AreaChart\";\n };\n\n return AreaChart;\n }(Chart));\n\n var GeoChart = /*@__PURE__*/(function (Chart) {\n function GeoChart () {\n Chart.apply(this, arguments);\n }\n\n if ( Chart ) GeoChart.__proto__ = Chart;\n GeoChart.prototype = Object.create( Chart && Chart.prototype );\n GeoChart.prototype.constructor = GeoChart;\n\n GeoChart.prototype.__processData = function __processData () {\n return processSimple(this);\n };\n\n GeoChart.prototype.__chartName = function __chartName () {\n return \"GeoChart\";\n };\n\n return GeoChart;\n }(Chart));\n\n var ScatterChart = /*@__PURE__*/(function (Chart) {\n function ScatterChart () {\n Chart.apply(this, arguments);\n }\n\n if ( Chart ) ScatterChart.__proto__ = Chart;\n ScatterChart.prototype = Object.create( Chart && Chart.prototype );\n ScatterChart.prototype.constructor = ScatterChart;\n\n ScatterChart.prototype.__processData = function __processData () {\n return processSeries(this, \"number\");\n };\n\n ScatterChart.prototype.__chartName = function __chartName () {\n return \"ScatterChart\";\n };\n\n return ScatterChart;\n }(Chart));\n\n var BubbleChart = /*@__PURE__*/(function (Chart) {\n function BubbleChart () {\n Chart.apply(this, arguments);\n }\n\n if ( Chart ) BubbleChart.__proto__ = Chart;\n BubbleChart.prototype = Object.create( Chart && Chart.prototype );\n BubbleChart.prototype.constructor = BubbleChart;\n\n BubbleChart.prototype.__processData = function __processData () {\n return processSeries(this, \"bubble\");\n };\n\n BubbleChart.prototype.__chartName = function __chartName () {\n return \"BubbleChart\";\n };\n\n return BubbleChart;\n }(Chart));\n\n var Timeline = /*@__PURE__*/(function (Chart) {\n function Timeline () {\n Chart.apply(this, arguments);\n }\n\n if ( Chart ) Timeline.__proto__ = Chart;\n Timeline.prototype = Object.create( Chart && Chart.prototype );\n Timeline.prototype.constructor = Timeline;\n\n Timeline.prototype.__processData = function __processData () {\n var data = this.rawData;\n for (var i = 0; i < data.length; i++) {\n data[i][1] = toDate(data[i][1]);\n data[i][2] = toDate(data[i][2]);\n }\n return data;\n };\n\n Timeline.prototype.__chartName = function __chartName () {\n return \"Timeline\";\n };\n\n return Timeline;\n }(Chart));\n\n Chartkick.LineChart = LineChart;\n Chartkick.PieChart = PieChart;\n Chartkick.ColumnChart = ColumnChart;\n Chartkick.BarChart = BarChart;\n Chartkick.AreaChart = AreaChart;\n Chartkick.GeoChart = GeoChart;\n Chartkick.ScatterChart = ScatterChart;\n Chartkick.BubbleChart = BubbleChart;\n Chartkick.Timeline = Timeline;\n\n // not ideal, but allows for simpler integration\n if (typeof window !== \"undefined\" && !window.Chartkick) {\n window.Chartkick = Chartkick;\n\n // clean up previous charts before Turbolinks loads new page\n document.addEventListener(\"turbolinks:before-render\", function () {\n if (Chartkick.config.autoDestroy !== false) {\n Chartkick.destroyAll();\n }\n });\n\n // clean up previous charts before Turbo loads new page\n document.addEventListener(\"turbo:before-render\", function () {\n if (Chartkick.config.autoDestroy !== false) {\n Chartkick.destroyAll();\n }\n });\n\n // use setTimeout so charting library can come later in same JS file\n setTimeout(function () {\n window.dispatchEvent(new Event(\"chartkick:load\"));\n }, 0);\n }\n\n // backwards compatibility for esm require\n Chartkick.default = Chartkick;\n\n return Chartkick;\n\n}));\n","!function(i){\"use strict\";\"function\"==typeof define&&define.amd?define([\"jquery\"],i):\"undefined\"!=typeof exports?module.exports=i(require(\"jquery\")):i(jQuery)}(function(i){\"use strict\";var e=window.Slick||{};(e=function(){var e=0;return function(t,o){var s,n=this;n.defaults={accessibility:!0,adaptiveHeight:!1,appendArrows:i(t),appendDots:i(t),arrows:!0,asNavFor:null,prevArrow:'',nextArrow:'',autoplay:!1,autoplaySpeed:3e3,centerMode:!1,centerPadding:\"50px\",cssEase:\"ease\",customPaging:function(e,t){return i('